DashboardScene: Render share snapshot radio button translations (#77136)

DashboardScene: Render share snapshot tab translations
This commit is contained in:
Dominik Prokop
2023-10-26 00:37:16 -07:00
committed by GitHub
parent 69af9f9ad7
commit 877b61e31d
@@ -15,26 +15,29 @@ import { transformSceneToSaveModel, trimDashboardForSnapshot } from '../serializ
import { SceneShareTabState } from './types';
const SNAPSHOTS_API_ENDPOINT = '/api/snapshots';
const DEFAULT_EXPIRE_OPTION: SelectableValue<number> = {
label: t('share-modal.snapshot.expire-never', `Never`),
value: 0,
};
const EXPIRE_OPTIONS = [
DEFAULT_EXPIRE_OPTION,
{
label: t('share-modal.snapshot.expire-hour', `1 Hour`),
value: 60 * 60,
},
{
label: t('share-modal.snapshot.expire-day', `1 Day`),
value: 60 * 60 * 24,
},
{
label: t('share-modal.snapshot.expire-week', `7 Days`),
value: 60 * 60 * 24 * 7,
},
];
const getExpireOptions = () => {
const DEFAULT_EXPIRE_OPTION: SelectableValue<number> = {
label: t('share-modal.snapshot.expire-never', `Never`),
value: 0,
};
return [
DEFAULT_EXPIRE_OPTION,
{
label: t('share-modal.snapshot.expire-hour', '1 Hour'),
value: 60 * 60,
},
{
label: t('share-modal.snapshot.expire-day', '1 Day'),
value: 60 * 60 * 24,
},
{
label: t('share-modal.snapshot.expire-week', '7 Days'),
value: 60 * 60 * 24 * 7,
},
];
};
type SnapshotSharingOptions = {
externalEnabled: boolean;
@@ -58,7 +61,7 @@ export class ShareSnapshotTab extends SceneObjectBase<ShareSnapshotTabState> {
super({
...state,
snapshotName: state.dashboardRef.resolve().state.title,
selectedExpireOption: DEFAULT_EXPIRE_OPTION,
selectedExpireOption: getExpireOptions()[0],
});
this.addActivationHandler(() => {
@@ -88,7 +91,7 @@ export class ShareSnapshotTab extends SceneObjectBase<ShareSnapshotTabState> {
public onExpireChange = (option: number) => {
this.setState({
selectedExpireOption: EXPIRE_OPTIONS.find((o) => o.value === option),
selectedExpireOption: getExpireOptions().find((o) => o.value === option),
});
};
@@ -184,7 +187,7 @@ function ShareSnapshoTabRenderer({ model }: SceneComponentProps<ShareSnapshotTab
<Field label={t('share-modal.snapshot.expire', `Expire`)}>
<RadioButtonGroup<number>
id="expire-select-input"
options={EXPIRE_OPTIONS}
options={getExpireOptions()}
value={selectedExpireOption?.value}
onChange={model.onExpireChange}
/>