-
Notifications
You must be signed in to change notification settings - Fork 41
web: add copy actions in Node/Deployment detail dialogs #109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,8 @@ import { | |
| import { Deployment } from '@/types/deployment'; | ||
| import { Pod } from '@/types/pod'; | ||
| import YAMLViewerDialog from '../YAMLViewerDialog'; | ||
| import { useAlert } from '@/hook/useAlert'; | ||
| import { copyToClipboard } from '@/helper/util'; | ||
|
|
||
| interface TabPanelProps { | ||
| children?: React.ReactNode; | ||
|
|
@@ -52,6 +54,7 @@ interface DeploymentDetailDialogProps { | |
| function DeploymentDetailDialog({ open, onClose, data, pods }: DeploymentDetailDialogProps) { | ||
| const [tab, setTab] = React.useState(0); | ||
| const [yamlDialogOpen, setYamlDialogOpen] = React.useState(false); | ||
| const { success } = useAlert(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| const handleYamlOpen = () => { | ||
| setYamlDialogOpen(true); | ||
|
|
@@ -63,6 +66,20 @@ function DeploymentDetailDialog({ open, onClose, data, pods }: DeploymentDetailD | |
|
|
||
| const displayPods = pods?.filter((pod) => pod.metadata?.ownerReferences?.[0]?.name?.includes(data?.metadata?.name || '')) || []; | ||
|
|
||
| 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'); | ||
| } | ||
| }; | ||
|
Comment on lines
+66
to
+78
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The This suggestion adds |
||
|
|
||
| return ( | ||
| <> | ||
| <Dialog open={!!open} onClose={onClose} maxWidth="md" fullWidth> | ||
|
|
@@ -208,6 +225,8 @@ function DeploymentDetailDialog({ open, onClose, data, pods }: DeploymentDetailD | |
| </DialogContent> | ||
| <DialogActions> | ||
| <Button onClick={onClose}>Cancel</Button> | ||
| <Button onClick={handleCopyName} variant="outlined">Copy Name</Button> | ||
| <Button onClick={handleCopyUID} variant="outlined">Copy ID</Button> | ||
| <Button onClick={handleYamlOpen} variant="contained"> | ||
| YAML | ||
| </Button> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| 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'; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| import { useTheme } from '@mui/material/styles'; | ||
| import YAMLViewerDialog from '@/component/Dialog/YAMLViewerDialog'; | ||
| import { Node } from '@/types/node'; | ||
|
|
@@ -15,6 +17,7 @@ interface NodeDetailDialogProps { | |
| export function NodeDetailDialog({ open, onClose, data }: NodeDetailDialogProps) { | ||
| const [yamlDialogOpen, setYamlDialogOpen] = useState(false); | ||
| const theme = useTheme(); | ||
| const { success } = useAlert(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| const handleYamlOpen = () => { | ||
| setYamlDialogOpen(true); | ||
|
|
@@ -24,6 +27,20 @@ export function NodeDetailDialog({ open, onClose, data }: NodeDetailDialogProps) | |
| setYamlDialogOpen(false); | ||
| }; | ||
|
|
||
| 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'); | ||
| } | ||
| }; | ||
|
Comment on lines
+29
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The This suggestion adds |
||
|
|
||
| return ( | ||
| <> | ||
| <Dialog open={!!open} onClose={onClose} fullWidth maxWidth="md"> | ||
|
|
@@ -100,6 +117,8 @@ export function NodeDetailDialog({ open, onClose, data }: NodeDetailDialogProps) | |
| </DialogContent> | ||
| <DialogActions> | ||
| <Button onClick={onClose}>Cancel</Button> | ||
| <Button onClick={handleCopyName} variant="outlined">Copy Name</Button> | ||
| <Button onClick={handleCopyUID} variant="outlined">Copy ID</Button> | ||
| <Button onClick={handleYamlOpen} variant="contained"> | ||
| YAML | ||
| </Button> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
copyToClipboardfunction is imported from@/helper/util, but it doesn't appear to be exported frommodules/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.