Skip to content

Commit

Permalink
fix(dashboard):Hide reports modal for anonymous users
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayur authored and mayurnewase committed Nov 11, 2021
1 parent effb35c commit eb697e2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
27 changes: 27 additions & 0 deletions superset-frontend/src/dashboard/components/Header/Header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 0 additions & 2 deletions superset-frontend/src/visualizations/presets/MainPreset.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ import {
EchartsTreemapChartPlugin,
EchartsMixedTimeseriesChartPlugin,
EchartsTreeChartPlugin,
EchartsSunburstChartPlugin
} from '@superset-ui/plugin-chart-echarts';
import {
SelectFilterPlugin,
Expand Down Expand Up @@ -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,
],
});
Expand Down

0 comments on commit eb697e2

Please sign in to comment.