mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 15:42:55 +08:00

* User Experience: apply the same pattern feedback for all copy to clipboard buttons * add copy icon to all ClipboardButton use cases * Change primary color for copy to clipboard in create token * Add success button variant * Remove copy confirmation from TableCellInspectModal because it's in the base component now * Design tweaks to copy confirmation - Only change the icon to tick to avoid the button changing size - Change button to success green - Only show copy confirmation state for 2 seconds * revert TabelCellInspectModal text button back * revert accidental change to ShareLink Co-authored-by: joshhunt <josh@trtr.co>
26 lines
845 B
TypeScript
26 lines
845 B
TypeScript
import React, { useCallback } from 'react';
|
|
import AutoSizer from 'react-virtualized-auto-sizer';
|
|
|
|
import { ClipboardButton, CodeEditor, Modal } from '@grafana/ui';
|
|
|
|
export interface ViewJsonModalProps {
|
|
json: string;
|
|
onDismiss: () => void;
|
|
}
|
|
|
|
export function ViewJsonModal({ json, onDismiss }: ViewJsonModalProps): JSX.Element {
|
|
const getClipboardText = useCallback(() => json, [json]);
|
|
return (
|
|
<Modal title="JSON" onDismiss={onDismiss} onClickBackdrop={onDismiss} isOpen>
|
|
<AutoSizer disableHeight>
|
|
{({ width }) => <CodeEditor value={json} language="json" showMiniMap={false} height="500px" width={width} />}
|
|
</AutoSizer>
|
|
<Modal.ButtonRow>
|
|
<ClipboardButton icon="copy" getText={getClipboardText}>
|
|
Copy to Clipboard
|
|
</ClipboardButton>
|
|
</Modal.ButtonRow>
|
|
</Modal>
|
|
);
|
|
}
|