Skip to content

Commit

Permalink
fix: show Import button only if has perms
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida committed Sep 21, 2021
1 parent 48a61ba commit b4466e3
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 46 deletions.
31 changes: 16 additions & 15 deletions superset-frontend/src/views/CRUD/chart/ChartList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -589,21 +589,22 @@ function ChartList(props: ChartListProps) {
window.location.assign('/chart/add');
},
});
}
if (isFeatureEnabled(FeatureFlag.VERSIONED_EXPORT)) {
subMenuButtons.push({
name: (
<Tooltip
id="import-tooltip"
title={t('Import charts')}
placement="bottomRight"
>
<Icons.Import data-test="import-button" />
</Tooltip>
),
buttonStyle: 'link',
onClick: openChartImportModal,
});

if (isFeatureEnabled(FeatureFlag.VERSIONED_EXPORT)) {
subMenuButtons.push({
name: (
<Tooltip
id="import-tooltip"
title={t('Import charts')}
placement="bottomRight"
>
<Icons.Import data-test="import-button" />
</Tooltip>
),
buttonStyle: 'link',
onClick: openChartImportModal,
});
}
}
return (
<>
Expand Down
31 changes: 16 additions & 15 deletions superset-frontend/src/views/CRUD/dashboard/DashboardList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -545,21 +545,22 @@ function DashboardList(props: DashboardListProps) {
window.location.assign('/dashboard/new');
},
});
}
if (isFeatureEnabled(FeatureFlag.VERSIONED_EXPORT)) {
subMenuButtons.push({
name: (
<Tooltip
id="import-tooltip"
title={t('Import dashboards')}
placement="bottomRight"
>
<Icons.Import data-test="import-button" />
</Tooltip>
),
buttonStyle: 'link',
onClick: openDashboardImportModal,
});

if (isFeatureEnabled(FeatureFlag.VERSIONED_EXPORT)) {
subMenuButtons.push({
name: (
<Tooltip
id="import-tooltip"
title={t('Import dashboards')}
placement="bottomRight"
>
<Icons.Import data-test="import-button" />
</Tooltip>
),
buttonStyle: 'link',
onClick: openDashboardImportModal,
});
}
}
return (
<>
Expand Down
30 changes: 15 additions & 15 deletions superset-frontend/src/views/CRUD/data/dataset/DatasetList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -492,22 +492,22 @@ const DatasetList: FunctionComponent<DatasetListProps> = ({
onClick: () => setDatasetAddModalOpen(true),
buttonStyle: 'primary',
});
}

if (isFeatureEnabled(FeatureFlag.VERSIONED_EXPORT)) {
buttonArr.push({
name: (
<Tooltip
id="import-tooltip"
title={t('Import datasets')}
placement="bottomRight"
>
<Icons.Import data-test="import-button" />
</Tooltip>
),
buttonStyle: 'link',
onClick: openDatasetImportModal,
});
if (isFeatureEnabled(FeatureFlag.VERSIONED_EXPORT)) {
buttonArr.push({
name: (
<Tooltip
id="import-tooltip"
title={t('Import datasets')}
placement="bottomRight"
>
<Icons.Import data-test="import-button" />
</Tooltip>
),
buttonStyle: 'link',
onClick: openDatasetImportModal,
});
}
}

menuData.buttons = buttonArr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ function SavedQueryList({
refreshData();
};

const canCreate = hasPerm('can_write');
const canEdit = hasPerm('can_write');
const canDelete = hasPerm('can_write');
const canExport =
Expand Down Expand Up @@ -185,7 +186,7 @@ function SavedQueryList({
buttonStyle: 'primary',
});

if (isFeatureEnabled(FeatureFlag.VERSIONED_EXPORT)) {
if (canCreate && isFeatureEnabled(FeatureFlag.VERSIONED_EXPORT)) {
subMenuButtons.push({
name: (
<Tooltip
Expand Down

0 comments on commit b4466e3

Please sign in to comment.