Skip to content

Commit

Permalink
feat(misc-section): add copy button to json fields
Browse files Browse the repository at this point in the history
Part of #782
Closes #786
  • Loading branch information
murilx committed Jan 21, 2025
1 parent c8836fe commit 97facbb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dashboard/src/components/Section/MiscSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ export const getMiscSection = ({
const miscInfos: SubsectionLink[] = Object.entries(misc).map(
([fieldKey, fieldValue]) => {
let stringField = fieldValue.toString();
let isObjectField = false;
if (typeof fieldValue === 'object') {
stringField = JSON.stringify(fieldValue);
isObjectField = true;
}
const isUrlResult = isUrl(stringField);

Expand All @@ -36,9 +38,11 @@ export const getMiscSection = ({
key: fieldKey,
unformattedTitle: fieldKey,
linkText: (
<TruncatedValueTooltip value={stringField} isUrl={isUrlResult} />
<>
<TruncatedValueTooltip value={stringField} isUrl={isUrlResult} />
),
link: isUrlResult ? stringField : undefined,
copyValue: isObjectField ? stringField : undefined,
};
},
);
Expand Down

0 comments on commit 97facbb

Please sign in to comment.