Skip to content

Commit

Permalink
Code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaker-dstl committed Jun 1, 2021
1 parent c40f6e6 commit d1f9cc8
Show file tree
Hide file tree
Showing 42 changed files with 676 additions and 607 deletions.
15 changes: 7 additions & 8 deletions src/main/app/src/Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const client: ExtendedHttpClient = {
return response.json() as Promise<R>
} else {
// When not 200 R should be void, so this is valid
return (undefined as unknown) as R
return undefined as unknown as R
}
})
},
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -217,17 +216,17 @@ export const createPipeline = async (
orderer: string = NO_OP_ORDERER,
persist = true
): Promise<void> => {
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,
})
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/app/src/Routes.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Response> => {
const fetchSpy = jest
.spyOn(global, 'fetch')
.mockImplementation(async (...args): Promise<Response> => {
console.error(...args)
return Promise.resolve({} as Response)
}
)
})

try {
const {
Expand Down
4 changes: 2 additions & 2 deletions src/main/app/src/components/ChooseTemplate/ChooseTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion src/main/app/src/components/Components/Components.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
16 changes: 8 additions & 8 deletions src/main/app/src/components/Components/Components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ export const Components: React.FC<ComponentsProps> = ({

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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ export interface ComponentsInfoCardProps
/**
* This is the contents of the component info card.
*/
const ComponentsInfoCardContent: React.FC<ComponentsInfoCardContentProps> = memo(
({ info }: ComponentsInfoCardContentProps) => {
const ComponentsInfoCardContent: React.FC<ComponentsInfoCardContentProps> =
memo(({ info }: ComponentsInfoCardContentProps) => {
const { componentClass, description, name, tags } = info
return (
<Column height="100%">
Expand All @@ -73,8 +73,7 @@ const ComponentsInfoCardContent: React.FC<ComponentsInfoCardContentProps> = memo
</Row>
</Column>
)
}
)
})

/**
* This component is to display the different server components
Expand Down
2 changes: 1 addition & 1 deletion src/main/app/src/components/Help/Help.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> => Promise.resolve()}
Expand Down
10 changes: 7 additions & 3 deletions src/main/app/src/components/MetricView/MetricView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,14 @@ export const MetricView: React.FC<MetricViewProps> = ({
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLDivElement>(null)
const [isHovering] = useHover<HTMLDivElement>(innerRef)
Expand Down
11 changes: 9 additions & 2 deletions src/main/app/src/components/PipelineEdit/PipelineEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -345,7 +349,10 @@ export const PipelineEdit: React.FC<PipelineEditProps> = ({
<Divider />
<Heading.h3 my={2}>Error Configuration</Heading.h3>
</Column>
<PipelineEditErrorConfiguration errorConfiguration={pipeline.errorConfiguration} setErrorConfiguration={setErrorConfiguration} />
<PipelineEditErrorConfiguration
errorConfiguration={pipeline.errorConfiguration}
setErrorConfiguration={setErrorConfiguration}
/>
</Page>
<ErrorNotifier error={error} />
<Busy open={busy}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,53 +44,50 @@ export interface PipelineEditComponentSeparatorProps {
/**
* PipelineEditComponentSeparator component
*/
export const PipelineEditComponentSeparator: React.FC<PipelineEditComponentSeparatorProps> = ({
onInsert,
isDragging,
type,
}: PipelineEditComponentSeparatorProps) => {
const serverDetails = useServerDetails()
const [showDialog, openDialog, closeDialog] = useDialog()
const innerRef = useRef<HTMLButtonElement>(null)
const [isHovering] = useHover(innerRef)
const [isFocused] = useFocus(innerRef)
export const PipelineEditComponentSeparator: React.FC<PipelineEditComponentSeparatorProps> =
({ onInsert, isDragging, type }: PipelineEditComponentSeparatorProps) => {
const serverDetails = useServerDetails()
const [showDialog, openDialog, closeDialog] = useDialog()
const innerRef = useRef<HTMLButtonElement>(null)
const [isHovering] = useHover(innerRef)
const [isFocused] = useFocus(innerRef)

if (isDragging) {
return null
if (isDragging) {
return null
}
return (
<>
<ButtonBase
ref={innerRef}
focusRipple
aria-label={
type === 'Processor' ? 'Insert Processors' : 'Insert Source'
}
title={type === 'Processor' ? 'Insert Processors' : 'Insert Source'}
onClick={openDialog}
>
<PipelineViewComponentSeparator />
<Fade in={isHovering || isFocused}>
<Box
position="absolute"
color="background.paper"
top="calc(50% - 14px)"
>
<Icons.Add />
</Box>
</Fade>
</ButtonBase>
<SelectComponentDialog
type={type}
components={
type === 'Processor'
? serverDetails.processors
: serverDetails.sources
}
open={showDialog}
onClose={closeDialog}
onSelect={onInsert}
/>
</>
)
}
return (
<>
<ButtonBase
ref={innerRef}
focusRipple
aria-label={
type === 'Processor' ? 'Insert Processors' : 'Insert Source'
}
title={type === 'Processor' ? 'Insert Processors' : 'Insert Source'}
onClick={openDialog}
>
<PipelineViewComponentSeparator />
<Fade in={isHovering || isFocused}>
<Box
position="absolute"
color="background.paper"
top="calc(50% - 14px)"
>
<Icons.Add />
</Box>
</Fade>
</ButtonBase>
<SelectComponentDialog
type={type}
components={
type === 'Processor'
? serverDetails.processors
: serverDetails.sources
}
open={showDialog}
onClose={closeDialog}
onSelect={onInsert}
/>
</>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -40,4 +40,4 @@ export const Default: React.FC = () => {
setErrorConfiguration={action('setErrorConfiguration')}
/>
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -46,4 +46,4 @@ it('renders dark without error', () => {
/>
)
expect(asFragment()).toMatchSnapshot()
})
})
Loading

0 comments on commit d1f9cc8

Please sign in to comment.