mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Share modal: Remove deprecated Form components (#84173)
* EmailSharingConfiguration: Remove deprecated component * CreatePublicDashboard: Remove deprecated component * Update imports * Update imports[2] * Fix import
This commit is contained in:
parent
9de3d75bea
commit
f26344e176
@ -1,21 +1,11 @@
|
||||
import { css } from '@emotion/css';
|
||||
import React from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { useForm, Controller } from 'react-hook-form';
|
||||
import { useWindowSize } from 'react-use';
|
||||
|
||||
import { GrafanaTheme2, SelectableValue } from '@grafana/data/src';
|
||||
import { selectors as e2eSelectors } from '@grafana/e2e-selectors/src';
|
||||
import { FieldSet } from '@grafana/ui';
|
||||
import {
|
||||
Button,
|
||||
ButtonGroup,
|
||||
Field,
|
||||
Input,
|
||||
InputControl,
|
||||
RadioButtonGroup,
|
||||
Spinner,
|
||||
useStyles2,
|
||||
} from '@grafana/ui/src';
|
||||
import { GrafanaTheme2, SelectableValue } from '@grafana/data';
|
||||
import { selectors as e2eSelectors } from '@grafana/e2e-selectors';
|
||||
import { FieldSet, Button, ButtonGroup, Field, Input, RadioButtonGroup, Spinner, useStyles2 } from '@grafana/ui';
|
||||
import { Trans, t } from 'app/core/internationalization';
|
||||
import { contextSrv } from 'app/core/services/context_srv';
|
||||
import {
|
||||
@ -156,7 +146,7 @@ export const EmailSharingConfiguration = () => {
|
||||
label={t('public-dashboard.config.can-view-dashboard-radio-button-label', 'Can view dashboard')}
|
||||
className={styles.field}
|
||||
>
|
||||
<InputControl
|
||||
<Controller
|
||||
name="shareType"
|
||||
control={control}
|
||||
render={({ field }) => {
|
||||
|
@ -1,18 +1,18 @@
|
||||
import { css } from '@emotion/css';
|
||||
import React from 'react';
|
||||
import { FormState, UseFormRegister } from 'react-hook-form';
|
||||
import { useForm } from 'react-hook-form';
|
||||
|
||||
import { GrafanaTheme2 } from '@grafana/data/src';
|
||||
import { selectors as e2eSelectors } from '@grafana/e2e-selectors/src';
|
||||
import { Button, Form, Spinner, useStyles2 } from '@grafana/ui/src';
|
||||
import { GrafanaTheme2 } from '@grafana/data';
|
||||
import { selectors as e2eSelectors } from '@grafana/e2e-selectors';
|
||||
import { Button, Spinner, useStyles2 } from '@grafana/ui';
|
||||
import { Trans } from 'app/core/internationalization';
|
||||
import { contextSrv } from 'app/core/services/context_srv';
|
||||
import { useCreatePublicDashboardMutation } from 'app/features/dashboard/api/publicDashboardApi';
|
||||
import { DashboardModel } from 'app/features/dashboard/state';
|
||||
import { DashboardScene } from 'app/features/dashboard-scene/scene/DashboardScene';
|
||||
import { DashboardInteractions } from 'app/features/dashboard-scene/utils/interactions';
|
||||
import { AccessControlAction, useSelector } from 'app/types';
|
||||
|
||||
import { contextSrv } from '../../../../../../core/services/context_srv';
|
||||
import { AccessControlAction, useSelector } from '../../../../../../types';
|
||||
import { NoUpsertPermissionsAlert } from '../ModalAlerts/NoUpsertPermissionsAlert';
|
||||
import { UnsupportedDataSourcesAlert } from '../ModalAlerts/UnsupportedDataSourcesAlert';
|
||||
import { UnsupportedTemplateVariablesAlert } from '../ModalAlerts/UnsupportedTemplateVariablesAlert';
|
||||
@ -49,6 +49,11 @@ export const CreatePublicDashboardBase = ({
|
||||
createPublicDashboard({ dashboard, payload: { isEnabled: true } });
|
||||
DashboardInteractions.generatePublicDashboardUrlClicked({});
|
||||
};
|
||||
const {
|
||||
handleSubmit,
|
||||
register,
|
||||
formState: { isValid },
|
||||
} = useForm<SharePublicDashboardAcknowledgmentInputs>({ mode: 'onChange' });
|
||||
|
||||
const disableInputs = !hasWritePermissions || isLoading || isError || hasError;
|
||||
|
||||
@ -73,15 +78,7 @@ export const CreatePublicDashboardBase = ({
|
||||
<UnsupportedDataSourcesAlert unsupportedDataSources={unsupportedDatasources.join(', ')} />
|
||||
)}
|
||||
|
||||
<Form onSubmit={onCreate} validateOn="onChange" maxWidth="none">
|
||||
{({
|
||||
register,
|
||||
formState: { isValid },
|
||||
}: {
|
||||
register: UseFormRegister<SharePublicDashboardAcknowledgmentInputs>;
|
||||
formState: FormState<SharePublicDashboardAcknowledgmentInputs>;
|
||||
}) => (
|
||||
<>
|
||||
<form onSubmit={handleSubmit(onCreate)}>
|
||||
<div className={styles.checkboxes}>
|
||||
<AcknowledgeCheckboxes disabled={disableInputs} register={register} />
|
||||
</div>
|
||||
@ -91,9 +88,7 @@ export const CreatePublicDashboardBase = ({
|
||||
{isLoading && <Spinner className={styles.loadingSpinner} />}
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</Form>
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user