Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 10 additions & 74 deletions features/admin.claims.v1/components/claims-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,10 @@
import { attributeConfig } from "@wso2is/admin.extensions.v1";
import { useGetCurrentOrganizationType } from "@wso2is/admin.organizations.v1/hooks/use-get-organization-type";
import { getProfileSchemas } from "@wso2is/admin.users.v1/api";
import { PRIMARY_USERSTORE } from "@wso2is/admin.userstores.v1/constants/user-store-constants";
import useUserStores from "@wso2is/admin.userstores.v1/hooks/use-user-stores";
import { UserStoreListItem } from "@wso2is/admin.userstores.v1/models/user-stores";
import { IdentityAppsApiException } from "@wso2is/core/exceptions";
import {
AlertLevels,
AttributeMapping,
Claim,
ClaimDialect,
ExternalClaim,
Expand All @@ -43,7 +40,6 @@
TestableComponentInterface
} from "@wso2is/core/models";
import { addAlert, setProfileSchemaRequestLoadingStatus, setSCIMSchemas } from "@wso2is/core/store";
import { StringUtils } from "@wso2is/core/utils";
import { FormValue, useTrigger } from "@wso2is/forms";
import {
AnimatedAvatar,
Expand Down Expand Up @@ -243,9 +239,9 @@

const dispatch: ThunkDispatch<AppState, any, any> = useDispatch();

const primaryUserStoreDomainName: string = useSelector((state: AppState) =>

Check warning on line 242 in features/admin.claims.v1/components/claims-list.tsx

View workflow job for this annotation

GitHub Actions / ⬣ ESLint (STATIC ANALYSIS) (lts/*, 8.7.4)

'primaryUserStoreDomainName' is assigned a value but never used. Allowed unused vars must match /^_/u
state?.config?.ui?.primaryUserStoreDomainName);
const systemReservedUserStores: string[] = useSelector((state: AppState) =>

Check warning on line 244 in features/admin.claims.v1/components/claims-list.tsx

View workflow job for this annotation

GitHub Actions / ⬣ ESLint (STATIC ANALYSIS) (lts/*, 8.7.4)

'systemReservedUserStores' is assigned a value but never used. Allowed unused vars must match /^_/u
state?.config?.ui?.systemReservedUserStores);

const [ submitExternalClaim, setSubmitExternalClaim ] = useTrigger();
Expand All @@ -269,33 +265,6 @@
mutateUserStoreList();
}, []);

/**
* This check if the input claim is mapped to attribute from every userstore.
*
* @param claim - The claim to be checked.
*
* @returns The array of userstore names without a mapped attribute.
*/
const checkUserStoreMapping = (claim: Claim): string[] => {
const userStoresNotSet: string[] = [];

userStores
?.filter((userStore: UserStoreListItem) => !systemReservedUserStores?.includes(userStore.name))
?.forEach((userStore: UserStoreListItem) => {
claim?.attributeMapping?.find((attribute: AttributeMapping) => {
return attribute.userstore.toLowerCase() === userStore.name.toLowerCase();
}) ?? userStoresNotSet.push(userStore.name);
});

claim?.attributeMapping?.find((attribute: AttributeMapping) => {
return attribute.userstore === primaryUserStoreDomainName;
}) ?? userStoresNotSet.push(StringUtils.isEqualCaseInsensitive(primaryUserStoreDomainName, PRIMARY_USERSTORE)
? t("console:manage.features.users.userstores.userstoreOptions.primary")
: primaryUserStoreDomainName);

return userStoresNotSet;
};

/**
* This checks if the list data is a local claim.
*
Expand Down Expand Up @@ -697,54 +666,21 @@
id: "displayName",
key: "displayName",
render: (claim: Claim) => {
const userStoresNotMapped: string[] = checkUserStoreMapping(claim);
const showWarning: boolean = userStoresNotMapped.length > 0;

return (
<Header as="h6" image>
<>
{ attributeConfig.attributes.showUserstoreMappingWarningIcon && showWarning && (
<Popup
trigger={ (
<Icon
className="notification-icon"
name="warning circle"
size="small"
color="red"
/>
) }
content={ (
<div>
{ t("claims:list.warning") }
<ul>
{
userStoresNotMapped.map((store: string, index: number) => {
return (
<li key={ index }>
{ store }
</li>
);
})
}
</ul>
</div>
) }
inverted
<AppAvatar
image={ (
<AnimatedAvatar
name={ generateInitialLetter(claim) }
size="mini"
data-testid={ `${ testId }-item-image-inner` }
/>
) }
<AppAvatar
image={ (
<AnimatedAvatar
name={ generateInitialLetter(claim) }
size="mini"
data-testid={ `${ testId }-item-image-inner` }
/>
) }
size="mini"
spaced="right"
data-testid={ `${ testId }-item-image` }
/>
</>
size="mini"
spaced="right"
data-testid={ `${ testId }-item-image` }
/>
<Header.Content>
{ claim.displayName }
<Header.Subheader>
Expand Down
Loading