-
Notifications
You must be signed in to change notification settings - Fork 903
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(kubernetes): convert find artifacts from resource stage to r…
…eact (#10157)
- Loading branch information
1 parent
269b738
commit 4040461
Showing
7 changed files
with
86 additions
and
63 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
35 changes: 35 additions & 0 deletions
35
...rnetes/src/pipelines/stages/findArtifactsFromResource/FindArtifactsFromResourceConfig.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,35 @@ | ||
import { defaults } from 'lodash'; | ||
import { useEffect } from 'react'; | ||
import React from 'react'; | ||
|
||
import type { IFormikStageConfigInjectedProps, IStageConfigProps } from '@spinnaker/core'; | ||
import { FormikStageConfig } from '@spinnaker/core'; | ||
|
||
import { FindArtifactsFromResourceStageForm } from './FindArtifactsFromResourceStageForm'; | ||
|
||
export function FindArtifactsFromResourceConfig({ | ||
application, | ||
pipeline, | ||
stage, | ||
updateStage, | ||
stageFieldUpdated, | ||
}: IStageConfigProps) { | ||
useEffect(() => { | ||
defaults(stage, { | ||
app: application.name, | ||
cloudProvider: 'kubernetes', | ||
}); | ||
}, []); | ||
|
||
return ( | ||
<FormikStageConfig | ||
application={application} | ||
pipeline={pipeline} | ||
stage={stage} | ||
onChange={updateStage} | ||
render={(props: IFormikStageConfigInjectedProps) => ( | ||
<FindArtifactsFromResourceStageForm {...props} stageFieldUpdated={stageFieldUpdated} /> | ||
)} | ||
/> | ||
); | ||
} |
37 changes: 37 additions & 0 deletions
37
...tes/src/pipelines/stages/findArtifactsFromResource/FindArtifactsFromResourceStageForm.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,37 @@ | ||
import React from 'react'; | ||
|
||
import type { IFormikStageConfigInjectedProps } from '@spinnaker/core'; | ||
|
||
import type { IManifestSelector } from '../../../manifest/selector/IManifestSelector'; | ||
import { SelectorMode } from '../../../manifest/selector/IManifestSelector'; | ||
import { ManifestSelector } from '../../../manifest/selector/ManifestSelector'; | ||
|
||
interface IFindArtifactsFromResourceStageConfigFormProps { | ||
stageFieldUpdated: () => void; | ||
} | ||
|
||
export function FindArtifactsFromResourceStageForm({ | ||
application, | ||
formik, | ||
stageFieldUpdated, | ||
}: IFindArtifactsFromResourceStageConfigFormProps & IFormikStageConfigInjectedProps) { | ||
const stage = formik.values; | ||
|
||
const onManifestSelectorChange = () => { | ||
stageFieldUpdated(); | ||
}; | ||
|
||
return ( | ||
<div className="form-horizontal"> | ||
<h4>Manifest</h4> | ||
<div className="horizontal-rule" /> | ||
<ManifestSelector | ||
application={application} | ||
selector={(stage as unknown) as IManifestSelector} | ||
modes={[SelectorMode.Static, SelectorMode.Dynamic]} | ||
onChange={onManifestSelectorChange} | ||
includeSpinnakerKinds={null} | ||
/> | ||
</div> | ||
); | ||
} |
28 changes: 0 additions & 28 deletions
28
.../pipelines/stages/findArtifactsFromResource/findArtifactsFromResourceConfig.controller.ts
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
...netes/src/pipelines/stages/findArtifactsFromResource/findArtifactsFromResourceConfig.html
This file was deleted.
Oops, something went wrong.
36 changes: 13 additions & 23 deletions
36
...bernetes/src/pipelines/stages/findArtifactsFromResource/findArtifactsFromResourceStage.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,28 +1,18 @@ | ||
import { module } from 'angular'; | ||
|
||
import { ExecutionArtifactTab, ExecutionDetailsTasks, Registry } from '@spinnaker/core'; | ||
|
||
import { KubernetesV2FindArtifactsFromResourceConfigCtrl } from './findArtifactsFromResourceConfig.controller'; | ||
import { KUBERNETES_MANIFEST_SELECTOR } from '../../../manifest/selector/selector.component'; | ||
import { FindArtifactsFromResourceConfig } from './FindArtifactsFromResourceConfig'; | ||
import { manifestSelectorValidators } from '../validators/manifestSelectorValidators'; | ||
|
||
export const KUBERNETES_FIND_ARTIFACTS_FROM_RESOURCE_STAGE = | ||
'spinnaker.kubernetes.v2.pipeline.stage.findArtifactsFromResource'; | ||
|
||
const STAGE_NAME = 'Find Artifacts From Resource (Manifest)'; | ||
module(KUBERNETES_FIND_ARTIFACTS_FROM_RESOURCE_STAGE, [KUBERNETES_MANIFEST_SELECTOR]) | ||
.config(() => { | ||
Registry.pipeline.registerStage({ | ||
label: STAGE_NAME, | ||
description: 'Finds artifacts from a Kubernetes resource.', | ||
key: 'findArtifactsFromResource', | ||
cloudProvider: 'kubernetes', | ||
templateUrl: require('./findArtifactsFromResourceConfig.html'), | ||
controller: 'KubernetesV2FindArtifactsFromResourceConfigCtrl', | ||
controllerAs: 'ctrl', | ||
executionDetailsSections: [ExecutionDetailsTasks, ExecutionArtifactTab], | ||
producesArtifacts: true, | ||
validators: manifestSelectorValidators(STAGE_NAME), | ||
}); | ||
}) | ||
.controller('KubernetesV2FindArtifactsFromResourceConfigCtrl', KubernetesV2FindArtifactsFromResourceConfigCtrl); | ||
const STAGE_KEY = 'findArtifactsFromResource'; | ||
|
||
Registry.pipeline.registerStage({ | ||
label: STAGE_NAME, | ||
description: 'Finds artifacts from a Kubernetes resource.', | ||
key: STAGE_KEY, | ||
cloudProvider: 'kubernetes', | ||
component: FindArtifactsFromResourceConfig, | ||
executionDetailsSections: [ExecutionDetailsTasks, ExecutionArtifactTab], | ||
producesArtifacts: true, | ||
validators: manifestSelectorValidators(STAGE_NAME), | ||
}); |
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