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
Léo-Paul Géneau
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 {
...
@@ -19,6 +19,10 @@ export default {
required
:
true
,
required
:
true
,
type
:
Boolean
,
type
:
Boolean
,
},
},
canDestroy
:
{
required
:
true
,
type
:
Boolean
,
},
issuableRef
:
{
issuableRef
:
{
type
:
String
,
type
:
String
,
required
:
true
,
required
:
true
,
...
@@ -134,6 +138,7 @@ export default {
...
@@ -134,6 +138,7 @@ export default {
:updated-at=
"state.updatedAt"
:updated-at=
"state.updatedAt"
:task-status=
"state.taskStatus"
/>
:task-status=
"state.taskStatus"
/>
<edit-actions
<edit-actions
v-if=
"canUpdate && showForm"
/>
v-if=
"canUpdate && showForm"
:can-destroy=
"canDestroy"
/>
</div>
</div>
</
template
>
</
template
>
app/assets/javascripts/issue_show/components/edit_actions.vue
View file @
3bd37bc4
...
@@ -2,6 +2,12 @@
...
@@ -2,6 +2,12 @@
import
eventHub
from
'
../event_hub
'
;
import
eventHub
from
'
../event_hub
'
;
export
default
{
export
default
{
props
:
{
canDestroy
:
{
type
:
Boolean
,
required
:
true
,
},
},
data
()
{
data
()
{
return
{
return
{
deleteLoading
:
false
,
deleteLoading
:
false
,
...
@@ -50,6 +56,7 @@
...
@@ -50,6 +56,7 @@
Cancel
Cancel
</button>
</button>
<button
<button
v-if=
"canDestroy"
class=
"btn btn-danger pull-right append-right-default"
class=
"btn btn-danger pull-right append-right-default"
:class=
"
{ disabled: deleteLoading }"
:class=
"
{ disabled: deleteLoading }"
type="button"
type="button"
...
...
app/assets/javascripts/issue_show/index.js
View file @
3bd37bc4
...
@@ -22,12 +22,14 @@ document.addEventListener('DOMContentLoaded', () => {
...
@@ -22,12 +22,14 @@ document.addEventListener('DOMContentLoaded', () => {
const
issuableDescriptionTextarea
=
issuableElement
.
querySelector
(
'
.js-task-list-field
'
);
const
issuableDescriptionTextarea
=
issuableElement
.
querySelector
(
'
.js-task-list-field
'
);
const
{
const
{
canUpdate
,
canUpdate
,
canDestroy
,
endpoint
,
endpoint
,
issuableRef
,
issuableRef
,
}
=
issuableElement
.
dataset
;
}
=
issuableElement
.
dataset
;
return
{
return
{
canUpdate
:
gl
.
utils
.
convertPermissionToBoolean
(
canUpdate
),
canUpdate
:
gl
.
utils
.
convertPermissionToBoolean
(
canUpdate
),
canDestroy
:
gl
.
utils
.
convertPermissionToBoolean
(
canDestroy
),
endpoint
,
endpoint
,
issuableRef
,
issuableRef
,
initialTitle
:
issuableTitleElement
.
innerHTML
,
initialTitle
:
issuableTitleElement
.
innerHTML
,
...
@@ -56,6 +58,7 @@ document.addEventListener('DOMContentLoaded', () => {
...
@@ -56,6 +58,7 @@ document.addEventListener('DOMContentLoaded', () => {
return
createElement
(
'
issuable-app
'
,
{
return
createElement
(
'
issuable-app
'
,
{
props
:
{
props
:
{
canUpdate
:
this
.
canUpdate
,
canUpdate
:
this
.
canUpdate
,
canDestroy
:
this
.
canDestroy
,
endpoint
:
this
.
endpoint
,
endpoint
:
this
.
endpoint
,
issuableRef
:
this
.
issuableRef
,
issuableRef
:
this
.
issuableRef
,
initialTitle
:
this
.
initialTitle
,
initialTitle
:
this
.
initialTitle
,
...
...
app/views/projects/issues/show.html.haml
View file @
3bd37bc4
...
@@ -53,6 +53,7 @@
...
@@ -53,6 +53,7 @@
.detail-page-description.content-block
.detail-page-description.content-block
#js-issuable-app
{
"data"
=>
{
"endpoint"
=>
namespace_project_issue_path
(
@project
.
namespace
,
@project
,
@issue
),
#js-issuable-app
{
"data"
=>
{
"endpoint"
=>
namespace_project_issue_path
(
@project
.
namespace
,
@project
,
@issue
),
"can-update"
=>
can?
(
current_user
,
:update_issue
,
@issue
).
to_s
,
"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
,
"issuable-ref"
=>
@issue
.
to_reference
,
}
}
}
}
%h2
.title
=
markdown_field
(
@issue
,
:title
)
%h2
.title
=
markdown_field
(
@issue
,
:title
)
...
...
spec/javascripts/issue_show/components/app_spec.js
View file @
3bd37bc4
...
@@ -28,12 +28,13 @@ describe('Issuable output', () => {
...
@@ -28,12 +28,13 @@ describe('Issuable output', () => {
vm
=
new
IssuableDescriptionComponent
({
vm
=
new
IssuableDescriptionComponent
({
propsData
:
{
propsData
:
{
canUpdate
:
true
,
canUpdate
:
true
,
canDestroy
:
true
,
endpoint
:
'
/gitlab-org/gitlab-shell/issues/9/rendered_title
'
,
endpoint
:
'
/gitlab-org/gitlab-shell/issues/9/rendered_title
'
,
issuableRef
:
'
#1
'
,
issuableRef
:
'
#1
'
,
initialTitle
:
''
,
initialTitle
:
''
,
initialDescriptionHtml
:
''
,
initialDescriptionHtml
:
''
,
initialDescriptionText
:
''
,
initialDescriptionText
:
''
,
showForm
:
tru
e
,
showForm
:
fals
e
,
},
},
}).
$mount
();
}).
$mount
();
});
});
...
@@ -62,6 +63,31 @@ describe('Issuable output', () => {
...
@@ -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
'
,
()
=>
{
describe
(
'
updateIssuable
'
,
()
=>
{
it
(
'
correctly updates issuable data
'
,
(
done
)
=>
{
it
(
'
correctly updates issuable data
'
,
(
done
)
=>
{
spyOn
(
vm
.
service
,
'
updateIssuable
'
).
and
.
callFake
(()
=>
new
Promise
((
resolve
)
=>
{
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', () => {
...
@@ -10,7 +10,11 @@ describe('Edit Actions components', () => {
spyOn
(
eventHub
,
'
$emit
'
);
spyOn
(
eventHub
,
'
$emit
'
);
vm
=
new
Component
().
$mount
();
vm
=
new
Component
({
propsData
:
{
canDestroy
:
true
,
},
}).
$mount
();
Vue
.
nextTick
(
done
);
Vue
.
nextTick
(
done
);
});
});
...
@@ -25,6 +29,18 @@ describe('Edit Actions components', () => {
...
@@ -25,6 +29,18 @@ describe('Edit Actions components', () => {
).
toBe
(
0
);
).
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
'
,
()
=>
{
describe
(
'
updateIssuable
'
,
()
=>
{
it
(
'
sends update.issauble event when clicking save button
'
,
()
=>
{
it
(
'
sends update.issauble event when clicking save button
'
,
()
=>
{
vm
.
$el
.
querySelector
(
'
.btn-save
'
).
click
();
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