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
3e5c90fb
Commit
3e5c90fb
authored
Nov 26, 2020
by
jerasmus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply suggestion with custom commit message
Added the ablity to apply a suggestion with a custom commit message
parent
175e3aee
Changes
23
Show whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
119 additions
and
48 deletions
+119
-48
app/assets/javascripts/api.js
app/assets/javascripts/api.js
+2
-2
app/assets/javascripts/diffs/components/app.vue
app/assets/javascripts/diffs/components/app.vue
+6
-0
app/assets/javascripts/diffs/index.js
app/assets/javascripts/diffs/index.js
+2
-0
app/assets/javascripts/diffs/store/actions.js
app/assets/javascripts/diffs/store/actions.js
+2
-0
app/assets/javascripts/diffs/store/modules/diff_state.js
app/assets/javascripts/diffs/store/modules/diff_state.js
+1
-0
app/assets/javascripts/diffs/store/mutations.js
app/assets/javascripts/diffs/store/mutations.js
+2
-0
app/assets/javascripts/notes/components/note_body.vue
app/assets/javascripts/notes/components/note_body.vue
+10
-4
app/assets/javascripts/notes/stores/actions.js
app/assets/javascripts/notes/stores/actions.js
+2
-2
app/assets/javascripts/vue_shared/components/markdown/apply_suggestion.vue
...ripts/vue_shared/components/markdown/apply_suggestion.vue
+17
-17
app/assets/javascripts/vue_shared/components/markdown/suggestion_diff.vue
...cripts/vue_shared/components/markdown/suggestion_diff.vue
+7
-2
app/assets/javascripts/vue_shared/components/markdown/suggestion_diff_header.vue
...vue_shared/components/markdown/suggestion_diff_header.vue
+19
-4
app/assets/javascripts/vue_shared/components/markdown/suggestions.vue
...avascripts/vue_shared/components/markdown/suggestions.vue
+22
-4
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+1
-0
app/helpers/merge_requests_helper.rb
app/helpers/merge_requests_helper.rb
+4
-0
app/views/projects/merge_requests/show.html.haml
app/views/projects/merge_requests/show.html.haml
+2
-1
config/feature_flags/development/suggestions_custom_commit.yml
...g/feature_flags/development/suggestions_custom_commit.yml
+8
-0
locale/gitlab.pot
locale/gitlab.pot
+0
-6
spec/features/merge_request/user_suggests_changes_on_diff_spec.rb
...tures/merge_request/user_suggests_changes_on_diff_spec.rb
+3
-0
spec/frontend/vue_shared/components/markdown/__snapshots__/suggestion_diff_spec.js.snap
...nents/markdown/__snapshots__/suggestion_diff_spec.js.snap
+1
-0
spec/frontend/vue_shared/components/markdown/apply_suggestion_spec.js
...d/vue_shared/components/markdown/apply_suggestion_spec.js
+4
-5
spec/frontend/vue_shared/components/markdown/suggestion_diff_header_spec.js
...shared/components/markdown/suggestion_diff_header_spec.js
+2
-1
spec/frontend/vue_shared/components/markdown/suggestion_diff_spec.js
...nd/vue_shared/components/markdown/suggestion_diff_spec.js
+1
-0
spec/frontend/vue_shared/components/markdown/suggestions_spec.js
...ontend/vue_shared/components/markdown/suggestions_spec.js
+1
-0
No files found.
app/assets/javascripts/api.js
View file @
3e5c90fb
...
@@ -442,10 +442,10 @@ const Api = {
...
@@ -442,10 +442,10 @@ const Api = {
});
});
},
},
applySuggestion
(
id
)
{
applySuggestion
(
id
,
message
)
{
const
url
=
Api
.
buildUrl
(
Api
.
applySuggestionPath
).
replace
(
'
:id
'
,
encodeURIComponent
(
id
));
const
url
=
Api
.
buildUrl
(
Api
.
applySuggestionPath
).
replace
(
'
:id
'
,
encodeURIComponent
(
id
));
return
axios
.
put
(
url
);
return
axios
.
put
(
url
,
{
commit_message
:
message
}
);
},
},
applySuggestionBatch
(
ids
)
{
applySuggestionBatch
(
ids
)
{
...
...
app/assets/javascripts/diffs/components/app.vue
View file @
3e5c90fb
...
@@ -124,6 +124,11 @@ export default {
...
@@ -124,6 +124,11 @@ export default {
required
:
false
,
required
:
false
,
default
:
false
,
default
:
false
,
},
},
defaultSuggestionCommitMessage
:
{
type
:
String
,
required
:
false
,
default
:
''
,
},
mrReviews
:
{
mrReviews
:
{
type
:
Object
,
type
:
Object
,
required
:
false
,
required
:
false
,
...
@@ -268,6 +273,7 @@ export default {
...
@@ -268,6 +273,7 @@ export default {
dismissEndpoint
:
this
.
dismissEndpoint
,
dismissEndpoint
:
this
.
dismissEndpoint
,
showSuggestPopover
:
this
.
showSuggestPopover
,
showSuggestPopover
:
this
.
showSuggestPopover
,
viewDiffsFileByFile
:
fileByFile
(
this
.
fileByFileUserPreference
),
viewDiffsFileByFile
:
fileByFile
(
this
.
fileByFileUserPreference
),
defaultSuggestionCommitMessage
:
this
.
defaultSuggestionCommitMessage
,
mrReviews
:
this
.
mrReviews
||
{},
mrReviews
:
this
.
mrReviews
||
{},
});
});
...
...
app/assets/javascripts/diffs/index.js
View file @
3e5c90fb
...
@@ -83,6 +83,7 @@ export default function initDiffsApp(store) {
...
@@ -83,6 +83,7 @@ export default function initDiffsApp(store) {
showSuggestPopover
:
parseBoolean
(
dataset
.
showSuggestPopover
),
showSuggestPopover
:
parseBoolean
(
dataset
.
showSuggestPopover
),
showWhitespaceDefault
:
parseBoolean
(
dataset
.
showWhitespaceDefault
),
showWhitespaceDefault
:
parseBoolean
(
dataset
.
showWhitespaceDefault
),
viewDiffsFileByFile
:
parseBoolean
(
dataset
.
fileByFileDefault
),
viewDiffsFileByFile
:
parseBoolean
(
dataset
.
fileByFileDefault
),
defaultSuggestionCommitMessage
:
dataset
.
defaultSuggestionCommitMessage
,
};
};
},
},
computed
:
{
computed
:
{
...
@@ -123,6 +124,7 @@ export default function initDiffsApp(store) {
...
@@ -123,6 +124,7 @@ export default function initDiffsApp(store) {
dismissEndpoint
:
this
.
dismissEndpoint
,
dismissEndpoint
:
this
.
dismissEndpoint
,
showSuggestPopover
:
this
.
showSuggestPopover
,
showSuggestPopover
:
this
.
showSuggestPopover
,
fileByFileUserPreference
:
this
.
viewDiffsFileByFile
,
fileByFileUserPreference
:
this
.
viewDiffsFileByFile
,
defaultSuggestionCommitMessage
:
this
.
defaultSuggestionCommitMessage
,
mrReviews
:
getReviewsForMergeRequest
(
mrPath
),
mrReviews
:
getReviewsForMergeRequest
(
mrPath
),
},
},
});
});
...
...
app/assets/javascripts/diffs/store/actions.js
View file @
3e5c90fb
...
@@ -62,6 +62,7 @@ export const setBaseConfig = ({ commit }, options) => {
...
@@ -62,6 +62,7 @@ export const setBaseConfig = ({ commit }, options) => {
projectPath
,
projectPath
,
dismissEndpoint
,
dismissEndpoint
,
showSuggestPopover
,
showSuggestPopover
,
defaultSuggestionCommitMessage
,
viewDiffsFileByFile
,
viewDiffsFileByFile
,
mrReviews
,
mrReviews
,
}
=
options
;
}
=
options
;
...
@@ -73,6 +74,7 @@ export const setBaseConfig = ({ commit }, options) => {
...
@@ -73,6 +74,7 @@ export const setBaseConfig = ({ commit }, options) => {
projectPath
,
projectPath
,
dismissEndpoint
,
dismissEndpoint
,
showSuggestPopover
,
showSuggestPopover
,
defaultSuggestionCommitMessage
,
viewDiffsFileByFile
,
viewDiffsFileByFile
,
mrReviews
,
mrReviews
,
});
});
...
...
app/assets/javascripts/diffs/store/modules/diff_state.js
View file @
3e5c90fb
...
@@ -45,5 +45,6 @@ export default () => ({
...
@@ -45,5 +45,6 @@ export default () => ({
fileFinderVisible
:
false
,
fileFinderVisible
:
false
,
dismissEndpoint
:
''
,
dismissEndpoint
:
''
,
showSuggestPopover
:
true
,
showSuggestPopover
:
true
,
defaultSuggestionCommitMessage
:
''
,
mrReviews
:
{},
mrReviews
:
{},
});
});
app/assets/javascripts/diffs/store/mutations.js
View file @
3e5c90fb
...
@@ -36,6 +36,7 @@ export default {
...
@@ -36,6 +36,7 @@ export default {
projectPath
,
projectPath
,
dismissEndpoint
,
dismissEndpoint
,
showSuggestPopover
,
showSuggestPopover
,
defaultSuggestionCommitMessage
,
viewDiffsFileByFile
,
viewDiffsFileByFile
,
mrReviews
,
mrReviews
,
}
=
options
;
}
=
options
;
...
@@ -47,6 +48,7 @@ export default {
...
@@ -47,6 +48,7 @@ export default {
projectPath
,
projectPath
,
dismissEndpoint
,
dismissEndpoint
,
showSuggestPopover
,
showSuggestPopover
,
defaultSuggestionCommitMessage
,
viewDiffsFileByFile
,
viewDiffsFileByFile
,
mrReviews
,
mrReviews
,
});
});
...
...
app/assets/javascripts/notes/components/note_body.vue
View file @
3e5c90fb
...
@@ -54,6 +54,7 @@ export default {
...
@@ -54,6 +54,7 @@ export default {
...
mapState
({
...
mapState
({
batchSuggestionsInfo
:
(
state
)
=>
state
.
notes
.
batchSuggestionsInfo
,
batchSuggestionsInfo
:
(
state
)
=>
state
.
notes
.
batchSuggestionsInfo
,
}),
}),
...
mapState
(
'
diffs
'
,
[
'
defaultSuggestionCommitMessage
'
]),
noteBody
()
{
noteBody
()
{
return
this
.
note
.
note
;
return
this
.
note
.
note
;
},
},
...
@@ -98,12 +99,16 @@ export default {
...
@@ -98,12 +99,16 @@ export default {
formCancelHandler
(
shouldConfirm
,
isDirty
)
{
formCancelHandler
(
shouldConfirm
,
isDirty
)
{
this
.
$emit
(
'
cancelForm
'
,
shouldConfirm
,
isDirty
);
this
.
$emit
(
'
cancelForm
'
,
shouldConfirm
,
isDirty
);
},
},
applySuggestion
({
suggestionId
,
flashContainer
,
callback
=
()
=>
{}
})
{
applySuggestion
({
suggestionId
,
flashContainer
,
callback
=
()
=>
{}
,
message
})
{
const
{
discussion_id
:
discussionId
,
id
:
noteId
}
=
this
.
note
;
const
{
discussion_id
:
discussionId
,
id
:
noteId
}
=
this
.
note
;
return
this
.
submitSuggestion
({
discussionId
,
noteId
,
suggestionId
,
flashContainer
}).
then
(
return
this
.
submitSuggestion
({
callback
,
discussionId
,
);
noteId
,
suggestionId
,
flashContainer
,
message
,
}).
then
(
callback
);
},
},
applySuggestionBatch
({
flashContainer
})
{
applySuggestionBatch
({
flashContainer
})
{
return
this
.
submitSuggestionBatch
({
flashContainer
});
return
this
.
submitSuggestionBatch
({
flashContainer
});
...
@@ -130,6 +135,7 @@ export default {
...
@@ -130,6 +135,7 @@ export default {
:note-html=
"note.note_html"
:note-html=
"note.note_html"
:line-type=
"lineType"
:line-type=
"lineType"
:help-page-path=
"helpPagePath"
:help-page-path=
"helpPagePath"
:default-commit-message=
"defaultSuggestionCommitMessage"
@
apply=
"applySuggestion"
@
apply=
"applySuggestion"
@
applyBatch=
"applySuggestionBatch"
@
applyBatch=
"applySuggestionBatch"
@
addToBatch=
"addSuggestionToBatch"
@
addToBatch=
"addSuggestionToBatch"
...
...
app/assets/javascripts/notes/stores/actions.js
View file @
3e5c90fb
...
@@ -559,7 +559,7 @@ export const updateResolvableDiscussionsCounts = ({ commit }) =>
...
@@ -559,7 +559,7 @@ export const updateResolvableDiscussionsCounts = ({ commit }) =>
export
const
submitSuggestion
=
(
export
const
submitSuggestion
=
(
{
commit
,
dispatch
},
{
commit
,
dispatch
},
{
discussionId
,
suggestionId
,
flashContainer
},
{
discussionId
,
suggestionId
,
flashContainer
,
message
},
)
=>
{
)
=>
{
const
dispatchResolveDiscussion
=
()
=>
const
dispatchResolveDiscussion
=
()
=>
dispatch
(
'
resolveDiscussion
'
,
{
discussionId
}).
catch
(()
=>
{});
dispatch
(
'
resolveDiscussion
'
,
{
discussionId
}).
catch
(()
=>
{});
...
@@ -567,7 +567,7 @@ export const submitSuggestion = (
...
@@ -567,7 +567,7 @@ export const submitSuggestion = (
commit
(
types
.
SET_RESOLVING_DISCUSSION
,
true
);
commit
(
types
.
SET_RESOLVING_DISCUSSION
,
true
);
dispatch
(
'
stopPolling
'
);
dispatch
(
'
stopPolling
'
);
return
Api
.
applySuggestion
(
suggestionId
)
return
Api
.
applySuggestion
(
suggestionId
,
message
)
.
then
(
dispatchResolveDiscussion
)
.
then
(
dispatchResolveDiscussion
)
.
catch
((
err
)
=>
{
.
catch
((
err
)
=>
{
const
defaultMessage
=
__
(
const
defaultMessage
=
__
(
...
...
app/assets/javascripts/vue_shared/components/markdown/apply_suggestion.vue
View file @
3e5c90fb
<
script
>
<
script
>
import
{
GlDropdown
,
GlDropdownForm
,
GlFormTextarea
,
GlButton
}
from
'
@gitlab/ui
'
;
import
{
GlDropdown
,
GlDropdownForm
,
GlFormTextarea
,
GlButton
}
from
'
@gitlab/ui
'
;
import
{
__
,
sprintf
}
from
'
~/locale
'
;
export
default
{
export
default
{
components
:
{
GlDropdown
,
GlDropdownForm
,
GlFormTextarea
,
GlButton
},
components
:
{
GlDropdown
,
GlDropdownForm
,
GlFormTextarea
,
GlButton
},
...
@@ -10,7 +9,7 @@ export default {
...
@@ -10,7 +9,7 @@ export default {
required
:
false
,
required
:
false
,
default
:
false
,
default
:
false
,
},
},
fileNam
e
:
{
defaultCommitMessag
e
:
{
type
:
String
,
type
:
String
,
required
:
true
,
required
:
true
,
},
},
...
@@ -18,18 +17,11 @@ export default {
...
@@ -18,18 +17,11 @@ export default {
data
()
{
data
()
{
return
{
return
{
message
:
null
,
message
:
null
,
buttonText
:
__
(
'
Apply suggestion
'
),
headerText
:
__
(
'
Apply suggestion commit message
'
),
};
};
},
},
computed
:
{
placeholderText
()
{
return
sprintf
(
__
(
'
Apply suggestion on %{fileName}
'
),
{
fileName
:
this
.
fileName
});
},
},
methods
:
{
methods
:
{
onApply
()
{
onApply
()
{
this
.
$emit
(
'
apply
'
,
this
.
message
||
this
.
placeholderText
);
this
.
$emit
(
'
apply
'
,
this
.
message
);
},
},
},
},
};
};
...
@@ -37,18 +29,26 @@ export default {
...
@@ -37,18 +29,26 @@ export default {
<
template
>
<
template
>
<gl-dropdown
<gl-dropdown
:text=
"buttonText"
:text=
"__('Apply suggestion')"
:header-text=
"headerText"
:disabled=
"disabled"
:disabled=
"disabled"
boundary=
"window"
boundary=
"window"
right
right
menu-class=
"gl-w-full! gl-pb-0!"
menu-class=
"gl-w-full!"
@
shown=
"$refs.commitMessage.$el.focus()"
>
>
<gl-dropdown-form
class=
"gl-m-3!"
>
<gl-dropdown-form
class=
"gl-px-4! gl-m-0!"
>
<gl-form-textarea
v-model=
"message"
:placeholder=
"placeholderText"
/>
<label
for=
"commit-message"
>
{{
__
(
'
Commit message
'
)
}}
</label>
<gl-form-textarea
id=
"commit-message"
ref=
"commitMessage"
v-model=
"message"
:placeholder=
"defaultCommitMessage"
submit-on-enter
@
submit=
"onApply"
/>
<gl-button
<gl-button
class=
"gl-w-
quarter! gl-mt-3 gl-text-center
! float-right"
class=
"gl-w-
auto! gl-mt-3 gl-text-center! gl-hover-text-white! gl-transition-medium
! float-right"
category=
"
second
ary"
category=
"
prim
ary"
variant=
"success"
variant=
"success"
@
click=
"onApply"
@
click=
"onApply"
>
>
...
...
app/assets/javascripts/vue_shared/components/markdown/suggestion_diff.vue
View file @
3e5c90fb
...
@@ -27,6 +27,10 @@ export default {
...
@@ -27,6 +27,10 @@ export default {
type
:
String
,
type
:
String
,
required
:
true
,
required
:
true
,
},
},
defaultCommitMessage
:
{
type
:
String
,
required
:
true
,
},
suggestionsCount
:
{
suggestionsCount
:
{
type
:
Number
,
type
:
Number
,
required
:
false
,
required
:
false
,
...
@@ -47,8 +51,8 @@ export default {
...
@@ -47,8 +51,8 @@ export default {
},
},
},
},
methods
:
{
methods
:
{
applySuggestion
(
callback
)
{
applySuggestion
(
callback
,
message
)
{
this
.
$emit
(
'
apply
'
,
{
suggestionId
:
this
.
suggestion
.
id
,
callback
});
this
.
$emit
(
'
apply
'
,
{
suggestionId
:
this
.
suggestion
.
id
,
callback
,
message
});
},
},
applySuggestionBatch
()
{
applySuggestionBatch
()
{
this
.
$emit
(
'
applyBatch
'
);
this
.
$emit
(
'
applyBatch
'
);
...
@@ -74,6 +78,7 @@ export default {
...
@@ -74,6 +78,7 @@ export default {
:is-applying-batch=
"suggestion.is_applying_batch"
:is-applying-batch=
"suggestion.is_applying_batch"
:batch-suggestions-count=
"batchSuggestionsCount"
:batch-suggestions-count=
"batchSuggestionsCount"
:help-page-path=
"helpPagePath"
:help-page-path=
"helpPagePath"
:default-commit-message=
"defaultCommitMessage"
:inapplicable-reason=
"suggestion.inapplicable_reason"
:inapplicable-reason=
"suggestion.inapplicable_reason"
@
apply=
"applySuggestion"
@
apply=
"applySuggestion"
@
applyBatch=
"applySuggestionBatch"
@
applyBatch=
"applySuggestionBatch"
...
...
app/assets/javascripts/vue_shared/components/markdown/suggestion_diff_header.vue
View file @
3e5c90fb
...
@@ -2,9 +2,10 @@
...
@@ -2,9 +2,10 @@
import
{
GlButton
,
GlLoadingIcon
,
GlTooltipDirective
,
GlIcon
}
from
'
@gitlab/ui
'
;
import
{
GlButton
,
GlLoadingIcon
,
GlTooltipDirective
,
GlIcon
}
from
'
@gitlab/ui
'
;
import
{
__
}
from
'
~/locale
'
;
import
{
__
}
from
'
~/locale
'
;
import
glFeatureFlagsMixin
from
'
~/vue_shared/mixins/gl_feature_flags_mixin
'
;
import
glFeatureFlagsMixin
from
'
~/vue_shared/mixins/gl_feature_flags_mixin
'
;
import
ApplySuggestion
from
'
./apply_suggestion.vue
'
;
export
default
{
export
default
{
components
:
{
GlIcon
,
GlButton
,
GlLoadingIcon
},
components
:
{
GlIcon
,
GlButton
,
GlLoadingIcon
,
ApplySuggestion
},
directives
:
{
'
gl-tooltip
'
:
GlTooltipDirective
},
directives
:
{
'
gl-tooltip
'
:
GlTooltipDirective
},
mixins
:
[
glFeatureFlagsMixin
()],
mixins
:
[
glFeatureFlagsMixin
()],
props
:
{
props
:
{
...
@@ -37,6 +38,10 @@ export default {
...
@@ -37,6 +38,10 @@ export default {
type
:
String
,
type
:
String
,
required
:
true
,
required
:
true
,
},
},
defaultCommitMessage
:
{
type
:
String
,
required
:
true
,
},
inapplicableReason
:
{
inapplicableReason
:
{
type
:
String
,
type
:
String
,
required
:
false
,
required
:
false
,
...
@@ -57,6 +62,9 @@ export default {
...
@@ -57,6 +62,9 @@ export default {
canBeBatched
()
{
canBeBatched
()
{
return
Boolean
(
this
.
glFeatures
.
batchSuggestions
);
return
Boolean
(
this
.
glFeatures
.
batchSuggestions
);
},
},
canAddCustomCommitMessage
()
{
return
this
.
glFeatures
.
suggestionsCustomCommit
;
},
isApplying
()
{
isApplying
()
{
return
this
.
isApplyingSingle
||
this
.
isApplyingBatch
;
return
this
.
isApplyingSingle
||
this
.
isApplyingBatch
;
},
},
...
@@ -77,10 +85,10 @@ export default {
...
@@ -77,10 +85,10 @@ export default {
},
},
},
},
methods
:
{
methods
:
{
applySuggestion
()
{
applySuggestion
(
message
)
{
if
(
!
this
.
canApply
)
return
;
if
(
!
this
.
canApply
)
return
;
this
.
isApplyingSingle
=
true
;
this
.
isApplyingSingle
=
true
;
this
.
$emit
(
'
apply
'
,
this
.
applySuggestionCallback
);
this
.
$emit
(
'
apply
'
,
this
.
applySuggestionCallback
,
message
);
},
},
applySuggestionCallback
()
{
applySuggestionCallback
()
{
this
.
isApplyingSingle
=
false
;
this
.
isApplyingSingle
=
false
;
...
@@ -142,7 +150,14 @@ export default {
...
@@ -142,7 +150,14 @@ export default {
>
>
{{
__
(
'
Add suggestion to batch
'
)
}}
{{
__
(
'
Add suggestion to batch
'
)
}}
</gl-button>
</gl-button>
<span
v-gl-tooltip.viewport=
"tooltipMessage"
tabindex=
"0"
>
<apply-suggestion
v-if=
"canAddCustomCommitMessage"
:disabled=
"isDisableButton"
:default-commit-message=
"defaultCommitMessage"
class=
"gl-ml-3"
@
apply=
"applySuggestion"
/>
<span
v-else
v-gl-tooltip.viewport=
"tooltipMessage"
tabindex=
"0"
>
<gl-button
<gl-button
v-if=
"isLoggedIn"
v-if=
"isLoggedIn"
class=
"btn-inverted js-apply-btn btn-grouped"
class=
"btn-inverted js-apply-btn btn-grouped"
...
...
app/assets/javascripts/vue_shared/components/markdown/suggestions.vue
View file @
3e5c90fb
...
@@ -38,6 +38,10 @@ export default {
...
@@ -38,6 +38,10 @@ export default {
type
:
String
,
type
:
String
,
required
:
true
,
required
:
true
,
},
},
defaultCommitMessage
:
{
type
:
String
,
required
:
true
,
},
suggestionsCount
:
{
suggestionsCount
:
{
type
:
Number
,
type
:
Number
,
required
:
false
,
required
:
false
,
...
@@ -82,16 +86,30 @@ export default {
...
@@ -82,16 +86,30 @@ export default {
this
.
isRendered
=
true
;
this
.
isRendered
=
true
;
},
},
generateDiff
(
suggestionIndex
)
{
generateDiff
(
suggestionIndex
)
{
const
{
suggestions
,
disabled
,
batchSuggestionsInfo
,
helpPagePath
,
suggestionsCount
}
=
this
;
const
{
suggestions
,
disabled
,
batchSuggestionsInfo
,
helpPagePath
,
defaultCommitMessage
,
suggestionsCount
,
}
=
this
;
const
suggestion
=
const
suggestion
=
suggestions
&&
suggestions
[
suggestionIndex
]
?
suggestions
[
suggestionIndex
]
:
{};
suggestions
&&
suggestions
[
suggestionIndex
]
?
suggestions
[
suggestionIndex
]
:
{};
const
SuggestionDiffComponent
=
Vue
.
extend
(
SuggestionDiff
);
const
SuggestionDiffComponent
=
Vue
.
extend
(
SuggestionDiff
);
const
suggestionDiff
=
new
SuggestionDiffComponent
({
const
suggestionDiff
=
new
SuggestionDiffComponent
({
propsData
:
{
disabled
,
suggestion
,
batchSuggestionsInfo
,
helpPagePath
,
suggestionsCount
},
propsData
:
{
disabled
,
suggestion
,
batchSuggestionsInfo
,
helpPagePath
,
defaultCommitMessage
,
suggestionsCount
,
},
});
});
suggestionDiff
.
$on
(
'
apply
'
,
({
suggestionId
,
callback
})
=>
{
suggestionDiff
.
$on
(
'
apply
'
,
({
suggestionId
,
callback
,
message
})
=>
{
this
.
$emit
(
'
apply
'
,
{
suggestionId
,
callback
,
flashContainer
:
this
.
$el
});
this
.
$emit
(
'
apply
'
,
{
suggestionId
,
callback
,
flashContainer
:
this
.
$el
,
message
});
});
});
suggestionDiff
.
$on
(
'
applyBatch
'
,
()
=>
{
suggestionDiff
.
$on
(
'
applyBatch
'
,
()
=>
{
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
3e5c90fb
...
@@ -42,6 +42,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
...
@@ -42,6 +42,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
push_frontend_feature_flag
(
:remove_resolve_note
,
@project
,
default_enabled:
true
)
push_frontend_feature_flag
(
:remove_resolve_note
,
@project
,
default_enabled:
true
)
push_frontend_feature_flag
(
:diffs_gradual_load
,
@project
,
default_enabled:
true
)
push_frontend_feature_flag
(
:diffs_gradual_load
,
@project
,
default_enabled:
true
)
push_frontend_feature_flag
(
:codequality_mr_diff
,
@project
)
push_frontend_feature_flag
(
:codequality_mr_diff
,
@project
)
push_frontend_feature_flag
(
:suggestions_custom_commit
,
@project
)
record_experiment_user
(
:invite_members_version_a
)
record_experiment_user
(
:invite_members_version_a
)
record_experiment_user
(
:invite_members_version_b
)
record_experiment_user
(
:invite_members_version_b
)
...
...
app/helpers/merge_requests_helper.rb
View file @
3e5c90fb
...
@@ -185,6 +185,10 @@ module MergeRequestsHelper
...
@@ -185,6 +185,10 @@ module MergeRequestsHelper
current_user
.
review_requested_open_merge_requests_count
current_user
.
review_requested_open_merge_requests_count
end
end
def
default_suggestion_commit_message
@project
.
suggestion_commit_message
.
presence
||
Gitlab
::
Suggestions
::
CommitMessage
::
DEFAULT_SUGGESTION_COMMIT_MESSAGE
end
end
end
MergeRequestsHelper
.
prepend_if_ee
(
'EE::MergeRequestsHelper'
)
MergeRequestsHelper
.
prepend_if_ee
(
'EE::MergeRequestsHelper'
)
app/views/projects/merge_requests/show.html.haml
View file @
3e5c90fb
...
@@ -90,7 +90,8 @@
...
@@ -90,7 +90,8 @@
dismiss_endpoint:
user_callouts_path
,
dismiss_endpoint:
user_callouts_path
,
show_suggest_popover:
show_suggest_popover?
.
to_s
,
show_suggest_popover:
show_suggest_popover?
.
to_s
,
show_whitespace_default:
@show_whitespace_default
.
to_s
,
show_whitespace_default:
@show_whitespace_default
.
to_s
,
file_by_file_default:
@file_by_file_default
.
to_s
}
file_by_file_default:
@file_by_file_default
.
to_s
,
default_suggestion_commit_message:
default_suggestion_commit_message
}
.mr-loading-status
.mr-loading-status
.loading.hide
.loading.hide
...
...
config/feature_flags/development/suggestions_custom_commit.yml
0 → 100644
View file @
3e5c90fb
---
name
:
suggestions_custom_commit
introduced_by_url
:
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/297404
milestone
:
'
13.9'
type
:
development
group
:
group::code review
default_enabled
:
false
locale/gitlab.pot
View file @
3e5c90fb
...
@@ -3543,12 +3543,6 @@ msgstr ""
...
@@ -3543,12 +3543,6 @@ msgstr ""
msgid "Apply suggestion"
msgid "Apply suggestion"
msgstr ""
msgstr ""
msgid "Apply suggestion commit message"
msgstr ""
msgid "Apply suggestion on %{fileName}"
msgstr ""
msgid "Apply suggestions"
msgid "Apply suggestions"
msgstr ""
msgstr ""
...
...
spec/features/merge_request/user_suggests_changes_on_diff_spec.rb
View file @
3e5c90fb
...
@@ -87,6 +87,7 @@ RSpec.describe 'User comments on a diff', :js do
...
@@ -87,6 +87,7 @@ RSpec.describe 'User comments on a diff', :js do
expect
(
page
).
not_to
have_content
(
'Applied'
)
expect
(
page
).
not_to
have_content
(
'Applied'
)
click_button
(
'Apply suggestion'
)
click_button
(
'Apply suggestion'
)
click_button
(
'Apply'
)
wait_for_requests
wait_for_requests
expect
(
page
).
to
have_content
(
'Applied'
)
expect
(
page
).
to
have_content
(
'Applied'
)
...
@@ -338,6 +339,7 @@ RSpec.describe 'User comments on a diff', :js do
...
@@ -338,6 +339,7 @@ RSpec.describe 'User comments on a diff', :js do
expect
(
page
).
not_to
have_content
(
'Applied'
)
expect
(
page
).
not_to
have_content
(
'Applied'
)
click_button
(
'Apply suggestion'
)
click_button
(
'Apply suggestion'
)
click_button
(
'Apply'
)
wait_for_requests
wait_for_requests
expect
(
page
).
to
have_content
(
'Applied'
)
expect
(
page
).
to
have_content
(
'Applied'
)
...
@@ -349,6 +351,7 @@ RSpec.describe 'User comments on a diff', :js do
...
@@ -349,6 +351,7 @@ RSpec.describe 'User comments on a diff', :js do
expect
(
page
).
not_to
have_content
(
'Unresolve thread'
)
expect
(
page
).
not_to
have_content
(
'Unresolve thread'
)
click_button
(
'Apply suggestion'
)
click_button
(
'Apply suggestion'
)
click_button
(
'Apply'
)
wait_for_requests
wait_for_requests
expect
(
page
).
to
have_content
(
'Unresolve thread'
)
expect
(
page
).
to
have_content
(
'Unresolve thread'
)
...
...
spec/frontend/vue_shared/components/markdown/__snapshots__/suggestion_diff_spec.js.snap
View file @
3e5c90fb
...
@@ -7,6 +7,7 @@ exports[`Suggestion Diff component matches snapshot 1`] = `
...
@@ -7,6 +7,7 @@ exports[`Suggestion Diff component matches snapshot 1`] = `
<suggestion-diff-header-stub
<suggestion-diff-header-stub
batchsuggestionscount="1"
batchsuggestionscount="1"
class="qa-suggestion-diff-header js-suggestion-diff-header"
class="qa-suggestion-diff-header js-suggestion-diff-header"
defaultcommitmessage="Apply suggestion"
helppagepath="path_to_docs"
helppagepath="path_to_docs"
isapplyingbatch="true"
isapplyingbatch="true"
isbatched="true"
isbatched="true"
...
...
spec/frontend/vue_shared/components/markdown/apply_suggestion_spec.js
View file @
3e5c90fb
...
@@ -3,7 +3,7 @@ import { GlDropdown, GlFormTextarea, GlButton } from '@gitlab/ui';
...
@@ -3,7 +3,7 @@ import { GlDropdown, GlFormTextarea, GlButton } from '@gitlab/ui';
import
ApplySuggestionComponent
from
'
~/vue_shared/components/markdown/apply_suggestion.vue
'
;
import
ApplySuggestionComponent
from
'
~/vue_shared/components/markdown/apply_suggestion.vue
'
;
describe
(
'
Apply Suggestion component
'
,
()
=>
{
describe
(
'
Apply Suggestion component
'
,
()
=>
{
const
propsData
=
{
fileName
:
'
test.js
'
,
disabled
:
false
};
const
propsData
=
{
defaultCommitMessage
:
'
Apply suggestion
'
,
disabled
:
false
};
let
wrapper
;
let
wrapper
;
const
createWrapper
=
(
props
)
=>
{
const
createWrapper
=
(
props
)
=>
{
...
@@ -27,7 +27,6 @@ describe('Apply Suggestion component', () => {
...
@@ -27,7 +27,6 @@ describe('Apply Suggestion component', () => {
expect
(
dropdown
.
exists
()).
toBe
(
true
);
expect
(
dropdown
.
exists
()).
toBe
(
true
);
expect
(
dropdown
.
props
(
'
text
'
)).
toBe
(
'
Apply suggestion
'
);
expect
(
dropdown
.
props
(
'
text
'
)).
toBe
(
'
Apply suggestion
'
);
expect
(
dropdown
.
props
(
'
headerText
'
)).
toBe
(
'
Apply suggestion commit message
'
);
expect
(
dropdown
.
props
(
'
disabled
'
)).
toBe
(
false
);
expect
(
dropdown
.
props
(
'
disabled
'
)).
toBe
(
false
);
});
});
...
@@ -35,7 +34,7 @@ describe('Apply Suggestion component', () => {
...
@@ -35,7 +34,7 @@ describe('Apply Suggestion component', () => {
const
textArea
=
findTextArea
();
const
textArea
=
findTextArea
();
expect
(
textArea
.
exists
()).
toBe
(
true
);
expect
(
textArea
.
exists
()).
toBe
(
true
);
expect
(
textArea
.
attributes
(
'
placeholder
'
)).
toBe
(
'
Apply suggestion
on test.js
'
);
expect
(
textArea
.
attributes
(
'
placeholder
'
)).
toBe
(
'
Apply suggestion
'
);
});
});
it
(
'
renders an apply button
'
,
()
=>
{
it
(
'
renders an apply button
'
,
()
=>
{
...
@@ -55,11 +54,11 @@ describe('Apply Suggestion component', () => {
...
@@ -55,11 +54,11 @@ describe('Apply Suggestion component', () => {
});
});
describe
(
'
apply suggestion
'
,
()
=>
{
describe
(
'
apply suggestion
'
,
()
=>
{
it
(
'
emits an apply event with
a default
message if no message was added
'
,
()
=>
{
it
(
'
emits an apply event with
no
message if no message was added
'
,
()
=>
{
findTextArea
().
vm
.
$emit
(
'
input
'
,
null
);
findTextArea
().
vm
.
$emit
(
'
input
'
,
null
);
findApplyButton
().
vm
.
$emit
(
'
click
'
);
findApplyButton
().
vm
.
$emit
(
'
click
'
);
expect
(
wrapper
.
emitted
(
'
apply
'
)).
toEqual
([[
'
Apply suggestion on test.js
'
]]);
expect
(
wrapper
.
emitted
(
'
apply
'
)).
toEqual
([[
null
]]);
});
});
it
(
'
emits an apply event with a user-defined message
'
,
()
=>
{
it
(
'
emits an apply event with a user-defined message
'
,
()
=>
{
...
...
spec/frontend/vue_shared/components/markdown/suggestion_diff_header_spec.js
View file @
3e5c90fb
...
@@ -9,6 +9,7 @@ const DEFAULT_PROPS = {
...
@@ -9,6 +9,7 @@ const DEFAULT_PROPS = {
isBatched
:
false
,
isBatched
:
false
,
isApplyingBatch
:
false
,
isApplyingBatch
:
false
,
helpPagePath
:
'
path_to_docs
'
,
helpPagePath
:
'
path_to_docs
'
,
defaultCommitMessage
:
'
Apply suggestion
'
,
};
};
describe
(
'
Suggestion Diff component
'
,
()
=>
{
describe
(
'
Suggestion Diff component
'
,
()
=>
{
...
@@ -91,7 +92,7 @@ describe('Suggestion Diff component', () => {
...
@@ -91,7 +92,7 @@ describe('Suggestion Diff component', () => {
});
});
it
(
'
emits apply
'
,
()
=>
{
it
(
'
emits apply
'
,
()
=>
{
expect
(
wrapper
.
emitted
().
apply
).
toEqual
([[
expect
.
any
(
Function
)]]);
expect
(
wrapper
.
emitted
().
apply
).
toEqual
([[
expect
.
any
(
Function
)
,
undefined
]]);
});
});
it
(
'
does not render apply suggestion and add to batch buttons
'
,
()
=>
{
it
(
'
does not render apply suggestion and add to batch buttons
'
,
()
=>
{
...
...
spec/frontend/vue_shared/components/markdown/suggestion_diff_spec.js
View file @
3e5c90fb
...
@@ -42,6 +42,7 @@ const MOCK_DATA = {
...
@@ -42,6 +42,7 @@ const MOCK_DATA = {
is_applying_batch
:
true
,
is_applying_batch
:
true
,
},
},
helpPagePath
:
'
path_to_docs
'
,
helpPagePath
:
'
path_to_docs
'
,
defaultCommitMessage
:
'
Apply suggestion
'
,
batchSuggestionsInfo
:
[{
suggestionId
}],
batchSuggestionsInfo
:
[{
suggestionId
}],
};
};
...
...
spec/frontend/vue_shared/components/markdown/suggestions_spec.js
View file @
3e5c90fb
...
@@ -44,6 +44,7 @@ const MOCK_DATA = {
...
@@ -44,6 +44,7 @@ const MOCK_DATA = {
`
,
`
,
isApplied
:
false
,
isApplied
:
false
,
helpPagePath
:
'
path_to_docs
'
,
helpPagePath
:
'
path_to_docs
'
,
defaultCommitMessage
:
'
Apply suggestion
'
,
};
};
describe
(
'
Suggestion component
'
,
()
=>
{
describe
(
'
Suggestion component
'
,
()
=>
{
...
...
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