Skip to content

Commit

Permalink
download all should be available only at the root (#1185)
Browse files Browse the repository at this point in the history
  • Loading branch information
VonnyJap authored Oct 8, 2024
1 parent 4eb4043 commit cf24b02
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
7 changes: 3 additions & 4 deletions app/components/artifact-preview/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ export default Component.extend({
window.open(downloadLink, '_blank');
},
downloadAll() {
const downloadLink = this.iframeUrl.replace(
/\/artifacts\/.*$/,
'/artifacts'
);
// https://api.screwdriver.cd/v4/documentation#/v4/getV4BuildsIdArtifacts
// Reconstruct the downloadLink from the env var since iframeUrl is not available for directory-level access.
const downloadLink = `${ENV.APP.SDAPI_HOSTNAME}/${ENV.APP.SDAPI_NAMESPACE}/builds/${this.buildId}/artifacts`;

window.open(downloadLink, '_blank');
}
Expand Down
35 changes: 19 additions & 16 deletions app/components/artifact-preview/template.hbs
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
<div>
<BsButton
@type="primary"
@icon="glyphicon glyphicon-download"
@onClick={{action "download"}}
title="Download current artifact"
>
Download
</BsButton>
<BsButton
@type="primary"
@icon="glyphicon glyphicon-download"
@onClick={{action "downloadAll"}}
title="Download all artifacts as ZIP file"
>
Download All
</BsButton>
{{#if (eq this.selectedArtifact "/")}}
<BsButton
@type="primary"
@icon="glyphicon glyphicon-download"
@onClick={{action "downloadAll"}}
title="Download all artifacts as ZIP file"
>
Download All
</BsButton>
{{else}}
<BsButton
@type="primary"
@icon="glyphicon glyphicon-download"
@onClick={{action "download"}}
title="Download current artifact"
>
Download
</BsButton>
{{/if}}
{{#if this.iframeUrl}}
<iframe id={{this.iframeId}} src={{this.iframeUrl}}>
<h4>
Expand Down
6 changes: 5 additions & 1 deletion app/components/build-step-collection/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@
</div>
<div class="col-9 partial-view">
{{#if this.isArtifacts}}
<ArtifactPreview @iframeUrl={{this.iframeUrl}} />
<ArtifactPreview
@iframeUrl={{this.iframeUrl}}
@selectedArtifact={{this.selectedArtifact}}
@buildId={{this.buildId}}
/>
{{else}}
<BuildLog
@stepName={{this.selectedStep}}
Expand Down

0 comments on commit cf24b02

Please sign in to comment.