Skip to content

Commit

Permalink
feat(Queries): allow users to copy query id
Browse files Browse the repository at this point in the history
  • Loading branch information
vitshev committed Nov 7, 2024
1 parent a368584 commit 6714f9e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/ui/src/ui/pages/query-tracker/QueryMetaTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {QueryItem} from '../module/api';
import {Button} from '@gravity-ui/uikit';
import Yson from '../../../components/Yson/Yson';
import SimpleModal from '../../../components/Modal/SimpleModal';
import ClipboardButton from '../../../components/ClipboardButton/ClipboardButton';

interface MetaTableProps {
query: QueryItem;
Expand All @@ -21,13 +22,16 @@ const valueClassName = b('value');
type QueryMetaItem = {
title: string;
value: string | number | boolean;
showCopy: boolean;
};

const exceptFields: (keyof QueryItem | 'access_control_object')[] = [
'query',
'access_control_object',
];

const FIELD_WITH_COPY_BUTTON = 'id';

export default function QueryMetaTable({query, className}: MetaTableProps) {
const [selectedOption, setSelectedOption] = useState<Record<string, unknown> | null>(null);
const [modalOpened, setModalOpened] = useState<boolean>(false);
Expand Down Expand Up @@ -58,6 +62,7 @@ export default function QueryMetaTable({query, className}: MetaTableProps) {
return {
title,
value: finalValue,
showCopy: FIELD_WITH_COPY_BUTTON === title,
};
});
}, [query]);
Expand All @@ -73,6 +78,13 @@ export default function QueryMetaTable({query, className}: MetaTableProps) {
{valueItems.map((value, index) => (
<dd key={index} className={valueClassName}>
{typeof value === 'boolean' ? String(value) : value}
{item.showCopy && (
<ClipboardButton
size="s"
text={value}
inlineMargins={true}
/>
)}
</dd>
))}
</React.Fragment>
Expand Down

0 comments on commit 6714f9e

Please sign in to comment.