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

* i18n: removes useTranslate hook * chore: fix duplicate imports * chore: fix import sorting and hook dependencies
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import { t } from '@grafana/i18n';
|
|
import { Icon, Stack, Tooltip } from '@grafana/ui';
|
|
import { OptionsPaneCategoryDescriptor } from 'app/features/dashboard/components/PanelEditor/OptionsPaneCategoryDescriptor';
|
|
import { OptionsPaneItemDescriptor } from 'app/features/dashboard/components/PanelEditor/OptionsPaneItemDescriptor';
|
|
|
|
import { ConditionalRendering } from './ConditionalRendering';
|
|
|
|
export function useConditionalRenderingEditor(
|
|
conditionalRendering?: ConditionalRendering
|
|
): OptionsPaneCategoryDescriptor | null {
|
|
if (!conditionalRendering) {
|
|
return null;
|
|
}
|
|
|
|
const title = t('dashboard.conditional-rendering.root.title', 'Show / hide rules');
|
|
|
|
return new OptionsPaneCategoryDescriptor({
|
|
title,
|
|
id: 'conditional-rendering-options',
|
|
renderTitle: () => (
|
|
<Stack direction="row" gap={1} alignItems="center">
|
|
<div>{title}</div>
|
|
<Tooltip content={conditionalRendering.info}>
|
|
<Icon name={!conditionalRendering.evaluate() ? 'eye-slash' : 'eye'} />
|
|
</Tooltip>
|
|
</Stack>
|
|
),
|
|
isOpenDefault: true,
|
|
}).addItem(
|
|
new OptionsPaneItemDescriptor({
|
|
title,
|
|
render: () => <conditionalRendering.Component model={conditionalRendering} />,
|
|
})
|
|
);
|
|
}
|