From 73c8fa547bf9b902c7b9512e26e4ae58d4e276aa Mon Sep 17 00:00:00 2001 From: Achintha Isuru Date: Wed, 15 Nov 2023 18:59:25 +0530 Subject: [PATCH] (fix) enable custom user store managers --- .../features/userstores/models/user-stores.ts | 7 ++++--- .../userstores/pages/userstores-templates.tsx | 21 ++++++++++--------- .../images/illustrations/ad-illustration.svg | 2 +- .../illustrations/jdbc-illustration.svg | 2 +- .../illustrations/ldap-illustration.svg | 2 +- .../ldap-readonly-illustration.svg | 2 +- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/apps/console/src/features/userstores/models/user-stores.ts b/apps/console/src/features/userstores/models/user-stores.ts index 87872a9342d..67790d9b26e 100644 --- a/apps/console/src/features/userstores/models/user-stores.ts +++ b/apps/console/src/features/userstores/models/user-stores.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2020, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. + * Copyright (c) 2020-2023, WSO2 LLC. (https://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -103,11 +103,12 @@ export interface TypeProperty { * The type of object returned by the type meta endpoint */ export interface UserstoreType { - name: string; + name?: string; typeName: string; typeId: string; + isLocal?: boolean; className: string; - description: string; + description?: string; properties: { Mandatory: TypeProperty[]; Optional: TypeProperty[]; diff --git a/apps/console/src/features/userstores/pages/userstores-templates.tsx b/apps/console/src/features/userstores/pages/userstores-templates.tsx index 1aff842bca0..88234be7bc7 100644 --- a/apps/console/src/features/userstores/pages/userstores-templates.tsx +++ b/apps/console/src/features/userstores/pages/userstores-templates.tsx @@ -1,5 +1,5 @@ /** - * Copyright (c) 2020, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. + * Copyright (c) 2020-2023, WSO2 LLC. (https://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -19,6 +19,7 @@ import { AlertLevels, TestableComponentInterface } from "@wso2is/core/models"; import { addAlert } from "@wso2is/core/store"; import { EmptyPlaceholder, PageLayout, TemplateGrid } from "@wso2is/react-components"; +import { AxiosError } from "axios"; import React, { FunctionComponent, ReactElement, SyntheticEvent, useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { useDispatch } from "react-redux"; @@ -91,14 +92,13 @@ const UserstoresTemplates: FunctionComponent = useEffect(() => { getUserstoreTypes().then(async (response: TypeResponse[]) => { setIsLoading(true); - const typeRequests: Promise[] = response.map((type: TypeResponse) => { + const typeRequests: Promise[] = response.map((type: TypeResponse) => { return getAType(type.typeId, null); }); - const results: UserstoreType[] = await Promise.all( - typeRequests.map(response => response.catch(error => { + const results: (void | UserstoreType)[] = await Promise.all( + typeRequests.map((response: Promise) => response.catch((error: AxiosError) => { dispatch(addAlert({ - description: error?.description - || t("console:manage.features.userstores.notifications." + + description: t("console:manage.features.userstores.notifications." + "fetchUserstoreTemplates.genericError.description"), level: AlertLevels.ERROR, message: error?.message @@ -140,9 +140,9 @@ const UserstoresTemplates: FunctionComponent = }); setUserstoreTypes(uniqueUserstoreTypes.concat(userstoreTypes)); setRawUserstoreTypes(rawUserstoreTypes); - }).catch(error => { + }).catch((error: AxiosError) => { dispatch(addAlert({ - description: error?.description || t("console:manage.features.userstores.notifications." + + description: t("console:manage.features.userstores.notifications." + "fetchUserstoreTypes.genericError.description"), level: AlertLevels.ERROR, message: error?.message || t("console:manage.features.userstores.notifications." + @@ -193,7 +193,8 @@ const UserstoresTemplates: FunctionComponent = type="userstore" templates={ userstoreTypes } onTemplateSelect={ (e: SyntheticEvent, { id }: { id: string }) => { - setSelectedType(rawUserstoreTypes.find((type) => type.typeId === id)); + setSelectedType(rawUserstoreTypes.find( + (type: UserstoreType) => type.typeId === id)); } } templateIcons={ getUserstoreTemplateIllustrations() as any } templateIconOptions={ { @@ -201,7 +202,7 @@ const UserstoresTemplates: FunctionComponent = } } templateIconSize="tiny" paginate={ true } - paginationLimit={ 4 } + paginationLimit={ userstoreTypes?.length ? userstoreTypes.length : 0 } paginationOptions={ { showLessButtonLabel: t("common:showLess"), showMoreButtonLabel: t("common:showMore") diff --git a/modules/theme/src/themes/default/assets/images/illustrations/ad-illustration.svg b/modules/theme/src/themes/default/assets/images/illustrations/ad-illustration.svg index 08edb937435..ee00b462b39 100644 --- a/modules/theme/src/themes/default/assets/images/illustrations/ad-illustration.svg +++ b/modules/theme/src/themes/default/assets/images/illustrations/ad-illustration.svg @@ -18,7 +18,7 @@ * under the License. --> - + diff --git a/modules/theme/src/themes/default/assets/images/illustrations/jdbc-illustration.svg b/modules/theme/src/themes/default/assets/images/illustrations/jdbc-illustration.svg index be8d550c137..7d422916c1a 100644 --- a/modules/theme/src/themes/default/assets/images/illustrations/jdbc-illustration.svg +++ b/modules/theme/src/themes/default/assets/images/illustrations/jdbc-illustration.svg @@ -18,7 +18,7 @@ * under the License. --> - + diff --git a/modules/theme/src/themes/default/assets/images/illustrations/ldap-illustration.svg b/modules/theme/src/themes/default/assets/images/illustrations/ldap-illustration.svg index 7f5f3681624..35b4f7fe146 100644 --- a/modules/theme/src/themes/default/assets/images/illustrations/ldap-illustration.svg +++ b/modules/theme/src/themes/default/assets/images/illustrations/ldap-illustration.svg @@ -18,7 +18,7 @@ * under the License. --> - + diff --git a/modules/theme/src/themes/default/assets/images/illustrations/ldap-readonly-illustration.svg b/modules/theme/src/themes/default/assets/images/illustrations/ldap-readonly-illustration.svg index c15364f71b4..887279317c6 100644 --- a/modules/theme/src/themes/default/assets/images/illustrations/ldap-readonly-illustration.svg +++ b/modules/theme/src/themes/default/assets/images/illustrations/ldap-readonly-illustration.svg @@ -18,7 +18,7 @@ * under the License. --> - +