DynamicDashboards: In view mode, hide config button when panel has not been configured (#115261)
This commit is contained in:
@@ -5,7 +5,19 @@ import { CoreApp, GrafanaTheme2, PanelPlugin, PanelProps } from '@grafana/data';
|
||||
import { Trans, t } from '@grafana/i18n';
|
||||
import { config, locationService } from '@grafana/runtime';
|
||||
import { sceneUtils } from '@grafana/scenes';
|
||||
import { Box, Button, ButtonGroup, Dropdown, Icon, Menu, Stack, Text, usePanelContext, useStyles2 } from '@grafana/ui';
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
ButtonGroup,
|
||||
Dropdown,
|
||||
EmptyState,
|
||||
Icon,
|
||||
Menu,
|
||||
Stack,
|
||||
Text,
|
||||
usePanelContext,
|
||||
useStyles2,
|
||||
} from '@grafana/ui';
|
||||
|
||||
import { NEW_PANEL_TITLE } from '../../dashboard/utils/dashboard';
|
||||
import { DashboardInteractions } from '../utils/interactions';
|
||||
@@ -92,20 +104,30 @@ function UnconfiguredPanelComp(props: PanelProps) {
|
||||
);
|
||||
}
|
||||
|
||||
const { isEditing } = dashboard.state;
|
||||
|
||||
return (
|
||||
<Stack direction={'row'} alignItems={'center'} height={'100%'} justifyContent={'center'}>
|
||||
<Box paddingBottom={2}>
|
||||
<ButtonGroup>
|
||||
<Button icon="sliders-v-alt" onClick={onConfigure}>
|
||||
<Trans i18nKey="dashboard.new-panel.configure-button">Configure</Trans>
|
||||
</Button>
|
||||
<Dropdown overlay={MenuActions} placement="bottom-end" onVisibleChange={onMenuClick}>
|
||||
<Button
|
||||
aria-label={t('dashboard.new-panel.configure-button-menu', 'Toggle menu')}
|
||||
icon={isOpen ? 'angle-up' : 'angle-down'}
|
||||
/>
|
||||
</Dropdown>
|
||||
</ButtonGroup>
|
||||
{isEditing ? (
|
||||
<ButtonGroup>
|
||||
<Button icon="sliders-v-alt" onClick={onConfigure}>
|
||||
<Trans i18nKey="dashboard.new-panel.configure-button">Configure</Trans>
|
||||
</Button>
|
||||
<Dropdown overlay={MenuActions} placement="bottom-end" onVisibleChange={onMenuClick}>
|
||||
<Button
|
||||
aria-label={t('dashboard.new-panel.configure-button-menu', 'Toggle menu')}
|
||||
icon={isOpen ? 'angle-up' : 'angle-down'}
|
||||
/>
|
||||
</Dropdown>
|
||||
</ButtonGroup>
|
||||
) : (
|
||||
<EmptyState
|
||||
variant="call-to-action"
|
||||
message={t('dashboard.new-panel.missing-config', 'Missing panel configuration')}
|
||||
hideImage
|
||||
/>
|
||||
)}
|
||||
</Box>
|
||||
</Stack>
|
||||
);
|
||||
|
||||
@@ -5133,6 +5133,7 @@
|
||||
"empty-state-message": "Run a query to visualize it here or go to all visualizations to add other panel types",
|
||||
"menu-open-panel-editor": "Configure",
|
||||
"menu-use-library-panel": "Use library panel",
|
||||
"missing-config": "Missing panel configuration",
|
||||
"suggestions": {
|
||||
"empty-state-message": "Run a query to start seeing suggested visualizations"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user