Skip to content

Commit bc8703d

Browse files
prakriti-solankeykartikpersistent
authored andcommitted
copy row (#803)
* copy row * column for copy * column copy
1 parent b7d2149 commit bc8703d

File tree

1 file changed

+29
-34
lines changed

1 file changed

+29
-34
lines changed

frontend/src/components/FileTable.tsx

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ const FileTable = forwardRef<ChildRef, FileTableProps>((props, ref) => {
7171
const skipPageResetRef = useRef<boolean>(false);
7272
const [_, copy] = useCopyToClipboard();
7373
const { colorMode } = useContext(ThemeWrapperContext);
74+
const [copyRow, setCopyRow] = useState<boolean>(false);
7475

7576
const tableRef = useRef(null);
7677

@@ -83,8 +84,13 @@ const FileTable = forwardRef<ChildRef, FileTableProps>((props, ref) => {
8384
}
8485
);
8586

86-
const handleCopy = (message: string) => {
87-
copy(message);
87+
const handleCopy = (rowData: any) => {
88+
const rowString = JSON.stringify(rowData, null, 2);
89+
copy(rowString);
90+
setCopyRow(true);
91+
setTimeout(() => {
92+
setCopyRow(false);
93+
}, 5000);
8894
};
8995
const columns = useMemo(
9096
() => [
@@ -154,18 +160,14 @@ const FileTable = forwardRef<ChildRef, FileTableProps>((props, ref) => {
154160
cell: (info) => {
155161
if (info.getValue() != 'Processing') {
156162
return (
157-
<Tip allowedPlacements={['left']}>
158-
<div
159-
className='cellClass'
160-
title={info.row.original?.status === 'Failed' ? info.row.original?.errorMessage : ''}
161-
>
162-
<Tip.Trigger>
163-
<StatusIndicator type={statusCheck(info.getValue())} />
164-
{info.getValue()}
165-
</Tip.Trigger>
166-
{(info.getValue() === 'Completed' ||
167-
info.getValue() === 'Failed' ||
168-
(info.getValue() === 'Cancelled' && !isReadOnlyUser)) && (
163+
<div
164+
className='cellClass'
165+
title={info.row.original?.status === 'Failed' ? info.row.original?.errorMessage : ''}
166+
>
167+
<StatusIndicator type={statusCheck(info.getValue())} />
168+
{info.getValue()}
169+
{(info.getValue() === 'Completed' || info.getValue() === 'Failed' || info.getValue() === 'Cancelled') &&
170+
!isReadOnlyUser && (
169171
<span className='mx-1'>
170172
<IconButtonWithToolTip
171173
placement='right'
@@ -179,25 +181,7 @@ const FileTable = forwardRef<ChildRef, FileTableProps>((props, ref) => {
179181
</IconButtonWithToolTip>
180182
</span>
181183
)}
182-
</div>
183-
184-
{info.row.original?.status === 'Failed' && (
185-
<Tip.Content>
186-
<IconButton
187-
aria-label='error copy'
188-
clean
189-
label='copy error'
190-
size='small'
191-
onClick={() => handleCopy(info.row.original?.errorMessage ?? '')}
192-
>
193-
<ClipboardDocumentIconOutline
194-
color={colorMode === 'light' ? 'white' : ''}
195-
className='w-4 h-4 inline-block'
196-
/>
197-
</IconButton>
198-
</Tip.Content>
199-
)}
200-
</Tip>
184+
</div>
201185
);
202186
} else if (info.getValue() === 'Processing' && info.row.original.processingProgress === undefined) {
203187
return (
@@ -531,9 +515,20 @@ const FileTable = forwardRef<ChildRef, FileTableProps>((props, ref) => {
531515
>
532516
<MagnifyingGlassCircleIconSolid />
533517
</IconButtonWithToolTip>
518+
<IconButtonWithToolTip
519+
placement='left'
520+
text='copy'
521+
size='large'
522+
label='Copy Row'
523+
disabled={info.getValue() === 'Uploading'}
524+
clean
525+
onClick={() => handleCopy(info.row.original)}
526+
>
527+
<ClipboardDocumentIconOutline className={`${copyRow} ? 'cursor-wait': 'cursor`} />
528+
</IconButtonWithToolTip>
534529
</>
535530
),
536-
header: () => <span>View</span>,
531+
header: () => <span>Actions</span>,
537532
footer: (info) => info.column.id,
538533
}),
539534
],

0 commit comments

Comments
 (0)