From de2d57de2304d8e9727a5331b331e021c5e0d084 Mon Sep 17 00:00:00 2001 From: julieg18 Date: Thu, 21 Dec 2023 18:23:35 -0600 Subject: [PATCH 1/2] Make ribbon block error indicators more obvious --- webview/src/plots/components/App.test.tsx | 25 ++++++++++++++----- .../plots/components/ribbon/RevisionIcon.tsx | 4 +-- .../plots/components/ribbon/RibbonBlock.tsx | 15 +++++++---- .../components/ribbon/RibbonBlockIcon.tsx | 23 +++++++++++++++++ .../components/ribbon/styles.module.scss | 19 +++++++------- 5 files changed, 62 insertions(+), 24 deletions(-) create mode 100644 webview/src/plots/components/ribbon/RibbonBlockIcon.tsx diff --git a/webview/src/plots/components/App.test.tsx b/webview/src/plots/components/App.test.tsx index 2544c369ac..526d39c1f1 100644 --- a/webview/src/plots/components/App.test.tsx +++ b/webview/src/plots/components/App.test.tsx @@ -49,6 +49,7 @@ import { toggleDragAndDropMode as toggleCustomPlotsDragAndDropMode } from './customPlots/customPlotsSlice' import { comparisonTableInitialState } from './comparisonTable/comparisonTableSlice' +import plotRibbonStyles from './ribbon/styles.module.scss' import { plotsReducers, plotsStore } from '../store' import { vsCodeApi } from '../../shared/api' import { @@ -2763,11 +2764,11 @@ describe('App', () => { }) }) - it('should show an error indicator for each revision with an error', () => { + it('should show an error icon and highlight the title for each revision with an error', () => { renderAppWithOptionalData({ comparison: comparisonTableFixture, selectedRevisions: plotsRevisionsFixture.map(rev => { - if (rev.label === 'main') { + if (rev.label === 'main' || rev.description === '[exp-e7a67]') { return { ...rev, errors: ['error'] @@ -2776,11 +2777,19 @@ describe('App', () => { return rev }) }) - const errorIndicators = screen.getAllByText('!') - expect(errorIndicators).toHaveLength(1) + const mainTitle = within(screen.getByTestId('ribbon-main')).getByText( + 'main' + ) + const expTitle = within(screen.getByTestId('ribbon-exp-e7a67')).getByText( + '[exp-e7a67]' + ) + const errorIndicators = screen.getAllByLabelText('Error Icon') + expect(errorIndicators).toHaveLength(2) + expect(mainTitle).toHaveClass(plotRibbonStyles.errorIndicator) + expect(expTitle).toHaveClass(plotRibbonStyles.errorIndicator) }) - it('should not show an error indicator for a loading revision', () => { + it('should not show an error icon or highlight the title for a loading revision', () => { renderAppWithOptionalData({ comparison: comparisonTableFixture, selectedRevisions: plotsRevisionsFixture.map(rev => { @@ -2794,7 +2803,11 @@ describe('App', () => { return rev }) }) - expect(screen.queryByText('!')).not.toBeInTheDocument() + expect(screen.queryByLabelText('Error Icon')).not.toBeInTheDocument() + const titleText = within(screen.getByTestId('ribbon-main')).getByText( + 'main' + ) + expect(titleText).not.toHaveClass(plotRibbonStyles.errorIndicator) }) }) diff --git a/webview/src/plots/components/ribbon/RevisionIcon.tsx b/webview/src/plots/components/ribbon/RevisionIcon.tsx index 21770886d5..51930b47d7 100644 --- a/webview/src/plots/components/ribbon/RevisionIcon.tsx +++ b/webview/src/plots/components/ribbon/RevisionIcon.tsx @@ -5,10 +5,8 @@ import styles from './styles.module.scss' export const RevisionIcon: React.FC<{ fetched: boolean - errors?: string[] -}> = ({ fetched, errors }) => ( +}> = ({ fetched }) => (
- {fetched && errors && '!'} {!fetched && ( )} diff --git a/webview/src/plots/components/ribbon/RibbonBlock.tsx b/webview/src/plots/components/ribbon/RibbonBlock.tsx index 2a62de70cb..5242995ae6 100644 --- a/webview/src/plots/components/ribbon/RibbonBlock.tsx +++ b/webview/src/plots/components/ribbon/RibbonBlock.tsx @@ -1,12 +1,14 @@ import { Revision } from 'dvc/src/plots/webview/contract' +import cx from 'classnames' import React from 'react' import styles from './styles.module.scss' +import { RibbonBlockIcon } from './RibbonBlockIcon' import { RibbonBlockTooltip } from './RibbonBlockTooltip' import { RevisionIcon } from './RevisionIcon' import { Icon } from '../../../shared/components/Icon' import Tooltip from '../../../shared/components/tooltip/Tooltip' import { CopyButton } from '../../../shared/components/copyButton/CopyButton' -import { Close, Info } from '../../../shared/components/icons' +import { Close } from '../../../shared/components/icons' interface RibbonBlockProps { revision: Revision @@ -27,6 +29,7 @@ export const RibbonBlock: React.FC = ({ id, label } = revision + const hasError = fetched && !!errors const mainContent = (
  • = ({ style={{ borderColor: displayColor }} data-testid={`ribbon-${id}`} > - +
    {description ? ( <>
    {label}
    -
    +
    {description} = ({
    ) : ( -
    +
    {label}
    )}
    - +
    -
    - -
    +