mirror of
https://github.com/grafana/grafana.git
synced 2025-08-01 00:02:33 +08:00

* i18n: removes useTranslate hook * chore: fix duplicate imports * chore: fix import sorting and hook dependencies
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
import * as React from 'react';
|
|
|
|
import { t } from '@grafana/i18n';
|
|
import { Icon, ModalsController } from '@grafana/ui';
|
|
|
|
import { OnRowOptionsUpdate } from './RowOptionsForm';
|
|
import { RowOptionsModal } from './RowOptionsModal';
|
|
|
|
export interface RowOptionsButtonProps {
|
|
title: string;
|
|
repeat?: string;
|
|
onUpdate: OnRowOptionsUpdate;
|
|
warning?: React.ReactNode;
|
|
}
|
|
|
|
export const RowOptionsButton = ({ repeat, title, onUpdate, warning }: RowOptionsButtonProps) => {
|
|
const onUpdateChange = (hideModal: () => void) => (title: string, repeat?: string | null) => {
|
|
onUpdate(title, repeat);
|
|
hideModal();
|
|
};
|
|
|
|
return (
|
|
<ModalsController>
|
|
{({ showModal, hideModal }) => {
|
|
return (
|
|
<button
|
|
type="button"
|
|
className="pointer"
|
|
aria-label={t('dashboard.row-options-button.aria-label-row-options', 'Row options')}
|
|
onClick={() => {
|
|
showModal(RowOptionsModal, {
|
|
title,
|
|
repeat,
|
|
onDismiss: hideModal,
|
|
onUpdate: onUpdateChange(hideModal),
|
|
warning,
|
|
});
|
|
}}
|
|
>
|
|
<Icon name="cog" />
|
|
</button>
|
|
);
|
|
}}
|
|
</ModalsController>
|
|
);
|
|
};
|
|
|
|
RowOptionsButton.displayName = 'RowOptionsButton';
|