Skip to content

Commit 19060b1

Browse files
authored
ACM-15320 Remove hard coded local-cluster from App UI (stolostron#4078)
* Remove hard coded local-cluster from App UI Signed-off-by: fxiang1 <fxiang@redhat.com> * Fix unit test Signed-off-by: fxiang1 <fxiang@redhat.com> * Fix sonar and add unit tests Signed-off-by: fxiang1 <fxiang@redhat.com> * Fix unit test Signed-off-by: fxiang1 <fxiang@redhat.com> * Add unit test Signed-off-by: fxiang1 <fxiang@redhat.com> * Add hook for getting hub cluster Signed-off-by: fxiang1 <fxiang@redhat.com> --------- Signed-off-by: fxiang1 <fxiang@redhat.com>
1 parent 77cf560 commit 19060b1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+4144
-2942
lines changed

frontend/public/locales/en/translation.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,6 @@
709709
"cluster.create.ocp.fips": "FIPS",
710710
"cluster.create.ocp.image": "Release image",
711711
"cluster.create.ocp.singleNode": "Single Node OpenShift",
712-
"cluster.status.offline": "Offline",
713712
"clusterClaim.cluster.name": "Cluster name",
714713
"clusterClaim.create.message": "Claiming a cluster from <bold>{{clusterPoolName}}</bold> will remove one of the available clusters from the pool and a new cluster will be created to replace it.",
715714
"clusterClaim.create.message.pending": "A cluster claim was created for <bold>{{clusterPoolName}}</bold> but no clusters were available. A Hibernating cluster will be resumed or a new cluster will be provisioned to fulfill the claim. This will take several minutes. Expand the cluster pool in the table to view or delete pending claims.",
@@ -2194,8 +2193,6 @@
21942193
"Project ID": "Project ID",
21952194
"prop.details.section": "Details",
21962195
"Propagation policy": "Propagation policy",
2197-
"props.show.yaml.argoset": "Applications set",
2198-
"props.show.yaml.argoset.yaml": "View application set YAML",
21992196
"Provide a kubeconfig that grants access to an external infrastructure cluster running OpenShift Virtualization.": "Provide a kubeconfig that grants access to an external infrastructure cluster running OpenShift Virtualization.",
22002197
"Provide customized control plane cluster configuration.": "Provide customized control plane cluster configuration.",
22012198
"Provides a link to the resource repository that is represented by the channel.": "Provides a link to the resource repository that is represented by the channel.",
@@ -2819,7 +2816,7 @@
28192816
"Tenant ID": "Tenant ID",
28202817
"Terminating": "Terminating",
28212818
"The <bold>{{clusterName}}</bold> cluster can only be destroyed through the CLI": "The <bold>{{clusterName}}</bold> cluster can only be destroyed through the CLI",
2822-
"The ArgoCD pull model does not support local-cluster as a destination cluster. Filter out local-cluster from the placement resource.": "The ArgoCD pull model does not support local-cluster as a destination cluster. Filter out local-cluster from the placement resource.",
2819+
"The ArgoCD pull model does not support the hub cluster as a destination cluster. Filter out the hub cluster from the placement resource.": "The ArgoCD pull model does not support the hub cluster as a destination cluster. Filter out the hub cluster from the placement resource.",
28232820
"The authentication method to use to connect to OpenShift Cluster Manager.": "The authentication method to use to connect to OpenShift Cluster Manager.",
28242821
"The automation template cannot be updated for any of the selected clusters.": "The automation template cannot be updated for any of the selected clusters.",
28252822
"The channel cannot be changed for any of the selected clusters.": "The channel cannot be changed for any of the selected clusters.",

frontend/src/hooks/application-queries.ts

-192
This file was deleted.

frontend/src/lib/search.ts

+1-102
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { useMemo } from 'react'
44
import { useLocation } from 'react-router-dom-v5-compat'
5-
import { ArgoApplication, OCPAppResource } from '../resources'
5+
import { OCPAppResource } from '../resources'
66
import { getBackendUrl, IRequestResult, postRequest } from '../resources/utils'
77
import { flatten, uniqBy } from 'lodash'
88

@@ -65,107 +65,6 @@ export function queryStatusCount(cluster: string): IRequestResult<ISearchResult>
6565
})
6666
}
6767

