Skip to content

Commit

Permalink
fix(cf): fix the alignment issue for artifacts in deploy SG (spinnake…
Browse files Browse the repository at this point in the history
  • Loading branch information
Jammy Louie authored and jkschneider committed Mar 15, 2019
1 parent 3dac1d9 commit 4f826d1
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import * as React from 'react';

import { HelpField } from '@spinnaker/core';

export interface IFormikConfigFieldProps {
label: string;
helpKey?: string;
children?: React.ReactNode;
}

export class FormikConfigField extends React.Component<IFormikConfigFieldProps> {
constructor(props: IFormikConfigFieldProps) {
super(props);
}

public render(): JSX.Element {
const { label, helpKey, children } = this.props;
return (
<div className={'StandardFieldLayout flex-container-h baseline margin-between-lg'}>
<label className={`sm-label-right`}>
<span className="label-text">{label} </span>
{helpKey && <HelpField id={helpKey} />}
</label>
<div className={`flex-grow`}>{children}</div>
</div>
);
}
}
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './CloudFoundryRadioButtonInput';
export * from './FormikConfigField';
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from '@spinnaker/core';

import { ICloudFoundryCreateServerGroupCommand } from 'cloudfoundry/serverGroup/configure/serverGroupConfigurationModel.cf';
import { FormikConfigField } from 'cloudfoundry/presentation';

export interface ICloudFoundryCreateServerGroupArtifactSettingsProps {
formik: FormikProps<ICloudFoundryCreateServerGroupCommand>;
Expand Down Expand Up @@ -52,7 +53,6 @@ export class CloudFoundryServerGroupArtifactSettings
<div className="form-group">
<div className="col-md-11">
<div className="StandardFieldLayout flex-container-h margin-between-lg">
<div className="sm-label-right">Artifact</div>
<div className="flex-grow">
<StageArtifactSelector
pipeline={pipeline}
Expand All @@ -62,6 +62,9 @@ export class CloudFoundryServerGroupArtifactSettings
onExpectedArtifactSelected={this.onExpectedArtifactSelected}
onArtifactEdited={this.onArtifactChanged}
excludedArtifactTypePatterns={this.excludedArtifactTypePatterns}
renderLabel={(field: React.ReactNode) => {
return <FormikConfigField label={'Artifact'}>{field}</FormikConfigField>;
}}
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { ICloudFoundryEnvVar } from 'cloudfoundry/domain';
import {
Buildpacks,
EnvironmentVariables,
FormikConfigField,
HealthCheck,
InstanceParameters,
Routes,
Expand Down Expand Up @@ -83,7 +84,6 @@ export class CloudFoundryServerGroupConfigurationSettings
<div className="form-group">
<div className="col-md-11">
<div className="StandardFieldLayout flex-container-h margin-between-lg">
<div className="sm-label-right">Artifact</div>
<div className="flex-grow">
<StageArtifactSelector
pipeline={pipeline}
Expand All @@ -93,6 +93,9 @@ export class CloudFoundryServerGroupConfigurationSettings
onExpectedArtifactSelected={this.onExpectedArtifactSelected}
onArtifactEdited={this.onArtifactChanged}
excludedArtifactTypePatterns={this.excludedArtifactTypePatterns}
renderLabel={(field: React.ReactNode) => {
return <FormikConfigField label={'Artifact'}>{field}</FormikConfigField>;
}}
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export interface IStageArtifactSelectorProps {

excludedArtifactIds?: string[];
excludedArtifactTypePatterns?: RegExp[];

renderLabel?: (reactNode: React.ReactNode) => React.ReactNode;
}

export interface IStageArtifactSelectorState {
Expand Down Expand Up @@ -87,7 +89,7 @@ export class StageArtifactSelector extends React.Component<IStageArtifactSelecto
};

public render() {
const { pipeline, stage, expectedArtifactId, artifact, excludedArtifactIds } = this.props;
const { pipeline, stage, expectedArtifactId, artifact, excludedArtifactIds, renderLabel } = this.props;
const expectedArtifacts = ExpectedArtifactService.getExpectedArtifactsAvailableToStage(stage, pipeline);
const expectedArtifact = expectedArtifactId
? expectedArtifacts.find(a => a.id === expectedArtifactId)
Expand All @@ -106,19 +108,21 @@ export class StageArtifactSelector extends React.Component<IStageArtifactSelecto
),
];

const select = (
<Select
clearable={false}
options={options}
value={expectedArtifact}
optionRenderer={this.renderArtifact}
valueRenderer={this.renderArtifact}
onChange={this.onExpectedArtifactSelected}
placeholder="Select an artifact..."
/>
);

return (
<>
<div className="sp-margin-m-bottom">
<Select
clearable={false}
options={options}
value={expectedArtifact}
optionRenderer={this.renderArtifact}
valueRenderer={this.renderArtifact}
onChange={this.onExpectedArtifactSelected}
placeholder="Select an artifact..."
/>
</div>
<div className="sp-margin-m-bottom">{renderLabel ? renderLabel(select) : select}</div>
{artifact && (
<ArtifactEditor
pipeline={pipeline}
Expand Down

0 comments on commit 4f826d1

Please sign in to comment.