Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(report): Fix permission check for set up email report on charts/dashboards. Fixes #21559 #21561

Merged
merged 2 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,26 @@ const stateWithOnlyUser = {
reports: {},
};

const stateWithNonAdminUser = {
explore: {
user: {
email: 'nonadmin@test.com',
firstName: 'nonadmin',
isActive: true,
lastName: 'nonadmin',
permissions: {},
createdOn: '2022-01-12T10:17:37.801361',
roles: {
Gamma: [['no_menu_access', 'Manage']],
OtherRole: [['menu_access', 'Manage']],
},
userId: 1,
username: 'nonadmin',
},
},
reports: {},
};

const stateWithUserAndReport = {
user: {
email: 'admin@test.com',
Expand Down Expand Up @@ -193,4 +213,17 @@ describe('Header Report Dropdown', () => {
});
expect(screen.getByText('Set up an email report')).toBeInTheDocument();
});

it('renders Schedule Email Reports as long as user has permission through any role', () => {
let mockedProps = createProps();
mockedProps = {
...mockedProps,
useTextMenu: true,
isDropdownVisible: true,
};
act(() => {
setup(mockedProps, stateWithNonAdminUser);
});
expect(screen.getByText('Set up an email report')).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default function HeaderReportDropDown({
perms => perms[0] === 'menu_access' && perms[1] === 'Manage',
),
);
return permissions[0].length > 0;
return permissions.some(permission => permission.length > 0);
};

const [currentReportDeleting, setCurrentReportDeleting] =
Expand Down