From 66cea5aac6000280646a6ec9aaa2d806beb793f2 Mon Sep 17 00:00:00 2001 From: Juan Cabanas Date: Fri, 28 Jul 2023 10:09:31 -0300 Subject: [PATCH] A11y: Make Annotations and Template Variables list and edit pages responsive (#71791) --- .../CallToActionCard/CallToActionCard.tsx | 5 +- .../AnnotationSettingsList.tsx | 107 ++++++++++-------- .../variables/editor/VariableEditorList.tsx | 81 +++++++------ .../editor/VariableTextAreaField.tsx | 4 + .../query/QueryVariableRefreshSelect.tsx | 22 +++- 5 files changed, 132 insertions(+), 87 deletions(-) diff --git a/packages/grafana-ui/src/components/CallToActionCard/CallToActionCard.tsx b/packages/grafana-ui/src/components/CallToActionCard/CallToActionCard.tsx index c78b57997da..e0be02a5e67 100644 --- a/packages/grafana-ui/src/components/CallToActionCard/CallToActionCard.tsx +++ b/packages/grafana-ui/src/components/CallToActionCard/CallToActionCard.tsx @@ -27,7 +27,6 @@ export const CallToActionCard = ({ message, callToActionElement, footer, classNa const getStyles = (theme: GrafanaTheme2) => ({ wrapper: css({ label: 'call-to-action-card', - padding: theme.spacing(3), background: theme.colors.background.secondary, borderRadius: theme.shape.radius.default, display: 'flex', @@ -35,6 +34,10 @@ const getStyles = (theme: GrafanaTheme2) => ({ alignItems: 'center', justifyContent: 'center', flexGrow: 1, + padding: theme.spacing(3), + [theme.breakpoints.down('sm')]: { + padding: theme.spacing(3, 1), + }, }), message: css({ marginBottom: theme.spacing(3), diff --git a/public/app/features/dashboard/components/AnnotationSettings/AnnotationSettingsList.tsx b/public/app/features/dashboard/components/AnnotationSettings/AnnotationSettingsList.tsx index 2799c59a324..21de6545af2 100644 --- a/public/app/features/dashboard/components/AnnotationSettings/AnnotationSettingsList.tsx +++ b/public/app/features/dashboard/components/AnnotationSettings/AnnotationSettingsList.tsx @@ -1,8 +1,9 @@ +import { css } from '@emotion/css'; import React, { useState } from 'react'; import { arrayUtils, AnnotationQuery } from '@grafana/data'; import { getDataSourceSrv } from '@grafana/runtime'; -import { Button, DeleteButton, IconButton, VerticalGroup } from '@grafana/ui'; +import { Button, DeleteButton, IconButton, useStyles2, VerticalGroup } from '@grafana/ui'; import EmptyListCTA from 'app/core/components/EmptyListCTA/EmptyListCTA'; import { DashboardModel } from '../../state/DashboardModel'; @@ -15,6 +16,7 @@ type Props = { }; export const AnnotationSettingsList = ({ dashboard, onNew, onEdit }: Props) => { + const styles = useStyles2(getStyles); const [annotations, updateAnnotations] = useState(dashboard.annotations.list); const onMove = (idx: number, direction: number) => { @@ -53,54 +55,56 @@ export const AnnotationSettingsList = ({ dashboard, onNew, onEdit }: Props) => { return ( {annotations.length > 0 && ( - - - - - - - - - - {dashboard.annotations.list.map((annotation, idx) => ( - - {annotation.builtIn ? ( - - ) : ( - - )} - - - - +
+
Query nameData source
onEdit(idx)}> - - onEdit(idx)}> - - onEdit(idx)}> - {dataSourceSrv.getInstanceSettings(annotation.datasource)?.name || annotation.datasource?.uid} - - {idx !== 0 && onMove(idx, -1)} tooltip="Move up" />} - - {dashboard.annotations.list.length > 1 && idx !== dashboard.annotations.list.length - 1 ? ( - onMove(idx, 1)} tooltip="Move down" /> - ) : null} - - {!annotation.builtIn && ( - onDelete(idx)} - aria-label={`Delete query with title "${annotation.name}"`} - /> - )} -
+ + + + + - ))} - -
Query nameData source
+ + + {dashboard.annotations.list.map((annotation, idx) => ( + + {annotation.builtIn ? ( + onEdit(idx)}> + + + ) : ( + onEdit(idx)}> + + + )} + onEdit(idx)}> + {dataSourceSrv.getInstanceSettings(annotation.datasource)?.name || annotation.datasource?.uid} + + + {idx !== 0 && onMove(idx, -1)} tooltip="Move up" />} + + + {dashboard.annotations.list.length > 1 && idx !== dashboard.annotations.list.length - 1 ? ( + onMove(idx, 1)} tooltip="Move down" /> + ) : null} + + + {!annotation.builtIn && ( + onDelete(idx)} + aria-label={`Delete query with title "${annotation.name}"`} + /> + )} + + + ))} + + + )} {showEmptyListCTA && ( {
); }; + +const getStyles = () => ({ + table: css` + width: 100%; + overflow-x: scroll; + `, +}); diff --git a/public/app/features/variables/editor/VariableEditorList.tsx b/public/app/features/variables/editor/VariableEditorList.tsx index 26b0723e688..b69cdf293aa 100644 --- a/public/app/features/variables/editor/VariableEditorList.tsx +++ b/public/app/features/variables/editor/VariableEditorList.tsx @@ -1,10 +1,11 @@ +import { css } from '@emotion/css'; import React, { ReactElement } from 'react'; import { DragDropContext, Droppable, DropResult } from 'react-beautiful-dnd'; import { selectors } from '@grafana/e2e-selectors'; import { Stack } from '@grafana/experimental'; import { reportInteraction } from '@grafana/runtime'; -import { Button } from '@grafana/ui'; +import { Button, useStyles2 } from '@grafana/ui'; import EmptyListCTA from 'app/core/components/EmptyListCTA/EmptyListCTA'; import { VariablesDependenciesButton } from '../inspect/VariablesDependenciesButton'; @@ -35,6 +36,7 @@ export function VariableEditorList({ onDelete, onDuplicate, }: Props): ReactElement { + const styles = useStyles2(getStyles); const onDragEnd = (result: DropResult) => { if (!result.destination || !result.source) { return; @@ -51,40 +53,42 @@ export function VariableEditorList({ {variables.length > 0 && ( - - - - - - - - - - {(provided) => ( - - {variables.map((variable, index) => ( - - ))} - {provided.placeholder} - - )} - - -
VariableDefinition -
+
+ + + + + + + + + + {(provided) => ( + + {variables.map((variable, index) => ( + + ))} + {provided.placeholder} + + )} + + +
VariableDefinition +
+