Skip to content

Commit

Permalink
feat(codebuild): List project names (#7926)
Browse files Browse the repository at this point in the history
Change text input field to select input field for project name
so that user could select project name from a dropdown list
instead of manually type in the name.

Fix a null pointer issue when creating a new CodeBuild stage.

Co-authored-by: Clare Liguori <[email protected]>
  • Loading branch information
Kaixiang-AWS and clareliguori authored Feb 21, 2020
1 parent 570a6ea commit d0659e8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
7 changes: 7 additions & 0 deletions app/scripts/modules/core/src/ci/igor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,11 @@ export class IgorService {
.one('accounts')
.get();
}

public static getCodeBuildProjects(account: string): IPromise<string[]> {
return API.one('codebuild')
.one('projects')
.one(account)
.get();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ export function AwsCodeBuildStageForm(props: IAwsCodeBuildStageFormProps & IForm
[],
);

const { result: fetchProjectsResult, status: fetchProjectsStatus } = useData(
() => IgorService.getCodeBuildProjects(stage.account),
[],
[stage.account],
);

const onFieldChange = (fieldName: string, fieldValue: any): void => {
props.formik.setFieldValue(fieldName, fieldValue);
};
Expand All @@ -53,12 +59,18 @@ export function AwsCodeBuildStageForm(props: IAwsCodeBuildStageFormProps & IForm
/>
)}
/>
{/* TODO: Select project from a drop-down list. Behind the scene, gate calls igor to fetch projects list */}
<FormikFormField
fastField={false}
label="Project Name"
name="projectName"
input={(inputProps: IFormInputProps) => <TextInput {...inputProps} />}
input={(inputProps: IFormInputProps) => (
<ReactSelectInput
{...inputProps}
clearable={false}
isLoading={fetchProjectsStatus === 'PENDING'}
stringOptions={fetchProjectsResult}
/>
)}
/>
<h4>Source Configuration</h4>
<FormikFormField
Expand All @@ -69,7 +81,7 @@ export function AwsCodeBuildStageForm(props: IAwsCodeBuildStageFormProps & IForm
<CheckboxInput {...inputProps} text="Override source to Spinnaker artifact" />
)}
/>
{stage.source.sourceOverride === true && (
{get(stage, 'source.sourceOverride') === true && (
<FormikFormField
fastField={false}
label="SourceType"
Expand All @@ -79,7 +91,7 @@ export function AwsCodeBuildStageForm(props: IAwsCodeBuildStageFormProps & IForm
)}
/>
)}
{stage.source.sourceOverride === true && (
{get(stage, 'source.sourceOverride') === true && (
<FormikFormField
fastField={false}
label="Source Artifact Override"
Expand Down

0 comments on commit d0659e8

Please sign in to comment.