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
f698f167
Commit
f698f167
authored
Jan 10, 2020
by
Natalia Tepluhina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added cancel button
- replaced button with GlButton components
parent
d4fcc206
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
146 additions
and
30 deletions
+146
-30
ee/app/assets/javascripts/design_management/components/design_notes/design_discussion.vue
..._management/components/design_notes/design_discussion.vue
+1
-0
ee/app/assets/javascripts/design_management/components/design_notes/design_reply_form.vue
..._management/components/design_notes/design_reply_form.vue
+46
-23
ee/changelogs/unreleased/37420-add-ability-to-cancel-a-design-discussion-that-has-not-been-submitt.yml
...-cancel-a-design-discussion-that-has-not-been-submitt.yml
+5
-0
ee/spec/frontend/design_management/components/design_notes/design_discussion_spec.js
...agement/components/design_notes/design_discussion_spec.js
+19
-0
ee/spec/frontend/design_management/components/design_notes/design_reply_form_spec.js
...agement/components/design_notes/design_reply_form_spec.js
+35
-7
ee/spec/frontend/design_management/pages/design/index_spec.js
...pec/frontend/design_management/pages/design/index_spec.js
+28
-0
locale/gitlab.pot
locale/gitlab.pot
+12
-0
No files found.
ee/app/assets/javascripts/design_management/components/design_notes/design_discussion.vue
View file @
f698f167
...
...
@@ -86,6 +86,7 @@ export default {
},
hideForm
()
{
this
.
isFormRendered
=
false
;
this
.
discussionComment
=
''
;
},
showForm
()
{
this
.
isFormRendered
=
true
;
...
...
ee/app/assets/javascripts/design_management/components/design_notes/design_reply_form.vue
View file @
f698f167
<
script
>
import
{
GlButton
,
GlModal
}
from
'
@gitlab/ui
'
;
import
MarkdownField
from
'
~/vue_shared/components/markdown/field.vue
'
;
export
default
{
name
:
'
DesignReplyForm
'
,
components
:
{
MarkdownField
,
GlButton
,
GlModal
,
},
props
:
{
markdownPreviewPath
:
{
...
...
@@ -33,12 +36,19 @@ export default {
submitForm
()
{
if
(
this
.
hasValue
)
this
.
$emit
(
'
submitForm
'
);
},
cancelComment
()
{
if
(
this
.
hasValue
)
{
this
.
$refs
.
cancelCommentModal
.
show
();
}
else
{
this
.
$emit
(
'
cancelForm
'
);
}
},
},
};
</
script
>
<
template
>
<form
class=
"new-note common-note-form"
>
<form
class=
"new-note common-note-form"
@
submit
.
prevent
>
<markdown-field
:markdown-preview-path=
"markdownPreviewPath"
:can-attach-file=
"false"
...
...
@@ -46,8 +56,8 @@ export default {
markdown-docs-path=
"/help/user/markdown"
class=
"bordered-box"
>
<template
#textarea
>
<textarea
slot=
"textarea"
ref=
"textarea"
:value=
"value"
class=
"note-textarea js-gfm-input js-autosize markdown-area"
...
...
@@ -59,21 +69,34 @@ export default {
@
input=
"$emit('input', $event.target.value)"
@
keydown.meta.enter=
"submitForm"
@
keydown.ctrl.enter=
"submitForm"
@
keyup.esc.stop=
"$emit('cancelForm')
"
@
keyup.esc.stop=
"cancelComment
"
>
</textarea>
</
template
>
</markdown-field>
<div
class=
"note-form-actions"
>
<button
<div
class=
"note-form-actions d-flex justify-content-between"
>
<gl-button
ref=
"submitButton"
:disabled=
"!hasValue || isSaving"
class=
"btn btn-success js-comment-button js-comment-submit-button
"
variant=
"success
"
type=
"submit"
data-track-event=
"click_button"
data-qa-selector=
"save_comment_button"
@
click
.prevent
=
"$emit('submitForm')"
@
click=
"$emit('submitForm')"
>
{{
__
(
'
Save comment
'
)
}}
</button>
{{ __('Comment') }}
</gl-button>
<gl-button
ref=
"cancelButton"
@
click=
"cancelComment"
>
{{ __('Cancel') }}
</gl-button>
</div>
<gl-modal
ref=
"cancelCommentModal"
ok-variant=
"danger"
:title=
"s__('DesignManagement|Cancel comment confirmation')"
:ok-title=
"s__('DesignManagement|Discard comment')"
:cancel-title=
"s__('DesignManagement|Keep comment')"
modal-id=
"cancel-comment-modal"
@
ok=
"$emit('cancelForm')"
>
{{ s__('DesignManagement|Are you sure you want to cancel creating this comment?') }}
</gl-modal>
</form>
</template>
ee/changelogs/unreleased/37420-add-ability-to-cancel-a-design-discussion-that-has-not-been-submitt.yml
0 → 100644
View file @
f698f167
---
title
:
Add ability to cancel a design discussion
merge_request
:
22241
author
:
type
:
added
ee/spec/frontend/design_management/components/design_notes/design_discussion_spec.js
View file @
f698f167
...
...
@@ -99,4 +99,23 @@ describe('Design discussions component', () => {
expect
(
findReplyForm
().
exists
()).
toBe
(
false
);
});
});
it
(
'
clears the discussion comment on closing comment form
'
,
()
=>
{
wrapper
.
setData
({
discussionComment
:
'
test
'
,
isFormRendered
:
true
,
});
return
wrapper
.
vm
.
$nextTick
()
.
then
(()
=>
{
findReplyForm
().
vm
.
$emit
(
'
cancelForm
'
);
expect
(
wrapper
.
vm
.
discussionComment
).
toBe
(
''
);
return
wrapper
.
vm
.
$nextTick
();
})
.
then
(()
=>
{
expect
(
findReplyForm
().
exists
()).
toBe
(
false
);
});
});
});
ee/spec/frontend/design_management/components/design_notes/design_reply_form_spec.js
View file @
f698f167
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
GlModal
}
from
'
@gitlab/ui
'
;
import
MarkdownField
from
'
~/vue_shared/components/markdown/field.vue
'
;
import
DesignReplyForm
from
'
ee/design_management/components/design_notes/design_reply_form.vue
'
;
...
...
@@ -6,7 +8,9 @@ describe('Design reply form component', () => {
let
wrapper
;
const
findTextarea
=
()
=>
wrapper
.
find
(
'
textarea
'
);
const
findSubmitButton
=
()
=>
wrapper
.
find
(
'
.js-comment-submit-button
'
);
const
findSubmitButton
=
()
=>
wrapper
.
find
({
ref
:
'
submitButton
'
});
const
findCancelButton
=
()
=>
wrapper
.
find
({
ref
:
'
cancelButton
'
});
const
findModal
=
()
=>
wrapper
.
find
({
ref
:
'
cancelCommentModal
'
});
function
createComponent
(
props
=
{})
{
wrapper
=
shallowMount
(
DesignReplyForm
,
{
...
...
@@ -15,6 +19,7 @@ describe('Design reply form component', () => {
isSaving
:
false
,
...
props
,
},
stubs
:
{
MarkdownField
,
GlModal
},
});
}
...
...
@@ -58,6 +63,18 @@ describe('Design reply form component', () => {
expect
(
wrapper
.
emitted
(
'
submitForm
'
)).
toBeFalsy
();
});
});
it
(
'
emits cancelForm event on pressing escape button on textarea
'
,
()
=>
{
findTextarea
().
trigger
(
'
keyup.esc
'
);
expect
(
wrapper
.
emitted
(
'
cancelForm
'
)).
toBeTruthy
();
});
it
(
'
emits cancelForm event on clicking Cancel button
'
,
()
=>
{
findCancelButton
().
vm
.
$emit
(
'
click
'
);
expect
(
wrapper
.
emitted
(
'
cancelForm
'
)).
toHaveLength
(
1
);
});
});
describe
(
'
when form has text
'
,
()
=>
{
...
...
@@ -71,8 +88,8 @@ describe('Design reply form component', () => {
expect
(
findSubmitButton
().
attributes
().
disabled
).
toBeFalsy
();
});
it
(
'
emits submitForm event on button click
'
,
()
=>
{
findSubmitButton
().
trigger
(
'
click
'
);
it
(
'
emits submitForm event on
Comment
button click
'
,
()
=>
{
findSubmitButton
().
vm
.
$emit
(
'
click
'
);
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
expect
(
wrapper
.
emitted
(
'
submitForm
'
)).
toBeTruthy
();
...
...
@@ -107,12 +124,23 @@ describe('Design reply form component', () => {
});
});
it
(
'
emits cancelForm event on pressing escape button on textarea
'
,
()
=>
{
it
(
'
opens confirmation modal on pressing Escape button
'
,
()
=>
{
findTextarea
().
trigger
(
'
keyup.esc
'
);
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
expect
(
wrapper
.
emitted
(
'
cancelForm
'
)).
toBeTruthy
();
expect
(
findModal
().
exists
()).
toBe
(
true
);
});
it
(
'
opens confirmation modal on Cancel button click
'
,
()
=>
{
findCancelButton
().
vm
.
$emit
(
'
click
'
);
expect
(
findModal
().
exists
()).
toBe
(
true
);
});
it
(
'
emits cancelForm event on modal Ok button click
'
,
()
=>
{
findTextarea
().
trigger
(
'
keyup.esc
'
);
findModal
().
vm
.
$emit
(
'
ok
'
);
expect
(
wrapper
.
emitted
(
'
cancelForm
'
)).
toBeTruthy
();
});
});
});
ee/spec/frontend/design_management/pages/design/index_spec.js
View file @
f698f167
...
...
@@ -199,6 +199,33 @@ describe('Design management design index page', () => {
});
});
it
(
'
closes the form and clears the comment on canceling form
'
,
()
=>
{
setDesign
();
wrapper
.
setData
({
design
:
{
...
design
,
discussions
:
{
edges
:
[],
},
},
annotationCoordinates
,
comment
:
newComment
,
});
return
wrapper
.
vm
.
$nextTick
()
.
then
(()
=>
{
findDiscussionForm
().
vm
.
$emit
(
'
cancelForm
'
);
expect
(
wrapper
.
vm
.
comment
).
toBe
(
''
);
return
wrapper
.
vm
.
$nextTick
();
})
.
then
(()
=>
{
expect
(
findDiscussionForm
().
exists
()).
toBe
(
false
);
});
});
describe
(
'
with error
'
,
()
=>
{
beforeEach
(()
=>
{
setDesign
();
...
...
@@ -213,6 +240,7 @@ describe('Design management design index page', () => {
errorMessage
:
'
woops
'
,
});
});
it
(
'
GlAlert is rendered in correct position with correct content
'
,
()
=>
{
expect
(
wrapper
.
element
).
toMatchSnapshot
();
});
...
...
locale/gitlab.pot
View file @
f698f167
...
...
@@ -6156,9 +6156,15 @@ msgstr ""
msgid "DesignManagement|Adding a design with the same filename replaces the file in a new version."
msgstr ""
msgid "DesignManagement|Are you sure you want to cancel creating this comment?"
msgstr ""
msgid "DesignManagement|Are you sure you want to delete the selected designs?"
msgstr ""
msgid "DesignManagement|Cancel comment confirmation"
msgstr ""
msgid "DesignManagement|Could not add a new comment. Please try again."
msgstr ""
...
...
@@ -6177,6 +6183,9 @@ msgstr ""
msgid "DesignManagement|Deselect all"
msgstr ""
msgid "DesignManagement|Discard comment"
msgstr ""
msgid "DesignManagement|Error uploading a new design. Please try again."
msgstr ""
...
...
@@ -6189,6 +6198,9 @@ msgstr ""
msgid "DesignManagement|Go to previous design"
msgstr ""
msgid "DesignManagement|Keep comment"
msgstr ""
msgid "DesignManagement|Requested design version does not exist. Showing latest version instead"
msgstr ""
...
...
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