Commit 8fcd9b51 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch '348218-use-correct-filetype-artifacts' into 'master'

Use archive file type for artifacts download button

See merge request gitlab-org/gitlab!76667
parents ca909ded 753fb7dd
......@@ -12,6 +12,7 @@ import {
JOB_SCHEDULED,
PLAY_JOB_CONFIRMATION_MESSAGE,
RUN_JOB_NOW_HEADER_TITLE,
FILE_TYPE_ARCHIVE,
} from '../constants';
import eventHub from '../event_hub';
import cancelJobMutation from '../graphql/mutations/job_cancel.mutation.graphql';
......@@ -58,8 +59,11 @@ export default {
},
},
computed: {
hasArtifacts() {
return this.job.artifacts.nodes.find((artifact) => artifact.fileType === FILE_TYPE_ARCHIVE);
},
artifactDownloadPath() {
return this.job.artifacts?.nodes[0]?.downloadPath;
return this.hasArtifacts.downloadPath;
},
canReadJob() {
return this.job.userPermissions?.readBuild;
......@@ -67,6 +71,9 @@ export default {
canUpdateJob() {
return this.job.userPermissions?.updateBuild;
},
canReadArtifacts() {
return this.job.userPermissions?.readJobArtifacts;
},
isActive() {
return this.job.active;
},
......@@ -89,7 +96,7 @@ export default {
return this.job.detailedStatus?.action?.method;
},
shouldDisplayArtifacts() {
return this.job.userPermissions?.readJobArtifacts && this.job.artifacts?.nodes.length > 0;
return this.canReadArtifacts && this.hasArtifacts;
},
},
methods: {
......
......@@ -17,6 +17,9 @@ export const DEFAULT = 'default';
/* Job Status Constants */
export const JOB_SCHEDULED = 'SCHEDULED';
/* Artifact file types */
export const FILE_TYPE_ARCHIVE = 'ARCHIVE';
/* i18n */
export const ACTIONS_DOWNLOAD_ARTIFACTS = __('Download artifacts');
export const ACTIONS_START_NOW = s__('DelayedJobs|Start now');
......
......@@ -19,6 +19,7 @@ query getJobs(
artifacts {
nodes {
downloadPath
fileType
}
}
allowFailure
......
......@@ -181,7 +181,7 @@ RSpec.describe 'User browses jobs' do
name: 'rspec tests',
stage: 'test')
create(:ci_job_artifact, :codequality, job: build)
create(:ci_job_artifact, :archive, job: build)
end
before do
......
......@@ -58,6 +58,14 @@ describe('Job actions cell', () => {
wrapper.destroy();
});
it('displays the artifacts download button with correct link', () => {
createComponent(playableJob);
expect(findDownloadArtifactsButton().attributes('href')).toBe(
playableJob.artifacts.nodes[0].downloadPath,
);
});
it('does not display an artifacts download button', () => {
createComponent(retryableJob);
......
......@@ -1489,15 +1489,18 @@ export const mockJobsQueryResponse = {
nodes: [
{
downloadPath: '/root/ci-project/-/jobs/2336/artifacts/download?file_type=trace',
fileType: 'TRACE',
__typename: 'CiJobArtifact',
},
{
downloadPath:
'/root/ci-project/-/jobs/2336/artifacts/download?file_type=metadata',
fileType: 'METADATA',
__typename: 'CiJobArtifact',
},
{
downloadPath: '/root/ci-project/-/jobs/2336/artifacts/download?file_type=archive',
fileType: 'ARCHIVE',
__typename: 'CiJobArtifact',
},
],
......@@ -1586,7 +1589,16 @@ export const mockJobsQueryEmptyResponse = {
};
export const retryableJob = {
artifacts: { nodes: [], __typename: 'CiJobArtifactConnection' },
artifacts: {
nodes: [
{
downloadPath: '/root/ci-project/-/jobs/847/artifacts/download?file_type=trace',
fileType: 'TRACE',
__typename: 'CiJobArtifact',
},
],
__typename: 'CiJobArtifactConnection',
},
allowFailure: false,
status: 'SUCCESS',
scheduledAt: null,
......@@ -1650,7 +1662,18 @@ export const playableJob = {
artifacts: {
nodes: [
{
downloadPath: '/root/test-job-artifacts/-/jobs/1982/artifacts/download?file_type=trace',
downloadPath: '/root/ci-project/-/jobs/621/artifacts/download?file_type=archive',
fileType: 'ARCHIVE',
__typename: 'CiJobArtifact',
},
{
downloadPath: '/root/ci-project/-/jobs/621/artifacts/download?file_type=metadata',
fileType: 'METADATA',
__typename: 'CiJobArtifact',
},
{
downloadPath: '/root/ci-project/-/jobs/621/artifacts/download?file_type=trace',
fileType: 'TRACE',
__typename: 'CiJobArtifact',
},
],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment