forked from spinnaker/deck
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(pipeline): reactify pipeline config actions dropdown (spinna…
- Loading branch information
Jammy Louie
committed
Sep 27, 2019
1 parent
677ab6b
commit f535e52
Showing
6 changed files
with
122 additions
and
38 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
app/scripts/modules/core/src/pipeline/config/actions/PipelineConfigAction.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,16 @@ | ||
import * as React from 'react'; | ||
|
||
interface IPipelineConfigActionProps { | ||
action?: () => void; | ||
name: string; | ||
} | ||
|
||
export function PipelineConfigAction(props: IPipelineConfigActionProps) { | ||
return ( | ||
<li> | ||
<a className={props.action ? 'clickable' : 'disable'} onClick={props.action}> | ||
{props.name} | ||
</a> | ||
</li> | ||
); | ||
} |
65 changes: 65 additions & 0 deletions
65
app/scripts/modules/core/src/pipeline/config/actions/PipelineConfigActions.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,65 @@ | ||
import * as React from 'react'; | ||
import { Dropdown } from 'react-bootstrap'; | ||
|
||
import { IPipeline } from 'core/domain'; | ||
import { SETTINGS } from 'core/config/settings'; | ||
import { PipelineConfigAction } from './PipelineConfigAction'; | ||
|
||
export interface IPipelineConfigActionsProps { | ||
hasHistory: boolean; | ||
loadingHistory: boolean; | ||
pipeline: IPipeline; | ||
renamePipeline: () => void; | ||
deletePipeline: () => void; | ||
enablePipeline: () => void; | ||
disablePipeline: () => void; | ||
lockPipeline: () => void; | ||
unlockPipeline: () => void; | ||
editPipelineJson: () => void; | ||
showHistory: () => void; | ||
exportPipelineTemplate: () => void; | ||
} | ||
|
||
export function PipelineConfigActions(props: IPipelineConfigActionsProps) { | ||
const { | ||
hasHistory, | ||
loadingHistory, | ||
pipeline, | ||
renamePipeline, | ||
deletePipeline, | ||
enablePipeline, | ||
disablePipeline, | ||
lockPipeline, | ||
unlockPipeline, | ||
editPipelineJson, | ||
showHistory, | ||
exportPipelineTemplate, | ||
} = props; | ||
const managedPipelineTemplatesV2UI = SETTINGS.feature.managedPipelineTemplatesV2UI; | ||
|
||
return ( | ||
<Dropdown className="dropdown" id="pipeline-actions-dropdown"> | ||
<Dropdown.Toggle className="btn btn-sm dropdown-toggle"> | ||
{pipeline.strategy === true ? 'Strategy' : 'Pipeline'} Actions | ||
</Dropdown.Toggle> | ||
<Dropdown.Menu className="dropdown-menu"> | ||
{!pipeline.locked && <PipelineConfigAction name="Rename" action={renamePipeline} />} | ||
{!pipeline.locked && <PipelineConfigAction name="Delete" action={deletePipeline} />} | ||
{!pipeline.locked && pipeline.disabled && <PipelineConfigAction name="Enable" action={enablePipeline} />} | ||
{!pipeline.locked && !pipeline.disabled && <PipelineConfigAction name="Disable" action={disablePipeline} />} | ||
{!pipeline.locked && <PipelineConfigAction name="Lock" action={lockPipeline} />} | ||
{pipeline.locked && pipeline.locked.allowUnlockUi && ( | ||
<PipelineConfigAction name="Unlock" action={unlockPipeline} /> | ||
)} | ||
{pipeline.locked && <PipelineConfigAction name="Show JSON" action={editPipelineJson} />} | ||
{!pipeline.locked && <PipelineConfigAction name="Edit as JSON" action={editPipelineJson} />} | ||
{loadingHistory && <PipelineConfigAction name="Loading History..." />} | ||
{!loadingHistory && hasHistory && <PipelineConfigAction name="Show Revision History" action={showHistory} />} | ||
{!loadingHistory && !hasHistory && <PipelineConfigAction name="No version history found" />} | ||
{managedPipelineTemplatesV2UI && ( | ||
<PipelineConfigAction name="Export as Pipeline Template" action={exportPipelineTemplate} /> | ||
)} | ||
</Dropdown.Menu> | ||
</Dropdown> | ||
); | ||
} |
32 changes: 0 additions & 32 deletions
32
app/scripts/modules/core/src/pipeline/config/actions/pipelineConfigActions.html
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
app/scripts/modules/core/src/pipeline/config/actions/pipelineConfigActions.module.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,21 @@ | ||
import { module } from 'angular'; | ||
import { react2angular } from 'react2angular'; | ||
import { PipelineConfigActions } from './PipelineConfigActions'; | ||
export const PIPELINE_CONFIG_ACTIONS = 'pinnaker.core.pipeline.config.actions'; | ||
module(PIPELINE_CONFIG_ACTIONS, []).component( | ||
'pipelineConfigActions', | ||
react2angular(PipelineConfigActions, [ | ||
'hasHistory', | ||
'loadingHistory', | ||
'pipeline', | ||
'renamePipeline', | ||
'deletePipeline', | ||
'enablePipeline', | ||
'disablePipeline', | ||
'lockPipeline', | ||
'unlockPipeline', | ||
'editPipelineJson', | ||
'showHistory', | ||
'exportPipelineTemplate', | ||
]), | ||
); |
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