2022-01-19 03:44:29 -06:00
|
|
|
import React, { useState } from 'react';
|
2022-04-22 08:33:13 -05:00
|
|
|
|
2022-07-20 04:33:46 -05:00
|
|
|
import { SelectableValue, UrlQueryMap, urlUtil } from '@grafana/data';
|
|
|
|
import { Checkbox, ClipboardButton, Field, FieldSet, Input, Modal, RadioButtonGroup } from '@grafana/ui';
|
2022-09-05 22:40:01 -05:00
|
|
|
import { buildBaseUrl } from 'app/features/dashboard/components/ShareModal/utils';
|
2022-04-22 08:33:13 -05:00
|
|
|
|
2022-01-19 03:44:29 -06:00
|
|
|
import { PlaylistMode } from './types';
|
|
|
|
|
2022-09-05 22:40:01 -05:00
|
|
|
interface Props {
|
2022-06-14 14:32:52 -05:00
|
|
|
playlistUid: string;
|
2022-01-19 03:44:29 -06:00
|
|
|
onDismiss: () => void;
|
|
|
|
}
|
|
|
|
|
2022-09-05 22:40:01 -05:00
|
|
|
export const ShareModal = ({ playlistUid, onDismiss }: Props) => {
|
2022-01-19 03:44:29 -06:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2022-06-14 14:32:52 -05:00
|
|
|
const shareUrl = urlUtil.renderUrl(`${buildBaseUrl()}/play/${playlistUid}`, params);
|
2022-01-19 03:44:29 -06:00
|
|
|
|
|
|
|
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={
|
2022-07-20 04:33:46 -05:00
|
|
|
<ClipboardButton icon="copy" variant="primary" getText={() => shareUrl}>
|
|
|
|
Copy
|
2022-01-19 03:44:29 -06:00
|
|
|
</ClipboardButton>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</Field>
|
|
|
|
</FieldSet>
|
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
};
|