Skip to content

Commit

Permalink
added support for error message displayed on delegation check and rel…
Browse files Browse the repository at this point in the history
…evant mock data (#1185)

Co-authored-by: Alexandra Vedeler <[email protected]>
  • Loading branch information
allinox and Alexandra Vedeler authored Dec 9, 2024
1 parent e345a9d commit e78e4c5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"status": "NotDelegable",
"details": [
{
"code": "MissingSrrRightAccess",
"code": "AccessListValidationFail",
"description": "The user have access through delegation(s) of the right to the recipient(s)",
"parameters": {
"roleRequirementsMatches": [
Expand All @@ -36,7 +36,7 @@
"status": "NotDelegable",
"details": [
{
"code": "MissingSrrRightAccess",
"code": "AccessListValidationFail",
"description": "The user have access through delegation(s) of the right to the recipient(s)",
"parameters": {
"roleRequirementsMatches": [
Expand All @@ -61,7 +61,7 @@
"status": "NotDelegable",
"details": [
{
"code": "MissingSrrRightAccess",
"code": "AccessListValidationFail",
"description": "The user have access through delegation(s) of the right to the recipient(s)",
"parameters": {
"roleRequirementsMatches": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ export const ResourceAlert = ({ resource, error, rightReasons }: ResourceAlertPr
</>
);
} else if (rightReasons) {
if (rightReasons.every((reason) => reason === ErrorCode.MissingSrrRightAccess)) {
if (
rightReasons.every(
(reason) =>
reason === ErrorCode.MissingSrrRightAccess ||
reason === ErrorCode.AccessListValidationFail,
)
) {
headingText = t('delegation_modal.service_error.general_heading');
content = (
<Paragraph>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ export const ResourceInfo = ({ resource, toParty, onDelegate }: ResourceInfoProp
const hasMissingSrrRightAccess = response.some(
(result) =>
!hasMissingRoleAccess &&
result.details?.some((detail) => detail.code === ErrorCode.MissingSrrRightAccess),
result.details?.some(
(detail) =>
detail.code === ErrorCode.MissingSrrRightAccess ||
detail.code === ErrorCode.AccessListValidationFail,
),
);

if (hasMissingRoleAccess) {
Expand Down
3 changes: 3 additions & 0 deletions src/resources/utils/errorCodeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export enum ErrorCode {
HTTPError = 'HTTPError',
Unauthorized = 'Unauthorized',
InsufficientAuthenticationLevel = 'InsufficientAuthenticationLevel',
AccessListValidationFail = 'AccessListValidationFail',
Unknown = 'Unknown',
}

Expand All @@ -16,6 +17,7 @@ export const getErrorCodeTextKey = (errorCode: string | undefined): string | und
case ErrorCode.MissingDelegationAccess:
return 'single_rights.missing_delegation_access';
case ErrorCode.MissingSrrRightAccess:
case ErrorCode.AccessListValidationFail:
return 'single_rights.missing_srr_right_access';
case ErrorCode.Unknown:
return 'single_rights.unknown';
Expand All @@ -39,6 +41,7 @@ export const prioritizeErrors = (errors: string[]): string[] => {
ErrorCode.MissingRoleAccess,
ErrorCode.MissingDelegationAccess,
ErrorCode.MissingSrrRightAccess,
ErrorCode.AccessListValidationFail,
ErrorCode.Unknown,
];

Expand Down

0 comments on commit e78e4c5

Please sign in to comment.