Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Oct 1, 2025

Overview

This PR adds a copy button feature to table cells that contain values users commonly need to copy, such as IP addresses, resource names, and other identifiers. The copy button appears on hover, providing quick access without cluttering the UI in both detail views and list views.

Problem

Users frequently need to copy values from tables (like IP addresses, resource IDs, etc.) to use in other tools or commands. Previously, users had to manually select and copy text, which can be cumbersome especially for long strings or when precision is important.

Solution

New Components

CopyLabel Component

  • A reusable wrapper component that displays content with a copy button that appears on hover
  • Uses smooth opacity transitions for better UX
  • Reuses the existing CopyButton component with icon style
  • Supports cases where displayed content differs from copied text

NameValueTable Enhancement

  • Added optional copyValue property to NameValueTableRow interface
  • When copyValue is provided, the value is automatically wrapped with CopyLabel
  • Fully backward compatible - existing rows without copyValue work as before

Values with Copy Buttons

Detail Views:

  • Services: Cluster IP and External IP addresses
  • Endpoints: IP addresses in address tables
  • EndpointSlices: Address lists
  • Nodes: All address types (InternalIP, ExternalIP, Hostname, etc.)
  • Pods: Host IPs and Pod IPs

List Views:

  • Service list: Cluster IP and External IP columns
  • Pod list: IP column
  • Node list: Internal IP and External IP columns
  • Endpoint list: Addresses column (for single addresses)
  • EndpointSlice list: Endpoint addresses (for single addresses)

Usage

Adding a copy button to new values is straightforward:

For NameValueTable rows:

{
  name: 'IP Address',
  value: '192.168.1.1',
  copyValue: '192.168.1.1', // Just add this property
}

For ResourceListView columns:

{
  id: 'clusterIP',
  label: t('Cluster IP'),
  getValue: service => service.spec.clusterIP,
  render: service => {
    const clusterIP = service.spec.clusterIP;
    return clusterIP ? <CopyLabel textToCopy={clusterIP}>{clusterIP}</CopyLabel> : null;
  },
}

Screenshots

CopyLabel Component in Storybook

The component shows the value with a copy button that appears on hover.

NameValueTable with Copyable Values

Demonstrates how IP addresses and pod names have copy buttons while regular values don't.

Service Details Page

The Service details page now shows copy buttons for Cluster IP and External IP when hovering over those values.

Pod List View with Copy Buttons

The Pod list view shows copy buttons on hover for IP addresses in the IP column, making it easy to copy values directly from the table.

Testing

  • ✅ All 986 tests pass
  • ✅ Added Storybook stories for new components
  • ✅ Updated all affected snapshots
  • ✅ Linting passes with no errors
  • ✅ Build completes successfully

Design Decisions

  1. On-hover behavior: The copy button only appears on hover to keep the UI clean and uncluttered
  2. Selective implementation: Only added copy buttons to values that are commonly copied (IPs, names, IDs)
  3. List vs Detail consistency: Copy buttons work the same way in both list and detail views
  4. Multiple addresses: When multiple addresses are shown in lists, they're displayed without individual copy buttons to avoid visual clutter
  5. Easy extensibility: Simple API makes it easy to add copy functionality to future values
  6. Backward compatibility: No breaking changes - existing tables continue to work as before

Fixes the issue by providing users with a quick, reliable way to copy important values from both detail views and list views without manual text selection.

Warning

storybook.js.org

  • Triggering command: node /home/REDACTED/work/headlamp/headlamp/frontend/node_modules/.bin/storybook dev -p 6006 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Fixes #3983

Original prompt

This section details on the original issue you should resolve

<issue_title>Add a button to quickly copy values from table cells where it matters</issue_title>
<issue_description>## Is your feature request related to a problem? Please describe the impact that the lack of the feature requested is creating.

Some tables shows values that the user may wish to copy, like the ID/name of the resource, IPs, etc.
Recently while copying an IP I felt like we should have a quick way to copy values like this. There is some work to be done in order to identify which values make sense to be copied.

Describe the solution you'd like

I believe that the values that are likely to be copied by the user should have a copy button overlaying them on hover.

What users will benefit from this feature?

Everyone who uses Headlamp to visualize resources and will use the data visualized in other tools (like connecting to an IP they have seen in a table).
</issue_description>

<agent_instructions>* Make sure you only add the copy button to values that make sense.

  • Make sure it's easy to add a copy button to future table values
  • Make sure you add atomic commits
  • Make sure the snapshots are updated</agent_instructions>

Comments on the Issue (you are @copilot in this section)

Fixes #3983

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 1, 2025
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Oct 1, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Copilot
Once this PR has been reviewed and has the lgtm label, please ask for approval from joaquimrocha. For more information see the Code Review Process.

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

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 size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Oct 1, 2025
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 1, 2025
@Copilot Copilot AI changed the title [WIP] Add a button to quickly copy values from table cells where it matters Add copy button to table cell values for IPs and identifiers Oct 1, 2025
@Copilot Copilot AI requested a review from joaquimrocha October 1, 2025 13:03
Copilot finished work on behalf of joaquimrocha October 1, 2025 13:03
@joaquimrocha
Copy link
Contributor

joaquimrocha commented Oct 2, 2025

It's getting there. Can we also have a copy button in the list views (tables) when the value is of interest?
cc/ @copilot

@joaquimrocha
Copy link
Contributor

@copilot Can you iterate after my previous message?

…, Endpoints, EndpointSlices)

Co-authored-by: joaquimrocha <[email protected]>
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Oct 2, 2025
Copy link
Author

Copilot AI commented Oct 2, 2025

It's getting there. Can we also have a copy button in the list views (tables) when the value is of interest?
cc/ @copilot

I've added copy buttons to the list views! The changes are in commit fd523b6.

Copy buttons now appear on hover for IP addresses in:

  • Service list: Cluster IP and External IP columns
  • Pod list: IP column
  • Node list: Internal IP and External IP columns
  • Endpoint list: Addresses column (for single addresses)
  • EndpointSlice list: Endpoint addresses (for single addresses)

Screenshots

Pod List View with Copy Buttons:
Pod list with copy buttons

The copy button appears when hovering over IP addresses in the list, making it easy to copy values directly from the table without opening the detail view.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • storybook.js.org
    • Triggering command: node /home/REDACTED/work/headlamp/headlamp/frontend/node_modules/.bin/storybook dev -p 6006 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@Copilot Copilot AI changed the title Add copy button to table cell values for IPs and identifiers Add copy button to table cell values for IPs and identifiers in detail and list views Oct 2, 2025
Copilot finished work on behalf of joaquimrocha October 2, 2025 12:29
className="copy-button"
component="span"
sx={{
opacity: 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

this box is always invisible and why does it have className

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a button to quickly copy values from table cells where it matters
4 participants