Feature #14503_keep_services_panel
Arvados-DCO-1.1-Signed-off-by: Janicki Artur <artur.janicki@contractors.roche.com>
}
public getIsAdmin(): boolean {
}
public getIsAdmin(): boolean {
- return !!localStorage.getItem(USER_IS_ADMIN);
+ return localStorage.getItem(USER_IS_ADMIN) === 'true';
}
public getUser(): User | undefined {
}
public getUser(): User | undefined {
import { KeepServiceResource } from '~/models/keep-services';
import { dialogActions } from '~/store/dialog/dialog-actions';
import { snackbarActions } from '~/store/snackbar/snackbar-actions';
import { KeepServiceResource } from '~/models/keep-services';
import { dialogActions } from '~/store/dialog/dialog-actions';
import { snackbarActions } from '~/store/snackbar/snackbar-actions';
+import { navigateToRootProject } from '~/store/navigation/navigation-action';
export const keepServicesActions = unionize({
SET_KEEP_SERVICES: ofType<KeepServiceResource[]>(),
export const keepServicesActions = unionize({
SET_KEEP_SERVICES: ofType<KeepServiceResource[]>(),
- REMOVE_KEEP_SERVICE: ofType<string>(),
- RESET_KEEP_SERVICES: ofType<{}>()
+ REMOVE_KEEP_SERVICE: ofType<string>()
});
export type KeepServicesActions = UnionOf<typeof keepServicesActions>;
});
export type KeepServicesActions = UnionOf<typeof keepServicesActions>;
export const KEEP_SERVICE_REMOVE_DIALOG = 'keepServiceRemoveDialog';
export const KEEP_SERVICE_ATTRIBUTES_DIALOG = 'keepServiceAttributesDialog';
export const KEEP_SERVICE_REMOVE_DIALOG = 'keepServiceRemoveDialog';
export const KEEP_SERVICE_ATTRIBUTES_DIALOG = 'keepServiceAttributesDialog';
-// ToDo: access denied for loading keepService and reset data and redirect
export const loadKeepServicesPanel = () =>
async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
export const loadKeepServicesPanel = () =>
async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
- try {
- dispatch(setBreadcrumbs([{ label: 'Keep Services' }]));
- const response = await services.keepService.list();
- dispatch(keepServicesActions.SET_KEEP_SERVICES(response.items));
- } catch (e) {
- return;
+ const user = getState().auth.user;
+ if(user && user.isAdmin) {
+ try {
+ dispatch(setBreadcrumbs([{ label: 'Keep Services' }]));
+ const response = await services.keepService.list();
+ dispatch(keepServicesActions.SET_KEEP_SERVICES(response.items));
+ } catch (e) {
+ return;
+ }
+ } else {
+ dispatch(navigateToRootProject);
+ dispatch(snackbarActions.OPEN_SNACKBAR({ message: "You don't have permissions to view this page", hideDuration: 2000 }));
-// ToDo: access denied for removing keepService and reset data and redirect
export const removeKeepService = (uuid: string) =>
async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Removing ...' }));
export const removeKeepService = (uuid: string) =>
async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Removing ...' }));
keepServicesActions.match(action, {
SET_KEEP_SERVICES: items => items,
REMOVE_KEEP_SERVICE: (uuid: string) => state.filter((keepService) => keepService.uuid !== uuid),
keepServicesActions.match(action, {
SET_KEEP_SERVICES: items => items,
REMOVE_KEEP_SERVICE: (uuid: string) => state.filter((keepService) => keepService.uuid !== uuid),
- RESET_KEEP_SERVICES: () => [],
default: () => state
});
\ No newline at end of file
default: () => state
});
\ No newline at end of file