From 67e5ad804d6948cb0e863f1d2c66de8af54b7875 Mon Sep 17 00:00:00 2001 From: Raghavi Date: Wed, 6 Mar 2024 18:18:03 +0530 Subject: [PATCH] feat(gui): Added GUI support for destinationServiceAccount field (#6) * Changes for new DestinationServiceAccount changes in AppProject Signed-off-by: anandf * feat(gui): Added GUI support for destinationServiceAccount field Signed-off-by: Raghavi Shirur * Revert "Changes for new DestinationServiceAccount changes in AppProject" This reverts commit 8d36c2217c1eb7fd9edf4d01576a62472a641c5a. --------- Signed-off-by: anandf Signed-off-by: Raghavi Shirur Co-authored-by: anandf Signed-off-by: anandf --- .../project-details/project-details.tsx | 101 ++++++++++++++++++ .../project-details/resource-lists-panel.tsx | 43 +++++++- ui/src/app/shared/models.ts | 7 ++ 3 files changed, 150 insertions(+), 1 deletion(-) diff --git a/ui/src/app/settings/components/project-details/project-details.tsx b/ui/src/app/settings/components/project-details/project-details.tsx index 8b00c8590edb75..7b239d9ef1e165 100644 --- a/ui/src/app/settings/components/project-details/project-details.tsx +++ b/ui/src/app/settings/components/project-details/project-details.tsx @@ -63,6 +63,15 @@ function reduceGlobal(projs: Project[]): ProjectSpec & {count: number} { ); }); + merged.destinationServiceAccounts = merged.destinationServiceAccounts.filter((item, index) => { + return ( + index === + merged.destinationServiceAccounts.findIndex(obj => { + return obj.server === item.server && obj.namespace === item.namespace && obj.defaultServiceAccount === item.defaultServiceAccount; + }) + ); + }); + merged.destinations = merged.destinations.filter((item, index) => { return ( index === @@ -130,6 +139,7 @@ function reduceGlobal(projs: Project[]): ProjectSpec & {count: number} { signatureKeys: [], destinations: [], description: '', + destinationServiceAccounts: [], roles: [], count: 0 } @@ -801,6 +811,97 @@ export class ProjectDetails extends React.Component + this.saveProject(item)} + values={proj} + title={ + + DESTINATION SERVICE ACCOUNTS{' '} + {helpTip( + 'Destination Service Accounts holds information about the service accounts to be impersonated for the application sync operation for each destination.' + )} + + } + view={ + + {proj.spec.destinationServiceAccounts ? ( + +
+
Server
+
Namespace
+
DefaultServiceAccount
+
+ {proj.spec.destinationServiceAccounts.map((dest, i) => ( +
+
{dest.server}
+
{dest.namespace}
+
{dest.defaultServiceAccount}
+
+ ))} +
+ ) : ( + emptyMessage('destinationServiceAccount') + )} +
+ } + edit={formApi => ( + services.clusters.list()}> + {clusters => ( + +
+
Server
+
Namespace
+
DefaultServiceAccount
+
+ {(formApi.values.spec.destinationServiceAccounts || []).map((_: Project, i: number) => ( +
+
+ cluster.server)}} + /> +
+
+ +
+
+ cluster.name)}} + /> +
+ formApi.setValue('spec.destinationServiceAccounts', removeEl(formApi.values.spec.destinationServiceAccounts, i))} + /> +
+ ))} + + +
+ )} +
+ )} + items={[]} + /> + this.saveProject(item)} /> {globalProj.count > 0 && ( ; + return ( + +

+ {info.title} {helpTip(info.helpText)} +

+ {(list || []).length > 0 ? ( + +
+
Server
+
Namespace
+
DefaultServiceAccount
+
+ {list.map((destinationServiceAccounts, i) => ( +
+
{destinationServiceAccounts.server}
+
{destinationServiceAccounts.namespace}
+
{destinationServiceAccounts.defaultServiceAccount}
+
+ ))} +
+ ) : ( +

The {info.title} is empty

+ )} +
+ ); +} + function editList(type: field, formApi: FormApi) { const info = infoByField[type]; @@ -213,6 +250,10 @@ export const ResourceListsPanel = ({proj, saveProject, title}: {proj: Project; t {!proj.metadata && Object.keys(sourceNamespacesInfoByField).map(key => {viewSourceNamespacesInfoList(key as field, proj)})} {!proj.metadata && Object.keys(destinationsInfoByField).map(key => {viewDestinationsInfoList(key as field, proj)})} + {!proj.metadata && + Object.keys(destinationServiceAccountsInfoByField).map(key => ( + {viewDestinationServiceAccountsInfoList(key as field, proj)} + ))} } edit={ diff --git a/ui/src/app/shared/models.ts b/ui/src/app/shared/models.ts index 823c61c34dc9a7..f9acf3ab2b0e33 100644 --- a/ui/src/app/shared/models.ts +++ b/ui/src/app/shared/models.ts @@ -170,6 +170,12 @@ export interface ApplicationDestination { name: string; } +export interface ApplicationDestinationServiceAccounts { + server: string; + namespace: string; + defaultServiceAccount: string; +} + export interface OrphanedResource { group: string; kind: string; @@ -717,6 +723,7 @@ export interface ProjectSpec { sourceRepos: string[]; sourceNamespaces: string[]; destinations: ApplicationDestination[]; + destinationServiceAccounts: ApplicationDestinationServiceAccounts[]; description: string; roles: ProjectRole[]; clusterResourceWhitelist: GroupKind[];