hughhhh commented on a change in pull request #16902:
URL: https://github.com/apache/superset/pull/16902#discussion_r719548418
##########
File path: superset-frontend/src/components/Menu/MenuRight.tsx
##########
@@ -83,134 +92,141 @@ const RightMenu = ({
settings,
navbarRight,
isFrontendRoute,
-}: RightMenuProps) => (
- <StyledDiv align={align}>
- <Menu mode="horizontal">
- {!navbarRight.user_is_anonymous && (
- <SubMenu
- data-test="new-dropdown"
- title={
- <StyledI data-test="new-dropdown-icon" className="fa fa-plus" />
- }
- icon={<Icons.TriangleDown />}
- >
- {dropdownItems.map(menu => (
- <Menu.Item key={menu.label}>
- <a href={menu.url}>
- <i
- data-test={`menu-item-${menu.label}`}
- className={`fa ${menu.icon}`}
- />{' '}
- {menu.label}
- </a>
- </Menu.Item>
- ))}
- </SubMenu>
- )}
- <SubMenu title="Settings" icon={<Icons.TriangleDown iconSize="xl" />}>
- {settings.map((section, index) => [
- <Menu.ItemGroup key={`${section.label}`} title={section.label}>
- {section.childs?.map(child => {
- if (typeof child !== 'string') {
- return (
- <Menu.Item key={`${child.label}`}>
- {isFrontendRoute(child.url) ? (
- <Link to={child.url || ''}>{child.label}</Link>
- ) : (
- <a href={child.url}>{child.label}</a>
- )}
- </Menu.Item>
- );
- }
- return null;
- })}
- </Menu.ItemGroup>,
- index < settings.length - 1 && <Menu.Divider />,
- ])}
+}: RightMenuProps) => {
+ const { roles } = useSelector<any, UserWithPermissionsAndRoles>(
+ state => state.user,
+ );
- {!navbarRight.user_is_anonymous && [
- <Menu.Divider key="user-divider" />,
- <Menu.ItemGroup key="user-section" title={t('User')}>
- {navbarRight.user_profile_url && (
- <Menu.Item key="profile">
- <a href={navbarRight.user_profile_url}>{t('Profile')}</a>
- </Menu.Item>
- )}
- {navbarRight.user_info_url && (
- <Menu.Item key="info">
- <a href={navbarRight.user_info_url}>{t('Info')}</a>
- </Menu.Item>
+ // if user has any of these roles the dropdown will appear
+ const canSql = findPermission('can_sqllab', 'Superset', roles);
+ const canDashboard = findPermission('can_write', 'Dashboard', roles);
+ const canChart = findPermission('can_write', 'Chart', roles);
+ const showActionDropdown = canSql || canChart || canDashboard;
+ return (
+ <StyledDiv align={align}>
+ <Menu mode="horizontal">
+ {!navbarRight.user_is_anonymous && showActionDropdown && (
+ <SubMenu
+ data-test="new-dropdown"
+ title={
+ <StyledI data-test="new-dropdown-icon" className="fa fa-plus" />
+ }
+ icon={<Icons.TriangleDown />}
+ >
+ {dropdownItems.map(
+ menu =>
+ findPermission(menu.perm, menu.view, roles) && (
+ <Menu.Item key={menu.label}>
+ <a href={menu.url}>
+ <i
+ data-test={`menu-item-${menu.label}`}
+ className={`fa ${menu.icon}`}
+ />{' '}
+ {menu.label}
+ </a>
+ </Menu.Item>
+ ),
)}
- <Menu.Item key="logout">
- <a href={navbarRight.user_logout_url}>{t('Logout')}</a>
- </Menu.Item>
- </Menu.ItemGroup>,
- ]}
- {(navbarRight.version_string ||
- navbarRight.version_sha ||
- navbarRight.build_number) && [
- <Menu.Divider key="version-info-divider" />,
- <Menu.ItemGroup key="about-section" title={t('About')}>
- <div className="about-section">
- {navbarRight.show_watermark && (
- <div css={versionInfoStyles}>
- {t('Powered by Apache Superset')}
- </div>
- )}
- {navbarRight.version_string && (
- <div css={versionInfoStyles}>
- Version: {navbarRight.version_string}
- </div>
- )}
- {navbarRight.version_sha && (
- <div css={versionInfoStyles}>
- SHA: {navbarRight.version_sha}
- </div>
+ </SubMenu>
+ )}
+ <SubMenu title="Settings" icon={<Icons.TriangleDown iconSize="xl" />}>
+ {settings.map((section, index) => [
+ <Menu.ItemGroup key={`${section.label}`} title={section.label}>
+ {section.childs?.map(child => {
+ if (typeof child !== 'string') {
+ return (
+ <Menu.Item key={`${child.label}`}>
+ {isFrontendRoute(child.url) ? (
+ <Link to={child.url || ''}>{child.label}</Link>
+ ) : (
+ <a href={child.url}>{child.label}</a>
+ )}
+ </Menu.Item>
+ );
+ }
+ return null;
+ })}
+ </Menu.ItemGroup>,
+ index < settings.length - 1 && <Menu.Divider />,
+ ])}
+
+ {!navbarRight.user_is_anonymous && [
+ <Menu.Divider key="user-divider" />,
+ <Menu.ItemGroup key="user-section" title={t('User')}>
+ {navbarRight.user_profile_url && (
+ <Menu.Item key="profile">
+ <a href={navbarRight.user_profile_url}>{t('Profile')}</a>
+ </Menu.Item>
)}
- {navbarRight.build_number && (
- <div css={versionInfoStyles}>
- Build: {navbarRight.build_number}
- </div>
+ {navbarRight.user_info_url && (
+ <Menu.Item key="info">
+ <a href={navbarRight.user_info_url}>{t('Info')}</a>
+ </Menu.Item>
)}
Review comment:
it was a bad rebase on my part just added it back and fixed the test.
The build number is here
(https://github.com/apache/superset/pull/16902/files#diff-66167b483c9360910449d7ed1078df9d2b3b2500ea69295657e3692e462c9095R192)
now
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]