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 { ...@@ -12,6 +12,7 @@ import {
JOB_SCHEDULED, JOB_SCHEDULED,
PLAY_JOB_CONFIRMATION_MESSAGE, PLAY_JOB_CONFIRMATION_MESSAGE,
RUN_JOB_NOW_HEADER_TITLE, RUN_JOB_NOW_HEADER_TITLE,
FILE_TYPE_ARCHIVE,
} from '../constants'; } from '../constants';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
import cancelJobMutation from '../graphql/mutations/job_cancel.mutation.graphql'; import cancelJobMutation from '../graphql/mutations/job_cancel.mutation.graphql';
...@@ -58,8 +59,11 @@ export default { ...@@ -58,8 +59,11 @@ export default {
}, },
}, },
computed: { computed: {
hasArtifacts() {
return this.job.artifacts.nodes.find((artifact) => artifact.fileType === FILE_TYPE_ARCHIVE);
},
artifactDownloadPath() { artifactDownloadPath() {
return this.job.artifacts?.nodes[0]?.downloadPath; return this.hasArtifacts.downloadPath;
}, },
canReadJob() { canReadJob() {
return this.job.userPermissions?.readBuild; return this.job.userPermissions?.readBuild;
...@@ -67,6 +71,9 @@ export default { ...@@ -67,6 +71,9 @@ export default {
canUpdateJob() { canUpdateJob() {
return this.job.userPermissions?.updateBuild; return this.job.userPermissions?.updateBuild;
}, },
canReadArtifacts() {
return this.job.userPermissions?.readJobArtifacts;
},
isActive() { isActive() {
return this.job.active; return this.job.active;
}, },
...@@ -89,7 +96,7 @@ export default { ...@@ -89,7 +96,7 @@ export default {
return this.job.detailedStatus?.action?.method; return this.job.detailedStatus?.action?.method;
}, },
shouldDisplayArtifacts() { shouldDisplayArtifacts() {
return this.job.userPermissions?.readJobArtifacts && this.job.artifacts?.nodes.length > 0; return this.canReadArtifacts && this.hasArtifacts;
}, },
}, },
methods: { methods: {
......
...@@ -17,6 +17,9 @@ export const DEFAULT = 'default'; ...@@ -17,6 +17,9 @@ export const DEFAULT = 'default';
/* Job Status Constants */ /* Job Status Constants */
export const JOB_SCHEDULED = 'SCHEDULED'; export const JOB_SCHEDULED = 'SCHEDULED';
/* Artifact file types */
export const FILE_TYPE_ARCHIVE = 'ARCHIVE';
/* i18n */ /* i18n */
export const ACTIONS_DOWNLOAD_ARTIFACTS = __('Download artifacts'); export const ACTIONS_DOWNLOAD_ARTIFACTS = __('Download artifacts');
export const ACTIONS_START_NOW = s__('DelayedJobs|Start now'); export const ACTIONS_START_NOW = s__('DelayedJobs|Start now');
......
...@@ -19,6 +19,7 @@ query getJobs( ...@@ -19,6 +19,7 @@ query getJobs(
artifacts { artifacts {
nodes { nodes {
downloadPath downloadPath
fileType
} }
} }
allowFailure allowFailure
......
...@@ -181,7 +181,7 @@ RSpec.describe 'User browses jobs' do ...@@ -181,7 +181,7 @@ RSpec.describe 'User browses jobs' do
name: 'rspec tests', name: 'rspec tests',
stage: 'test') stage: 'test')
create(:ci_job_artifact, :codequality, job: build) create(:ci_job_artifact, :archive, job: build)
end end
before do before do
......
...@@ -58,6 +58,14 @@ describe('Job actions cell', () => { ...@@ -58,6 +58,14 @@ describe('Job actions cell', () => {
wrapper.destroy(); 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', () => { it('does not display an artifacts download button', () => {
createComponent(retryableJob); createComponent(retryableJob);
......
...@@ -1489,15 +1489,18 @@ export const mockJobsQueryResponse = { ...@@ -1489,15 +1489,18 @@ export const mockJobsQueryResponse = {
nodes: [ nodes: [
{ {
downloadPath: '/root/ci-project/-/jobs/2336/artifacts/download?file_type=trace', downloadPath: '/root/ci-project/-/jobs/2336/artifacts/download?file_type=trace',
fileType: 'TRACE',
__typename: 'CiJobArtifact', __typename: 'CiJobArtifact',
}, },
{ {
downloadPath: downloadPath:
'/root/ci-project/-/jobs/2336/artifacts/download?file_type=metadata', '/root/ci-project/-/jobs/2336/artifacts/download?file_type=metadata',
fileType: 'METADATA',
__typename: 'CiJobArtifact', __typename: 'CiJobArtifact',
}, },
{ {
downloadPath: '/root/ci-project/-/jobs/2336/artifacts/download?file_type=archive', downloadPath: '/root/ci-project/-/jobs/2336/artifacts/download?file_type=archive',
fileType: 'ARCHIVE',
__typename: 'CiJobArtifact', __typename: 'CiJobArtifact',
}, },
], ],
...@@ -1586,7 +1589,16 @@ export const mockJobsQueryEmptyResponse = { ...@@ -1586,7 +1589,16 @@ export const mockJobsQueryEmptyResponse = {
}; };
export const retryableJob = { 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, allowFailure: false,
status: 'SUCCESS', status: 'SUCCESS',
scheduledAt: null, scheduledAt: null,
...@@ -1650,7 +1662,18 @@ export const playableJob = { ...@@ -1650,7 +1662,18 @@ export const playableJob = {
artifacts: { artifacts: {
nodes: [ 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', __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