mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Form migrations: Last components from Forms namespace (#23556)
* Migrate RadioButtonGroup * Migrate Label * Migrate Form * Migrate Field * Missing Form import * Migrate InputControl * Migrate Checkbox * Move InputControl and uncomment * Fix small issues * inor fix * Fix import * Fix stuff
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { Button, Forms, HorizontalGroup, Input, Switch } from '@grafana/ui';
|
||||
import { Button, HorizontalGroup, Input, Switch, Form, Field, InputControl } from '@grafana/ui';
|
||||
import { DashboardModel, PanelModel } from 'app/features/dashboard/state';
|
||||
import { FolderPicker } from 'app/core/components/Select/FolderPicker';
|
||||
import { SaveDashboardFormProps } from '../types';
|
||||
@@ -62,7 +62,7 @@ export const SaveDashboardAsForm: React.FC<SaveDashboardFormProps & { isNew?: bo
|
||||
};
|
||||
|
||||
return (
|
||||
<Forms.Form
|
||||
<Form
|
||||
defaultValues={defaultValues}
|
||||
onSubmit={async (data: SaveDashboardAsFormDTO) => {
|
||||
const clone = getSaveAsDashboardClone(dashboard);
|
||||
@@ -86,7 +86,7 @@ export const SaveDashboardAsForm: React.FC<SaveDashboardFormProps & { isNew?: bo
|
||||
>
|
||||
{({ register, control, errors, getValues }) => (
|
||||
<>
|
||||
<Forms.Field label="Dashboard name" invalid={!!errors.title} error={errors.title?.message}>
|
||||
<Field label="Dashboard name" invalid={!!errors.title} error={errors.title?.message}>
|
||||
<Input
|
||||
name="title"
|
||||
ref={register({
|
||||
@@ -95,9 +95,9 @@ export const SaveDashboardAsForm: React.FC<SaveDashboardFormProps & { isNew?: bo
|
||||
aria-label="Save dashboard title field"
|
||||
autoFocus
|
||||
/>
|
||||
</Forms.Field>
|
||||
<Forms.Field label="Folder">
|
||||
<Forms.InputControl
|
||||
</Field>
|
||||
<Field label="Folder">
|
||||
<InputControl
|
||||
as={FolderPicker}
|
||||
control={control}
|
||||
name="$folder"
|
||||
@@ -107,10 +107,10 @@ export const SaveDashboardAsForm: React.FC<SaveDashboardFormProps & { isNew?: bo
|
||||
enableCreateNew
|
||||
useNewForms
|
||||
/>
|
||||
</Forms.Field>
|
||||
<Forms.Field label="Copy tags">
|
||||
</Field>
|
||||
<Field label="Copy tags">
|
||||
<Switch name="copyTags" ref={register} />
|
||||
</Forms.Field>
|
||||
</Field>
|
||||
<HorizontalGroup>
|
||||
<Button type="submit" aria-label="Save dashboard button">
|
||||
Save
|
||||
@@ -121,6 +121,6 @@ export const SaveDashboardAsForm: React.FC<SaveDashboardFormProps & { isNew?: bo
|
||||
</HorizontalGroup>
|
||||
</>
|
||||
)}
|
||||
</Forms.Form>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { useMemo } from 'react';
|
||||
|
||||
import { Forms, Button, HorizontalGroup, TextArea } from '@grafana/ui';
|
||||
import { Button, HorizontalGroup, TextArea, Form, Checkbox } from '@grafana/ui';
|
||||
import { e2e } from '@grafana/e2e';
|
||||
import { SaveDashboardFormProps } from '../types';
|
||||
|
||||
@@ -15,7 +15,7 @@ export const SaveDashboardForm: React.FC<SaveDashboardFormProps> = ({ dashboard,
|
||||
const hasVariableChanged = useMemo(() => dashboard.hasVariableValuesChanged(), [dashboard]);
|
||||
|
||||
return (
|
||||
<Forms.Form
|
||||
<Form
|
||||
onSubmit={async (data: SaveDashboardFormDTO) => {
|
||||
const result = await onSubmit(dashboard.getSaveModelClone(data), data, dashboard);
|
||||
if (result.status === 'success') {
|
||||
@@ -33,7 +33,7 @@ export const SaveDashboardForm: React.FC<SaveDashboardFormProps> = ({ dashboard,
|
||||
<>
|
||||
<div className="gf-form-group">
|
||||
{hasTimeChanged && (
|
||||
<Forms.Checkbox
|
||||
<Checkbox
|
||||
label="Save current time range as dashboard default"
|
||||
name="saveTimerange"
|
||||
ref={register}
|
||||
@@ -41,7 +41,7 @@ export const SaveDashboardForm: React.FC<SaveDashboardFormProps> = ({ dashboard,
|
||||
/>
|
||||
)}
|
||||
{hasVariableChanged && (
|
||||
<Forms.Checkbox
|
||||
<Checkbox
|
||||
label="Save current variable values as dashboard default"
|
||||
name="saveVariables"
|
||||
ref={register}
|
||||
@@ -63,6 +63,6 @@ export const SaveDashboardForm: React.FC<SaveDashboardFormProps> = ({ dashboard,
|
||||
</HorizontalGroup>
|
||||
</>
|
||||
)}
|
||||
</Forms.Form>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user