68-
function getRemoteArgoFilters({
69-
cluster,
70-
clusters = [],
71-
name,
72-
namespace,
73-
}: Pick<DiscoveredAppsParams, 'clusters'> & {
74-
cluster?: DiscoveredAppsParams['search']
75-
name?: DiscoveredAppsParams['search']
76-
namespace?: DiscoveredAppsParams['search']
77-
}) {
78-
const clustersFilter = { property: 'cluster', values: [] as string[] }
79-
const filtersArr = [
80-
{ property: 'kind', values: ['Application'] },
81-
{ property: 'apigroup', values: ['argoproj.io'] },
82-
clustersFilter,
83-
...(name ? [{ property: 'name', values: [`*${name}*`] }] : []),
84-
...(namespace ? [{ property: 'destinationNamespace', values: [`*${namespace}*`] }] : []),
85-
]
86-
87-
if (clusters.length) {
88-
clustersFilter.values = clustersFilter.values.concat(clusters)
89-
} else if (cluster) {
90-
clustersFilter.values.push(`*${cluster}*`)
91-
} else {
92-
clustersFilter.values.push('!local-cluster')
93-
}
94-
95-
return filtersArr
96-
}
97-
98-
export async function queryRemoteArgoApps(params: DiscoveredAppsParams): Promise<ArgoApplication[]>
99-
export async function queryRemoteArgoApps(params: DiscoveredAppsParams & { countOnly: true }): Promise<number>
100-
export async function queryRemoteArgoApps(
101-
params: DiscoveredAppsParams & { countOnly?: true }
102-
): Promise<ArgoApplication[] | number> {
103-
const { clusters = [], search, searchLimit, countOnly = false } = params
104-
105-
let variables: SearchQuery['variables']
106-
let query: string
107-
108-
const limitObject = countOnly ? {} : { limit: searchLimit }
109-
110-
if (search) {
111-
variables = {
112-
byNameInput: [
113-
{
114-
filters: getRemoteArgoFilters({ clusters, name: search }),
115-
...limitObject,
116-
},
117-
],
118-
byNamespaceInput: [
119-
{
120-
filters: getRemoteArgoFilters({ clusters, namespace: search }),
121-
...limitObject,
122-
},
123-
],
124-
...(clusters.length
125-
? {}
126-
: {
127-
byClusterInput: [
128-
{
129-
filters: getRemoteArgoFilters({ cluster: search }),
130-
...limitObject,
131-
},
132-
],
133-
}),
134-
}
135-
if (clusters.length) {
136-
query = countOnly ? searchMatchAndFilterQueryCount : searchMatchAndFilterQuery
137-
} else {
138-
query = countOnly ? searchMatchWithClusterAndFilterQueryCount : searchMatchWithClusterAndFilterQuery
139-
}
140-
} else {
141-
variables = {
142-
input: [
143-
{
144-
filters: getRemoteArgoFilters({ clusters }),
145-
...limitObject,
146-
},
147-
],
148-
}
149-
query = countOnly ? searchFilterQueryCount : searchFilterQuery
150-
}
151-
152-
const { promise } = postRequest<SearchQuery, ISearchResult>(getBackendUrl() + apiSearchUrl, {
153-
operationName: 'searchResult',
154-
variables,
155-
query,
156-
})
157-
return promise.then((result) => {
158-
if (countOnly) {
159-
return Math.max(...Object.values(result.data).map((value) => value?.[0]?.count || 0))
160-
} else {
161-
return uniqBy(
162-
flatten(Object.values(result.data).map((value) => value?.[0]?.items || [])),
163-
(item) => item._uid
164-
) as ArgoApplication[]
165-
}
166-
})
167-
}
168-
16968
export type DiscoveredAppsParams = {
17069
clusters?: string[]
17170
types?: string[]

0 commit comments

Comments
 (0)