Skip to content

Commit

Permalink
address concerns
Browse files Browse the repository at this point in the history
  • Loading branch information
hughhhh committed Feb 22, 2022
1 parent 58d7607 commit b1aeaa4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
38 changes: 20 additions & 18 deletions superset-frontend/src/views/components/MenuRight.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,24 @@ export const dropdownItems: MenuObjectProps[] = [
icon: 'fa-database',
childs: [
{
icon: 'fa-upload',
label: t('Connect Database'),
name: GlobalMenuDataOptions.DB_CONNECTION,
},
{
label: t('Connect Google Sheet'),
name: GlobalMenuDataOptions.GOOGLE_SHEETS,
},
{
label: t('Upload a CSV'),
name: 'Upload a CSV',
url: '/csvtodatabaseview/form',
},
{
icon: 'fa-upload',
label: t('Upload a Columnar File'),
name: 'Upload a Columnar file',
url: '/columnartodatabaseview/form',
},
{
icon: 'fa-upload',
label: t('Upload Excel'),
name: 'Upload Excel',
url: '/exceltodatabaseview/form',
Expand Down Expand Up @@ -133,6 +138,8 @@ const RightMenu = ({
'Upload a CSV': CSV_EXTENSIONS,
'Upload a Columnar file': COLUMNAR_EXTENSIONS,
'Upload Excel': EXCEL_EXTENSIONS,
[GlobalMenuDataOptions.GOOGLE_SHEETS]: SHOW_GLOBAL_GSHEETS,
[GlobalMenuDataOptions.DB_CONNECTION]: true, // todo(hugh): add permission check here for database creation
};
const canSql = findPermission('can_sqllab', 'Superset', roles);
const canDashboard = findPermission('can_write', 'Dashboard', roles);
Expand All @@ -146,10 +153,10 @@ const RightMenu = ({
);

const handleMenuSelection = (itemChose: any) => {
if (Number(itemChose.key) === GlobalMenuDataOptions.DB_CONNECTION) {
if (itemChose.key === GlobalMenuDataOptions.DB_CONNECTION) {
setShowModal(true);
setEngine('');
} else if (Number(itemChose.key) === GlobalMenuDataOptions.GOOGLE_SHEETS) {
} else if (itemChose.key === GlobalMenuDataOptions.GOOGLE_SHEETS) {
setShowModal(true);
setEngine('Google Sheets');
}
Expand Down Expand Up @@ -179,22 +186,17 @@ const RightMenu = ({
className="data-menu"
title={menuIconAndLabel(menu)}
>
<Menu.Item key={GlobalMenuDataOptions.DB_CONNECTION}>
Connect Database
</Menu.Item>
{SHOW_GLOBAL_GSHEETS && (
<Menu.Item key={GlobalMenuDataOptions.GOOGLE_SHEETS}>
Connect Google Sheet
</Menu.Item>
)}
<Menu.Divider />
{menu.childs.map(item =>
{menu.childs.map((item, idx) =>
typeof item !== 'string' &&
item.name &&
configMap[item.name] === true ? (
<Menu.Item key={item.name}>
<a href={item.url}> {item.label} </a>
</Menu.Item>
<>
{idx === 2 && <Menu.Divider />}
<Menu.Item key={item.name}>
{item.url && <a href={item.url}> {item.label} </a>}
{item.url === undefined && item.label}
</Menu.Item>
</>
) : null,
)}
</SubMenu>
Expand Down
4 changes: 2 additions & 2 deletions superset-frontend/src/views/components/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ export interface RightMenuProps {
}

export enum GlobalMenuDataOptions {
GOOGLE_SHEETS,
DB_CONNECTION,
GOOGLE_SHEETS = 'gsheets',
DB_CONNECTION = 'dbconnection',
}

0 comments on commit b1aeaa4

Please sign in to comment.