mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 01:53:33 -06:00
* Add and configure eslint-plugin-import * Fix the lint:ts npm command * Autofix + prettier all the files * Manually fix remaining files * Move jquery code in jest-setup to external file to safely reorder imports * Resolve issue caused by circular dependencies within Prometheus * Update .betterer.results * Fix missing // @ts-ignore * ignore iconBundle.ts * Fix missing // @ts-ignore
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import React, { FC, useCallback, useState } from 'react';
|
|
|
|
import { Button, Field, Form, Modal, Input } from '@grafana/ui';
|
|
|
|
import { RepeatRowSelect } from '../RepeatRowSelect/RepeatRowSelect';
|
|
|
|
export type OnRowOptionsUpdate = (title: string, repeat?: string | null) => void;
|
|
|
|
export interface Props {
|
|
title: string;
|
|
repeat?: string | null;
|
|
onUpdate: OnRowOptionsUpdate;
|
|
onCancel: () => void;
|
|
}
|
|
|
|
export const RowOptionsForm: FC<Props> = ({ repeat, title, onUpdate, onCancel }) => {
|
|
const [newRepeat, setNewRepeat] = useState<string | null | undefined>(repeat);
|
|
const onChangeRepeat = useCallback((name?: string | null) => setNewRepeat(name), [setNewRepeat]);
|
|
|
|
return (
|
|
<Form
|
|
defaultValues={{ title }}
|
|
onSubmit={(formData: { title: string }) => {
|
|
onUpdate(formData.title, newRepeat);
|
|
}}
|
|
>
|
|
{({ register }) => (
|
|
<>
|
|
<Field label="Title">
|
|
<Input {...register('title')} type="text" />
|
|
</Field>
|
|
|
|
<Field label="Repeat for">
|
|
<RepeatRowSelect repeat={newRepeat} onChange={onChangeRepeat} />
|
|
</Field>
|
|
|
|
<Modal.ButtonRow>
|
|
<Button type="button" variant="secondary" onClick={onCancel} fill="outline">
|
|
Cancel
|
|
</Button>
|
|
<Button type="submit">Update</Button>
|
|
</Modal.ButtonRow>
|
|
</>
|
|
)}
|
|
</Form>
|
|
);
|
|
};
|