Commit 0660b130 authored by Simon Knox's avatar Simon Knox

Merge branch '329340-add-dynamic-job-link' into 'master'

Add dynamic job link

See merge request gitlab-org/gitlab!60947
parents 0bad4de1 4e7e3a21
...@@ -52,6 +52,9 @@ export default { ...@@ -52,6 +52,9 @@ export default {
isScheduledJob() { isScheduledJob() {
return Boolean(this.job.scheduledAt); return Boolean(this.job.scheduledAt);
}, },
canReadJob() {
return this.job?.userPermissions?.readBuild;
},
}, },
}; };
</script> </script>
...@@ -59,7 +62,16 @@ export default { ...@@ -59,7 +62,16 @@ export default {
<template> <template>
<div> <div>
<div class="gl-text-truncate"> <div class="gl-text-truncate">
<gl-link class="gl-text-gray-500!" :href="jobPath" data-testid="job-id">{{ jobId }}</gl-link> <gl-link
v-if="canReadJob"
class="gl-text-gray-500!"
:href="jobPath"
data-testid="job-id-link"
>
{{ jobId }}
</gl-link>
<span v-else data-testid="job-id-limited-access">{{ jobId }}</span>
<div class="gl-display-flex gl-align-items-center"> <div class="gl-display-flex gl-align-items-center">
<div v-if="jobRef" class="gl-max-w-15 gl-text-truncate"> <div v-if="jobRef" class="gl-max-w-15 gl-text-truncate">
......
...@@ -59,6 +59,9 @@ query getJobs($fullPath: ID!, $statuses: [CiJobStatus!]) { ...@@ -59,6 +59,9 @@ query getJobs($fullPath: ID!, $statuses: [CiJobStatus!]) {
playable playable
cancelable cancelable
active active
userPermissions {
readBuild
}
} }
} }
} }
......
...@@ -6,11 +6,13 @@ import { mockJobsInTable } from '../../../mock_data'; ...@@ -6,11 +6,13 @@ import { mockJobsInTable } from '../../../mock_data';
const mockJob = mockJobsInTable[0]; const mockJob = mockJobsInTable[0];
const mockJobCreatedByTag = mockJobsInTable[1]; const mockJobCreatedByTag = mockJobsInTable[1];
const mockJobLimitedAccess = mockJobsInTable[2];
describe('Job Cell', () => { describe('Job Cell', () => {
let wrapper; let wrapper;
const findJobId = () => wrapper.findByTestId('job-id'); const findJobIdLink = () => wrapper.findByTestId('job-id-link');
const findJobIdNoLink = () => wrapper.findByTestId('job-id-limited-access');
const findJobRef = () => wrapper.findByTestId('job-ref'); const findJobRef = () => wrapper.findByTestId('job-ref');
const findJobSha = () => wrapper.findByTestId('job-sha'); const findJobSha = () => wrapper.findByTestId('job-sha');
const findLabelIcon = () => wrapper.findByTestId('label-icon'); const findLabelIcon = () => wrapper.findByTestId('label-icon');
...@@ -34,15 +36,24 @@ describe('Job Cell', () => { ...@@ -34,15 +36,24 @@ describe('Job Cell', () => {
}); });
describe('Job Id', () => { describe('Job Id', () => {
beforeEach(() => { it('displays the job id and links to the job', () => {
createComponent(); createComponent();
});
it('displays the job id and links to the job', () => {
const expectedJobId = `#${getIdFromGraphQLId(mockJob.id)}`; const expectedJobId = `#${getIdFromGraphQLId(mockJob.id)}`;
expect(findJobId().text()).toBe(expectedJobId); expect(findJobIdLink().text()).toBe(expectedJobId);
expect(findJobId().attributes('href')).toBe(mockJob.detailedStatus.detailsPath); expect(findJobIdLink().attributes('href')).toBe(mockJob.detailedStatus.detailsPath);
expect(findJobIdNoLink().exists()).toBe(false);
});
it('display the job id with no link', () => {
createComponent(mockJobLimitedAccess);
const expectedJobId = `#${getIdFromGraphQLId(mockJobLimitedAccess.id)}`;
expect(findJobIdNoLink().text()).toBe(expectedJobId);
expect(findJobIdNoLink().exists()).toBe(true);
expect(findJobIdLink().exists()).toBe(false);
}); });
}); });
......
...@@ -1322,6 +1322,7 @@ export const mockJobsInTable = [ ...@@ -1322,6 +1322,7 @@ export const mockJobsInTable = [
playable: true, playable: true,
cancelable: false, cancelable: false,
active: false, active: false,
userPermissions: { readBuild: true, __typename: 'JobPermissions' },
__typename: 'CiJob', __typename: 'CiJob',
}, },
{ {
...@@ -1360,6 +1361,7 @@ export const mockJobsInTable = [ ...@@ -1360,6 +1361,7 @@ export const mockJobsInTable = [
playable: false, playable: false,
cancelable: false, cancelable: false,
active: false, active: false,
userPermissions: { readBuild: true, __typename: 'JobPermissions' },
__typename: 'CiJob', __typename: 'CiJob',
}, },
{ {
...@@ -1405,6 +1407,7 @@ export const mockJobsInTable = [ ...@@ -1405,6 +1407,7 @@ export const mockJobsInTable = [
playable: false, playable: false,
cancelable: false, cancelable: false,
active: false, active: false,
userPermissions: { readBuild: false, __typename: 'JobPermissions' },
__typename: 'CiJob', __typename: 'CiJob',
}, },
]; ];
...@@ -1492,6 +1495,7 @@ export const mockJobsQueryResponse = { ...@@ -1492,6 +1495,7 @@ export const mockJobsQueryResponse = {
playable: false, playable: false,
cancelable: false, cancelable: false,
active: false, active: false,
userPermissions: { readBuild: true, __typename: 'JobPermissions' },
__typename: 'CiJob', __typename: 'CiJob',
}, },
], ],
......
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