fix(dashboard): don't show report modal for anonymous user (#17106)

* Added sunburst echart

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

* Address comments

* Make prettier happy

Co-authored-by: Mayur <mayurp@kpmg.com>
This commit is contained in:
Mayur 2021-11-11 16:20:12 +05:30 committed by GitHub
parent 45480f7ae5
commit 8756c9089e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 2 deletions

View File

@ -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();
});
});

View File

@ -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;
}

View File

@ -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;
}