From 7601e0bbd31f9bf864723ac3957c5260bb0c6274 Mon Sep 17 00:00:00 2001 From: Dominik Prokop Date: Wed, 29 Apr 2020 15:41:33 +0200 Subject: [PATCH] NewPanelEditor: minor UI twekas (#24042) * Forward ref for tabs, use html props * Inspect: add inspect label to drawer title * Add tooltips to sidebar pane tabs, copy changes * Remove unused import * Place tooltips over tabs * Inspector: dont show transformations select if there is only one data frame * Review --- e2e/suite1/specs/inspect-drawer.spec.ts | 6 +-- .../grafana-data/src/panel/PanelPlugin.ts | 2 +- .../grafana-ui/src/components/Tabs/Tab.tsx | 47 +++++++++++-------- .../grafana-ui/src/utils/standardEditors.tsx | 2 +- .../components/Inspector/InspectDataTab.tsx | 10 ++-- .../components/Inspector/PanelInspector.tsx | 2 +- .../dashboard/components/Inspector/styles.ts | 1 + .../PanelEditor/OptionsPaneContent.tsx | 6 ++- .../PanelEditor/PanelOptionsTab.tsx | 12 ++--- 9 files changed, 51 insertions(+), 37 deletions(-) diff --git a/e2e/suite1/specs/inspect-drawer.spec.ts b/e2e/suite1/specs/inspect-drawer.spec.ts index 1d48b66377e..7a9fb14547d 100644 --- a/e2e/suite1/specs/inspect-drawer.spec.ts +++ b/e2e/suite1/specs/inspect-drawer.spec.ts @@ -31,7 +31,7 @@ e2e.scenario({ .should('be.visible') .click(); - e2e.components.Drawer.General.title(PANEL_UNDER_TEST) + e2e.components.Drawer.General.title(`Inspect: ${PANEL_UNDER_TEST}`) .should('be.visible') .within(() => { e2e.components.Tab.title('Query').should('be.visible'); @@ -44,7 +44,7 @@ e2e.scenario({ }); const expectDrawerTabsAndContent = () => { - e2e.components.Drawer.General.title(PANEL_UNDER_TEST) + e2e.components.Drawer.General.title(`Inspect: ${PANEL_UNDER_TEST}`) .should('be.visible') .within(() => { e2e.components.Tab.title('Data').should('be.visible'); @@ -87,7 +87,7 @@ const expectDrawerTabsAndContent = () => { const expectDrawerClose = () => { // close using close button e2e.components.Drawer.General.close().click(); - e2e.components.Drawer.General.title(PANEL_UNDER_TEST).should('not.be.visible'); + e2e.components.Drawer.General.title(`Inspect: ${PANEL_UNDER_TEST}`).should('not.be.visible'); }; const expectDrawerExpandAndContract = (viewPortWidth: number) => { diff --git a/packages/grafana-data/src/panel/PanelPlugin.ts b/packages/grafana-data/src/panel/PanelPlugin.ts index de4d147ea52..640976526dd 100644 --- a/packages/grafana-data/src/panel/PanelPlugin.ts +++ b/packages/grafana-data/src/panel/PanelPlugin.ts @@ -314,7 +314,7 @@ export class PanelPlugin { label: string; active?: boolean; icon?: IconName; @@ -16,6 +16,31 @@ export interface TabProps { counter?: number; } +export const Tab = React.forwardRef( + ({ label, active, icon, onChangeTab, counter, className, ...otherProps }, ref) => { + const theme = useTheme(); + const tabsStyles = getTabStyles(theme); + + return ( +
  • { + if (!active) { + onChangeTab(); + } + }} + aria-label={selectors.components.Tab.title(label)} + ref={ref} + > + {icon && } + {label} + {typeof counter === 'number' && } +
  • + ); + } +); + const getTabStyles = stylesFactory((theme: GrafanaTheme) => { const colors = theme.colors; @@ -47,6 +72,7 @@ const getTabStyles = stylesFactory((theme: GrafanaTheme) => { background: ${colors.bodyBg}; color: ${colors.link}; overflow: hidden; + cursor: default; &::before { display: block; @@ -61,20 +87,3 @@ const getTabStyles = stylesFactory((theme: GrafanaTheme) => { `, }; }); - -export const Tab: FC = ({ label, active, icon, onChangeTab, counter }) => { - const theme = useTheme(); - const tabsStyles = getTabStyles(theme); - - return ( -
  • - {icon && } - {label} - {typeof counter === 'number' && } -
  • - ); -}; diff --git a/packages/grafana-ui/src/utils/standardEditors.tsx b/packages/grafana-ui/src/utils/standardEditors.tsx index bbd1b20b066..8de61d6a66d 100644 --- a/packages/grafana-ui/src/utils/standardEditors.tsx +++ b/packages/grafana-ui/src/utils/standardEditors.tsx @@ -32,7 +32,7 @@ import { StatsPickerEditor } from '../components/OptionsUI/stats'; * Returns collection of common field config properties definitions */ export const getStandardFieldConfigs = () => { - const category = ['Standard field options']; + const category = ['Standard options']; const title: FieldConfigPropertyItem = { id: 'title', path: 'title', diff --git a/public/app/features/dashboard/components/Inspector/InspectDataTab.tsx b/public/app/features/dashboard/components/Inspector/InspectDataTab.tsx index f132d30524d..4afdac365c5 100644 --- a/public/app/features/dashboard/components/Inspector/InspectDataTab.tsx +++ b/public/app/features/dashboard/components/Inspector/InspectDataTab.tsx @@ -84,7 +84,7 @@ export class InspectDataTab extends PureComponent { } render() { - const { isLoading } = this.props; + const { isLoading, data } = this.props; const { dataFrameIndex, transformId, transformationOptions } = this.state; const styles = getPanelInspectorStyles(); @@ -112,9 +112,11 @@ export class InspectDataTab extends PureComponent { return (
    - - + + )} {choices.length > 1 && ( onPanelConfigChange('title', e.currentTarget.value)} /> @@ -65,7 +65,7 @@ export const PanelOptionsTab: FC = ({ ); elements.push( - + ); @@ -73,7 +73,7 @@ export const PanelOptionsTab: FC = ({ // Old legacy react editor if (plugin.editor && panel && !plugin.optionEditors) { elements.push( - + ); @@ -98,9 +98,7 @@ export const PanelOptionsTab: FC = ({ elements.push( ( - <>Panel links {!isExpanded && panelLinksCount > 0 && } - )} + renderTitle={isExpanded => <>Links {!isExpanded && panelLinksCount > 0 && }} id="panel links" key="panel links" defaultToClosed @@ -115,7 +113,7 @@ export const PanelOptionsTab: FC = ({ ); elements.push( - +