Skip to content

Commit

Permalink
Fix access denied handling for attributes and permissions (#722)
Browse files Browse the repository at this point in the history
  • Loading branch information
AbbyB97 authored Aug 22, 2024
1 parent e1a8c4f commit a736900
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/components/Attributes/CustomAttributeWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Field, Form } from 'react-final-form';
import { useDispatch, useSelector } from 'react-redux';
import Select from 'react-select';
import { Form as BootstrapForm, Col, Row } from 'reactstrap';
import { LockWidgetNameEnum } from 'types/user-interface';
import { actions as customAttributesActions, selectors as customAttributesSelectors } from '../../../ducks/customAttributes';
import { AttributeResponseModel, BaseAttributeContentModel, CustomAttributeModel } from '../../../types/attributes';
import { Resource } from '../../../types/openapi';
Expand Down Expand Up @@ -94,7 +95,12 @@ export default function CustomAttributeWidget({ resource, resourceUuid, attribut
);

return (
<Widget title={'Custom Attributes'} busy={isFetchingResourceCustomAttributes || isUpdatingContent} titleSize="large">
<Widget
title={'Custom Attributes'}
busy={isFetchingResourceCustomAttributes || isUpdatingContent}
titleSize="large"
widgetLockName={LockWidgetNameEnum.CustomAttributeWidget}
>
<AttributeViewer
attributes={loadedAttributes}
descriptors={resourceCustomAttributes}
Expand Down
4 changes: 2 additions & 2 deletions src/ducks/auth-epics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const getAuthResources: AppEpic = (action$, state$, deps) => {
catchError((err) =>
of(
slice.actions.getAuthResourcesFailure(),
appRedirectActions.fetchError({ error: err.payload.error, message: 'Failed to get user resources' }),
appRedirectActions.fetchError({ error: err, message: 'Failed to get user resources' }),
),
),
),
Expand All @@ -87,7 +87,7 @@ const getObjectsForResource: AppEpic = (action$, state$, deps) => {
catchError((err) =>
of(
slice.actions.getObjectsForResourceFailure(),
appRedirectActions.fetchError({ error: err.payload.error, message: 'Failed to get objects list' }),
appRedirectActions.fetchError({ error: err, message: 'Failed to get objects list' }),
),
),
),
Expand Down
1 change: 1 addition & 0 deletions src/ducks/certificateGroups-epics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const listGroups: AppEpic = (action$, state$, deps) => {
catchError((err) =>
of(
slice.actions.listGroupsFailure({ error: extractError(err, 'Failed to get Group list') }),
alertActions.error(extractError(err, 'Failed to get Group list')),
userInterfaceActions.insertWidgetLock(err, LockWidgetNameEnum.ListOfGroups),
),
),
Expand Down
8 changes: 7 additions & 1 deletion src/ducks/customAttributes-epics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,19 @@ const listResourceCustomAttributes: AppEpic = (action$, state$, deps) => {
filter(slice.actions.listResourceCustomAttributes.match),
switchMap((action) =>
deps.apiClients.customAttributes.getResourceCustomAttributes({ resource: action.payload }).pipe(
map((list) => slice.actions.listResourceCustomAttributesSuccess(list.map(transformCustomAttributeDtoToModel))),
switchMap((list) =>
of(
slice.actions.listResourceCustomAttributesSuccess(list.map(transformCustomAttributeDtoToModel)),
userInterfaceActions.removeWidgetLock(LockWidgetNameEnum.CustomAttributeWidget),
),
),
catchError((err) =>
of(
slice.actions.listResourceCustomAttributesFailure({
error: extractError(err, 'Failed to get Resource Custom Attributes list'),
}),
appRedirectActions.fetchError({ error: err, message: 'Failed to get Resource Custom Attributes list' }),
userInterfaceActions.insertWidgetLock(err, LockWidgetNameEnum.CustomAttributeWidget),
),
),
),
Expand Down
1 change: 1 addition & 0 deletions src/ducks/token-profiles-epics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const listTokenProfiles: AppEpic = (action$, state$, deps) => {
catchError((error) =>
of(
slice.actions.listTokenProfilesFailure({ error: extractError(error, 'Failed to get Token profiles list') }),
alertActions.error(extractError(error, 'Failed to get Token profiles list')),
userInterfaceActions.insertWidgetLock(error, LockWidgetNameEnum.ListOfTokenProfiles),
),
),
Expand Down
1 change: 1 addition & 0 deletions src/types/user-interface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export enum LockWidgetNameEnum {
SchedulerJobDetail,
ListOfNotifications,
NotificationsOverview,
CustomAttributeWidget,
}

export interface WidgetLockModel {
Expand Down

0 comments on commit a736900

Please sign in to comment.