Files
grafana/public/app/features/dashboard/components/ShareModal/SharePublicDashboard/ConfigPublicDashboard/Configuration.tsx
Polina Boneva 1110cb4d44 Public Dashboard: Redesign modal (v2) (#71151)
* Update public/app/features/dashboard/components/ShareModal/SharePublicDashboard/ConfigPublicDashboard/SettingsBar.tsx

Co-authored-by: Juan Cabanas <juan.cabanas@grafana.com>

* revert modal styling and add specific styling to Sharing

* Update public/app/features/dashboard/components/ShareModal/SharePublicDashboard/ConfigPublicDashboard/SettingsBar.tsx

Co-authored-by: Juan Cabanas <juan.cabanas@grafana.com>

* functions > const

* put a gat between all items in email config, instead of margins for each item

* fix html semantic elements

* ad theme to class component ShareModal

* add labels

* fix failing tests; now Settings has a summary and has to be opened to be able to see the On/Off toggles

* fix dashboard-public-create test with settings dropdown
2023-07-25 13:17:39 +03:00

66 lines
2.5 KiB
TypeScript

import React from 'react';
import { UseFormRegister } from 'react-hook-form';
import { TimeRange } from '@grafana/data/src';
import { selectors as e2eSelectors } from '@grafana/e2e-selectors/src';
import { reportInteraction } from '@grafana/runtime/src';
import { FieldSet, Label, Switch, TimeRangeInput, VerticalGroup } from '@grafana/ui/src';
import { Layout } from '@grafana/ui/src/components/Layout/Layout';
import { ConfigPublicDashboardForm } from './ConfigPublicDashboard';
const selectors = e2eSelectors.pages.ShareDashboardModal.PublicDashboard;
export const Configuration = ({
disabled,
onChange,
register,
timeRange,
}: {
disabled: boolean;
onChange: (name: keyof ConfigPublicDashboardForm, value: boolean) => void;
register: UseFormRegister<ConfigPublicDashboardForm>;
timeRange: TimeRange;
}) => {
return (
<>
<FieldSet disabled={disabled}>
<VerticalGroup spacing="md">
<Layout orientation={1} spacing="xs" justify="space-between">
<Label description="The public dashboard uses the default time range settings of the dashboard">
Default time range
</Label>
<TimeRangeInput value={timeRange} disabled onChange={() => {}} />
</Layout>
<Layout orientation={0} spacing="sm">
<Switch
{...register('isTimeSelectionEnabled')}
data-testid={selectors.EnableTimeRangeSwitch}
onChange={(e) => {
reportInteraction('grafana_dashboards_public_time_selection_clicked', {
action: e.currentTarget.checked ? 'enable' : 'disable',
});
onChange('isTimeSelectionEnabled', e.currentTarget.checked);
}}
/>
<Label description="Allow viewers to change time range">Time range picker enabled</Label>
</Layout>
<Layout orientation={0} spacing="sm">
<Switch
{...register('isAnnotationsEnabled')}
onChange={(e) => {
reportInteraction('grafana_dashboards_public_annotations_clicked', {
action: e.currentTarget.checked ? 'enable' : 'disable',
});
onChange('isAnnotationsEnabled', e.currentTarget.checked);
}}
data-testid={selectors.EnableAnnotationsSwitch}
/>
<Label description="Show annotations on public dashboard">Show annotations</Label>
</Layout>
</VerticalGroup>
</FieldSet>
</>
);
};