From d1f9cc8c2e8978c05c67243d90eb5e8d551c0c9a Mon Sep 17 00:00:00 2001 From: James Baker Date: Tue, 1 Jun 2021 08:08:04 +0100 Subject: [PATCH] Code formatting --- src/main/app/src/Api.ts | 15 +- src/main/app/src/Routes.test.tsx | 8 +- .../ChooseTemplate/ChooseTemplate.tsx | 4 +- .../components/Components/Components.test.tsx | 3 +- .../src/components/Components/Components.tsx | 16 +- .../ComponentsInfoCard/ComponentsInfoCard.tsx | 7 +- src/main/app/src/components/Help/Help.tsx | 2 +- .../src/components/MetricView/MetricView.tsx | 10 +- .../PipelineComponent/PipelineComponent.tsx | 7 +- .../components/PipelineEdit/PipelineEdit.tsx | 11 +- .../PipelineEditComponentSeparator.tsx | 93 ++++++----- ...PipelineEditErrorConfiguration.stories.tsx | 4 +- .../PipelineEditErrorConfiguration.test.tsx | 4 +- .../PipelineEditErrorConfiguration.tsx | 93 +++++++---- .../PipelineMetadataCard.stories.tsx | 20 ++- .../PipelineMetadataCard.tsx | 26 +++- .../PipelineMetrics/PipelineMetrics.tsx | 4 +- .../components/PipelineView/PipelineView.tsx | 32 ++-- ...PipelineViewErrorConfiguration.stories.tsx | 26 ++-- .../PipelineViewErrorConfiguration.test.tsx | 12 +- .../PipelineViewErrorConfiguration.tsx | 146 +++++++++--------- .../src/components/Pipelines/Pipelines.tsx | 2 +- .../SelectComponentDialog.tsx | 8 +- .../ThemeProvider/ThemeProvider.stories.tsx | 7 +- .../ThemeProvider/ThemeProvider.tsx | 42 ++--- .../src/containers/ComponentsContainer.tsx | 8 +- .../src/containers/PipelineEditContainer.tsx | 18 +-- .../containers/PipelineEditFetchContainer.tsx | 146 +++++++++--------- .../containers/PipelineMetadataContainer.tsx | 74 +++++---- .../containers/PipelineMetricsContainer.tsx | 75 ++++----- .../containers/PipelineTemplateContainer.tsx | 118 +++++++------- .../src/containers/PipelineViewContainer.tsx | 8 +- .../containers/PipelineViewLogsContainer.tsx | 51 +++--- .../app/src/containers/PipelinesContainer.tsx | 21 ++- .../app/src/containers/SubmitContainer.tsx | 12 +- src/main/app/src/context/ServerContext.tsx | 19 +-- src/main/app/src/hooks/useStateTracking.ts | 4 +- src/main/app/src/metrics.ts | 8 +- src/main/app/src/types/examples.ts | 53 ++++--- src/main/app/src/utils/download.test.ts | 4 +- src/main/app/src/utils/pipeline.ts | 52 +++---- src/main/app/src/utils/validator.ts | 10 +- 42 files changed, 676 insertions(+), 607 deletions(-) diff --git a/src/main/app/src/Api.ts b/src/main/app/src/Api.ts index 7e90e8f..b7d7254 100644 --- a/src/main/app/src/Api.ts +++ b/src/main/app/src/Api.ts @@ -89,7 +89,7 @@ const client: ExtendedHttpClient = { return response.json() as Promise } else { // When not 200 R should be void, so this is valid - return (undefined as unknown) as R + return undefined as unknown as R } }) }, @@ -166,9 +166,8 @@ export class ExtendedRestApplicationClient extends RestApplicationClient { } } -export const Api: ExtendedRestApplicationClient = new ExtendedRestApplicationClient( - client -) +export const Api: ExtendedRestApplicationClient = + new ExtendedRestApplicationClient(client) export const getPipelines = async ( _fetchKey: string @@ -217,17 +216,17 @@ export const createPipeline = async ( orderer: string = NO_OP_ORDERER, persist = true ): Promise => { - const { name, description, sources, processors, errorConfiguration } = pipeline + const { name, description, sources, processors, errorConfiguration } = + pipeline const { onSourceError, onProcessorError, onItemError } = errorConfiguration const components: PipelineComponents = { sources, processors } - return Api.createPipeline(name, components, - { + return Api.createPipeline(name, components, { description, orderer, persist, onSourceError, onProcessorError, - onItemError + onItemError, }) } diff --git a/src/main/app/src/Routes.test.tsx b/src/main/app/src/Routes.test.tsx index 6fbf9b2..bb51164 100644 --- a/src/main/app/src/Routes.test.tsx +++ b/src/main/app/src/Routes.test.tsx @@ -57,12 +57,12 @@ jest.mock('./containers/PipelineTemplateContainer', () => { test('full app rendering/navigating', async () => { // Just to check no requests are being made - const fetchSpy = jest.spyOn(global, 'fetch').mockImplementation( - async (...args): Promise => { + const fetchSpy = jest + .spyOn(global, 'fetch') + .mockImplementation(async (...args): Promise => { console.error(...args) return Promise.resolve({} as Response) - } - ) + }) try { const { diff --git a/src/main/app/src/components/ChooseTemplate/ChooseTemplate.tsx b/src/main/app/src/components/ChooseTemplate/ChooseTemplate.tsx index 9d0114a..688613e 100644 --- a/src/main/app/src/components/ChooseTemplate/ChooseTemplate.tsx +++ b/src/main/app/src/components/ChooseTemplate/ChooseTemplate.tsx @@ -86,8 +86,8 @@ const uploadTemplate: PipelineTemplate = { errorConfiguration: { onItemError: 'DISCARD_ITEM', onProcessorError: 'REMOVE_PROCESSOR', - onSourceError: 'REMOVE_SOURCE' - } + onSourceError: 'REMOVE_SOURCE', + }, } const StyledCardContent: React.ComponentType<{ selected: boolean }> = styled( diff --git a/src/main/app/src/components/Components/Components.test.tsx b/src/main/app/src/components/Components/Components.test.tsx index 65c6e1c..b6c14bc 100644 --- a/src/main/app/src/components/Components/Components.test.tsx +++ b/src/main/app/src/components/Components/Components.test.tsx @@ -36,7 +36,8 @@ const sources: ComponentMap = { } const settings: SettingsMap = { [exampleComponentInfo1.settingsClass as string]: exampleSettingsSchema, - 'io.annot8.components.files.sources.FileSystemSourceSettings': exampleSettingSchemaComplex, + 'io.annot8.components.files.sources.FileSystemSourceSettings': + exampleSettingSchemaComplex, } const orderers = { NO_OP_ORDERER: { diff --git a/src/main/app/src/components/Components/Components.tsx b/src/main/app/src/components/Components/Components.tsx index 76c5409..43af1d8 100644 --- a/src/main/app/src/components/Components/Components.tsx +++ b/src/main/app/src/components/Components/Components.tsx @@ -43,15 +43,15 @@ export const Components: React.FC = ({ const elevation = trigger ? 4 : 0 - const filteredOrderers = useMemo(() => filterComponents(orderers, search), [ - orderers, - search, - ]) + const filteredOrderers = useMemo( + () => filterComponents(orderers, search), + [orderers, search] + ) - const filteredSources = useMemo(() => filterComponents(sources, search), [ - sources, - search, - ]) + const filteredSources = useMemo( + () => filterComponents(sources, search), + [sources, search] + ) const filteredProcessors = useMemo( () => filterComponents(processors, search), diff --git a/src/main/app/src/components/ComponentsInfoCard/ComponentsInfoCard.tsx b/src/main/app/src/components/ComponentsInfoCard/ComponentsInfoCard.tsx index ea44a73..d6db589 100644 --- a/src/main/app/src/components/ComponentsInfoCard/ComponentsInfoCard.tsx +++ b/src/main/app/src/components/ComponentsInfoCard/ComponentsInfoCard.tsx @@ -51,8 +51,8 @@ export interface ComponentsInfoCardProps /** * This is the contents of the component info card. */ -const ComponentsInfoCardContent: React.FC = memo( - ({ info }: ComponentsInfoCardContentProps) => { +const ComponentsInfoCardContent: React.FC = + memo(({ info }: ComponentsInfoCardContentProps) => { const { componentClass, description, name, tags } = info return ( @@ -73,8 +73,7 @@ const ComponentsInfoCardContent: React.FC = memo ) - } -) + }) /** * This component is to display the different server components diff --git a/src/main/app/src/components/Help/Help.tsx b/src/main/app/src/components/Help/Help.tsx index 564e5c2..072f5a0 100644 --- a/src/main/app/src/components/Help/Help.tsx +++ b/src/main/app/src/components/Help/Help.tsx @@ -248,7 +248,7 @@ export const Help: React.FC = () => { name: 'Pipeline Name', description: 'A helpful description of the Pipeline to remind you of its purpose.', - running: true + running: true, }} isDeleting={false} onDelete={async (): Promise => Promise.resolve()} diff --git a/src/main/app/src/components/MetricView/MetricView.tsx b/src/main/app/src/components/MetricView/MetricView.tsx index ae47877..2c1d0a8 100644 --- a/src/main/app/src/components/MetricView/MetricView.tsx +++ b/src/main/app/src/components/MetricView/MetricView.tsx @@ -99,10 +99,14 @@ export const MetricView: React.FC = ({ measurements, }: MetricViewProps) => { const transform = metadata?.transform ?? identity - const computedValue = computeValue(measurements); + const computedValue = computeValue(measurements) - if(computedValue === undefined || typeof computedValue !== "number" || Number.isNaN(computedValue)) - return null; + if ( + computedValue === undefined || + typeof computedValue !== 'number' || + Number.isNaN(computedValue) + ) + return null const value = transform(computedValue) const displayName = metadata?.name ?? javaNameToReadable(name) diff --git a/src/main/app/src/components/PipelineComponent/PipelineComponent.tsx b/src/main/app/src/components/PipelineComponent/PipelineComponent.tsx index e36394a..98a320f 100644 --- a/src/main/app/src/components/PipelineComponent/PipelineComponent.tsx +++ b/src/main/app/src/components/PipelineComponent/PipelineComponent.tsx @@ -207,11 +207,8 @@ export const PipelineComponent = React.forwardRef< if (componentClassName === undefined) { throw Error('Pipeline component does not define a type') } - const [ - showSettingsDialog, - openSettingsDialog, - closeSettingsDialog, - ] = useDialog() + const [showSettingsDialog, openSettingsDialog, closeSettingsDialog] = + useDialog() const [showNameDialog, openNameDialog, closeNameDialog] = useDialog() const innerRef = useRef(null) const [isHovering] = useHover(innerRef) diff --git a/src/main/app/src/components/PipelineEdit/PipelineEdit.tsx b/src/main/app/src/components/PipelineEdit/PipelineEdit.tsx index 6d3ef86..9f592ac 100644 --- a/src/main/app/src/components/PipelineEdit/PipelineEdit.tsx +++ b/src/main/app/src/components/PipelineEdit/PipelineEdit.tsx @@ -29,7 +29,11 @@ import Backdrop from '@material-ui/core/Backdrop' import React from 'react' import { GlobalHotKeys, KeyMap } from 'react-hotkeys' import { useDialog, useServerDetails } from '../../hooks' -import { ComponentInfo, PipelineEditDescriptor, ErrorConfiguration } from '../../types' +import { + ComponentInfo, + PipelineEditDescriptor, + ErrorConfiguration, +} from '../../types' import { DescriptionDialog } from '../DescriptionDialog' import { Divider } from '../Divider' import { ErrorNotifier } from '../ErrorNotifier' @@ -345,7 +349,10 @@ export const PipelineEdit: React.FC = ({ Error Configuration - + diff --git a/src/main/app/src/components/PipelineEditComponentSeparator/PipelineEditComponentSeparator.tsx b/src/main/app/src/components/PipelineEditComponentSeparator/PipelineEditComponentSeparator.tsx index c67a759..06335bf 100644 --- a/src/main/app/src/components/PipelineEditComponentSeparator/PipelineEditComponentSeparator.tsx +++ b/src/main/app/src/components/PipelineEditComponentSeparator/PipelineEditComponentSeparator.tsx @@ -44,53 +44,50 @@ export interface PipelineEditComponentSeparatorProps { /** * PipelineEditComponentSeparator component */ -export const PipelineEditComponentSeparator: React.FC = ({ - onInsert, - isDragging, - type, -}: PipelineEditComponentSeparatorProps) => { - const serverDetails = useServerDetails() - const [showDialog, openDialog, closeDialog] = useDialog() - const innerRef = useRef(null) - const [isHovering] = useHover(innerRef) - const [isFocused] = useFocus(innerRef) +export const PipelineEditComponentSeparator: React.FC = + ({ onInsert, isDragging, type }: PipelineEditComponentSeparatorProps) => { + const serverDetails = useServerDetails() + const [showDialog, openDialog, closeDialog] = useDialog() + const innerRef = useRef(null) + const [isHovering] = useHover(innerRef) + const [isFocused] = useFocus(innerRef) - if (isDragging) { - return null + if (isDragging) { + return null + } + return ( + <> + + + + + + + + + + + ) } - return ( - <> - - - - - - - - - - - ) -} diff --git a/src/main/app/src/components/PipelineEditErrorConfiguration/PipelineEditErrorConfiguration.stories.tsx b/src/main/app/src/components/PipelineEditErrorConfiguration/PipelineEditErrorConfiguration.stories.tsx index 58291a6..0caf9c6 100644 --- a/src/main/app/src/components/PipelineEditErrorConfiguration/PipelineEditErrorConfiguration.stories.tsx +++ b/src/main/app/src/components/PipelineEditErrorConfiguration/PipelineEditErrorConfiguration.stories.tsx @@ -31,7 +31,7 @@ export const Default: React.FC = () => { const errorConfiguration: ErrorConfiguration = { onSourceError: 'REMOVE_SOURCE', onProcessorError: 'REMOVE_PROCESSOR', - onItemError: 'DISCARD_ITEM' + onItemError: 'DISCARD_ITEM', } return ( @@ -40,4 +40,4 @@ export const Default: React.FC = () => { setErrorConfiguration={action('setErrorConfiguration')} /> ) -} \ No newline at end of file +} diff --git a/src/main/app/src/components/PipelineEditErrorConfiguration/PipelineEditErrorConfiguration.test.tsx b/src/main/app/src/components/PipelineEditErrorConfiguration/PipelineEditErrorConfiguration.test.tsx index 8a7da20..0f1578f 100644 --- a/src/main/app/src/components/PipelineEditErrorConfiguration/PipelineEditErrorConfiguration.test.tsx +++ b/src/main/app/src/components/PipelineEditErrorConfiguration/PipelineEditErrorConfiguration.test.tsx @@ -25,7 +25,7 @@ import { ErrorConfiguration } from '../../types' const errorConfiguration: ErrorConfiguration = { onSourceError: 'REMOVE_SOURCE', onProcessorError: 'REMOVE_PROCESSOR', - onItemError: 'DISCARD_ITEM' + onItemError: 'DISCARD_ITEM', } it('renders without error', () => { @@ -46,4 +46,4 @@ it('renders dark without error', () => { /> ) expect(asFragment()).toMatchSnapshot() -}) \ No newline at end of file +}) diff --git a/src/main/app/src/components/PipelineEditErrorConfiguration/PipelineEditErrorConfiguration.tsx b/src/main/app/src/components/PipelineEditErrorConfiguration/PipelineEditErrorConfiguration.tsx index c40da7e..2c437be 100644 --- a/src/main/app/src/components/PipelineEditErrorConfiguration/PipelineEditErrorConfiguration.tsx +++ b/src/main/app/src/components/PipelineEditErrorConfiguration/PipelineEditErrorConfiguration.tsx @@ -19,42 +19,58 @@ */ import React from 'react' import { CenteredRow } from '../CenteredRow' -import { Box, Card, CardContent, CardHeader, Typography } from '@committed/components' +import { + Box, + Card, + CardContent, + CardHeader, + Typography, +} from '@committed/components' import { Select } from '@material-ui/core' -import { ErrorConfiguration, OnSourceError, OnProcessingError } from '../../types' +import { + ErrorConfiguration, + OnSourceError, + OnProcessingError, +} from '../../types' export interface PipelineEditErrorConfigurationProps { errorConfiguration: ErrorConfiguration setErrorConfiguration: (errorConfiguration: ErrorConfiguration) => void } -export const PipelineEditErrorConfiguration: React.FC = ({ +export const PipelineEditErrorConfiguration: React.FC = + ({ errorConfiguration, - setErrorConfiguration + setErrorConfiguration, }: PipelineEditErrorConfigurationProps) => { + const handleSourceChange = ( + event: React.ChangeEvent<{ value: unknown }> + ): void => { + setErrorConfiguration({ + ...errorConfiguration, + onSourceError: event.target.value as OnSourceError, + }) + } - const handleSourceChange = (event: React.ChangeEvent<{value: unknown }>): void => { - setErrorConfiguration({ - ...errorConfiguration, - onSourceError: event.target.value as OnSourceError, - }); - } - - const handleProcessorChange = (event: React.ChangeEvent<{value: unknown }>): void => { - setErrorConfiguration({ - ...errorConfiguration, - onProcessorError: event.target.value as OnProcessingError, - }); - } + const handleProcessorChange = ( + event: React.ChangeEvent<{ value: unknown }> + ): void => { + setErrorConfiguration({ + ...errorConfiguration, + onProcessorError: event.target.value as OnProcessingError, + }) + } - const handleItemChange = (event: React.ChangeEvent<{value: unknown }>): void => { - setErrorConfiguration({ - ...errorConfiguration, - onItemError: event.target.value as OnProcessingError, - }); - } + const handleItemChange = ( + event: React.ChangeEvent<{ value: unknown }> + ): void => { + setErrorConfiguration({ + ...errorConfiguration, + onItemError: event.target.value as OnProcessingError, + }) + } - return ( + return ( <> @@ -62,9 +78,14 @@ export const PipelineEditErrorConfiguration: React.FCSource Error - If a source error occurs, then the pipeline will take the following action: + If a source error occurs, then the pipeline will take the + following action: - @@ -76,9 +97,14 @@ export const PipelineEditErrorConfiguration: React.FCProcessor Error - If a processor error occurs, then the pipeline will take the following action: + If a processor error occurs, then the pipeline will take the + following action: - @@ -91,9 +117,14 @@ export const PipelineEditErrorConfiguration: React.FCItem Error - If an item error occurs, then the pipeline will take the following action: + If an item error occurs, then the pipeline will take the + following action: - @@ -104,4 +135,4 @@ export const PipelineEditErrorConfiguration: React.FC ) -} + } diff --git a/src/main/app/src/components/PipelineMetadataCard/PipelineMetadataCard.stories.tsx b/src/main/app/src/components/PipelineMetadataCard/PipelineMetadataCard.stories.tsx index 4cc7938..89b212e 100644 --- a/src/main/app/src/components/PipelineMetadataCard/PipelineMetadataCard.stories.tsx +++ b/src/main/app/src/components/PipelineMetadataCard/PipelineMetadataCard.stories.tsx @@ -38,7 +38,11 @@ const onStop = async (): Promise => Promise.resolve(stopAction()) export const Default: React.FC = () => { return ( { export const Stopped: React.FC = () => { return ( { export const Deleting: React.FC = () => { return ( { pipelineMetadata={{ name: 'Name', description: 'Press delete to trigger error', - running: true + running: true, }} isDeleting={false} error={error} diff --git a/src/main/app/src/components/PipelineMetadataCard/PipelineMetadataCard.tsx b/src/main/app/src/components/PipelineMetadataCard/PipelineMetadataCard.tsx index 608fd01..e7eda8e 100644 --- a/src/main/app/src/components/PipelineMetadataCard/PipelineMetadataCard.tsx +++ b/src/main/app/src/components/PipelineMetadataCard/PipelineMetadataCard.tsx @@ -96,7 +96,9 @@ export const PipelineMetadataCard: React.FC = ({
@@ -119,12 +121,18 @@ export const PipelineMetadataCard: React.FC = ({ - {pipelineMetadata.running ? () : ()} + {pipelineMetadata.running ? ( + + ) : ( + + )} = ({ /> ) diff --git a/src/main/app/src/components/PipelineMetrics/PipelineMetrics.tsx b/src/main/app/src/components/PipelineMetrics/PipelineMetrics.tsx index 3530bae..719b073 100644 --- a/src/main/app/src/components/PipelineMetrics/PipelineMetrics.tsx +++ b/src/main/app/src/components/PipelineMetrics/PipelineMetrics.tsx @@ -49,7 +49,7 @@ export const PipelineMetrics: React.FC = ({ return ( {Object.keys(measurements) - .filter(key => key in metrics) + .filter((key) => key in metrics) .sort((a, b) => a.localeCompare(b)) .map((key) => ( = ({ metadata={metrics[`${key}`]} measurements={measurements[`${key}`]} /> - ))} + ))} ) } diff --git a/src/main/app/src/components/PipelineView/PipelineView.tsx b/src/main/app/src/components/PipelineView/PipelineView.tsx index a3c984d..6c02dc2 100644 --- a/src/main/app/src/components/PipelineView/PipelineView.tsx +++ b/src/main/app/src/components/PipelineView/PipelineView.tsx @@ -101,8 +101,7 @@ export const PipelineView = ({ setError(error) } - if(triggerRunningUpdate !== undefined) - triggerRunningUpdate(); + if (triggerRunningUpdate !== undefined) triggerRunningUpdate() } const onStop = async (): Promise => { try { @@ -112,12 +111,10 @@ export const PipelineView = ({ } // Display structure view - no logs for a stopped pipeline - if(showLogs) - toggleLogs(); + if (showLogs) toggleLogs() // Update running state - if(triggerRunningUpdate !== undefined) - triggerRunningUpdate(); + if (triggerRunningUpdate !== undefined) triggerRunningUpdate() } const handleCloseConfirmStartStop = (): void => setShowConfirmStartStop(false) const handleRequestStartStop = (): void => setShowConfirmStartStop(true) @@ -170,9 +167,7 @@ export const PipelineView = ({ key="startstop" icon={running ? : } onClick={handleRequestStartStop} - title={ - running ? 'Stop the pipeline' : 'Start the pipeline' - } + title={running ? 'Stop the pipeline' : 'Start the pipeline'} > {running ? 'Stop Pipeline' : 'Start Pipeline'} , @@ -192,7 +187,12 @@ export const PipelineView = ({ {!running && ( - )} @@ -215,7 +215,9 @@ export const PipelineView = ({ <> - + )} @@ -230,10 +232,14 @@ export const PipelineView = ({ /> ) diff --git a/src/main/app/src/components/PipelineViewErrorConfiguration/PipelineViewErrorConfiguration.stories.tsx b/src/main/app/src/components/PipelineViewErrorConfiguration/PipelineViewErrorConfiguration.stories.tsx index 3b41587..b8b631d 100644 --- a/src/main/app/src/components/PipelineViewErrorConfiguration/PipelineViewErrorConfiguration.stories.tsx +++ b/src/main/app/src/components/PipelineViewErrorConfiguration/PipelineViewErrorConfiguration.stories.tsx @@ -30,13 +30,11 @@ export const Default: React.FC = () => { const errorConfiguration: ErrorConfiguration = { onSourceError: 'REMOVE_SOURCE', onProcessorError: 'REMOVE_PROCESSOR', - onItemError: 'DISCARD_ITEM' + onItemError: 'DISCARD_ITEM', } return ( - + ) } @@ -44,13 +42,11 @@ export const Ignore: React.FC = () => { const errorConfiguration: ErrorConfiguration = { onSourceError: 'IGNORE', onProcessorError: 'IGNORE', - onItemError: 'IGNORE' + onItemError: 'IGNORE', } return ( - + ) } @@ -58,13 +54,11 @@ export const Remove: React.FC = () => { const errorConfiguration: ErrorConfiguration = { onSourceError: 'REMOVE_SOURCE', onProcessorError: 'REMOVE_PROCESSOR', - onItemError: 'REMOVE_PROCESSOR' + onItemError: 'REMOVE_PROCESSOR', } return ( - + ) } @@ -72,12 +66,10 @@ export const Discard: React.FC = () => { const errorConfiguration: ErrorConfiguration = { onSourceError: 'REMOVE_SOURCE', onProcessorError: 'DISCARD_ITEM', - onItemError: 'DISCARD_ITEM' + onItemError: 'DISCARD_ITEM', } return ( - + ) -} \ No newline at end of file +} diff --git a/src/main/app/src/components/PipelineViewErrorConfiguration/PipelineViewErrorConfiguration.test.tsx b/src/main/app/src/components/PipelineViewErrorConfiguration/PipelineViewErrorConfiguration.test.tsx index ca0efa9..2b4fbdf 100644 --- a/src/main/app/src/components/PipelineViewErrorConfiguration/PipelineViewErrorConfiguration.test.tsx +++ b/src/main/app/src/components/PipelineViewErrorConfiguration/PipelineViewErrorConfiguration.test.tsx @@ -24,23 +24,19 @@ import { render, renderDark } from '../../utils/test' const errorConfiguration = { onSourceError: 'REMOVE_SOURCE', onProcessorError: 'REMOVE_PROCESSOR', - onItemError: 'DISCARD_ITEM' + onItemError: 'DISCARD_ITEM', } it('renders without error', () => { const { asFragment } = render( - + ) expect(asFragment()).toMatchSnapshot() }) it('renders dark without error', () => { const { asFragment } = renderDark( - + ) expect(asFragment()).toMatchSnapshot() -}) \ No newline at end of file +}) diff --git a/src/main/app/src/components/PipelineViewErrorConfiguration/PipelineViewErrorConfiguration.tsx b/src/main/app/src/components/PipelineViewErrorConfiguration/PipelineViewErrorConfiguration.tsx index bc2863f..00c2b2e 100644 --- a/src/main/app/src/components/PipelineViewErrorConfiguration/PipelineViewErrorConfiguration.tsx +++ b/src/main/app/src/components/PipelineViewErrorConfiguration/PipelineViewErrorConfiguration.tsx @@ -27,75 +27,83 @@ export interface PipelineViewErrorConfigurationProps { readonly errorConfiguration: ErrorConfiguration } -export const PipelineViewErrorConfiguration: React.FC = ({ - errorConfiguration, - }: PipelineViewErrorConfigurationProps) => { +export const PipelineViewErrorConfiguration: React.FC = + ({ errorConfiguration }: PipelineViewErrorConfigurationProps) => { + let sourceError, + processorError, + itemError = null + switch (errorConfiguration.onSourceError) { + case 'IGNORE': + sourceError = ( + + If a source error occurs, then the error will be{' '} + ignored by this pipeline. + + ) + break + case 'REMOVE_SOURCE': + sourceError = ( + + If a source error occurs, then the source will be{' '} + removed from this pipeline. + + ) + break + } + switch (errorConfiguration.onProcessorError) { + case 'IGNORE': + processorError = ( + + If a processor error occurs, then the error will be{' '} + ignored by this pipeline. + + ) + break + case 'REMOVE_PROCESSOR': + processorError = ( + + If a processor error occurs, then the processor will be{' '} + removed from this pipeline. + + ) + break + case 'DISCARD_ITEM': + processorError = ( + + If a processor error occurs, then the item will be{' '} + discarded by this pipeline. + + ) + break + } + switch (errorConfiguration.onItemError) { + case 'IGNORE': + itemError = ( + + If an item error occurs, then the error will be{' '} + ignored by this pipeline. + + ) + break + case 'REMOVE_PROCESSOR': + itemError = ( + + If an item error occurs, then the processor will be{' '} + removed from this pipeline. + + ) + break + case 'DISCARD_ITEM': + itemError = ( + + If an item error occurs, then the item will be{' '} + discarded by this pipeline. + + ) + break + } - let sourceError, processorError, itemError = null; - switch ( errorConfiguration.onSourceError ) { - case 'IGNORE': - sourceError = ( - - If a source error occurs, then the error will be ignored by this pipeline. - - ) - break; - case 'REMOVE_SOURCE': - sourceError = ( - - If a source error occurs, then the source will be removed from this pipeline. - - ) - break; - } - switch ( errorConfiguration.onProcessorError ) { - case 'IGNORE': - processorError = ( - - If a processor error occurs, then the error will be ignored by this pipeline. - - ) - break; - case 'REMOVE_PROCESSOR': - processorError = ( - - If a processor error occurs, then the processor will be removed from this pipeline. - - ) - break; - case 'DISCARD_ITEM': - processorError = ( - - If a processor error occurs, then the item will be discarded by this pipeline. - - ) - break; - } - switch ( errorConfiguration.onItemError ) { - case 'IGNORE': - itemError = ( - - If an item error occurs, then the error will be ignored by this pipeline. - - ) - break; - case 'REMOVE_PROCESSOR': - itemError = ( - - If an item error occurs, then the processor will be removed from this pipeline. - - ) - break; - case 'DISCARD_ITEM': - itemError = ( - - If an item error occurs, then the item will be discarded by this pipeline. - - ) - break; - } - - return ( + return ( <> Error Configuration @@ -122,4 +130,4 @@ export const PipelineViewErrorConfiguration: React.FC ) -} + } diff --git a/src/main/app/src/components/Pipelines/Pipelines.tsx b/src/main/app/src/components/Pipelines/Pipelines.tsx index e6b61d7..7306636 100644 --- a/src/main/app/src/components/Pipelines/Pipelines.tsx +++ b/src/main/app/src/components/Pipelines/Pipelines.tsx @@ -48,7 +48,7 @@ export const Pipelines: React.FC = ({ pipelines, deletePipeline, startPipeline, - stopPipeline + stopPipeline, }: PipelinesProps) => ( {pipelines.map((pipeline) => ( diff --git a/src/main/app/src/components/SelectComponentDialog/SelectComponentDialog.tsx b/src/main/app/src/components/SelectComponentDialog/SelectComponentDialog.tsx index 6403c04..2bcbaab 100644 --- a/src/main/app/src/components/SelectComponentDialog/SelectComponentDialog.tsx +++ b/src/main/app/src/components/SelectComponentDialog/SelectComponentDialog.tsx @@ -74,10 +74,10 @@ export const SelectComponentDialog: React.FC = ({ const [selected, setSelected] = useState([]) const [search, setSearch] = useState('') - const filtered = useMemo(() => filterComponents(components, search), [ - components, - search, - ]) + const filtered = useMemo( + () => filterComponents(components, search), + [components, search] + ) useEffect(() => { if (open) { diff --git a/src/main/app/src/components/ThemeProvider/ThemeProvider.stories.tsx b/src/main/app/src/components/ThemeProvider/ThemeProvider.stories.tsx index cc2db84..75072d8 100644 --- a/src/main/app/src/components/ThemeProvider/ThemeProvider.stories.tsx +++ b/src/main/app/src/components/ThemeProvider/ThemeProvider.stories.tsx @@ -62,9 +62,10 @@ const Overview: React.FC = () => { multiline: 'Controlled', currency: 'EUR', }) - const handleChange = (name: string) => ( - event: React.ChangeEvent - ): void => setForm({ ...form, [name]: event.target.value }) + const handleChange = + (name: string) => + (event: React.ChangeEvent): void => + setForm({ ...form, [name]: event.target.value }) const [checked, setChecked] = useState(true) diff --git a/src/main/app/src/components/ThemeProvider/ThemeProvider.tsx b/src/main/app/src/components/ThemeProvider/ThemeProvider.tsx index ae761a8..84ce054 100644 --- a/src/main/app/src/components/ThemeProvider/ThemeProvider.tsx +++ b/src/main/app/src/components/ThemeProvider/ThemeProvider.tsx @@ -67,27 +67,29 @@ const darkText: TextPalette = { hint: secondaryDarkTextColour, } -export const createLightPalette: () => () => PaletteOptions = () => (): PaletteOptions => ({ - ...createCommittedLightPaletteOptions(), - primary: { main: primaryColour }, - brand: { main: brandLightColour }, - secondary: { main: secondaryColour }, - info: { main: infoColour }, - warning: { main: warnColour }, - error: { main: errorColour }, - text: lightText, -}) +export const createLightPalette: () => () => PaletteOptions = + () => (): PaletteOptions => ({ + ...createCommittedLightPaletteOptions(), + primary: { main: primaryColour }, + brand: { main: brandLightColour }, + secondary: { main: secondaryColour }, + info: { main: infoColour }, + warning: { main: warnColour }, + error: { main: errorColour }, + text: lightText, + }) -export const createDarkPalette: () => () => PaletteOptions = () => (): PaletteOptions => ({ - ...createCommittedDarkPaletteOptions(), - primary: { main: primaryColour }, - brand: { main: brandDarkColour }, - secondary: { main: secondaryColour }, - info: { main: infoColour }, - warning: { main: warnColour }, - error: { main: errorColour }, - text: darkText, -}) +export const createDarkPalette: () => () => PaletteOptions = + () => (): PaletteOptions => ({ + ...createCommittedDarkPaletteOptions(), + primary: { main: primaryColour }, + brand: { main: brandDarkColour }, + secondary: { main: secondaryColour }, + info: { main: infoColour }, + warning: { main: warnColour }, + error: { main: errorColour }, + text: darkText, + }) const fontFamily = 'Inter, Helvetica, Arial, sans-serif' const headingFontWeight = 700 diff --git a/src/main/app/src/containers/ComponentsContainer.tsx b/src/main/app/src/containers/ComponentsContainer.tsx index 927d737..acd8635 100644 --- a/src/main/app/src/containers/ComponentsContainer.tsx +++ b/src/main/app/src/containers/ComponentsContainer.tsx @@ -23,12 +23,8 @@ import { useServerDetails } from '../hooks' import { ServerDetails } from '../types' export const ComponentsContainer: React.FC = () => { - const { - orderers, - sources, - processors, - settings, - }: ServerDetails = useServerDetails() + const { orderers, sources, processors, settings }: ServerDetails = + useServerDetails() return ( = ({ processorOrder, components, orderer, - errorConfiguration + errorConfiguration, } = pipeline const sources = sourceOrder.map((s) => components[`${s}`].descriptor) @@ -277,7 +277,7 @@ export const PipelineEditContainer: React.FC = ({ description, sources, processors, - errorConfiguration + errorConfiguration, } try { await onSave(createPipeline, orderer) @@ -297,7 +297,7 @@ export const PipelineEditContainer: React.FC = ({ sourceOrder, processorOrder, components, - errorConfiguration + errorConfiguration, } = pipeline const sources = sourceOrder.map((s) => components[`${s}`].descriptor) const processors = processorOrder.map((p) => components[`${p}`].descriptor) @@ -307,22 +307,20 @@ export const PipelineEditContainer: React.FC = ({ description, sources, processors, - errorConfiguration + errorConfiguration, } try { - const { - sources: orderedSources, - processors: orderedProcessors, - } = await orderPipeline(toOrderPipeline, orderer) + const { sources: orderedSources, processors: orderedProcessors } = + await orderPipeline(toOrderPipeline, orderer) modify((draft: PipelineEditDescriptor): void => { const newOrderedPipeline: PipelineDescriptor = { name, description, -// orderer, //TODO: Remove this? + // orderer, //TODO: Remove this? sources: orderedSources, processors: orderedProcessors, - errorConfiguration + errorConfiguration, } const created = createPipelineEditDescriptor( diff --git a/src/main/app/src/containers/PipelineEditFetchContainer.tsx b/src/main/app/src/containers/PipelineEditFetchContainer.tsx index ab0feb7..a8c9d50 100644 --- a/src/main/app/src/containers/PipelineEditFetchContainer.tsx +++ b/src/main/app/src/containers/PipelineEditFetchContainer.tsx @@ -44,83 +44,85 @@ interface PipelineEditFetchContainerProps { navigate: NavigateFn } -export const PipelineEditFetchContainer: React.FC = ({ - name, - navigate, -}: PipelineEditFetchContainerProps) => { - const { data: pipelines } = useSWR( - getPipelinesFetchKey, - getPipelines, - { - refreshInterval: 5000, - } - ) - - const usedNames = - pipelines?.map((p) => p.name).filter((p) => p !== name) ?? [] +export const PipelineEditFetchContainer: React.FC = + ({ name, navigate }: PipelineEditFetchContainerProps) => { + const { data: pipelines } = useSWR( + getPipelinesFetchKey, + getPipelines, + { + refreshInterval: 5000, + } + ) - const { data: pipeline, error, mutate } = useSWR( - [getPipelinesFetchKey, name], - getPipeline, - { - revalidateOnFocus: false, - revalidateOnMount: true, - } - ) + const usedNames = + pipelines?.map((p) => p.name).filter((p) => p !== name) ?? [] - if (error !== undefined) { - return ( - <> -
- => { - await mutate() - }} - /> - + const { + data: pipeline, + error, + mutate, + } = useSWR( + [getPipelinesFetchKey, name], + getPipeline, + { + revalidateOnFocus: false, + revalidateOnMount: true, + } ) - } - if (pipeline === undefined || pipelines === undefined) { - return ( - <> -
- - - ) - } + if (error !== undefined) { + return ( + <> +
+ => { + await mutate() + }} + /> + + ) + } - const handleSave = async ( - pipeline: PipelineDescriptor, - // Not used, se below - _orderer: string - ): Promise => { - // delete existing pipeline - try { - await deletePipeline(name) - } catch (e) { - // Ignore if already deleted - if (e instanceof Error && !e.message.includes('404')) { - throw e + if (pipeline === undefined || pipelines === undefined) { + return ( + <> +
+ + + ) + } + + const handleSave = async ( + pipeline: PipelineDescriptor, + // Not used, se below + _orderer: string + ): Promise => { + // delete existing pipeline + try { + await deletePipeline(name) + } catch (e) { + // Ignore if already deleted + if (e instanceof Error && !e.message.includes('404')) { + throw e + } } + // We do not apply the orderer, leaving the ordering to the use in the UI + // In future we may want to ask the use if they have a non-no-op order selected and haven't applied it + // if they want to send it + await createPipeline(pipeline) + // navigate to new pipeline + await navigate(`/view/${pipeline.name}`, { + state: { initialValue: pipeline }, + }) } - // We do not apply the orderer, leaving the ordering to the use in the UI - // In future we may want to ask the use if they have a non-no-op order selected and haven't applied it - // if they want to send it - await createPipeline(pipeline) - // navigate to new pipeline - await navigate(`/view/${pipeline.name}`, { - state: { initialValue: pipeline }, - }) - } - return ( - - ) -} + return ( + + ) + } diff --git a/src/main/app/src/containers/PipelineMetadataContainer.tsx b/src/main/app/src/containers/PipelineMetadataContainer.tsx index 3c4f19d..f71b91e 100644 --- a/src/main/app/src/containers/PipelineMetadataContainer.tsx +++ b/src/main/app/src/containers/PipelineMetadataContainer.tsx @@ -40,49 +40,45 @@ export interface PipelineMetadataContainerProps { readonly stopPipeline: (pipeline: PipelineMetadata) => Promise } -export const PipelineMetadataContainer: React.FC = ({ - pipelineMetadata, - deletePipeline, - startPipeline, - stopPipeline -}) => { - const [error, setError] = useState() - const [isDeleting, setDeleting] = useState(false) +export const PipelineMetadataContainer: React.FC = + ({ pipelineMetadata, deletePipeline, startPipeline, stopPipeline }) => { + const [error, setError] = useState() + const [isDeleting, setDeleting] = useState(false) - const onDelete = async (): Promise => { - setDeleting(true) - try { - await deletePipeline(pipelineMetadata) - } catch (error) { - setDeleting(false) - setError(error) + const onDelete = async (): Promise => { + setDeleting(true) + try { + await deletePipeline(pipelineMetadata) + } catch (error) { + setDeleting(false) + setError(error) + } } - } - const onStart = async (): Promise => { - try { - await startPipeline(pipelineMetadata) - } catch (error) { - setError(error) + const onStart = async (): Promise => { + try { + await startPipeline(pipelineMetadata) + } catch (error) { + setError(error) + } } - } - const onStop = async (): Promise => { - try { - await stopPipeline(pipelineMetadata) - } catch (error) { - setError(error) + const onStop = async (): Promise => { + try { + await stopPipeline(pipelineMetadata) + } catch (error) { + setError(error) + } } - } - return ( - - ) -} + return ( + + ) + } diff --git a/src/main/app/src/containers/PipelineMetricsContainer.tsx b/src/main/app/src/containers/PipelineMetricsContainer.tsx index 91525c9..78cc316 100644 --- a/src/main/app/src/containers/PipelineMetricsContainer.tsx +++ b/src/main/app/src/containers/PipelineMetricsContainer.tsx @@ -32,42 +32,45 @@ interface PipelineMetricsContainerProps { name: string } -export const PipelineMetricsContainer: React.FC = ({ - name, -}: PipelineMetricsContainerProps) => { - const { data: metrics, error, mutate } = useSWR( - ['api/v3/pipelines/{name}/metrics', name], - getPipelineMetrics, - { refreshInterval: 5000 } - ) - - if (error !== undefined) { - return ( - - => { - await mutate() - }} - > - Retry - - } - > - Error loading metrics - - +export const PipelineMetricsContainer: React.FC = + ({ name }: PipelineMetricsContainerProps) => { + const { + data: metrics, + error, + mutate, + } = useSWR( + ['api/v3/pipelines/{name}/metrics', name], + getPipelineMetrics, + { refreshInterval: 5000 } ) - } - if (metrics === undefined) { - return Loading metrics... - } else { - return + if (error !== undefined) { + return ( + + => { + await mutate() + }} + > + Retry + + } + > + Error loading metrics + + + ) + } + + if (metrics === undefined) { + return Loading metrics... + } else { + return + } } -} diff --git a/src/main/app/src/containers/PipelineTemplateContainer.tsx b/src/main/app/src/containers/PipelineTemplateContainer.tsx index 5d8ca34..4ffd408 100644 --- a/src/main/app/src/containers/PipelineTemplateContainer.tsx +++ b/src/main/app/src/containers/PipelineTemplateContainer.tsx @@ -45,71 +45,69 @@ interface PipelineTemplateContainerProps { navigate: NavigateFn } -export const PipelineTemplateContainer: React.FC = ({ - template: provided, - navigate, -}: PipelineTemplateContainerProps) => { - const { data: pipelines } = useSWR( - getPipelinesFetchKey, - getPipelines, - { refreshInterval: 5000 } - ) +export const PipelineTemplateContainer: React.FC = + ({ template: provided, navigate }: PipelineTemplateContainerProps) => { + const { data: pipelines } = useSWR( + getPipelinesFetchKey, + getPipelines, + { refreshInterval: 5000 } + ) - const usedNames = pipelines?.map((p) => p.name) ?? [] + const usedNames = pipelines?.map((p) => p.name) ?? [] - const templates = useTemplates() - const [template, setTemplate] = useState() + const templates = useTemplates() + const [template, setTemplate] = useState() - useEffect(() => { - setTemplate(provided) - }, [provided]) + useEffect(() => { + setTemplate(provided) + }, [provided]) - const onSave = async ( - pipeline: PipelineDescriptor, - // Not currently used, see below - _orderer: string - ): Promise => { - // We do not apply the orderer, leaving the ordering to the use in the UI - // In future we may want to ask the use if they have a non-no-op order selected and haven't applied it - // if they want to send it - await createPipeline(pipeline) - await navigate(`/view/${pipeline.name}`, { - state: { initialValue: pipeline }, - }) - } + const onSave = async ( + pipeline: PipelineDescriptor, + // Not currently used, see below + _orderer: string + ): Promise => { + // We do not apply the orderer, leaving the ordering to the use in the UI + // In future we may want to ask the use if they have a non-no-op order selected and haven't applied it + // if they want to send it + await createPipeline(pipeline) + await navigate(`/view/${pipeline.name}`, { + state: { initialValue: pipeline }, + }) + } - if (pipelines === undefined) { - return ( - <> -
- - - ) - } + if (pipelines === undefined) { + return ( + <> +
+ + + ) + } - if (template === undefined) { - return ( - <> -
- - +
+ + + + + ) + } else { + return ( +
+ - - - ) - } else { - return ( -
- -
- ) +
+ ) + } } -} diff --git a/src/main/app/src/containers/PipelineViewContainer.tsx b/src/main/app/src/containers/PipelineViewContainer.tsx index d313e29..a459cb4 100644 --- a/src/main/app/src/containers/PipelineViewContainer.tsx +++ b/src/main/app/src/containers/PipelineViewContainer.tsx @@ -52,14 +52,18 @@ export const PipelineViewContainer: React.FC = ({ initialValue, }: PipelineViewContainerProps) => { const serverDetails = useServerDetails() - const { data: pipeline, error, mutate } = useSWR( + const { + data: pipeline, + error, + mutate, + } = useSWR( [getPipelinesFetchKey, name], getPipeline, { initialData: initialValue } ) const { data: running, mutate: runningMutate } = useSWR( - [getPipelinesFetchKey, name, "running"], + [getPipelinesFetchKey, name, 'running'], getPipelineRunning, { refreshInterval: 10000 } ) diff --git a/src/main/app/src/containers/PipelineViewLogsContainer.tsx b/src/main/app/src/containers/PipelineViewLogsContainer.tsx index 41a9fcf..de0ffcf 100644 --- a/src/main/app/src/containers/PipelineViewLogsContainer.tsx +++ b/src/main/app/src/containers/PipelineViewLogsContainer.tsx @@ -33,29 +33,32 @@ interface PipelineViewLogsContainerProps { /** * */ -export const PipelineViewLogsContainer: React.FC = ({ - name, -}: PipelineViewLogsContainerProps) => { - const [max, setMax] = useState(10) - const [level, setLevel] = useState('INFO') +export const PipelineViewLogsContainer: React.FC = + ({ name }: PipelineViewLogsContainerProps) => { + const [max, setMax] = useState(10) + const [level, setLevel] = useState('INFO') - const { data: logs, error, mutate } = useSWR( - ['api/v3/pipelines/{name}/logs', name, max, level], - getLogs - ) + const { + data: logs, + error, + mutate, + } = useSWR( + ['api/v3/pipelines/{name}/logs', name, max, level], + getLogs + ) - return ( - => { - await mutate([]) - }} - loading={logs === undefined} - error={error} - /> - ) -} + return ( + => { + await mutate([]) + }} + loading={logs === undefined} + error={error} + /> + ) + } diff --git a/src/main/app/src/containers/PipelinesContainer.tsx b/src/main/app/src/containers/PipelinesContainer.tsx index 4409d91..9197055 100644 --- a/src/main/app/src/containers/PipelinesContainer.tsx +++ b/src/main/app/src/containers/PipelinesContainer.tsx @@ -28,11 +28,13 @@ import { Pipelines } from '../components/Pipelines' import { PipelineMetadata } from '../types' export const PipelinesContainer: React.FC = () => { - const { data: pipelines, error, mutate } = useSWR( - getPipelinesFetchKey, - getPipelines, - { refreshInterval: 5000 } - ) + const { + data: pipelines, + error, + mutate, + } = useSWR(getPipelinesFetchKey, getPipelines, { + refreshInterval: 5000, + }) if (error !== undefined) { return @@ -74,5 +76,12 @@ export const PipelinesContainer: React.FC = () => { }) } - return + return ( + + ) } diff --git a/src/main/app/src/containers/SubmitContainer.tsx b/src/main/app/src/containers/SubmitContainer.tsx index c8150fc..5eca64d 100644 --- a/src/main/app/src/containers/SubmitContainer.tsx +++ b/src/main/app/src/containers/SubmitContainer.tsx @@ -60,12 +60,12 @@ const readFile = async (file: File): Promise => { }) } -const submitFile = (name: string): ((file: File) => Promise) => async ( - file: File -): Promise => - readFile(file).then(async (binaryStr) => - Api.submitStreamData(name, binaryStr) - ) +const submitFile = + (name: string): ((file: File) => Promise) => + async (file: File): Promise => + readFile(file).then(async (binaryStr) => + Api.submitStreamData(name, binaryStr) + ) export const SubmitContainer: React.FC = ({ name, diff --git a/src/main/app/src/context/ServerContext.tsx b/src/main/app/src/context/ServerContext.tsx index c298638..0325124 100644 --- a/src/main/app/src/context/ServerContext.tsx +++ b/src/main/app/src/context/ServerContext.tsx @@ -54,15 +54,13 @@ function byName(a: { name: string }, b: { name: string }): number { function toComponentMap(components: Annot8ComponentInfo[]): ComponentMap { return components - .map( - (s: Annot8ComponentInfo): ComponentInfo => { - if (s.name === undefined) { - return { ...s, name: javaToReadable(s.componentClass) } - } else { - return s as ComponentInfo - } + .map((s: Annot8ComponentInfo): ComponentInfo => { + if (s.name === undefined) { + return { ...s, name: javaToReadable(s.componentClass) } + } else { + return s as ComponentInfo } - ) + }) .sort(byName) .reduce((acc, s) => { acc[s.componentClass] = s @@ -96,9 +94,8 @@ export const ServerProvider: React.FC = ({ children }) => { const [sources, setSources] = useLocalState('sources') const [settings, setSettings] = useLocalState('settings') const [orderers, setOrderers] = useLocalState('orderers') - const [templates, setTemplates] = useLocalState( - 'templates' - ) + const [templates, setTemplates] = + useLocalState('templates') const [error, setError] = useState() useEffect(() => { diff --git a/src/main/app/src/hooks/useStateTracking.ts b/src/main/app/src/hooks/useStateTracking.ts index cbad988..33335df 100644 --- a/src/main/app/src/hooks/useStateTracking.ts +++ b/src/main/app/src/hooks/useStateTracking.ts @@ -30,9 +30,7 @@ export interface Initializer { (): T } -export function useStateTracking( - initialState: T -): { +export function useStateTracking(initialState: T): { current: T modify: (mutator: Mutator) => void initialize: (initializer: Initializer) => void diff --git a/src/main/app/src/metrics.ts b/src/main/app/src/metrics.ts index 1c678ca..132476c 100644 --- a/src/main/app/src/metrics.ts +++ b/src/main/app/src/metrics.ts @@ -35,7 +35,7 @@ export const metrics: { [key: string]: MetricMetadata } = { itemProcessingTime: { name: 'Processing Time', description: 'The average time taken to process an item', - units: 'seconds per item' + units: 'seconds per item', }, itemsCreated: { name: 'Created', @@ -49,12 +49,14 @@ export const metrics: { [key: string]: MetricMetadata } = { }, 'itemsProcessed.processorError': { name: 'Processed (Processor Error)', - description: 'The number of items that failed to process successfully due to a Processor Error', + description: + 'The number of items that failed to process successfully due to a Processor Error', units: 'items', }, 'itemsProcessed.itemError': { name: 'Processed (Item Error)', - description: 'The number of items that failed to process successfully due to an Item Error', + description: + 'The number of items that failed to process successfully due to an Item Error', units: 'items', }, } diff --git a/src/main/app/src/types/examples.ts b/src/main/app/src/types/examples.ts index cd0ad40..87ddca4 100644 --- a/src/main/app/src/types/examples.ts +++ b/src/main/app/src/types/examples.ts @@ -166,8 +166,8 @@ export const exampleEmptyPipeline: PipelineDescriptor = { errorConfiguration: { onItemError: 'DISCARD_ITEM', onProcessorError: 'REMOVE_PROCESSOR', - onSourceError: 'REMOVE_SOURCE' - } + onSourceError: 'REMOVE_SOURCE', + }, } export const exampleEmptyPipelineView: PipelineViewDescriptor = { @@ -179,8 +179,8 @@ export const exampleEmptyPipelineView: PipelineViewDescriptor = { errorConfiguration: { onItemError: 'DISCARD_ITEM', onProcessorError: 'REMOVE_PROCESSOR', - onSourceError: 'REMOVE_SOURCE' - } + onSourceError: 'REMOVE_SOURCE', + }, } export const exampleEmptyPipelineEdit: PipelineEditDescriptor = { @@ -219,8 +219,8 @@ export const examplePipeline: PipelineDescriptor = { errorConfiguration: { onItemError: 'DISCARD_ITEM', onProcessorError: 'REMOVE_PROCESSOR', - onSourceError: 'REMOVE_SOURCE' - } + onSourceError: 'REMOVE_SOURCE', + }, } export const examplePipelineView: PipelineViewDescriptor = { @@ -292,8 +292,8 @@ export const examplePipelineView: PipelineViewDescriptor = { errorConfiguration: { onItemError: 'DISCARD_ITEM', onProcessorError: 'REMOVE_PROCESSOR', - onSourceError: 'REMOVE_SOURCE' - } + onSourceError: 'REMOVE_SOURCE', + }, } export const examplePipelineEdit: PipelineEditDescriptor = { @@ -342,8 +342,8 @@ export const multipleSourcePipeline: PipelineDescriptor = { errorConfiguration: { onItemError: 'DISCARD_ITEM', onProcessorError: 'REMOVE_PROCESSOR', - onSourceError: 'REMOVE_SOURCE' - } + onSourceError: 'REMOVE_SOURCE', + }, } export const multipleSourcePipelineView: PipelineViewDescriptor = { @@ -456,8 +456,8 @@ export const multipleSourcePipelineView: PipelineViewDescriptor = { errorConfiguration: { onItemError: 'DISCARD_ITEM', onProcessorError: 'REMOVE_PROCESSOR', - onSourceError: 'REMOVE_SOURCE' - } + onSourceError: 'REMOVE_SOURCE', + }, } export const multipleSourcePipelineEdit: PipelineEditDescriptor = { @@ -471,33 +471,32 @@ export const examplePipelinesMetadata: PipelineMetadata[] = [ { description: 'Non voluptatibus corporis accusantium. Velit saepe odio. Dolorum veritatis et natus est qui molestias. Culpa est veritatis quia explicabo. Quas sint in. Aliquid eos et eos ut eius ut animi reiciendis.', - name: - 'scalable optimal British Indian Ocean Territory (Chagos Archipelago) Versatile invoice', - running: true + name: 'scalable optimal British Indian Ocean Territory (Chagos Archipelago) Versatile invoice', + running: true, }, { description: 'Totam fugiat velit. Maxime ab nisi et earum. Eos omnis consequuntur dolorem doloribus maiores at eius quia optio. Qui nostrum perspiciatis sunt aliquid odio.', name: 'interactive value-added deliver Denar Maryland', - running: true + running: true, }, { description: 'Hic vel hic. Voluptatum vel et inventore ut praesentium minus. Et ullam voluptates. Doloribus necessitatibus consequatur. Eum soluta alias dignissimos ad ab sed fugit. Natus beatae debitis amet et perferendis omnis.', name: 'Delaware Checking Account Ergonomic Metal Table olive extensible', - running: true + running: true, }, { description: 'Dolore non labore dolorem voluptatem officiis eveniet consequatur. Porro fuga est nihil. Est alias ut voluptas est. Facere voluptas quis velit est aliquid animi modi dolore. Non molestiae esse rerum recusandae. Reiciendis rem est est voluptatibus quia alias molestias aut.', name: 'bi-directional Plastic quantify generating', - running: true + running: true, }, { description: 'Nulla non quam ducimus omnis et voluptates. Dolor hic alias. Esse et omnis magnam rem vel ipsum. Est quo in sequi rerum quia ut.', name: 'Pants forecast Crest', - running: true + running: true, }, ] @@ -972,8 +971,8 @@ export const exampleTemplates: PipelineTemplate[] = [ errorConfiguration: { onItemError: 'DISCARD_ITEM', onProcessorError: 'REMOVE_PROCESSOR', - onSourceError: 'REMOVE_SOURCE' - } + onSourceError: 'REMOVE_SOURCE', + }, }, { name: 'NLP Base', @@ -1006,8 +1005,8 @@ export const exampleTemplates: PipelineTemplate[] = [ errorConfiguration: { onItemError: 'DISCARD_ITEM', onProcessorError: 'REMOVE_PROCESSOR', - onSourceError: 'REMOVE_SOURCE' - } + onSourceError: 'REMOVE_SOURCE', + }, }, { name: 'People', @@ -1020,8 +1019,8 @@ export const exampleTemplates: PipelineTemplate[] = [ errorConfiguration: { onItemError: 'DISCARD_ITEM', onProcessorError: 'REMOVE_PROCESSOR', - onSourceError: 'REMOVE_SOURCE' - } + onSourceError: 'REMOVE_SOURCE', + }, }, { name: 'Full', @@ -1033,7 +1032,7 @@ export const exampleTemplates: PipelineTemplate[] = [ errorConfiguration: { onItemError: 'DISCARD_ITEM', onProcessorError: 'REMOVE_PROCESSOR', - onSourceError: 'REMOVE_SOURCE' - } + onSourceError: 'REMOVE_SOURCE', + }, }, ] diff --git a/src/main/app/src/utils/download.test.ts b/src/main/app/src/utils/download.test.ts index 7bcc979..f3d259b 100644 --- a/src/main/app/src/utils/download.test.ts +++ b/src/main/app/src/utils/download.test.ts @@ -23,13 +23,13 @@ import { downloadJson } from './download' describe('downloadJson', () => { it('will download and write json', () => { - const anchorMocked: HTMLAnchorElement = ({ + const anchorMocked: HTMLAnchorElement = { href: '', download: '', click: jest.fn(), remove: jest.fn(), setAttribute: jest.fn(), - } as unknown) as HTMLAnchorElement + } as unknown as HTMLAnchorElement anchorMocked.setAttribute = ( key: 'href' | 'download', value: string diff --git a/src/main/app/src/utils/pipeline.ts b/src/main/app/src/utils/pipeline.ts index 2cfb2bb..0c17e65 100644 --- a/src/main/app/src/utils/pipeline.ts +++ b/src/main/app/src/utils/pipeline.ts @@ -114,34 +114,32 @@ export const isPipelineValid = ( return errors } -export const createComponent = ( - settings: SettingsMap, - types: ComponentMap, - configured = true -) => (descriptor: Annot8ComponentDescriptor): ComponentMetadata => { - const id = uuid() - const type = Object.keys(descriptor)[0] - const info: ComponentInfo | undefined = types[`${type}`] - const schema: SettingsSchema | undefined = - info !== undefined && info.settingsClass !== undefined - ? settings[info.settingsClass] - : undefined - - if (schema !== undefined && descriptor[`${type}`].settings === undefined) { - descriptor[`${type}`].settings = defaultSettings(schema) - } +export const createComponent = + (settings: SettingsMap, types: ComponentMap, configured = true) => + (descriptor: Annot8ComponentDescriptor): ComponentMetadata => { + const id = uuid() + const type = Object.keys(descriptor)[0] + const info: ComponentInfo | undefined = types[`${type}`] + const schema: SettingsSchema | undefined = + info !== undefined && info.settingsClass !== undefined + ? settings[info.settingsClass] + : undefined + + if (schema !== undefined && descriptor[`${type}`].settings === undefined) { + descriptor[`${type}`].settings = defaultSettings(schema) + } - return { - id, - descriptor, - info, - schema, - valid: - info !== undefined && - isSettingsValid(schema, descriptor[`${type}`].settings), - configured, + return { + id, + descriptor, + info, + schema, + valid: + info !== undefined && + isSettingsValid(schema, descriptor[`${type}`].settings), + configured, + } } -} export const createPipelineViewDescriptor = ( pipeline: PipelineDescriptor, @@ -171,7 +169,7 @@ export const createPipelineViewDescriptor = ( sourceOrder, processorOrder, components, - errorConfiguration: pipeline.errorConfiguration + errorConfiguration: pipeline.errorConfiguration, } } diff --git a/src/main/app/src/utils/validator.ts b/src/main/app/src/utils/validator.ts index 1daeb60..ffed9f5 100644 --- a/src/main/app/src/utils/validator.ts +++ b/src/main/app/src/utils/validator.ts @@ -50,19 +50,19 @@ const validate = ajv.compile({ onItemError: { enum: ['DISCARD_ITEM', 'REMOVE_PROCESSOR', 'IGNORE'], title: 'Item Error', - description: 'What to do on an Item error' + description: 'What to do on an Item error', }, onProcessorError: { enum: ['DISCARD_ITEM', 'REMOVE_PROCESSOR', 'IGNORE'], title: 'Processor Error', - description: 'What to do on a Processor error' + description: 'What to do on a Processor error', }, onSourceError: { enum: ['REMOVE_SOURCE', 'IGNORE'], title: 'Source Error', - description: 'What to do on a Source error' - } - } + description: 'What to do on a Source error', + }, + }, }, sources: { type: 'array',