[ACM-17770] Add labels column and filtering to Application table#5720
[ACM-17770] Add labels column and filtering to Application table#5720Ginxo wants to merge 12 commits intostolostron:mainfrom
Conversation
Signed-off-by: Enrique Mingorance Cano <emingora@redhat.com>
|
Skipping CI for Draft Pull Request. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Ginxo The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Signed-off-by: Enrique Mingorance Cano <emingora@redhat.com>
Signed-off-by: Enrique Mingorance Cano <emingora@redhat.com>
Signed-off-by: Enrique Mingorance Cano <emingora@redhat.com>
Signed-off-by: Enrique Mingorance Cano <emingora@redhat.com>
| const getApplicationId = (resource: IResource, clusters: string[]): string => { | ||
| const stringified = JSON.stringify(clusters) | ||
| const hash = sha256(stringified) | ||
| return `${resource.metadata?.name}-${resource.metadata?.namespace}-${hash}` |
There was a problem hiding this comment.
I'm not able to see a better way to uniquely identify a single application, so name+ns+clusters (as hash)
| import { sha256 } from 'js-sha256' | ||
| import { IResource } from '../../resources' | ||
|
|
||
| const isOCPAppResource = ( |
There was a problem hiding this comment.
old method moved here as it is needed by the new useFetchApplicationLabels hook
| import { IResource, OCPAppResource } from '../../../resources' | ||
| import { ApplicationStatus } from './application-status' | ||
|
|
||
| export type IApplicationResource = (IResource<ApplicationStatus> | OCPAppResource<ApplicationStatus>) & { id: string } |
There was a problem hiding this comment.
old type moved here as it is needed by the new utils.ts
id property also added to identify Application (for the LabelMap)
| @@ -0,0 +1,6 @@ | |||
| /* Copyright Contributors to the Open Cluster Management project */ | |||
|
|
|||
| export type ApplicationStatus = { | |||
There was a problem hiding this comment.
old type moved here as it is needed by the new utils.ts and useFetchApplicationLabels hook
| const LabelCell = ({ labels }: { labels: string[] | Record<string, string> }) => ( | ||
| <AcmLabels labels={labels} isCompact={true} /> | ||
| ) |
There was a problem hiding this comment.
new inner component for rendering label
Signed-off-by: Enrique Mingorance Cano <emingora@redhat.com>
| // Cannot add properties directly to objects in typescript | ||
| return { ...tableItem, ...transformedObject } | ||
| return { | ||
| id: getApplicationId(tableItem, clusters), |
There was a problem hiding this comment.
new id for table elements, it is needed for label filtering
| return items.map((app) => generateTransformData(app)) | ||
| }, [allApplications, deletedApps, generateTransformData, resultCounts]) | ||
|
|
||
| const { labelOptions, labelMap } = useFetchApplicationLabels(tableItems) |
There was a problem hiding this comment.
the different labelOptions for the filter
the LabelMap representing application.id: labels
| if (applicationData && applicationData.length !== storedApplicationData?.length) { | ||
| const allLabels = new Set<string>() | ||
| const labelMap: LabelMap = {} | ||
| applicationData.filter(isOCPAppResource).forEach((resource) => { | ||
| const labels: string[] = [] | ||
| const pairs: Record<string, string> = {} | ||
| resource.label?.split(';').forEach((label) => { | ||
| labels.push(label.trim()) | ||
| const [key, value] = label.split('=').map((seg) => seg.trim()) | ||
| pairs[key] = value | ||
| allLabels.add(label.trim()) | ||
| }) | ||
| labelMap[resource.id] = { pairs, labels } | ||
| }) | ||
| setLabelMap(labelMap) | ||
| setLabelOptions(Array.from(allLabels).map((label) => ({ label, value: label }))) | ||
| setStoredApplicationData(applicationData) |
There was a problem hiding this comment.
adapted from already existing code for DiscoveryPolicies, see https://github.com/stolostron/console/blob/e6ed850825a9bbb921fc7a45ceaa72279b59a363/frontend/src/routes/Governance/common/util.tsx#L767C17-L767C44
Signed-off-by: Enrique Mingorance Cano <emingora@redhat.com>
Signed-off-by: Enrique Mingorance Cano <emingora@redhat.com>
Signed-off-by: Enrique Mingorance Cano <emingora@redhat.com>
Signed-off-by: Enrique Mingorance Cano <emingora@redhat.com>
|
/retest |
|
/test unit-tests-sonarcloud |
|
/retest |
| { | ||
| header: t('table.labels'), | ||
| cell: (resource) => ( | ||
| <AcmLabels labels={getLabels(resource as OCPAppResource<ApplicationStatus>)} isCompact={true} /> |
There was a problem hiding this comment.
@Ginxo I think this looks great! One issue I see is that only OCP apps are supported. There are also other app types that we need to support ie. ArgoCD, Application Set. For Subscription apps we can probably skip since that's deprecated. Thanks!
There was a problem hiding this comment.
I would like to do so but according to the object contract just OCP applications contain label, check this for instance.
There was a problem hiding this comment.
Ah ok that's a good point. In that case can you add a tooltip for the Labels column and just explain that only OCP and Flux apps have labels. It might be confusing to users why some apps have labels and other don't.
There was a problem hiding this comment.
I've checked again the different objects coming from multicloud/aggregate/applications request and ApplicationSet is also containing labels at
{
"apiVersion": "argoproj.io/v1alpha1",
"kind": "ApplicationSet",
"metadata": {
"name": "kikes",
"namespace": "openshift-gitops",
...
},
"spec": {
"template": {
"metadata": {
"name": "kikes-{{name}}",
"labels": {
"apps.open-cluster-management.io/pull-to-ocm-managed-cluster": "true",
"velero.io/exclude-from-backup": "true"
}
...
},
...
I'm not able to check ArgoCD kind of applications, could you please guide me on creating one @fxiang1 ? thanks for your help here 😊
There was a problem hiding this comment.
Yes, the ArgoCD apps are actually created from the ArgoCD console
You will need to click Log In with OpenShift, use the kubeadmin creds.
Click New App
Fill in all the fields
You can take a look at the example app I have in the console weekly cluster to see what values to use
https://openshift-gitops-server-openshift-gitops.apps.cs-aws-420-4mccv.dev02.red-chesterfield.com/applications/openshift-gitops/feng-standalone-argo?view=tree&resource=

Once the app is created it should get discovered in the ACM Applications page.
Signed-off-by: Enrique Mingorance Cano <emingora@redhat.com>
|
/retest |
Signed-off-by: Enrique Mingorance Cano <emingora@redhat.com>
📝 Summary
Evidences
Video_2026-02-18_10-30-02.mp4
Ticket Summary (Title):
Add labels column and filtering to Application table
Ticket Link:
https://issues.redhat.com/browse/ACM-17770
Type of Change:
✅ Checklist
General
ACM-12340 Fix bug with...)If Feature
If Bugfix
🗒️ Notes for Reviewers