From effb35c11905233341e00a99856412d613af2a46 Mon Sep 17 00:00:00 2001 From: Mayur Date: Mon, 27 Sep 2021 06:30:42 +0530 Subject: [PATCH 1/4] Added sunburst echart --- superset-frontend/src/visualizations/presets/MainPreset.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/superset-frontend/src/visualizations/presets/MainPreset.js b/superset-frontend/src/visualizations/presets/MainPreset.js index 97c14a99d57da..c572b02e858c3 100644 --- a/superset-frontend/src/visualizations/presets/MainPreset.js +++ b/superset-frontend/src/visualizations/presets/MainPreset.js @@ -70,6 +70,7 @@ import { EchartsTreemapChartPlugin, EchartsMixedTimeseriesChartPlugin, EchartsTreeChartPlugin, + EchartsSunburstChartPlugin } from '@superset-ui/plugin-chart-echarts'; import { SelectFilterPlugin, @@ -166,6 +167,7 @@ export default class MainPreset extends Preset { new TimeColumnFilterPlugin().configure({ key: 'filter_timecolumn' }), new TimeGrainFilterPlugin().configure({ key: 'filter_timegrain' }), new EchartsTreeChartPlugin().configure({ key: 'tree_chart' }), + new EchartsSunburstChartPlugin().configure({ key: 'sunburst_2' }), ...experimentalplugins, ], }); From eb697e28e988f1096593332fb0925367b8cdb431 Mon Sep 17 00:00:00 2001 From: Mayur Date: Thu, 14 Oct 2021 08:34:23 +0530 Subject: [PATCH 2/4] fix(dashboard):Hide reports modal for anonymous users --- .../components/Header/Header.test.tsx | 27 +++++++++++++++++++ .../src/dashboard/components/Header/index.jsx | 2 +- .../components/ExploreChartHeader/index.jsx | 2 +- .../src/visualizations/presets/MainPreset.js | 2 -- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/superset-frontend/src/dashboard/components/Header/Header.test.tsx b/superset-frontend/src/dashboard/components/Header/Header.test.tsx index 9e285f1c66af1..b5cf6c0cf84f9 100644 --- a/superset-frontend/src/dashboard/components/Header/Header.test.tsx +++ b/superset-frontend/src/dashboard/components/Header/Header.test.tsx @@ -465,4 +465,31 @@ describe('Email Report Modal', () => { // BLOCKER: I cannot get report to populate, as its data is handled through redux expect.anything(); }); + + it('Should render report header', async () => { + const mockedProps = createProps(); + render(setup(mockedProps)); + expect( + screen.getByRole('button', { name: 'Schedule email report' }), + ).toBeInTheDocument(); + }); + + it('Should not render report header even with menu access for anonymous user', async () => { + const mockedProps = createProps(); + const anonymousUserProps = { + ...mockedProps, + user: { + roles: { + Public: [['menu_access', 'Manage']], + }, + permissions: { + datasource_access: ['[examples].[birth_names](id:2)'], + }, + }, + }; + render(setup(anonymousUserProps)); + expect(() => + screen.getByRole('button', { name: 'Schedule email report' }), + ).toThrowError('Unable to find'); + }); }); diff --git a/superset-frontend/src/dashboard/components/Header/index.jsx b/superset-frontend/src/dashboard/components/Header/index.jsx index f8ca74b8e9713..1fb26eb0cc914 100644 --- a/superset-frontend/src/dashboard/components/Header/index.jsx +++ b/superset-frontend/src/dashboard/components/Header/index.jsx @@ -435,7 +435,7 @@ class Header extends React.PureComponent { return false; } const { user } = this.props; - if (!user) { + if (!user?.userId) { // this is in the case that there is an anonymous user. return false; } diff --git a/superset-frontend/src/explore/components/ExploreChartHeader/index.jsx b/superset-frontend/src/explore/components/ExploreChartHeader/index.jsx index 008ff0a5950cf..be713614a4178 100644 --- a/superset-frontend/src/explore/components/ExploreChartHeader/index.jsx +++ b/superset-frontend/src/explore/components/ExploreChartHeader/index.jsx @@ -227,7 +227,7 @@ export class ExploreChartHeader extends React.PureComponent { return false; } const { user } = this.props; - if (!user) { + if (!user?.userId) { // this is in the case that there is an anonymous user. return false; } diff --git a/superset-frontend/src/visualizations/presets/MainPreset.js b/superset-frontend/src/visualizations/presets/MainPreset.js index c572b02e858c3..97c14a99d57da 100644 --- a/superset-frontend/src/visualizations/presets/MainPreset.js +++ b/superset-frontend/src/visualizations/presets/MainPreset.js @@ -70,7 +70,6 @@ import { EchartsTreemapChartPlugin, EchartsMixedTimeseriesChartPlugin, EchartsTreeChartPlugin, - EchartsSunburstChartPlugin } from '@superset-ui/plugin-chart-echarts'; import { SelectFilterPlugin, @@ -167,7 +166,6 @@ export default class MainPreset extends Preset { new TimeColumnFilterPlugin().configure({ key: 'filter_timecolumn' }), new TimeGrainFilterPlugin().configure({ key: 'filter_timegrain' }), new EchartsTreeChartPlugin().configure({ key: 'tree_chart' }), - new EchartsSunburstChartPlugin().configure({ key: 'sunburst_2' }), ...experimentalplugins, ], }); From bd9c2a13b992f75ea46d01603778673ee790f196 Mon Sep 17 00:00:00 2001 From: Mayur Date: Thu, 11 Nov 2021 14:19:12 +0530 Subject: [PATCH 3/4] Address comments --- .../src/dashboard/components/Header/Header.test.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/superset-frontend/src/dashboard/components/Header/Header.test.tsx b/superset-frontend/src/dashboard/components/Header/Header.test.tsx index b5cf6c0cf84f9..61f23a6dd5ae4 100644 --- a/superset-frontend/src/dashboard/components/Header/Header.test.tsx +++ b/superset-frontend/src/dashboard/components/Header/Header.test.tsx @@ -488,8 +488,8 @@ describe('Email Report Modal', () => { }, }; render(setup(anonymousUserProps)); - expect(() => - screen.getByRole('button', { name: 'Schedule email report' }), - ).toThrowError('Unable to find'); + expect( + screen.queryByRole('button', { name: 'Schedule email report' }) + ).not.toBeInTheDocument() }); }); From 95e6c11a335e53c9e10e2dbc45e8cca5bf274bef Mon Sep 17 00:00:00 2001 From: Mayur Date: Thu, 11 Nov 2021 14:41:50 +0530 Subject: [PATCH 4/4] Make prettier happy --- .../src/dashboard/components/Header/Header.test.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/superset-frontend/src/dashboard/components/Header/Header.test.tsx b/superset-frontend/src/dashboard/components/Header/Header.test.tsx index 61f23a6dd5ae4..b8034bf92457d 100644 --- a/superset-frontend/src/dashboard/components/Header/Header.test.tsx +++ b/superset-frontend/src/dashboard/components/Header/Header.test.tsx @@ -489,7 +489,7 @@ describe('Email Report Modal', () => { }; render(setup(anonymousUserProps)); expect( - screen.queryByRole('button', { name: 'Schedule email report' }) - ).not.toBeInTheDocument() + screen.queryByRole('button', { name: 'Schedule email report' }), + ).not.toBeInTheDocument(); }); });