From a1f216031735f937d80e712fd84046cc25e873a5 Mon Sep 17 00:00:00 2001 From: karan Date: Wed, 28 Feb 2024 13:02:44 +0530 Subject: [PATCH 1/8] fix: ecosystem invite from dashboard Signed-off-by: karan --- src/components/User/UserDashBoard.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/User/UserDashBoard.tsx b/src/components/User/UserDashBoard.tsx index e00ae32b5..eadd805e7 100644 --- a/src/components/User/UserDashBoard.tsx +++ b/src/components/User/UserDashBoard.tsx @@ -415,7 +415,8 @@ const UserDashBoard = () => { window.location.href = pathRoutes.organizations.credentials; }; - const navigateToInvitation = () => { + const navigateToInvitation = async (ecosystemId: string) => { + await setToLocalStorage(storageKeys.ECOSYSTEM_ID, ecosystemId); window.location.href = pathRoutes.ecosystem.sentinvitation; }; @@ -1179,7 +1180,7 @@ const UserDashBoard = () => { ?.name === EcosystemRoles.ecosystemLead && ( ) : ( <> {!isEcosystemData?.isEcosystemLead && - isEcosystemData?.isEcosystemMember && - props.endorsementData?.status === EndorsementStatus.signed ? ( + isEcosystemData?.isEcosystemMember && + props.endorsementData?.status === EndorsementStatus.signed ? (
) : ( @@ -273,7 +289,7 @@ const EndorsementPopup = (props: { )} - + ); }; diff --git a/src/components/organization/OrganizationsList.tsx b/src/components/organization/OrganizationsList.tsx index 1a3de17b7..4807ffbb8 100644 --- a/src/components/organization/OrganizationsList.tsx +++ b/src/components/organization/OrganizationsList.tsx @@ -14,7 +14,10 @@ import RoleViewButton from '../RoleViewButton'; import SearchInput from '../SearchInput'; import { getOrganizations } from '../../api/organization'; import { pathRoutes } from '../../config/pathRoutes'; -import { setToLocalStorage } from '../../api/Auth'; +import { + removeFromLocalStorage, + setToLocalStorage, +} from '../../api/Auth'; import { EmptyListMessage } from '../EmptyListComponent'; import CustomSpinner from '../CustomSpinner'; import CreateEcosystemOrgModal from '../CreateEcosystemOrgModal'; @@ -48,7 +51,6 @@ const OrganizationsList = () => { props.setOpenModal(true); }; - //Fetch the user organization list const getAllOrganizations = async () => { setLoading(true); const response = await getOrganizations( @@ -80,7 +82,6 @@ const OrganizationsList = () => { setLoading(false); }; - //This useEffect is called when the searchText changes useEffect(() => { let getData: NodeJS.Timeout; @@ -105,12 +106,15 @@ const OrganizationsList = () => { } }, []); - //onCHnage of Search input text const searchInputChange = (e: ChangeEvent) => { setSearchText(e.target.value); }; const redirectOrgDashboard = async (activeOrg: Organisation) => { + await removeFromLocalStorage(storageKeys.ECOSYSTEM_ID); + await removeFromLocalStorage(storageKeys.ECOSYSTEM_ROLE); + await removeFromLocalStorage(storageKeys.ORG_DETAILS); + await setToLocalStorage(storageKeys.ORG_ID, activeOrg.id.toString()); const roles: string[] = activeOrg?.userOrgRoles.map( (role) => role.orgRole.name, @@ -168,7 +172,8 @@ const OrganizationsList = () => { key={index} className="m-1 bg-primary-50 text-blue-800 text-sm font-medium mr-2 px-2.5 py-0.5 rounded dark:bg-blue-900 dark:text-blue-300" > - {role.charAt(0).toUpperCase() + role.slice(1)} + {role.charAt(0).toUpperCase() + + role.slice(1)} ); })} @@ -228,32 +233,37 @@ const OrganizationsList = () => { -
+

Organizations

- +
- - +
+ +
} onClickEvent={createOrganizationModel} /> -
- setMessage(data)} diff --git a/src/config/ecosystem.ts b/src/config/ecosystem.ts index b5df99a4a..7ac58c4e9 100644 --- a/src/config/ecosystem.ts +++ b/src/config/ecosystem.ts @@ -1,7 +1,7 @@ import type { AxiosResponse } from 'axios'; import { getFromLocalStorage, setToLocalStorage } from '../api/Auth'; import { getEcosystems } from '../api/ecosystem'; -import { EcosystemRoles } from '../common/enums'; +import { EcosystemRoles, OrganizationRoles } from '../common/enums'; import { apiStatusCodes, storageKeys } from './CommonConstant'; import { getOrganizationById } from '../api/organization'; import { Roles } from '../utils/enums/roles'; @@ -52,10 +52,7 @@ const checkEcosystem = async (): Promise => { const isEnabledEcosystem = userData?.enableEcosystem; const ecosystemRole = role || EcosystemRoles.ecosystemLead; - const orgRoles = await getFromLocalStorage(storageKeys.ORG_ROLES) - const isMultiEcosystem = userData?.multiEcosystemSupport; - // const isMultiEcosystem = false const isLead = ecosystemRole === EcosystemRoles.ecosystemLead && isEnabledEcosystem @@ -107,6 +104,12 @@ const getUserRoles = async () => { return roles } + const getOwnerAdminRole = async () => { + const orgRoles = await getFromLocalStorage(storageKeys.ORG_ROLES); + const roles = orgRoles.includes(OrganizationRoles.organizationOwner) || orgRoles.includes(OrganizationRoles.organizationAdmin) + return roles + }; + const getOrgDetails = async (): Promise => { const orgId = await getOrgId(); const org = await getOrgData(); @@ -140,4 +143,4 @@ const getOrgDetails = async (): Promise => { return orgData; }; -export { checkEcosystem, getEcosystemId, getOrgDetails, getUserRoles }; +export { checkEcosystem, getEcosystemId, getOrgDetails, getUserRoles, getOwnerAdminRole }; From 6416ae4763dbd123b18dc03efef97a4fd61e92d2 Mon Sep 17 00:00:00 2001 From: karan Date: Thu, 29 Feb 2024 12:34:41 +0530 Subject: [PATCH 4/8] fix: variable name changes Signed-off-by: karan --- src/components/Ecosystem/Dashboard.tsx | 4 ++-- src/components/Ecosystem/Endorsement/EndorsementPopup.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/Ecosystem/Dashboard.tsx b/src/components/Ecosystem/Dashboard.tsx index 1a567a0df..67397bfb1 100644 --- a/src/components/Ecosystem/Dashboard.tsx +++ b/src/components/Ecosystem/Dashboard.tsx @@ -206,8 +206,8 @@ const Dashboard = () => { setIsEcosystemLead(Boolean(data)); }; const checkEcosystemAccess = async () => { - const datas = await getOwnerAdminRole(); - setIsAccess(datas); + const data = await getOwnerAdminRole(); + setIsAccess(data); }; useEffect(() => { getDashboardData(); diff --git a/src/components/Ecosystem/Endorsement/EndorsementPopup.tsx b/src/components/Ecosystem/Endorsement/EndorsementPopup.tsx index eba19df2c..250761714 100644 --- a/src/components/Ecosystem/Endorsement/EndorsementPopup.tsx +++ b/src/components/Ecosystem/Endorsement/EndorsementPopup.tsx @@ -37,8 +37,8 @@ const EndorsementPopup = (props: { setIsEcosystemData(data); }; const checkEcosystemAccess = async () => { - const datas = await getOwnerAdminRole(); - setIsAccess(datas); + const data = await getOwnerAdminRole(); + setIsAccess(data); }; useEffect(() => { From 1392c89fd4bbde0031d437449acde01453d686a3 Mon Sep 17 00:00:00 2001 From: karan Date: Thu, 29 Feb 2024 13:44:49 +0530 Subject: [PATCH 5/8] fix: user role acces for edit ecosystem Signed-off-by: karan --- src/components/Ecosystem/Dashboard.tsx | 4 ++-- src/components/Ecosystem/Endorsement/EndorsementPopup.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Ecosystem/Dashboard.tsx b/src/components/Ecosystem/Dashboard.tsx index 67397bfb1..80f76bfd8 100644 --- a/src/components/Ecosystem/Dashboard.tsx +++ b/src/components/Ecosystem/Dashboard.tsx @@ -354,7 +354,7 @@ const Dashboard = () => { Invitations - {dropdownOpen ? ( + {dropdownOpen && isAccess ? ( ( @@ -380,7 +380,7 @@ const Dashboard = () => { ) : ( {loadingReject && ( From b66ebcd1cb2e3e10c4670531d8a192b6d21b4d54 Mon Sep 17 00:00:00 2001 From: karan Date: Thu, 29 Feb 2024 18:25:00 +0530 Subject: [PATCH 6/8] fix: user role access Signed-off-by: karan --- .../Endorsement/EndorsementPopup.tsx | 19 +++++----- .../EcosystemInvite/SentInvitations.tsx | 14 ++++++-- src/components/User/UserDashBoard.tsx | 19 +++++++--- .../invitations/SendInvitationModal.tsx | 2 +- .../organization/users/EditUserRolesModal.tsx | 1 + src/config/ecosystem.ts | 36 +++++++++++++------ src/pages/organizations/users.astro | 4 +-- 7 files changed, 63 insertions(+), 32 deletions(-) diff --git a/src/components/Ecosystem/Endorsement/EndorsementPopup.tsx b/src/components/Ecosystem/Endorsement/EndorsementPopup.tsx index a9289e998..73bac71f3 100644 --- a/src/components/Ecosystem/Endorsement/EndorsementPopup.tsx +++ b/src/components/Ecosystem/Endorsement/EndorsementPopup.tsx @@ -17,6 +17,7 @@ import { import type { AxiosResponse } from 'axios'; import { AlertComponent } from '../../AlertComponent'; import { getFromLocalStorage } from '../../../api/Auth'; +import React from 'react'; const EndorsementPopup = (props: { openModal: boolean; @@ -78,6 +79,7 @@ const EndorsementPopup = (props: { const SubmitEndorsement = async (endorsementId: string) => { try { setLoading(true); + setLoadingReject(true); const organizationId = await getFromLocalStorage(storageKeys.ORG_ID); const ecoId = await getEcosystemId(); const SubmitEndorsementrequest = await SubmitEndorsementRequest( @@ -96,6 +98,7 @@ const EndorsementPopup = (props: { setLoading(false); } catch (error) { setLoading(false); + setLoadingReject(false); console.error('Error while Submit schema:', error); } }; @@ -172,16 +175,11 @@ const EndorsementPopup = (props: { {isEcosystemData?.isEcosystemLead && props.endorsementData?.status === EndorsementStatus.requested ? (
- +