Skip to content

Commit

Permalink
fix(artifacts): fix artifact account default logic (#7324)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jammy Louie authored and maggieneterval committed Aug 15, 2019
1 parent cf8c35b commit c39bf0b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { cloneDeep } from 'lodash';
import { cloneDeep, head } from 'lodash';
import { IArtifactAccount } from 'core/account';
import { ArtifactAccountSelector } from 'core/artifact';
import { IArtifact, IPipeline } from 'core/domain';
Expand Down Expand Up @@ -35,7 +35,9 @@ export class ArtifactEditor extends React.Component<IArtifactEditorProps> {
private defaultArtifactAccountIfNecessary(): void {
const { artifact, artifactAccounts } = this.props;
if (!artifact.artifactAccount && artifactAccounts.length > 0) {
this.onArtifactAccountChanged(artifactAccounts[0]);
this.onArtifactAccountChanged(
head(artifactAccounts.filter(a => a.types.includes(artifact.type))) || head(artifactAccounts),
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ export function ExpectedArtifact(props: IExpectedArtifactProps) {
Match against
<HelpField id="pipeline.config.expectedArtifact.matchArtifact" />
</div>
<div className="col-md-1 col-md-offset-8">
<div className="col-md-2 col-md-offset-7">
<Tooltip value="Remove expected artifact">
<button
className="btn btn-sm btn-default"
onClick={() => removeExpectedArtifact(pipeline, expectedArtifact)}
>
<span className="glyphicon glyphicon-trash" />
<span className="visible-xl-inline">Remove artifact</span>
<span>Remove artifact</span>
</button>
</Tooltip>
</div>
Expand Down

0 comments on commit c39bf0b

Please sign in to comment.