Skip to content

Commit

Permalink
feat(docker): allow extra inline help on tag selector (#7143)
Browse files Browse the repository at this point in the history
  • Loading branch information
anotherchrisberry committed Jun 28, 2019
1 parent 422be22 commit e08e36f
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions app/scripts/modules/docker/src/image/DockerImageAndTagSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export interface IDockerImageAndTagSelectorProps {
export interface IDockerImageAndTagSelectorState {
accountOptions: Array<Option<string>>;
switchedManualWarning: string;
missingFields?: string[];
imagesLoaded: boolean;
imagesLoading: boolean;
organizationOptions: Array<Option<string>>;
Expand Down Expand Up @@ -293,6 +294,7 @@ export class DockerImageAndTagSelector extends React.Component<
if (!tagFound) {
missingFields.push('tag');
}
newState.missingFields = missingFields;
newState.switchedManualWarning = `Could not find ${missingFields.join(' or ')}, switched to manual entry`;
} else if (!imageId || !imageId.includes('${')) {
this.synchronizeChanges(
Expand Down Expand Up @@ -402,7 +404,7 @@ export class DockerImageAndTagSelector extends React.Component<
const newFields = DockerImageUtils.splitImageId(this.props.imageId || '');
this.props.onChange(newFields);
if (this.state.switchedManualWarning) {
this.setState({ switchedManualWarning: undefined });
this.setState({ switchedManualWarning: undefined, missingFields: undefined });
}
}
this.setState({ defineManually });
Expand All @@ -425,6 +427,7 @@ export class DockerImageAndTagSelector extends React.Component<
const {
accountOptions,
switchedManualWarning,
missingFields,
imagesLoading,
lookupType,
organizationOptions,
Expand Down Expand Up @@ -467,7 +470,14 @@ export class DockerImageAndTagSelector extends React.Component<
<div className="sp-formItem__right">
<div className="messageContainer warningMessage">
<i className="fa icon-alert-triangle" />
<div className="message">{switchedManualWarning}</div>
<div className="message">
{switchedManualWarning}
{(missingFields || []).map(f => (
<div>
<HelpField expand={true} key={f} id={`pipeline.config.docker.trigger.missing.${f}`} />
</div>
))}
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -638,15 +648,18 @@ export class DockerImageAndTagSelector extends React.Component<
required={true}
/>
) : (
<Select
value={tag || ''}
disabled={imagesLoading || !repository}
isLoading={imagesLoading}
onChange={(o: Option<string>) => this.valueChanged('tag', o ? o.value : undefined)}
options={tagOptions}
placeholder="No tag"
required={true}
/>
<>
<Select
value={tag || ''}
disabled={imagesLoading || !repository}
isLoading={imagesLoading}
onChange={(o: Option<string>) => this.valueChanged('tag', o ? o.value : undefined)}
options={tagOptions}
placeholder="No tag"
required={true}
/>
<HelpField id="pipeline.config.docker.trigger.tag.additionalInfo" expand={true} />
</>
)}
</span>
</div>
Expand Down

0 comments on commit e08e36f

Please sign in to comment.