Snapshots: Change default expiration (#83550)

This commit is contained in:
Ezequiel Victorero 2024-02-28 11:45:22 -03:00 committed by GitHub
parent 58d6ce1c87
commit 7d6d256335
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 25 additions and 21 deletions

View File

@ -17,12 +17,11 @@ import { SceneShareTabState } from './types';
const getExpireOptions = () => {
const DEFAULT_EXPIRE_OPTION: SelectableValue<number> = {
label: t('share-modal.snapshot.expire-never', `Never`),
value: 0,
label: t('share-modal.snapshot.expire-week', '1 Week'),
value: 60 * 60 * 24 * 7,
};
return [
DEFAULT_EXPIRE_OPTION,
{
label: t('share-modal.snapshot.expire-hour', '1 Hour'),
value: 60 * 60,
@ -31,13 +30,18 @@ const getExpireOptions = () => {
label: t('share-modal.snapshot.expire-day', '1 Day'),
value: 60 * 60 * 24,
},
DEFAULT_EXPIRE_OPTION,
{
label: t('share-modal.snapshot.expire-week', '7 Days'),
value: 60 * 60 * 24 * 7,
label: t('share-modal.snapshot.expire-never', `Never`),
value: 0,
},
];
};
const getDefaultExpireOption = () => {
return getExpireOptions()[2];
};
export interface ShareSnapshotTabState extends SceneShareTabState {
panelRef?: SceneObjectRef<VizPanel>;
dashboardRef: SceneObjectRef<DashboardScene>;
@ -55,7 +59,7 @@ export class ShareSnapshotTab extends SceneObjectBase<ShareSnapshotTabState> {
super({
...state,
snapshotName: state.dashboardRef.resolve().state.title,
selectedExpireOption: getExpireOptions()[0],
selectedExpireOption: getDefaultExpireOption(),
});
this.addActivationHandler(() => {
@ -207,7 +211,7 @@ function ShareSnapshoTabRenderer({ model }: SceneComponentProps<ShareSnapshotTab
</Button>
)}
<Button variant="primary" disabled={snapshotResult.loading} onClick={() => createSnapshot()}>
<Trans i18nKey="share-modal.snapshot.local-button">Local Snapshot</Trans>
<Trans i18nKey="share-modal.snapshot.local-button">Publish Snapshot</Trans>
</Button>
</Modal.ButtonRow>
</>

View File

@ -36,10 +36,6 @@ export class ShareSnapshot extends PureComponent<Props, State> {
super(props);
this.dashboard = props.dashboard;
this.expireOptions = [
{
label: t('share-modal.snapshot.expire-never', `Never`),
value: 0,
},
{
label: t('share-modal.snapshot.expire-hour', `1 Hour`),
value: 60 * 60,
@ -49,15 +45,19 @@ export class ShareSnapshot extends PureComponent<Props, State> {
value: 60 * 60 * 24,
},
{
label: t('share-modal.snapshot.expire-week', `7 Days`),
label: t('share-modal.snapshot.expire-week', `1 Week`),
value: 60 * 60 * 24 * 7,
},
{
label: t('share-modal.snapshot.expire-never', `Never`),
value: 0,
},
];
this.state = {
isLoading: false,
step: 1,
selectedExpireOption: this.expireOptions[0],
snapshotExpires: this.expireOptions[0].value,
selectedExpireOption: this.expireOptions[2],
snapshotExpires: this.expireOptions[2].value,
snapshotName: props.dashboard.title,
timeoutSeconds: 4,
snapshotUrl: '',
@ -277,7 +277,7 @@ export class ShareSnapshot extends PureComponent<Props, State> {
</Button>
)}
<Button variant="primary" disabled={isLoading} onClick={this.createSnapshot()}>
<Trans i18nKey="share-modal.snapshot.local-button">Local Snapshot</Trans>
<Trans i18nKey="share-modal.snapshot.local-button">Publish Snapshot</Trans>
</Button>
</Modal.ButtonRow>
</>

View File

@ -1415,10 +1415,10 @@
"expire-day": "1 Day",
"expire-hour": "1 Hour",
"expire-never": "Never",
"expire-week": "7 Days",
"expire-week": "1 Week",
"info-text-1": "A snapshot is an instant way to share an interactive dashboard publicly. When created, we strip sensitive data like queries (metric, template, and annotation) and panel links, leaving only the visible metric data and series names embedded in your dashboard.",
"info-text-2": "Keep in mind, your snapshot <1>can be viewed by anyone</1> that has the link and can access the URL. Share wisely.",
"local-button": "Local Snapshot",
"local-button": "Publish Snapshot",
"mistake-message": "Did you make a mistake? ",
"name": "Snapshot name",
"timeout": "Timeout (seconds)",
@ -1431,7 +1431,7 @@
"library-panel": "Library panel",
"link": "Link",
"panel-embed": "Embed",
"public-dashboard": "Public Dashboard",
"public-dashboard": "Publish Dashboard",
"public-dashboard-title": "Public dashboard",
"snapshot": "Snapshot"
},

View File

@ -1415,10 +1415,10 @@
"expire-day": "1 Đäy",
"expire-hour": "1 Ħőūř",
"expire-never": "Ńęvęř",
"expire-week": "7 Đäyş",
"expire-week": "1 Ŵęęĸ",
"info-text-1": "Å şʼnäpşĥőŧ įş äʼn įʼnşŧäʼnŧ ŵäy ŧő şĥäřę äʼn įʼnŧęřäčŧįvę đäşĥþőäřđ pūþľįčľy. Ŵĥęʼn čřęäŧęđ, ŵę şŧřįp şęʼnşįŧįvę đäŧä ľįĸę qūęřįęş (męŧřįč, ŧęmpľäŧę, äʼnđ äʼnʼnőŧäŧįőʼn) äʼnđ päʼnęľ ľįʼnĸş, ľęävįʼnģ őʼnľy ŧĥę vįşįþľę męŧřįč đäŧä äʼnđ şęřįęş ʼnämęş ęmþęđđęđ įʼn yőūř đäşĥþőäřđ.",
"info-text-2": "Ķęęp įʼn mįʼnđ, yőūř şʼnäpşĥőŧ <1>čäʼn þę vįęŵęđ þy äʼnyőʼnę</1> ŧĥäŧ ĥäş ŧĥę ľįʼnĸ äʼnđ čäʼn äččęşş ŧĥę ŮŖĿ. Ŝĥäřę ŵįşęľy.",
"local-button": "Ŀőčäľ Ŝʼnäpşĥőŧ",
"local-button": "Pūþľįşĥ Ŝʼnäpşĥőŧ",
"mistake-message": "Đįđ yőū mäĸę ä mįşŧäĸę? ",
"name": "Ŝʼnäpşĥőŧ ʼnämę",
"timeout": "Ŧįmęőūŧ (şęčőʼnđş)",
@ -1431,7 +1431,7 @@
"library-panel": "Ŀįþřäřy päʼnęľ",
"link": "Ŀįʼnĸ",
"panel-embed": "Ēmþęđ",
"public-dashboard": "Pūþľįč Đäşĥþőäřđ",
"public-dashboard": "Pūþľįşĥ Đäşĥþőäřđ",
"public-dashboard-title": "Pūþľįč đäşĥþőäřđ",
"snapshot": "Ŝʼnäpşĥőŧ"
},