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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
3bd37bc4
Commit
3bd37bc4
authored
May 12, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Shows delete button if permissions are correct
[ci skip]
parent
86700b97
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
61 additions
and
3 deletions
+61
-3
app/assets/javascripts/issue_show/components/app.vue
app/assets/javascripts/issue_show/components/app.vue
+6
-1
app/assets/javascripts/issue_show/components/edit_actions.vue
...assets/javascripts/issue_show/components/edit_actions.vue
+7
-0
app/assets/javascripts/issue_show/index.js
app/assets/javascripts/issue_show/index.js
+3
-0
app/views/projects/issues/show.html.haml
app/views/projects/issues/show.html.haml
+1
-0
spec/javascripts/issue_show/components/app_spec.js
spec/javascripts/issue_show/components/app_spec.js
+27
-1
spec/javascripts/issue_show/components/edit_actions_spec.js
spec/javascripts/issue_show/components/edit_actions_spec.js
+17
-1
No files found.
app/assets/javascripts/issue_show/components/app.vue
View file @
3bd37bc4
...
...
@@ -19,6 +19,10 @@ export default {
required
:
true
,
type
:
Boolean
,
},
canDestroy
:
{
required
:
true
,
type
:
Boolean
,
},
issuableRef
:
{
type
:
String
,
required
:
true
,
...
...
@@ -134,6 +138,7 @@ export default {
:updated-at=
"state.updatedAt"
:task-status=
"state.taskStatus"
/>
<edit-actions
v-if=
"canUpdate && showForm"
/>
v-if=
"canUpdate && showForm"
:can-destroy=
"canDestroy"
/>
</div>
</
template
>
app/assets/javascripts/issue_show/components/edit_actions.vue
View file @
3bd37bc4
...
...
@@ -2,6 +2,12 @@
import
eventHub
from
'
../event_hub
'
;
export
default
{
props
:
{
canDestroy
:
{
type
:
Boolean
,
required
:
true
,
},
},
data
()
{
return
{
deleteLoading
:
false
,
...
...
@@ -50,6 +56,7 @@
Cancel
</button>
<button
v-if=
"canDestroy"
class=
"btn btn-danger pull-right append-right-default"
:class=
"
{ disabled: deleteLoading }"
type="button"
...
...
app/assets/javascripts/issue_show/index.js
View file @
3bd37bc4
...
...
@@ -22,12 +22,14 @@ document.addEventListener('DOMContentLoaded', () => {
const
issuableDescriptionTextarea
=
issuableElement
.
querySelector
(
'
.js-task-list-field
'
);
const
{
canUpdate
,
canDestroy
,
endpoint
,
issuableRef
,
}
=
issuableElement
.
dataset
;
return
{
canUpdate
:
gl
.
utils
.
convertPermissionToBoolean
(
canUpdate
),
canDestroy
:
gl
.
utils
.
convertPermissionToBoolean
(
canDestroy
),
endpoint
,
issuableRef
,
initialTitle
:
issuableTitleElement
.
innerHTML
,
...
...
@@ -56,6 +58,7 @@ document.addEventListener('DOMContentLoaded', () => {
return
createElement
(
'
issuable-app
'
,
{
props
:
{
canUpdate
:
this
.
canUpdate
,
canDestroy
:
this
.
canDestroy
,
endpoint
:
this
.
endpoint
,
issuableRef
:
this
.
issuableRef
,
initialTitle
:
this
.
initialTitle
,
...
...
app/views/projects/issues/show.html.haml
View file @
3bd37bc4
...
...
@@ -53,6 +53,7 @@
.detail-page-description.content-block
#js-issuable-app
{
"data"
=>
{
"endpoint"
=>
namespace_project_issue_path
(
@project
.
namespace
,
@project
,
@issue
),
"can-update"
=>
can?
(
current_user
,
:update_issue
,
@issue
).
to_s
,
"can-destroy"
=>
can?
(
current_user
,
:destroy_issue
,
@issue
).
to_s
,
"issuable-ref"
=>
@issue
.
to_reference
,
}
}
%h2
.title
=
markdown_field
(
@issue
,
:title
)
...
...
spec/javascripts/issue_show/components/app_spec.js
View file @
3bd37bc4
...
...
@@ -28,12 +28,13 @@ describe('Issuable output', () => {
vm
=
new
IssuableDescriptionComponent
({
propsData
:
{
canUpdate
:
true
,
canDestroy
:
true
,
endpoint
:
'
/gitlab-org/gitlab-shell/issues/9/rendered_title
'
,
issuableRef
:
'
#1
'
,
initialTitle
:
''
,
initialDescriptionHtml
:
''
,
initialDescriptionText
:
''
,
showForm
:
tru
e
,
showForm
:
fals
e
,
},
}).
$mount
();
});
...
...
@@ -62,6 +63,31 @@ describe('Issuable output', () => {
});
});
it
(
'
shows actions if permissions are correct
'
,
(
done
)
=>
{
vm
.
showForm
=
true
;
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.btn
'
),
).
not
.
toBeNull
();
done
();
});
});
it
(
'
does not show actions if permissions are incorrect
'
,
(
done
)
=>
{
vm
.
showForm
=
true
;
vm
.
canUpdate
=
false
;
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.btn
'
),
).
toBeNull
();
done
();
});
});
describe
(
'
updateIssuable
'
,
()
=>
{
it
(
'
correctly updates issuable data
'
,
(
done
)
=>
{
spyOn
(
vm
.
service
,
'
updateIssuable
'
).
and
.
callFake
(()
=>
new
Promise
((
resolve
)
=>
{
...
...
spec/javascripts/issue_show/components/edit_actions_spec.js
View file @
3bd37bc4
...
...
@@ -10,7 +10,11 @@ describe('Edit Actions components', () => {
spyOn
(
eventHub
,
'
$emit
'
);
vm
=
new
Component
().
$mount
();
vm
=
new
Component
({
propsData
:
{
canDestroy
:
true
,
},
}).
$mount
();
Vue
.
nextTick
(
done
);
});
...
...
@@ -25,6 +29,18 @@ describe('Edit Actions components', () => {
).
toBe
(
0
);
});
it
(
'
does not render delete button if canUpdate is false
'
,
(
done
)
=>
{
vm
.
canDestroy
=
false
;
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.btn-danger
'
),
).
toBeNull
();
done
();
});
});
describe
(
'
updateIssuable
'
,
()
=>
{
it
(
'
sends update.issauble event when clicking save button
'
,
()
=>
{
vm
.
$el
.
querySelector
(
'
.btn-save
'
).
click
();
...
...
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