Commit 46165a7f by Torkel Ödegaard Committed by GitHub

SaveDashboard: Updated modal design/layout a bit (#22810)

parent a3037e36
...@@ -10,6 +10,7 @@ import { Field } from './Field'; ...@@ -10,6 +10,7 @@ import { Field } from './Field';
import { Button, LinkButton } from './Button'; import { Button, LinkButton } from './Button';
import { Switch } from './Switch'; import { Switch } from './Switch';
import { TextArea } from './TextArea/TextArea'; import { TextArea } from './TextArea/TextArea';
import { Checkbox } from './Checkbox';
const Forms = { const Forms = {
RadioButtonGroup, RadioButtonGroup,
...@@ -26,6 +27,7 @@ const Forms = { ...@@ -26,6 +27,7 @@ const Forms = {
InputControl, InputControl,
AsyncSelect, AsyncSelect,
TextArea, TextArea,
Checkbox,
}; };
export { ButtonVariant } from './Button'; export { ButtonVariant } from './Button';
......
import React, { useMemo } from 'react'; import React, { useMemo } from 'react';
import { Forms, Button, HorizontalGroup } from '@grafana/ui'; import { Forms, Button, HorizontalGroup } from '@grafana/ui';
import { e2e } from '@grafana/e2e'; import { e2e } from '@grafana/e2e';
import { SaveDashboardFormProps } from '../types'; import { SaveDashboardFormProps } from '../types';
...@@ -30,32 +31,32 @@ export const SaveDashboardForm: React.FC<SaveDashboardFormProps> = ({ dashboard, ...@@ -30,32 +31,32 @@ export const SaveDashboardForm: React.FC<SaveDashboardFormProps> = ({ dashboard,
> >
{({ register, errors }) => ( {({ register, errors }) => (
<> <>
<Forms.Field label="Changes description"> <div className="gf-form-group">
<Forms.TextArea {hasTimeChanged && (
name="message" <Forms.Checkbox
ref={register} label="Save current time range as dashboard default"
placeholder="Add a note to describe your changes..."
autoFocus
/>
</Forms.Field>
{hasTimeChanged && (
<Forms.Field label="Save current time range" description="Dashboard time range has changed">
<Forms.Switch
name="saveTimerange" name="saveTimerange"
ref={register} ref={register}
aria-label={e2e.pages.SaveDashboardModal.selectors.saveTimerange} aria-label={e2e.pages.SaveDashboardModal.selectors.saveTimerange}
/> />
</Forms.Field> )}
)} {hasVariableChanged && (
{hasVariableChanged && ( <Forms.Checkbox
<Forms.Field label="Save current variables" description="Dashboard variables have changed"> label="Save current variable values as dashboard default"
<Forms.Switch
name="saveVariables" name="saveVariables"
ref={register} ref={register}
aria-label={e2e.pages.SaveDashboardModal.selectors.saveVariables} aria-label={e2e.pages.SaveDashboardModal.selectors.saveVariables}
/> />
</Forms.Field> )}
)} {(hasVariableChanged || hasTimeChanged) && <div className="gf-form-group" />}
<Forms.TextArea
name="message"
ref={register}
placeholder="Add a note to describe your changes..."
autoFocus
/>
</div>
<HorizontalGroup> <HorizontalGroup>
<Button type="submit" aria-label={e2e.pages.SaveDashboardModal.selectors.save}> <Button type="submit" aria-label={e2e.pages.SaveDashboardModal.selectors.save}>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment