Skip to content

Commit

Permalink
geosolutions-it#9932: On Binary dashboard public dashboard have + but…
Browse files Browse the repository at this point in the history
  • Loading branch information
mahmoudadel54 authored May 6, 2024
1 parent 9203e24 commit a3dfe06
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
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

0 comments on commit a3dfe06

Please sign in to comment.