From 0c6cf2fccc1f1c2a175610312d4b1b83adf9df75 Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Tue, 22 Mar 2022 11:19:26 -0300 Subject: [PATCH] 16672: Adds 'copy to clipboard' feature. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- src/views/process-panel/process-log-card.tsx | 15 ++++++++++++++- src/views/process-panel/process-panel-root.tsx | 2 ++ src/views/process-panel/process-panel.tsx | 8 ++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/views/process-panel/process-log-card.tsx b/src/views/process-panel/process-log-card.tsx index 56ac4d92..ac409ec1 100644 --- a/src/views/process-panel/process-log-card.tsx +++ b/src/views/process-panel/process-log-card.tsx @@ -19,6 +19,7 @@ import { ArvadosTheme } from 'common/custom-theme'; import { CloseIcon, CollectionIcon, + CopyIcon, LogIcon, MaximizeIcon, TextDecreaseIcon, @@ -34,6 +35,7 @@ import { import { ProcessLogCodeSnippet } from 'views/process-panel/process-log-code-snippet'; import { DefaultView } from 'components/default-view/default-view'; import { CodeSnippetDataProps } from 'components/code-snippet/code-snippet'; +import CopyToClipboard from 'react-copy-to-clipboard'; type CssRules = 'card' | 'content' | 'title' | 'iconHeader' | 'header' | 'root' | 'logViewer' | 'logViewerContainer'; @@ -77,6 +79,7 @@ export interface ProcessLogsCardDataProps { export interface ProcessLogsCardActionProps { onLogFilterChange: (filter: FilterOption) => void; navigateToLog: (uuid: string) => void; + onCopy: (text: string) => void; } type ProcessLogsCardProps = ProcessLogsCardDataProps @@ -86,7 +89,8 @@ type ProcessLogsCardProps = ProcessLogsCardDataProps & MPVPanelProps; export const ProcessLogsCard = withStyles(styles)( - ({ classes, process, filters, selectedFilter, lines, onLogFilterChange, navigateToLog, + ({ classes, process, filters, selectedFilter, lines, + onLogFilterChange, navigateToLog, onCopy, doHidePanel, doMaximizePanel, panelMaximized, panelName }: ProcessLogsCardProps) => { const [wordWrapToggle, setWordWrapToggle] = useState(true); const [fontSize, setFontSize] = useState(3); @@ -116,6 +120,15 @@ export const ProcessLogsCard = withStyles(styles)( + + + + onCopy("Log copied to clipboard")}> + + + + + setWordWrapToggle(!wordWrapToggle)}> diff --git a/src/views/process-panel/process-panel-root.tsx b/src/views/process-panel/process-panel-root.tsx index 862dbd68..3e695a2f 100644 --- a/src/views/process-panel/process-panel-root.tsx +++ b/src/views/process-panel/process-panel-root.tsx @@ -42,6 +42,7 @@ export interface ProcessPanelRootActionProps { cancelProcess: (uuid: string) => void; onLogFilterChange: (filter: FilterOption) => void; navigateToLog: (uuid: string) => void; + onLogCopyToClipboard: (uuid: string) => void; } export type ProcessPanelRootProps = ProcessPanelRootDataProps & ProcessPanelRootActionProps & WithStyles; @@ -72,6 +73,7 @@ export const ProcessPanelRoot = withStyles(styles)( { const uuid = getProcessPanelCurrentUuid(router) || ''; @@ -38,6 +39,13 @@ const mapStateToProps = ({ router, resources, processPanel, processLogsPanel }: }; const mapDispatchToProps = (dispatch: Dispatch): ProcessPanelRootActionProps => ({ + onLogCopyToClipboard: (message: string) => { + dispatch(snackbarActions.OPEN_SNACKBAR({ + message, + hideDuration: 2000, + kind: SnackbarKind.SUCCESS, + })); + }, onContextMenu: (event, process) => { dispatch(openProcessContextMenu(event, process)); }, -- 2.30.2