diff --git a/superset-frontend/src/views/App.tsx b/superset-frontend/src/views/App.tsx
index 4e193bbf776aa..b996fa708a929 100644
--- a/superset-frontend/src/views/App.tsx
+++ b/superset-frontend/src/views/App.tsx
@@ -38,7 +38,9 @@ import { RootContextProviders } from './RootContextProviders';
setupApp();
const user = { ...bootstrapData.user };
-const menu = { ...bootstrapData.common.menu_data };
+const menu = {
+ ...bootstrapData.common.menu_data,
+};
let lastLocationPathname: string;
initFeatureFlags(bootstrapData.common.feature_flags);
diff --git a/superset-frontend/src/views/components/Menu.test.tsx b/superset-frontend/src/views/components/Menu.test.tsx
index 8dd8f56b89024..b990ddc1804a9 100644
--- a/superset-frontend/src/views/components/Menu.test.tsx
+++ b/superset-frontend/src/views/components/Menu.test.tsx
@@ -89,6 +89,26 @@ const mockedProps = {
url: '/dashboard/list/',
index: 4,
},
+ {
+ name: 'Data',
+ icon: 'fa-database',
+ label: 'Data',
+ childs: [
+ {
+ name: 'Databases',
+ icon: 'fa-database',
+ label: 'Databases',
+ url: '/databaseview/list/',
+ },
+ {
+ name: 'Datasets',
+ icon: 'fa-table',
+ label: 'Datasets',
+ url: '/tablemodelview/list/',
+ },
+ '-',
+ ],
+ },
],
brand: {
path: '/superset/profile/admin/',
@@ -220,13 +240,11 @@ test('should render the dropdown items', async () => {
render(
);
const dropdown = screen.getByTestId('new-dropdown-icon');
userEvent.hover(dropdown);
- expect(await screen.findByText(dropdownItems[0].label)).toHaveAttribute(
+ // todo (philip): test data submenu
+ expect(await screen.findByText(dropdownItems[1].label)).toHaveAttribute(
'href',
- dropdownItems[0].url,
+ dropdownItems[1].url,
);
- expect(
- screen.getByTestId(`menu-item-${dropdownItems[0].label}`),
- ).toBeInTheDocument();
expect(await screen.findByText(dropdownItems[1].label)).toHaveAttribute(
'href',
dropdownItems[1].url,
diff --git a/superset-frontend/src/views/components/Menu.tsx b/superset-frontend/src/views/components/Menu.tsx
index a29671c902dd9..cc98130d4d400 100644
--- a/superset-frontend/src/views/components/Menu.tsx
+++ b/superset-frontend/src/views/components/Menu.tsx
@@ -17,7 +17,7 @@
* under the License.
*/
import React, { useState, useEffect } from 'react';
-import { styled, css } from '@superset-ui/core';
+import { styled, css, useTheme, SupersetTheme } from '@superset-ui/core';
import { debounce } from 'lodash';
import { Global } from '@emotion/react';
import { getUrlParam } from 'src/utils/urlUtils';
@@ -75,10 +75,12 @@ export interface MenuProps {
interface MenuObjectChildProps {
label: string;
name?: string;
- icon: string;
- index: number;
+ icon?: string;
+ index?: number;
url?: string;
isFrontendRoute?: boolean;
+ perm?: string;
+ view?: string;
}
export interface MenuObjectProps extends MenuObjectChildProps {
@@ -172,7 +174,21 @@ const StyledHeader = styled.header`
}
}
`;
-
+const globalStyles = (theme: SupersetTheme) => css`
+ .ant-menu-submenu.ant-menu-submenu-popup.ant-menu.ant-menu-light.ant-menu-submenu-placement-bottomLeft {
+ border-radius: 0px;
+ }
+ .ant-menu-submenu.ant-menu-submenu-popup.ant-menu.ant-menu-light {
+ border-radius: 0px;
+ }
+ .ant-menu-vertical > .ant-menu-submenu.data-menu > .ant-menu-submenu-title {
+ height: 28px;
+ i {
+ padding-right: ${theme.gridUnit * 2}px;
+ margin-left: ${theme.gridUnit * 1.75}px;
+ }
+ }
+`;
const { SubMenu } = DropdownMenu;
const { useBreakpoint } = Grid;
@@ -184,6 +200,7 @@ export function Menu({
const [showMenu, setMenu] = useState('horizontal');
const screens = useBreakpoint();
const uiConig = useUiConfig();
+ const theme = useTheme();
useEffect(() => {
function handleResize() {
@@ -251,16 +268,7 @@ export function Menu({
};
return (
-
+
(
state => state.user,
);
-
+ // @ts-ignore
+ const { CSV_EXTENSIONS, COLUMNAR_EXTENSIONS, EXCEL_EXTENSIONS } = useSelector<
+ any,
+ CommonBootstrapData
+ >(state => state.common.conf);
// if user has any of these roles the dropdown will appear
+ const configMap = {
+ 'Upload a CSV': CSV_EXTENSIONS,
+ 'Upload a Columnar file': COLUMNAR_EXTENSIONS,
+ 'Upload Excel': EXCEL_EXTENSIONS,
+ };
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;
+ const menuIconAndLabel = (menu: MenuObjectProps) => (
+ <>
+
+ {menu.label}
+ >
+ );
return (