Skip to content

Commit

Permalink
chore: cleanup of unused variables (flyteorg#394)
Browse files Browse the repository at this point in the history
Signed-off-by: Nastya Rusina <[email protected]>
  • Loading branch information
anrusina authored Apr 15, 2022
1 parent 32a2436 commit 3acb21d
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 90 deletions.
12 changes: 8 additions & 4 deletions .storybook/StorybookContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import * as React from 'react';
import { CssBaseline } from '@material-ui/core';
import { makeStyles, Theme } from '@material-ui/core/styles';
import { ThemeProvider } from '@material-ui/styles';
import * as React from 'react';
import { QueryClientProvider } from 'react-query';
import { MemoryRouter } from 'react-router-dom';
import { SnackbarProvider } from 'notistack';

import { ErrorBoundary } from '../src/components/common/ErrorBoundary';
import { createQueryClient } from '../src/components/data/queryCache';
import { muiTheme } from '../src/components/Theme/muiTheme';
Expand All @@ -22,9 +24,11 @@ export const StorybookContainer: React.FC = ({ children }) => {
<CssBaseline />
<ErrorBoundary>
<MemoryRouter>
<QueryClientProvider client={queryClient}>
<div className={useStyles().container}>{children}</div>
</QueryClientProvider>
<SnackbarProvider maxSnack={2} anchorOrigin={{ vertical: 'top', horizontal: 'right' }}>
<QueryClientProvider client={queryClient}>
<div className={useStyles().container}>{children}</div>
</QueryClientProvider>
</SnackbarProvider>
</MemoryRouter>
</ErrorBoundary>
</ThemeProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ import { NodeExecutionPhase } from 'models/Execution/enums';
export const CASHED_GREEN = 'rgba(74,227,174,0.25)'; // statusColors.SUCCESS (Mint20) with 25% opacity
export const TRANSPARENT = 'rgba(0, 0, 0, 0)';

export enum RelationToCache {
None = 'none',
ReadFromCaceh = 'Read from Cache',
WroteToCache = 'Wrote to cache',
}

export interface BarItemData {
phase: NodeExecutionPhase;
startOffsetSec: number;
Expand Down Expand Up @@ -45,11 +39,6 @@ export const formatSecondsToHmsFormat = (seconds: number) => {
return `${seconds}s`;
};

export const getOffsetColor = (isCachedValue: boolean[]) => {
const colors = isCachedValue.map((val) => (val === true ? CASHED_GREEN : TRANSPARENT));
return colors;
};

/**
* Generates chart data maps per each BarItemData ("node") section
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
CASHED_GREEN,
formatSecondsToHmsFormat,
generateChartData,
getOffsetColor,
TRANSPARENT,
} from '../Timeline/TimelineChart/utils';
import { mockbarItems } from './__mocks__/NodeExecution.mock';
Expand All @@ -27,17 +26,6 @@ describe('ExecutionDetails > Timeline > BarChart', () => {
expect(formatSecondsToHmsFormat(0)).toEqual('0s');
});

it('getOffsetColor returns colored background for cached items', () => {
const cachedArray = [false, true, false];
const offsetColors = getOffsetColor(cachedArray);

// If items is not cached - offset is transparent
expect(offsetColors[0]).toEqual(TRANSPARENT);
expect(offsetColors[2]).toEqual(TRANSPARENT);
// If cached - colored backfground
expect(offsetColors[1]).toEqual(CASHED_GREEN);
});

it('generateChartData properly generates map of data for ChartBars', () => {
const chartData = generateChartData(mockbarItems);
expect(chartData.durations).toEqual([15, 11, 23, 0]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { Collapse } from '@material-ui/core';
import * as React from 'react';
import { makeStyles, Theme } from '@material-ui/core/styles';
import { action } from '@storybook/addon-actions';
import { storiesOf } from '@storybook/react';
import { ExecutionState } from 'models/Execution/enums';
import { createMockWorkflowExecutionsListResponse } from 'models/Execution/__mocks__/mockWorkflowExecutionsData';
import { SnackbarProvider } from 'notistack';
import * as React from 'react';
import { WorkflowExecutionsTable, WorkflowExecutionsTableProps } from '../WorkflowExecutionsTable';

const useStyles = makeStyles((theme: Theme) => ({
Expand Down Expand Up @@ -36,38 +34,11 @@ const props: WorkflowExecutionsTableProps = {
fetch: () => Promise.resolve(() => fetchAction() as unknown),
};

// wrapper - to ensure that error/success notification shown as expected in storybook
const Wrapper = (props) => {
return (
<SnackbarProvider
maxSnack={2}
anchorOrigin={{ vertical: 'top', horizontal: 'right' }}
TransitionComponent={Collapse}
>
{props.children}
</SnackbarProvider>
);
};

const stories = storiesOf('Tables/WorkflowExecutionsTable', module);
stories.addDecorator((story) => <div className={useStyles().container}>{story()}</div>);
stories.add('Basic', () => (
<Wrapper>
<WorkflowExecutionsTable {...props} />
</Wrapper>
));
stories.add('Only archived items', () => (
<Wrapper>
<WorkflowExecutionsTable {...propsArchived} />
</Wrapper>
));
stories.add('Basic', () => <WorkflowExecutionsTable {...props} />);
stories.add('Only archived items', () => <WorkflowExecutionsTable {...propsArchived} />);
stories.add('With more items available', () => (
<Wrapper>
<WorkflowExecutionsTable {...props} moreItemsAvailable={true} />
</Wrapper>
));
stories.add('With no items', () => (
<Wrapper>
<WorkflowExecutionsTable {...props} value={[]} />
</Wrapper>
<WorkflowExecutionsTable {...props} moreItemsAvailable={true} />
));
stories.add('With no items', () => <WorkflowExecutionsTable {...props} value={[]} />);
3 changes: 1 addition & 2 deletions src/components/Launch/LaunchForm/useLaunchTaskFormState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,12 @@ async function submit(
throw new Error('Unexpected empty role input ref');
}

const { authRole, securityContext } = roleInputRef.current?.getValue();
const { securityContext } = roleInputRef.current?.getValue();
const literals = formInputsRef.current.getValues();
const launchPlanId = taskVersion;
const { domain, project } = taskVersion;

const response = await createWorkflowExecution({
authRole,
securityContext,
domain,
launchPlanId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ async function submit(
throw new Error('Unexpected empty form inputs ref');
}

const { authRole, securityContext } = roleInputRef.current?.getValue() as LaunchRoles;
const { securityContext } = roleInputRef.current?.getValue() as LaunchRoles;
const literals = formInputsRef.current.getValues();
const { disableAll, labels, annotations, maxParallelism, rawOutputDataConfig } =
advancedOptionsRef.current?.getValues() || {};
Expand All @@ -175,7 +175,6 @@ async function submit(

const response = await createWorkflowExecution({
annotations,
authRole,
securityContext,
disableAll,
maxParallelism,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,17 @@
import { Collapse } from '@material-ui/core';
import * as React from 'react';
import { action } from '@storybook/addon-actions';
import { storiesOf } from '@storybook/react';
import { sampleWorkflowNames } from 'models/__mocks__/sampleWorkflowNames';
import { SnackbarProvider } from 'notistack';
import * as React from 'react';
import { SearchableWorkflowNameList } from '../SearchableWorkflowNameList';

const baseProps = { workflows: [...sampleWorkflowNames] };

// wrapper - to ensure that error/success notification shown as expected in storybook
const Wrapper = (props) => {
return (
<SnackbarProvider
maxSnack={2}
anchorOrigin={{ vertical: 'top', horizontal: 'right' }}
TransitionComponent={Collapse}
>
{props.children}
</SnackbarProvider>
);
};

const stories = storiesOf('Workflow/SearchableWorkflowNameList', module);
stories.addDecorator((story) => <div style={{ width: '650px' }}>{story()}</div>);
stories.add('basic', () => (
<Wrapper>
<SearchableWorkflowNameList
showArchived={false}
onArchiveFilterChange={action('onArchiveFilterChange')}
{...baseProps}
/>
</Wrapper>
<SearchableWorkflowNameList
showArchived={false}
onArchiveFilterChange={action('onArchiveFilterChange')}
{...baseProps}
/>
));
2 changes: 0 additions & 2 deletions src/models/Execution/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export const getExecutionData = (id: WorkflowExecutionIdentifier, config?: Reque

export interface CreateWorkflowExecutionArguments {
annotations?: Admin.IAnnotations | null;
authRole?: Admin.IAuthRole;
securityContext?: Core.ISecurityContext;
domain: string;
disableAll?: boolean | null;
Expand All @@ -97,7 +96,6 @@ export interface CreateWorkflowExecutionArguments {
export const createWorkflowExecution = (
{
annotations,
authRole,
securityContext,
domain,
disableAll,
Expand Down

0 comments on commit 3acb21d

Please sign in to comment.