From 3e79fbadf98801a793e370ae051d7e7c2b61d188 Mon Sep 17 00:00:00 2001 From: jasquat Date: Tue, 3 Oct 2023 10:43:22 -0400 Subject: [PATCH] added button to copy report links to share w/ burnettk --- .../src/components/Filters.tsx | 73 +++++++++++++++---- .../components/ProcessInstanceListTable.tsx | 1 + .../src/routes/ProcessInstanceShow.tsx | 2 +- 3 files changed, 62 insertions(+), 14 deletions(-) diff --git a/spiffworkflow-frontend/src/components/Filters.tsx b/spiffworkflow-frontend/src/components/Filters.tsx index 279315c8..3d43fc9b 100644 --- a/spiffworkflow-frontend/src/components/Filters.tsx +++ b/spiffworkflow-frontend/src/components/Filters.tsx @@ -1,5 +1,7 @@ -import { Filter } from '@carbon/icons-react'; +import { Filter, Link as LinkIcon } from '@carbon/icons-react'; import { Button, Grid, Column } from '@carbon/react'; +import { useState } from 'react'; +import { Notification } from './Notification'; type OwnProps = { showFilterOptions: boolean; @@ -7,6 +9,7 @@ type OwnProps = { filterOptions: Function; filtersEnabled?: boolean; reportSearchComponent?: Function | null; + reportHash?: string | null; }; export default function Filters({ @@ -15,16 +18,67 @@ export default function Filters({ filterOptions, reportSearchComponent = null, filtersEnabled = true, + reportHash, }: OwnProps) { const toggleShowFilterOptions = () => { setShowFilterOptions(!showFilterOptions); }; + const [copiedReportLinktoClipboard, setCopiedReportLinkToClipboard] = + useState(false); + + const copyReportLink = () => { + if (reportHash) { + const piShortLink = `${window.location.origin}${window.location.pathname}?report_hash=${reportHash}`; + navigator.clipboard.writeText(piShortLink); + setCopiedReportLinkToClipboard(true); + } + }; + + const buttonElements = () => { + const elements = []; + if (reportHash && showFilterOptions) { + elements.push( +