Skip to content

Commit

Permalink
fix(dashboard): don't show report modal for anonymous user (#17106)
Browse files Browse the repository at this point in the history
* Added sunburst echart

* fix(dashboard):Hide reports modal for anonymous users

* Address comments

* Make prettier happy

Co-authored-by: Mayur <mayurp@kpmg.com>
  • Loading branch information
mayurnewase and Mayur committed Nov 11, 2021
1 parent 45480f7 commit 8756c90
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 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.queryByRole('button', { name: 'Schedule email report' }),
).not.toBeInTheDocument();
});
});
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

0 comments on commit 8756c90

Please sign in to comment.