Skip to content

Commit d9f1976

Browse files
committed
Read the claims values from the claims for UI property.
1 parent 682b6ef commit d9f1976

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

.changeset/three-walls-run.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@wso2is/common.workflow-approvals.v1": patch
3+
---
4+
5+
Read the claims from the claimsUI property.

features/common.workflow-approvals.v1/components/approval-task.tsx

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -97,22 +97,6 @@ export const ApprovalTaskComponent: FunctionComponent<ApprovalTaskComponentProps
9797
const { t } = useTranslation();
9898
const { isMobileViewport } = useMediaContext();
9999

100-
const getClaimDisplayName = (claim: string): string => {
101-
const equalIndex: number = claim.indexOf("=");
102-
103-
if (equalIndex === -1) {
104-
return claim.trim();
105-
}
106-
107-
const claimUri: string = claim.substring(0, equalIndex).trim();
108-
const displayName: string = claimUri.split("/").pop();
109-
110-
return displayName || claim;
111-
};
112-
113-
114-
115-
116100
/**
117101
* Removes unnecessary commas at the end of property values and splits
118102
* up the claim values.
@@ -128,18 +112,24 @@ export const ApprovalTaskComponent: FunctionComponent<ApprovalTaskComponentProps
128112
*/
129113
const populateProperties = (key: string, value: string): string | JSX.Element => {
130114
if (key === "Claims") {
115+
return;
116+
}
117+
if (key === "ClaimsUI") {
118+
// Remove the curly braces at the start and end of the value.
131119
value = value.replace(/^\{|\}$/g, "").trim();
132120
const claims: string[] = value.split(",");
133121

134122
return (
135123
<>
136124
{ claims.map((claim: string, index: number) => {
137-
const claimValue: string = claim.split("=")[1]?.trim();
125+
const claimParts: string[] = claim.split("=");
126+
const claimDisplayName: string = claimParts[0]?.trim();
127+
const claimValue: string = claimParts[1]?.trim();
138128

139129
return (
140130
<Table.Row key={ `${key}-${index}` }>
141131
<Table.Cell className="key-cell">
142-
{ getClaimDisplayName(claim) }
132+
{ claimDisplayName }
143133
</Table.Cell>
144134
<Table.Cell collapsing className="values-cell">
145135
<Popup

0 commit comments

Comments
 (0)