Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 7 additions & 0 deletions web/client/selectors/__tests__/dashboard-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ describe('dashboard selectors', () => {
}
}
})).toBe(false);
expect(buttonCanEdit({
router: {
location: {
pathname: '/dashboard/1'
}
}
})).toBe(false);
});

it("test dashboardServicesSelector", () => {
Expand Down
4 changes: 3 additions & 1 deletion web/client/selectors/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export const isDashboardLoading = state => state && state.dashboard && state.das
export const getDashboardSaveErrors = state => state && state.dashboard && state.dashboard.saveErrors;
export const isBrowserMobile = state => state && state.browser && state.browser.mobile;
export const buttonCanEdit = createSelector(pathnameSelector, dashboardResource, isBrowserMobile,
(path, resource, isMobile) => isMobile ? !isMobile : (resource && resource.canEdit || isNaN(path.substr(-4))));
// can edit only on desktop, when the resource is saved and editable by the user or when we are editing a new dashboard
// in that case the `path` ends with a number. Like `dashboard/1` or `dashboard/1234`.
(path, resource, isMobile) => isMobile ? !isMobile : (resource && resource.canEdit || isNaN(path.substr(-1))));
export const originalDataSelector = state => state?.dashboard?.originalData;

export const dashboardServicesSelector = state => state && state.dashboard && state.dashboard.services;
Expand Down