From a0e26ac339beaedd90e2e6c08f19cd040703e869 Mon Sep 17 00:00:00 2001 From: Michael Roytman Date: Mon, 3 Aug 2020 15:07:07 -0400 Subject: [PATCH] only show Maintenance user menu link when the user is an administrator (edX staff) (#27) --- src/studio-header/Header.jsx | 49 +++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/src/studio-header/Header.jsx b/src/studio-header/Header.jsx index bb8882dd8..dbc8b1372 100644 --- a/src/studio-header/Header.jsx +++ b/src/studio-header/Header.jsx @@ -29,23 +29,38 @@ function Header({ courseId }) { }, ]; - const userMenu = authenticatedUser === null ? [] : [ - { - type: 'item', - href: config.STUDIO_BASE_URL, - content: 'Studio Home', - }, - { - type: 'item', - href: `${config.STUDIO_BASE_URL}/maintenance`, - content: 'Maintenance', - }, - { - type: 'item', - href: config.LOGOUT_URL, - content: 'Sign Out', - }, - ]; + const studioHomeItem = { + type: 'item', + href: config.STUDIO_BASE_URL, + content: 'Studio Home', + }; + + const logoutItem = { + type: 'item', + href: config.LOGOUT_URL, + content: 'Sign Out', + }; + + let userMenu = []; + + if (authenticatedUser !== null) { + if (authenticatedUser.administrator) { + userMenu = [ + studioHomeItem, + { + type: 'item', + href: `${config.STUDIO_BASE_URL}/maintenance`, + content: 'Maintenance', + }, + logoutItem, + ]; + } else { + userMenu = [ + studioHomeItem, + logoutItem, + ]; + } + } const props = { logo: StudioLogoPNG,