Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
78fa47db
Commit
78fa47db
authored
Dec 02, 2021
by
Payton Burdette
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix user permissions for job
Do not show retry button to user if they cannot update the build.
parent
afc27f2f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
5 deletions
+57
-5
app/assets/javascripts/jobs/components/table/cells/actions_cell.vue
.../javascripts/jobs/components/table/cells/actions_cell.vue
+4
-1
app/assets/javascripts/jobs/components/table/graphql/queries/get_jobs.query.graphql
...s/components/table/graphql/queries/get_jobs.query.graphql
+1
-0
spec/frontend/jobs/components/table/cells/actions_cell_spec.js
...frontend/jobs/components/table/cells/actions_cell_spec.js
+19
-1
spec/frontend/jobs/mock_data.js
spec/frontend/jobs/mock_data.js
+33
-3
No files found.
app/assets/javascripts/jobs/components/table/cells/actions_cell.vue
View file @
78fa47db
...
@@ -64,6 +64,9 @@ export default {
...
@@ -64,6 +64,9 @@ export default {
canReadJob
()
{
canReadJob
()
{
return
this
.
job
.
userPermissions
?.
readBuild
;
return
this
.
job
.
userPermissions
?.
readBuild
;
},
},
canUpdateJob
()
{
return
this
.
job
.
userPermissions
?.
updateBuild
;
},
isActive
()
{
isActive
()
{
return
this
.
job
.
active
;
return
this
.
job
.
active
;
},
},
...
@@ -139,7 +142,7 @@ export default {
...
@@ -139,7 +142,7 @@ export default {
<
template
>
<
template
>
<gl-button-group>
<gl-button-group>
<template
v-if=
"canReadJob"
>
<template
v-if=
"canReadJob
&& canUpdateJob
"
>
<gl-button
<gl-button
v-if=
"isActive"
v-if=
"isActive"
data-testid=
"cancel-button"
data-testid=
"cancel-button"
...
...
app/assets/javascripts/jobs/components/table/graphql/queries/get_jobs.query.graphql
View file @
78fa47db
...
@@ -75,6 +75,7 @@ query getJobs(
...
@@ -75,6 +75,7 @@ query getJobs(
userPermissions
{
userPermissions
{
readBuild
readBuild
readJobArtifacts
readJobArtifacts
updateBuild
}
}
}
}
}
}
...
...
spec/frontend/jobs/components/table/cells/actions_cell_spec.js
View file @
78fa47db
...
@@ -5,7 +5,14 @@ import ActionsCell from '~/jobs/components/table/cells/actions_cell.vue';
...
@@ -5,7 +5,14 @@ import ActionsCell from '~/jobs/components/table/cells/actions_cell.vue';
import
JobPlayMutation
from
'
~/jobs/components/table/graphql/mutations/job_play.mutation.graphql
'
;
import
JobPlayMutation
from
'
~/jobs/components/table/graphql/mutations/job_play.mutation.graphql
'
;
import
JobRetryMutation
from
'
~/jobs/components/table/graphql/mutations/job_retry.mutation.graphql
'
;
import
JobRetryMutation
from
'
~/jobs/components/table/graphql/mutations/job_retry.mutation.graphql
'
;
import
JobUnscheduleMutation
from
'
~/jobs/components/table/graphql/mutations/job_unschedule.mutation.graphql
'
;
import
JobUnscheduleMutation
from
'
~/jobs/components/table/graphql/mutations/job_unschedule.mutation.graphql
'
;
import
{
playableJob
,
retryableJob
,
scheduledJob
}
from
'
../../../mock_data
'
;
import
{
playableJob
,
retryableJob
,
scheduledJob
,
cannotRetryJob
,
cannotPlayJob
,
cannotPlayScheduledJob
,
}
from
'
../../../mock_data
'
;
describe
(
'
Job actions cell
'
,
()
=>
{
describe
(
'
Job actions cell
'
,
()
=>
{
let
wrapper
;
let
wrapper
;
...
@@ -57,6 +64,17 @@ describe('Job actions cell', () => {
...
@@ -57,6 +64,17 @@ describe('Job actions cell', () => {
expect
(
findDownloadArtifactsButton
().
exists
()).
toBe
(
false
);
expect
(
findDownloadArtifactsButton
().
exists
()).
toBe
(
false
);
});
});
it
.
each
`
button | action | jobType
${
findPlayButton
}
|
${
'
play
'
}
|
${
cannotPlayJob
}
${
findRetryButton
}
|
${
'
retry
'
}
|
${
cannotRetryJob
}
${
findPlayScheduledJobButton
}
|
${
'
download artifacts
'
}
|
${
cannotPlayScheduledJob
}
`
(
'
does not display the $action button if user cannot update build
'
,
({
button
,
jobType
})
=>
{
createComponent
(
jobType
);
expect
(
button
().
exists
()).
toBe
(
false
);
});
it
.
each
`
it
.
each
`
button | action | jobType
button | action | jobType
${
findPlayButton
}
|
${
'
play
'
}
|
${
playableJob
}
${
findPlayButton
}
|
${
'
play
'
}
|
${
playableJob
}
...
...
spec/frontend/jobs/mock_data.js
View file @
78fa47db
...
@@ -1636,10 +1636,15 @@ export const retryableJob = {
...
@@ -1636,10 +1636,15 @@ export const retryableJob = {
cancelable
:
false
,
cancelable
:
false
,
active
:
false
,
active
:
false
,
stuck
:
false
,
stuck
:
false
,
userPermissions
:
{
readBuild
:
true
,
__typename
:
'
JobPermissions
'
},
userPermissions
:
{
readBuild
:
true
,
updateBuild
:
true
,
__typename
:
'
JobPermissions
'
},
__typename
:
'
CiJob
'
,
__typename
:
'
CiJob
'
,
};
};
export
const
cannotRetryJob
=
{
...
retryableJob
,
userPermissions
:
{
readBuild
:
true
,
updateBuild
:
false
,
__typename
:
'
JobPermissions
'
},
};
export
const
playableJob
=
{
export
const
playableJob
=
{
artifacts
:
{
artifacts
:
{
nodes
:
[
nodes
:
[
...
@@ -1700,10 +1705,25 @@ export const playableJob = {
...
@@ -1700,10 +1705,25 @@ export const playableJob = {
cancelable
:
false
,
cancelable
:
false
,
active
:
false
,
active
:
false
,
stuck
:
false
,
stuck
:
false
,
userPermissions
:
{
readBuild
:
true
,
readJobArtifacts
:
true
,
__typename
:
'
JobPermissions
'
},
userPermissions
:
{
readBuild
:
true
,
readJobArtifacts
:
true
,
updateBuild
:
true
,
__typename
:
'
JobPermissions
'
,
},
__typename
:
'
CiJob
'
,
__typename
:
'
CiJob
'
,
};
};
export
const
cannotPlayJob
=
{
...
playableJob
,
userPermissions
:
{
readBuild
:
true
,
readJobArtifacts
:
true
,
updateBuild
:
false
,
__typename
:
'
JobPermissions
'
,
},
};
export
const
scheduledJob
=
{
export
const
scheduledJob
=
{
artifacts
:
{
nodes
:
[],
__typename
:
'
CiJobArtifactConnection
'
},
artifacts
:
{
nodes
:
[],
__typename
:
'
CiJobArtifactConnection
'
},
allowFailure
:
false
,
allowFailure
:
false
,
...
@@ -1756,6 +1776,16 @@ export const scheduledJob = {
...
@@ -1756,6 +1776,16 @@ export const scheduledJob = {
cancelable
:
false
,
cancelable
:
false
,
active
:
false
,
active
:
false
,
stuck
:
false
,
stuck
:
false
,
userPermissions
:
{
readBuild
:
true
,
__typename
:
'
JobPermissions
'
},
userPermissions
:
{
readBuild
:
true
,
updateBuild
:
true
,
__typename
:
'
JobPermissions
'
},
__typename
:
'
CiJob
'
,
__typename
:
'
CiJob
'
,
};
};
export
const
cannotPlayScheduledJob
=
{
...
scheduledJob
,
userPermissions
:
{
readBuild
:
true
,
readJobArtifacts
:
true
,
updateBuild
:
false
,
__typename
:
'
JobPermissions
'
,
},
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment