You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2021/11/11 10:51:32 UTC
[superset] branch master updated: fix(dashboard): don't show report
modal for anonymous user (#17106)
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 8756c90 fix(dashboard): don't show report modal for anonymous user (#17106)
8756c90 is described below
commit 8756c9089ea765454cebcb8ab76fffddb86f916a
Author: Mayur <ma...@gmail.com>
AuthorDate: Thu Nov 11 16:20:12 2021 +0530
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 <ma...@kpmg.com>
---
.../dashboard/components/Header/Header.test.tsx | 27 ++++++++++++++++++++++
.../src/dashboard/components/Header/index.jsx | 2 +-
.../components/ExploreChartHeader/index.jsx | 2 +-
3 files changed, 29 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 9e285f1..b8034bf 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.queryByRole('button', { name: 'Schedule email report' }),
+ ).not.toBeInTheDocument();
+ });
});
diff --git a/superset-frontend/src/dashboard/components/Header/index.jsx b/superset-frontend/src/dashboard/components/Header/index.jsx
index f8ca74b..1fb26eb 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 008ff0a..be71361 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;
}