Skip to content

frontend: ResourceTable: Add new 'labels' column to all list views to allow searching by label#5035

Open
sniok wants to merge 1 commit intokubernetes-sigs:mainfrom
sniok:add-labels-column
Open

frontend: ResourceTable: Add new 'labels' column to all list views to allow searching by label#5035
sniok wants to merge 1 commit intokubernetes-sigs:mainfrom
sniok:add-labels-column

Conversation

@sniok
Copy link
Copy Markdown
Contributor

@sniok sniok commented Apr 1, 2026

fixes #2547

This PR adds a new 'labels' column (hidden by default) to all list views
This allows users to search items by label (like app=test) using the existing search bar in the table
Search works even if column is hidden, which it is by default

I've chosen the label=value format instead of label:value to keep it in line with kubectl (for example kubectl get pods -l app=agent-sandbox-controller -A)

image

How to test

  1. Go to any table
  2. type in label selector in the search bar

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sniok

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 1, 2026
@k8s-ci-robot k8s-ci-robot requested review from ashu8912 and skoeva April 1, 2026 21:05
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Apr 1, 2026
@sniok sniok force-pushed the add-labels-column branch from afcb9df to f931bed Compare April 1, 2026 21:11
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Apr 1, 2026
@sniok sniok force-pushed the add-labels-column branch from f931bed to a36a495 Compare April 2, 2026 14:53
@sniok sniok requested a review from skoeva April 3, 2026 14:19
@illume illume requested a review from Copilot April 4, 2026 18:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new built-in labels column (hidden by default) across resource list views so users can search resources by label selectors (e.g. app=test) using the existing table search.

Changes:

  • Extends ResourceTable column support with a new labels ColumnType, including default hidden visibility.
  • Appends 'labels' to the columns list for many list views so label data participates in global search.
  • Updates the Namespace list storyshot snapshot to reflect the new column behavior.

Reviewed changes

Copilot reviewed 43 out of 43 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
frontend/src/components/common/Resource/ResourceTable.tsx Adds labels to ColumnType, implements the built-in labels column accessor, and hides it by default.
frontend/src/components/webhookconfiguration/ValidatingWebhookConfigList.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/webhookconfiguration/MutatingWebhookConfigList.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/verticalPodAutoscaler/List.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/storage/VolumeList.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/storage/ClassList.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/storage/ClaimList.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/statefulset/List.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/serviceaccount/List.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/service/List.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/secret/List.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/runtimeClass/List.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/role/List.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/role/BindingList.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/resourceQuota/List.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/replicaset/List.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/priorityClass/List.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/podDisruptionBudget/List.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/pod/List.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/node/List.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/networkpolicy/List.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/namespace/List.tsx Adds 'labels' to columns (but currently introduces a duplicate labels column id).
frontend/src/components/namespace/snapshots/NamespaceList.Regular.stories.storyshot Updates snapshot output for namespace list table rendering/columns.
frontend/src/components/lease/List.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/job/List.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/ingress/List.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/ingress/ClassList.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/horizontalPodAutoscaler/List.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/gateway/ReferenceGrantList.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/gateway/HTTPRouteList.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/gateway/GatewayList.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/gateway/ClassList.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/gateway/BackendTrafficPolicyList.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/gateway/BackendTLSPolicyList.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/endpointSlices/List.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/endpoints/List.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/deployments/List.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/daemonset/List.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/cronjob/List.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/crd/List.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/crd/CustomResourceList.tsx Adds 'labels' column to enable label searching for CR instances.
frontend/src/components/crd/CustomResourceInstancesList.tsx Adds 'labels' column to enable label searching in this list view.
frontend/src/components/configmap/List.tsx Adds 'labels' column to enable label searching in this list view.

render: ns =>
ns.metadata.labels ? <MetadataDictGrid dict={ns.metadata.labels} /> : null,
},
'labels',
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The columns array defines a custom column with id: 'labels' and then also includes the built-in 'labels' ColumnType. This results in duplicate column IDs, which can cause the later built-in column to override the custom one (and potentially break sorting/filtering/visibility). Remove the extra 'labels' entry here, or rename the custom column id (and/or set its show to false) so there is only one labels column id in the table.

Suggested change
'labels',

Copilot uses AI. Check for mistakes.
Comment on lines +223 to +226
// Labels column is hidden by default
if (col === 'labels') {
visibility[col] = false;
}
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR introduces a new hidden-by-default labels column intended to make key=value label searches work via the table’s global filter. There’s existing story-based coverage for global search (e.g., NameSearch in ResourceTable.stories.tsx), but nothing that asserts label searches work when the labels column is hidden. Add a story/test case that sets the global filter to a label selector string and verifies the matching row(s) are returned even though the column is not visible.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filtering/searching by pod labels

4 participants