You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by di...@apache.org on 2024/01/25 15:58:15 UTC
(superset) 01/01: Add can_view_and_drill permission
This is an automated email from the ASF dual-hosted git repository.
diegopucci pushed a commit to branch diego/ch77449/embedded_drill_permission
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 03abeb0af75babe083cadd1c3984cd65b388881a
Author: geido <di...@gmail.com>
AuthorDate: Thu Jan 25 16:57:58 2024 +0100
Add can_view_and_drill permission
---
.../components/Chart/ChartContextMenu/ChartContextMenu.tsx | 7 +++++--
.../src/dashboard/components/SliceHeaderControls/index.tsx | 11 ++++++++---
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/superset-frontend/src/components/Chart/ChartContextMenu/ChartContextMenu.tsx b/superset-frontend/src/components/Chart/ChartContextMenu/ChartContextMenu.tsx
index 6ab80aad9e..a12592de0f 100644
--- a/superset-frontend/src/components/Chart/ChartContextMenu/ChartContextMenu.tsx
+++ b/superset-frontend/src/components/Chart/ChartContextMenu/ChartContextMenu.tsx
@@ -90,6 +90,9 @@ const ChartContextMenu = (
const canExplore = useSelector((state: RootState) =>
findPermission('can_explore', 'Superset', state.user?.roles),
);
+ const canViewDrill = useSelector((state: RootState) =>
+ findPermission('can_view_and_drill', 'Dashboard', state.user?.roles),
+ );
const crossFiltersEnabled = useSelector<RootState, boolean>(
({ dashboardInfo }) => dashboardInfo.crossFiltersEnabled,
);
@@ -108,12 +111,12 @@ const ChartContextMenu = (
const showDrillToDetail =
isFeatureEnabled(FeatureFlag.DRILL_TO_DETAIL) &&
- canExplore &&
+ (canExplore || canViewDrill) &&
isDisplayed(ContextMenuItem.DrillToDetail);
const showDrillBy =
isFeatureEnabled(FeatureFlag.DRILL_BY) &&
- canExplore &&
+ (canExplore || canViewDrill) &&
isDisplayed(ContextMenuItem.DrillBy);
const showCrossFilters =
diff --git a/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx b/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx
index 305bc38434..9bea901cea 100644
--- a/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx
+++ b/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx
@@ -58,6 +58,7 @@ import { DrillDetailMenuItems } from 'src/components/Chart/DrillDetail';
import { LOG_ACTIONS_CHART_DOWNLOAD_AS_IMAGE } from 'src/logger/LogUtils';
import { RootState } from 'src/dashboard/types';
import { useCrossFiltersScopingModal } from '../nativeFilters/FilterBar/CrossFilters/ScopingModal/useCrossFiltersScopingModal';
+import { findPermission } from 'src/utils/findPermission';
const MENU_KEYS = {
DOWNLOAD_AS_IMAGE: 'download_as_image',
@@ -260,6 +261,10 @@ const SliceHeaderControls = (props: SliceHeaderControlsPropsWithRouter) => {
.get(props.slice.viz_type)
?.behaviors?.includes(Behavior.INTERACTIVE_CHART);
+ const canViewDrill = useSelector((state: RootState) =>
+ findPermission('can_view_and_drill', 'Dashboard', state.user?.roles),
+ );
+
const refreshChart = () => {
if (props.updatedDttm) {
props.forceRefresh(props.slice.slice_id, props.dashboardId);
@@ -428,7 +433,7 @@ const SliceHeaderControls = (props: SliceHeaderControlsPropsWithRouter) => {
</>
)}
- {props.supersetCanExplore && (
+ {(props.supersetCanExplore || canViewDrill) && (
<Menu.Item key={MENU_KEYS.VIEW_QUERY}>
<ModalTrigger
triggerNode={
@@ -443,7 +448,7 @@ const SliceHeaderControls = (props: SliceHeaderControlsPropsWithRouter) => {
</Menu.Item>
)}
- {props.supersetCanExplore && (
+ {(props.supersetCanExplore || canViewDrill) && (
<Menu.Item key={MENU_KEYS.VIEW_RESULTS}>
<ViewResultsModalTrigger
exploreUrl={props.exploreUrl}
@@ -465,7 +470,7 @@ const SliceHeaderControls = (props: SliceHeaderControlsPropsWithRouter) => {
)}
{isFeatureEnabled(FeatureFlag.DRILL_TO_DETAIL) &&
- props.supersetCanExplore && (
+ (props.supersetCanExplore || canViewDrill) && (
<DrillDetailMenuItems
chartId={slice.slice_id}
formData={props.formData}