Skip to content

web: add copy actions in Node/Deployment detail dialogs#109

Open
ddc-baiye wants to merge 4 commits into
kubeedge:mainfrom
ddc-baiye:feat/detail-copy-actions
Open

web: add copy actions in Node/Deployment detail dialogs#109
ddc-baiye wants to merge 4 commits into
kubeedge:mainfrom
ddc-baiye:feat/detail-copy-actions

Conversation

@ddc-baiye
Copy link
Copy Markdown
Contributor

Type

  • /kind feature
    What this PR does / why we need it
  • Adds small “Copy Name” and “Copy ID” actions to Node and Deployment detail dialogs to improve operator ergonomics. This enables quick copy of frequently referenced identifiers without changing existing layouts or backend behavior.
    Special notes for your reviewer
  • UI-only change in detail dialogs; no backend or global request/middleware behavior is modified. Scope limited to modules/web/src/component/Dialog/NodeDetailDialog/index.tsx and modules/web/src/component/Dialog/DeploymentDetailDialog/index.tsx. Uses the global alert provider to surface success messages.
    Which issue(s) this PR fixes
  • NONE
    Release note
  • Add copy actions (Name, ID) to Node and Deployment detail dialogs.

Add small copy buttons for Name and ID in Node and Deployment detail dialogs to improve operator ergonomics. UI-only change; no backend or global request behavior modified.

Signed-off-by: ddc-baiye <dongdong.chen@bluedotai.cn>
@kubeedge-bot
Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign vincentgoat after the PR has been reviewed.
You can assign the PR to them by writing /assign @vincentgoat in a comment when ready.

The full list of commands accepted by this bot can be found 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

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @ddc-baiye, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a quality-of-life improvement for operators by integrating "Copy Name" and "Copy ID" actions directly into the Node and Deployment detail dialogs. This feature streamlines the process of retrieving and utilizing critical identifiers, making the user interface more efficient without altering any underlying system behavior.

Highlights

  • New Copy Actions: Added "Copy Name" and "Copy ID" buttons to both Node and Deployment detail dialogs.
  • Improved Ergonomics: Enhances operator workflow by allowing quick copying of frequently referenced identifiers directly from the UI.
  • UI-Only Change: The modifications are limited to the UI components and do not impact backend logic or global middleware.
  • User Feedback: Success messages are displayed using a global alert provider when an item is copied to the clipboard.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@kubeedge-bot kubeedge-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 28, 2025
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds a useful "Copy Name" and "Copy ID" feature to the Node and Deployment detail dialogs, improving user experience. The implementation is straightforward. My review focuses on a critical import issue that will break the build, and suggestions to improve error handling and code duplication in the new copy handlers. Addressing these points will make the new feature more robust and maintainable.

import { Pod } from '@/types/pod';
import YAMLViewerDialog from '../YAMLViewerDialog';
import { useAlert } from '@/hook/useAlert';
import { copyToClipboard } from '@/helper/util';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

The copyToClipboard function is imported from @/helper/util, but it doesn't appear to be exported from modules/web/src/helper/util.ts. This will cause a build failure. Please ensure this utility function is correctly implemented and exported from the specified file.

import React, { useState } from 'react';
import { Box, Button, Dialog, DialogTitle, DialogContent, DialogActions, Typography } from '@mui/material';
import { useAlert } from '@/hook/useAlert';
import { copyToClipboard } from '@/helper/util';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

The copyToClipboard function is imported from @/helper/util, but it doesn't appear to be exported from modules/web/src/helper/util.ts. This will cause a build failure. Please ensure this utility function is correctly implemented and exported from the specified file.

function DeploymentDetailDialog({ open, onClose, data, pods }: DeploymentDetailDialogProps) {
const [tab, setTab] = React.useState(0);
const [yamlDialogOpen, setYamlDialogOpen] = React.useState(false);
const { success } = useAlert();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

To provide feedback to the user when a copy action fails, you should also retrieve the error function from useAlert. This will be used in the error handling for the copy functions.

Suggested change
const { success } = useAlert();
const { success, error } = useAlert();

Comment on lines +69 to +81
const handleCopyName = async () => {
if (data?.metadata?.name) {
await copyToClipboard(String(data.metadata.name));
success('Copied name');
}
};

const handleCopyUID = async () => {
if (data?.metadata?.uid) {
await copyToClipboard(String(data.metadata.uid));
success('Copied ID');
}
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The handleCopyName and handleCopyUID functions lack error handling for the copyToClipboard async operation, which can lead to unhandled promise rejections. Also, the String() conversion is unnecessary.

This suggestion adds try...catch blocks for robust error handling. For further improvement, consider refactoring these two similar functions into a single generic handler to reduce code duplication.

  const handleCopyName = async () => {
    if (data?.metadata?.name) {
      try {
        await copyToClipboard(data.metadata.name);
        success('Copied name');
      } catch (err) {
        console.error('Failed to copy name:', err);
        error('Failed to copy name');
      }
    }
  };

  const handleCopyUID = async () => {
    if (data?.metadata?.uid) {
      try {
        await copyToClipboard(data.metadata.uid);
        success('Copied ID');
      } catch (err) {
        console.error('Failed to copy ID:', err);
        error('Failed to copy ID');
      }
    }
  };

export function NodeDetailDialog({ open, onClose, data }: NodeDetailDialogProps) {
const [yamlDialogOpen, setYamlDialogOpen] = useState(false);
const theme = useTheme();
const { success } = useAlert();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

To provide feedback to the user when a copy action fails, you should also retrieve the error function from useAlert. This will be used in the error handling for the copy functions.

Suggested change
const { success } = useAlert();
const { success, error } = useAlert();

Comment on lines +30 to +42
const handleCopyName = async () => {
if (data?.metadata?.name) {
await copyToClipboard(String(data.metadata.name));
success('Copied name');
}
};

const handleCopyUID = async () => {
if (data?.metadata?.uid) {
await copyToClipboard(String(data.metadata.uid));
success('Copied ID');
}
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The handleCopyName and handleCopyUID functions lack error handling for the copyToClipboard async operation, which can lead to unhandled promise rejections. Also, the String() conversion is unnecessary.

This suggestion adds try...catch blocks for robust error handling. For further improvement, consider refactoring these two similar functions into a single generic handler to reduce code duplication.

  const handleCopyName = async () => {
    if (data?.metadata?.name) {
      try {
        await copyToClipboard(data.metadata.name);
        success('Copied name');
      } catch (err) {
        console.error('Failed to copy name:', err);
        error('Failed to copy name');
      }
    }
  };

  const handleCopyUID = async () => {
    if (data?.metadata?.uid) {
      try {
        await copyToClipboard(data.metadata.uid);
        success('Copied ID');
      } catch (err) {
        console.error('Failed to copy ID:', err);
        error('Failed to copy ID');
      }
    }
  };

@kubeedge-bot kubeedge-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 21, 2025
@kubeedge-bot kubeedge-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 22, 2025
Signed-off-by: ddc-baiye <dongdong.chen@bluedotai.cn>
Signed-off-by: ddc-baiye <dongdong.chen@bluedotai.cn>
@ddc-baiye ddc-baiye force-pushed the feat/detail-copy-actions branch from 74c4988 to 6588a2a Compare December 22, 2025 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants