grafana/public/app/features/playlist/ShareModal.tsx
Ezequiel Victorero 0633840777
GrafanaUI: Add success state to ClipboardButton (#52069)
* 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>
2022-07-20 10:33:46 +01:00

67 lines
1.8 KiB
TypeScript

import React, { useState } from 'react';
import { SelectableValue, UrlQueryMap, urlUtil } from '@grafana/data';
import { Checkbox, ClipboardButton, Field, FieldSet, Input, Modal, RadioButtonGroup } from '@grafana/ui';
import { buildBaseUrl } from '../dashboard/components/ShareModal/utils';
import { PlaylistMode } from './types';
interface ShareModalProps {
playlistUid: string;
onDismiss: () => void;
}
export const ShareModal = ({ playlistUid, onDismiss }: ShareModalProps) => {
const [mode, setMode] = useState<PlaylistMode>(false);
const [autoFit, setAutofit] = useState(false);
const modes: Array<SelectableValue<PlaylistMode>> = [
{ label: 'Normal', value: false },
{ label: 'TV', value: 'tv' },
{ label: 'Kiosk', value: true },
];
const params: UrlQueryMap = {};
if (mode) {
params.kiosk = mode;
}
if (autoFit) {
params.autofitpanels = true;
}
const shareUrl = urlUtil.renderUrl(`${buildBaseUrl()}/play/${playlistUid}`, params);
return (
<Modal isOpen={true} title="Share playlist" onDismiss={onDismiss}>
<FieldSet>
<Field label="Mode">
<RadioButtonGroup value={mode} options={modes} onChange={setMode} />
</Field>
<Field>
<Checkbox
label="Autofit"
description="Panel heights will be adjusted to fit screen size"
name="autofix"
value={autoFit}
onChange={(e) => setAutofit(e.currentTarget.checked)}
/>
</Field>
<Field label="Link URL">
<Input
id="link-url-input"
value={shareUrl}
readOnly
addonAfter={
<ClipboardButton icon="copy" variant="primary" getText={() => shareUrl}>
Copy
</ClipboardButton>
}
/>
</Field>
</FieldSet>
</Modal>
);
};