Skip to content

Commit

Permalink
Revert "fix: Remove Studio Maintenance link (#553)"
Browse files Browse the repository at this point in the history
This reverts commit a229c34.
  • Loading branch information
kdmccormick authored Jan 14, 2025
1 parent edb2231 commit 1fb25fe
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Header.messages.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ const messages = defineMessages({
defaultMessage: 'Studio Home',
description: 'Link to the Studio Home',
},
'header.user.menu.studio.maintenance': {
id: 'header.user.menu.studio.maintenance',
defaultMessage: 'Maintenance',
description: 'Link to the Studio Maintenance',
},
'header.label.account.nav': {
id: 'header.label.account.nav',
defaultMessage: 'Account',
Expand Down
20 changes: 20 additions & 0 deletions src/studio-header/StudioHeader.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Context as ResponsiveContext } from 'react-responsive';
import { MemoryRouter } from 'react-router-dom';

import StudioHeader from './StudioHeader';
import messages from './messages';

const authenticatedUser = {
userId: 3,
Expand Down Expand Up @@ -114,6 +115,16 @@ describe('Header', () => {
expect(dropdownOption).toBeVisible();
});

it('maintenance should not be in user menu', async () => {
currentUser = { ...authenticatedUser, administrator: false };
const { getAllByRole, queryByText } = render(<RootWrapper {...props} />);
const userMenu = getAllByRole('button')[1];
await waitFor(() => fireEvent.click(userMenu));
const maintenanceButton = queryByText(messages['header.user.menu.maintenance'].defaultMessage);

expect(maintenanceButton).toBeNull();
});

it('user menu should use avatar icon', async () => {
currentUser = { ...authenticatedUser, avatar: null };
const { getByTestId } = render(<RootWrapper {...props} />);
Expand Down Expand Up @@ -175,6 +186,15 @@ describe('Header', () => {
expect(desktopMenu).toBeNull();
});

it('maintenance should be in user menu', async () => {
const { getAllByRole, getByText } = render(<RootWrapper {...props} />);
const userMenu = getAllByRole('button')[1];
await waitFor(() => fireEvent.click(userMenu));
const maintenanceButton = getByText(messages['header.user.menu.maintenance'].defaultMessage);

expect(maintenanceButton).toBeVisible();
});

it('user menu should use avatar image', async () => {
const { getByTestId } = render(<RootWrapper {...props} />);
const avatarImage = getByTestId('avatar-image');
Expand Down
5 changes: 5 additions & 0 deletions src/studio-header/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ const messages = defineMessages({
defaultMessage: 'Studio Home',
description: 'Link to Studio Home',
},
'header.user.menu.maintenance': {
id: 'header.user.menu.maintenance',
defaultMessage: 'Maintenance',
description: 'Link to the Studio maintenance page',
},
'header.user.menu.logout': {
id: 'header.user.menu.logout',
defaultMessage: 'Logout',
Expand Down
4 changes: 4 additions & 0 deletions src/studio-header/utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getConfig } from '@edx/frontend-platform';
import messages from './messages';

const getUserMenuItems = ({
Expand All @@ -20,6 +21,9 @@ const getUserMenuItems = ({
{
href: `${studioBaseUrl}`,
title: intl.formatMessage(messages['header.user.menu.studio']),
}, {
href: `${getConfig().STUDIO_BASE_URL}/maintenance`,
title: intl.formatMessage(messages['header.user.menu.maintenance']),
}, {
href: `${logoutUrl}`,
title: intl.formatMessage(messages['header.user.menu.logout']),
Expand Down

0 comments on commit 1fb25fe

Please sign in to comment.