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
2defec23
Commit
2defec23
authored
Jan 26, 2021
by
Nadia Sotnikova
Committed by
Paul Slaughter
Jan 26, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate to GlButton in note_form
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/42221
parent
6e61ded5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
52 deletions
+68
-52
app/assets/javascripts/notes/components/note_form.vue
app/assets/javascripts/notes/components/note_form.vue
+48
-37
changelogs/unreleased/229293-migrate-to-GlButton-note-form.yml
...elogs/unreleased/229293-migrate-to-GlButton-note-form.yml
+5
-0
spec/features/merge_request/user_posts_notes_spec.rb
spec/features/merge_request/user_posts_notes_spec.rb
+1
-1
spec/frontend/notes/components/note_form_spec.js
spec/frontend/notes/components/note_form_spec.js
+14
-14
No files found.
app/assets/javascripts/notes/components/note_form.vue
View file @
2defec23
<
script
>
<
script
>
/* eslint-disable vue/no-v-html */
/* eslint-disable vue/no-v-html */
import
{
mapGetters
,
mapActions
,
mapState
}
from
'
vuex
'
;
import
{
mapGetters
,
mapActions
,
mapState
}
from
'
vuex
'
;
import
{
GlButton
}
from
'
@gitlab/ui
'
;
import
{
mergeUrlParams
}
from
'
~/lib/utils/url_utility
'
;
import
{
mergeUrlParams
}
from
'
~/lib/utils/url_utility
'
;
import
eventHub
from
'
../event_hub
'
;
import
eventHub
from
'
../event_hub
'
;
import
markdownField
from
'
~/vue_shared/components/markdown/field.vue
'
;
import
markdownField
from
'
~/vue_shared/components/markdown/field.vue
'
;
...
@@ -16,6 +17,7 @@ export default {
...
@@ -16,6 +17,7 @@ export default {
components
:
{
components
:
{
markdownField
,
markdownField
,
CommentFieldLayout
,
CommentFieldLayout
,
GlButton
,
},
},
mixins
:
[
glFeatureFlagsMixin
(),
issuableStateMixin
,
resolvable
],
mixins
:
[
glFeatureFlagsMixin
(),
issuableStateMixin
,
resolvable
],
props
:
{
props
:
{
...
@@ -378,61 +380,70 @@ export default {
...
@@ -378,61 +380,70 @@ export default {
</
template
>
</
template
>
</label>
</label>
</p>
</p>
<div>
<div
class=
"gl-display-sm-flex gl-flex-wrap"
>
<button
<
gl-
button
:disabled=
"isDisabled"
:disabled=
"isDisabled"
type=
"button"
category=
"primary"
class=
"btn btn-success"
variant=
"success"
class=
"gl-mr-3"
data-qa-selector=
"start_review_button"
data-qa-selector=
"start_review_button"
@
click=
"handleAddToReview"
@
click=
"handleAddToReview"
>
>
<
template
v-if=
"hasDrafts"
>
{{
__
(
'
Add to review
'
)
}}
</
template
>
<
template
v-if=
"hasDrafts"
>
{{
__
(
'
Add to review
'
)
}}
</
template
>
<
template
v-else
>
{{
__
(
'
Start a review
'
)
}}
</
template
>
<
template
v-else
>
{{
__
(
'
Start a review
'
)
}}
</
template
>
</button>
</
gl-
button>
<button
<
gl-
button
:disabled=
"isDisabled"
:disabled=
"isDisabled"
type=
"button
"
category=
"secondary
"
class=
"btn js-comment-button
"
variant=
"default
"
data-qa-selector=
"comment_now_button"
data-qa-selector=
"comment_now_button"
class=
"gl-mr-3 js-comment-button"
@
click=
"handleUpdate()"
@
click=
"handleUpdate()"
>
>
{{ __('Add comment now') }}
{{ __('Add comment now') }}
</button>
</gl-button>
<button
<gl-button
class=
"btn note-edit-cancel js-close-discussion-note-form"
class=
"note-edit-cancel js-close-discussion-note-form"
type=
"button"
category=
"secondary"
variant=
"default"
data-testid=
"cancelBatchCommentsEnabled"
data-testid=
"cancelBatchCommentsEnabled"
@
click=
"cancelHandler(true)"
@
click=
"cancelHandler(true)"
>
>
{{ __('Cancel') }}
{{ __('Cancel') }}
</button>
</
gl-
button>
</div>
</div>
</template>
</template>
<
template
v-else
>
<
template
v-else
>
<button
<div
class=
"gl-display-sm-flex gl-flex-wrap"
>
:disabled=
"isDisabled"
<gl-button
type=
"button"
:disabled=
"isDisabled"
class=
"js-vue-issue-save btn btn-success js-comment-button"
category=
"primary"
data-qa-selector=
"reply_comment_button"
variant=
"success"
@
click=
"handleUpdate()"
data-qa-selector=
"reply_comment_button"
>
class=
"gl-mr-3 js-vue-issue-save js-comment-button"
{{
saveButtonTitle
}}
@
click=
"handleUpdate()"
</button>
>
<button
{{
saveButtonTitle
}}
v-if=
"discussion.resolvable"
</gl-button>
class=
"btn btn-default gl-mr-3 js-comment-resolve-button"
<gl-button
@
click.prevent=
"handleUpdate(true)"
v-if=
"discussion.resolvable"
>
category=
"secondary"
{{
resolveButtonTitle
}}
variant=
"default"
</button>
class=
"gl-mr-3 js-comment-resolve-button"
<button
@
click.prevent=
"handleUpdate(true)"
class=
"btn btn-cancel note-edit-cancel js-close-discussion-note-form"
>
type=
"button"
{{
resolveButtonTitle
}}
data-testid=
"cancel"
</gl-button>
@
click=
"cancelHandler(true)"
<gl-button
>
class=
"note-edit-cancel js-close-discussion-note-form"
{{
__
(
'
Cancel
'
)
}}
category=
"secondary"
</button>
variant=
"default"
data-testid=
"cancel"
@
click=
"cancelHandler(true)"
>
{{
__
(
'
Cancel
'
)
}}
</gl-button>
</div>
</
template
>
</
template
>
</div>
</div>
</form>
</form>
...
...
changelogs/unreleased/229293-migrate-to-GlButton-note-form.yml
0 → 100644
View file @
2defec23
---
title
:
Migrate button to gitlab ui in note form
merge_request
:
42221
author
:
type
:
changed
spec/features/merge_request/user_posts_notes_spec.rb
View file @
2defec23
...
@@ -161,7 +161,7 @@ RSpec.describe 'Merge request > User posts notes', :js do
...
@@ -161,7 +161,7 @@ RSpec.describe 'Merge request > User posts notes', :js do
fill_in
'note[note]'
,
with:
'Some new content'
fill_in
'note[note]'
,
with:
'Some new content'
accept_confirm
do
accept_confirm
do
find
(
'
.btn-cancel
'
).
click
find
(
'
[data-testid="cancel"]
'
).
click
end
end
end
end
expect
(
find
(
'.js-note-text'
).
text
).
to
eq
''
expect
(
find
(
'.js-note-text'
).
text
).
to
eq
''
...
...
spec/frontend/notes/components/note_form_spec.js
View file @
2defec23
...
@@ -4,9 +4,8 @@ import createStore from '~/notes/stores';
...
@@ -4,9 +4,8 @@ import createStore from '~/notes/stores';
import
NoteForm
from
'
~/notes/components/note_form.vue
'
;
import
NoteForm
from
'
~/notes/components/note_form.vue
'
;
import
batchComments
from
'
~/batch_comments/stores/modules/batch_comments
'
;
import
batchComments
from
'
~/batch_comments/stores/modules/batch_comments
'
;
import
MarkdownField
from
'
~/vue_shared/components/markdown/field.vue
'
;
import
MarkdownField
from
'
~/vue_shared/components/markdown/field.vue
'
;
import
{
noteableDataMock
,
notesDataMock
,
discussionMock
}
from
'
../mock_data
'
;
import
{
getDraft
,
updateDraft
}
from
'
~/lib/utils/autosave
'
;
import
{
getDraft
,
updateDraft
}
from
'
~/lib/utils/autosave
'
;
import
{
noteableDataMock
,
notesDataMock
,
discussionMock
}
from
'
../mock_data
'
;
jest
.
mock
(
'
~/lib/utils/autosave
'
);
jest
.
mock
(
'
~/lib/utils/autosave
'
);
...
@@ -25,6 +24,8 @@ describe('issue_note_form component', () => {
...
@@ -25,6 +24,8 @@ describe('issue_note_form component', () => {
});
});
};
};
const
findCancelButton
=
()
=>
wrapper
.
find
(
'
[data-testid="cancel"]
'
);
beforeEach
(()
=>
{
beforeEach
(()
=>
{
getDraft
.
mockImplementation
((
key
)
=>
{
getDraft
.
mockImplementation
((
key
)
=>
{
if
(
key
===
dummyAutosaveKey
)
{
if
(
key
===
dummyAutosaveKey
)
{
...
@@ -160,8 +161,8 @@ describe('issue_note_form component', () => {
...
@@ -160,8 +161,8 @@ describe('issue_note_form component', () => {
});
});
await
nextTick
();
await
nextTick
();
const
cancelButton
=
wrapper
.
find
(
'
[data-testid="cancel"]
'
);
const
cancelButton
=
findCancelButton
(
);
cancelButton
.
trigger
(
'
click
'
);
cancelButton
.
vm
.
$emit
(
'
click
'
);
await
nextTick
();
await
nextTick
();
expect
(
wrapper
.
emitted
().
cancelForm
).
toHaveLength
(
1
);
expect
(
wrapper
.
emitted
().
cancelForm
).
toHaveLength
(
1
);
...
@@ -177,7 +178,7 @@ describe('issue_note_form component', () => {
...
@@ -177,7 +178,7 @@ describe('issue_note_form component', () => {
const
textarea
=
wrapper
.
find
(
'
textarea
'
);
const
textarea
=
wrapper
.
find
(
'
textarea
'
);
textarea
.
setValue
(
'
Foo
'
);
textarea
.
setValue
(
'
Foo
'
);
const
saveButton
=
wrapper
.
find
(
'
.js-vue-issue-save
'
);
const
saveButton
=
wrapper
.
find
(
'
.js-vue-issue-save
'
);
saveButton
.
trigger
(
'
click
'
);
saveButton
.
vm
.
$emit
(
'
click
'
);
expect
(
wrapper
.
vm
.
isSubmitting
).
toBe
(
true
);
expect
(
wrapper
.
vm
.
isSubmitting
).
toBe
(
true
);
});
});
...
@@ -272,7 +273,7 @@ describe('issue_note_form component', () => {
...
@@ -272,7 +273,7 @@ describe('issue_note_form component', () => {
await
nextTick
();
await
nextTick
();
const
cancelButton
=
wrapper
.
find
(
'
[data-testid="cancelBatchCommentsEnabled"]
'
);
const
cancelButton
=
wrapper
.
find
(
'
[data-testid="cancelBatchCommentsEnabled"]
'
);
cancelButton
.
trigger
(
'
click
'
);
cancelButton
.
vm
.
$emit
(
'
click
'
);
expect
(
wrapper
.
vm
.
cancelHandler
).
toHaveBeenCalledWith
(
true
);
expect
(
wrapper
.
vm
.
cancelHandler
).
toHaveBeenCalledWith
(
true
);
});
});
...
@@ -302,16 +303,16 @@ describe('issue_note_form component', () => {
...
@@ -302,16 +303,16 @@ describe('issue_note_form component', () => {
expect
(
wrapper
.
find
(
'
.js-resolve-checkbox
'
).
exists
()).
toBe
(
false
);
expect
(
wrapper
.
find
(
'
.js-resolve-checkbox
'
).
exists
()).
toBe
(
false
);
});
});
it
(
'
hides actions for commits
'
,
()
=>
{
it
(
'
hides actions for commits
'
,
async
()
=>
{
wrapper
.
setProps
({
discussion
:
{
for_commit
:
true
}
});
wrapper
.
setProps
({
discussion
:
{
for_commit
:
true
}
});
return
nextTick
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
find
(
'
.note-form-actions
'
).
text
()).
not
.
toContain
(
'
Start a review
'
);
}
);
expect
(
wrapper
.
find
(
'
.note-form-actions
'
).
text
()).
not
.
toContain
(
'
Start a review
'
);
});
});
describe
(
'
on enter
'
,
()
=>
{
describe
(
'
on enter
'
,
()
=>
{
it
(
'
should start review or add to review when cmd+enter is pressed
'
,
()
=>
{
it
(
'
should start review or add to review when cmd+enter is pressed
'
,
async
()
=>
{
const
textarea
=
wrapper
.
find
(
'
textarea
'
);
const
textarea
=
wrapper
.
find
(
'
textarea
'
);
jest
.
spyOn
(
wrapper
.
vm
,
'
handleAddToReview
'
);
jest
.
spyOn
(
wrapper
.
vm
,
'
handleAddToReview
'
);
...
@@ -319,9 +320,8 @@ describe('issue_note_form component', () => {
...
@@ -319,9 +320,8 @@ describe('issue_note_form component', () => {
textarea
.
setValue
(
'
Foo
'
);
textarea
.
setValue
(
'
Foo
'
);
textarea
.
trigger
(
'
keydown.enter
'
,
{
metaKey
:
true
});
textarea
.
trigger
(
'
keydown.enter
'
,
{
metaKey
:
true
});
return
nextTick
(()
=>
{
await
nextTick
();
expect
(
wrapper
.
vm
.
handleAddToReview
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
handleAddToReview
).
toHaveBeenCalled
();
});
});
});
});
});
});
});
...
...
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