Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add non blocking pipeline creation flow
- Loading branch information
karthik
committed
Nov 19, 2020
1 parent
33da36b
commit 687dcee
Showing
10 changed files
with
183 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
frontend/packages/dev-console/src/components/topology/redux/const.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export const TOPOLOGY_DISPLAY_FILTERS_LOCAL_STORAGE_KEY = `bridge/topology-display-filters`; | ||
export const PIPELINE_RUN_AUTO_START_FAILED = `bridge/pipeline-run-auto-start-failed`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...es/pipelines-plugin/src/components/pipelines/pipeline-overview/PipelineOverviewAlert.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.pipeline-overview-alert { | ||
margin-top: var(--pf-global--spacer--md); | ||
} |
26 changes: 26 additions & 0 deletions
26
...ges/pipelines-plugin/src/components/pipelines/pipeline-overview/PipelineOverviewAlert.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import * as React from 'react'; | ||
import { Alert, AlertActionCloseButton, AlertProps } from '@patternfly/react-core'; | ||
|
||
import './PipelineOverviewAlert.scss'; | ||
|
||
type PipelineOverviewAlertProps = { | ||
title: string; | ||
onClose?: () => void; | ||
}; | ||
|
||
const PipelineOverviewAlert: React.FC<PipelineOverviewAlertProps & AlertProps> = ({ | ||
title, | ||
onClose, | ||
}) => { | ||
return ( | ||
<Alert | ||
className="pipeline-overview-alert" | ||
variant="default" | ||
isInline | ||
title={title} | ||
actionClose={<AlertActionCloseButton onClose={onClose} />} | ||
/> | ||
); | ||
}; | ||
|
||
export default PipelineOverviewAlert; |
54 changes: 54 additions & 0 deletions
54
...ugin/src/components/pipelines/pipeline-overview/__tests__/pipeline-overview-utils.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import * as overviewUtils from '../pipeline-overview-utils'; | ||
|
||
describe('pipeline-overview-utils', () => { | ||
beforeEach(() => { | ||
sessionStorage.clear(); | ||
}); | ||
|
||
it('should properly set the failed pipeline names in the session storage', () => { | ||
overviewUtils.setPipelineNotStarted('pipeline-one'); | ||
overviewUtils.setPipelineNotStarted('pipeline-two'); | ||
overviewUtils.setPipelineNotStarted('pipeline-three'); | ||
|
||
expect(overviewUtils.getNotStartedPipelines()).toHaveLength(3); | ||
}); | ||
|
||
it('should not set the session storage if empty string or null is passed', () => { | ||
overviewUtils.setPipelineNotStarted(''); | ||
overviewUtils.setPipelineNotStarted(null); | ||
overviewUtils.setPipelineNotStarted(undefined); | ||
|
||
expect(overviewUtils.getNotStartedPipelines()).toHaveLength(0); | ||
}); | ||
|
||
it('should remove the pipeline names from the session storage', () => { | ||
overviewUtils.setPipelineNotStarted('pipeline-one'); | ||
overviewUtils.setPipelineNotStarted('pipeline-two'); | ||
overviewUtils.setPipelineNotStarted('pipeline-three'); | ||
|
||
overviewUtils.removePipelineNotStarted('pipeline-three'); | ||
overviewUtils.removePipelineNotStarted('pipeline-two'); | ||
const failedPipelines = overviewUtils.getNotStartedPipelines(); | ||
|
||
expect(failedPipelines).toHaveLength(1); | ||
expect(failedPipelines[0]).toBe('pipeline-one'); | ||
}); | ||
|
||
it('should not affect existing values if we pass null or undefined values to remove operation', () => { | ||
overviewUtils.setPipelineNotStarted('pipeline-one'); | ||
|
||
overviewUtils.removePipelineNotStarted(null); | ||
overviewUtils.removePipelineNotStarted(undefined); | ||
|
||
expect(overviewUtils.getNotStartedPipelines()).toHaveLength(1); | ||
}); | ||
|
||
it('should return true or false based on pipeline name availability in the session storage', () => { | ||
overviewUtils.setPipelineNotStarted('pipeline-one'); | ||
overviewUtils.setPipelineNotStarted('pipeline-two'); | ||
|
||
expect(overviewUtils.isPipelineNotStarted('pipeline-one')).toBeTruthy(); | ||
expect(overviewUtils.isPipelineNotStarted('pipeline-two')).toBeTruthy(); | ||
expect(overviewUtils.isPipelineNotStarted('pipeline-three')).toBeFalsy(); | ||
}); | ||
}); |
22 changes: 22 additions & 0 deletions
22
...es/pipelines-plugin/src/components/pipelines/pipeline-overview/pipeline-overview-utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { PIPELINE_RUN_AUTO_START_FAILED } from '@console/dev-console/src/components/topology/redux/const'; | ||
|
||
export const getNotStartedPipelines = () => { | ||
return JSON.parse(sessionStorage.getItem(PIPELINE_RUN_AUTO_START_FAILED) ?? '[]'); | ||
}; | ||
export const isPipelineNotStarted = (pipelineName: string): boolean => { | ||
return getNotStartedPipelines().includes(pipelineName); | ||
}; | ||
|
||
export const removePipelineNotStarted = (pipelineName: string): void => { | ||
const newList = getNotStartedPipelines().filter((pName) => pName !== pipelineName); | ||
sessionStorage.setItem(PIPELINE_RUN_AUTO_START_FAILED, JSON.stringify(newList)); | ||
}; | ||
|
||
export const setPipelineNotStarted = (pipelineName: string): void => { | ||
if (!pipelineName) return; | ||
const pipelineList = getNotStartedPipelines(); | ||
if (pipelineList.length === 0 || !pipelineList.includes(pipelineName)) { | ||
pipelineList.push(pipelineName); | ||
} | ||
sessionStorage.setItem(PIPELINE_RUN_AUTO_START_FAILED, JSON.stringify(pipelineList)); | ||
}; |