Skip to content

Commit

Permalink
fix: Add perm for showing DBC-UI in Global Nav (#19023)
Browse files Browse the repository at this point in the history
* add perm for global db add

* fix permissions

* missing roles params
  • Loading branch information
hughhhh committed Mar 11, 2022
1 parent ae13d83 commit c337491
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions superset-frontend/src/views/components/MenuRight.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,25 @@ const RightMenu = ({
const canSql = findPermission('can_sqllab', 'Superset', roles);
const canDashboard = findPermission('can_write', 'Dashboard', roles);
const canChart = findPermission('can_write', 'Chart', roles);
const canDatabase = findPermission('can_write', 'Database', roles);

const canUploadCSV = findPermission(
'can_this_form_get',
'CsvToDatabaseView',
roles,
);
const canUploadColumnar = findPermission(
'can_this_form_get',
'ColumnarToDatabaseView',
roles,
);
const canUploadExcel = findPermission(
'can_this_form_get',
'ExcelToDatabaseView',
roles,
);

const canUpload = canUploadCSV || canUploadColumnar || canUploadExcel;
const showActionDropdown = canSql || canChart || canDashboard;
const dropdownItems: MenuObjectProps[] = [
{
Expand All @@ -94,30 +113,30 @@ const RightMenu = ({
{
label: t('Connect database'),
name: GlobalMenuDataOptions.DB_CONNECTION,
perm: true,
perm: canDatabase,
},
{
label: t('Connect Google Sheet'),
name: GlobalMenuDataOptions.GOOGLE_SHEETS,
perm: HAS_GSHEETS_INSTALLED,
perm: canDatabase && HAS_GSHEETS_INSTALLED,
},
{
label: t('Upload CSV to database'),
name: 'Upload a CSV',
url: '/csvtodatabaseview/form',
perm: CSV_EXTENSIONS,
perm: CSV_EXTENSIONS && canUploadCSV,
},
{
label: t('Upload columnar file to database'),
name: 'Upload a Columnar file',
url: '/columnartodatabaseview/form',
perm: COLUMNAR_EXTENSIONS,
perm: COLUMNAR_EXTENSIONS && canUploadColumnar,
},
{
label: t('Upload Excel file to database'),
name: 'Upload Excel',
url: '/exceltodatabaseview/form',
perm: EXCEL_EXTENSIONS,
perm: EXCEL_EXTENSIONS && canUploadExcel,
},
],
},
Expand Down Expand Up @@ -183,7 +202,7 @@ const RightMenu = ({
>
{dropdownItems.map(menu => {
if (menu.childs) {
return (
return canDatabase || canUpload ? (
<SubMenu
key="sub2"
className="data-menu"
Expand All @@ -206,7 +225,7 @@ const RightMenu = ({
) : null,
)}
</SubMenu>
);
) : null;
}
return (
findPermission(
Expand Down

0 comments on commit c337491

Please sign in to comment.