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
8ce24304
Commit
8ce24304
authored
Feb 09, 2021
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab master
parents
1033618c
9c266113
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
211 additions
and
4 deletions
+211
-4
app/assets/javascripts/diffs/store/getters.js
app/assets/javascripts/diffs/store/getters.js
+16
-0
app/assets/javascripts/diffs/utils/suggestions.js
app/assets/javascripts/diffs/utils/suggestions.js
+28
-0
app/assets/javascripts/notes/components/note_body.vue
app/assets/javascripts/notes/components/note_body.vue
+24
-2
app/assets/javascripts/notes/components/noteable_note.vue
app/assets/javascripts/notes/components/noteable_note.vue
+1
-0
changelogs/unreleased/231173-gl-button.yml
changelogs/unreleased/231173-gl-button.yml
+5
-0
changelogs/unreleased/tor-defect-commit-message-placeholders.yml
...ogs/unreleased/tor-defect-commit-message-placeholders.yml
+6
-0
ee/app/views/projects/services/gitlab_slack_application/_slack_integration_form.html.haml
...itlab_slack_application/_slack_integration_form.html.haml
+2
-2
spec/frontend/diffs/store/getters_spec.js
spec/frontend/diffs/store/getters_spec.js
+60
-0
spec/frontend/diffs/utils/suggestions_spec.js
spec/frontend/diffs/utils/suggestions_spec.js
+15
-0
spec/frontend/notes/components/note_body_spec.js
spec/frontend/notes/components/note_body_spec.js
+54
-0
No files found.
app/assets/javascripts/diffs/store/getters.js
View file @
8ce24304
...
@@ -4,6 +4,7 @@ import {
...
@@ -4,6 +4,7 @@ import {
INLINE_DIFF_VIEW_TYPE
,
INLINE_DIFF_VIEW_TYPE
,
INLINE_DIFF_LINES_KEY
,
INLINE_DIFF_LINES_KEY
,
}
from
'
../constants
'
;
}
from
'
../constants
'
;
import
{
computeSuggestionCommitMessage
}
from
'
../utils/suggestions
'
;
import
{
parallelizeDiffLines
}
from
'
./utils
'
;
import
{
parallelizeDiffLines
}
from
'
./utils
'
;
export
*
from
'
./getters_versions_dropdowns
'
;
export
*
from
'
./getters_versions_dropdowns
'
;
...
@@ -154,3 +155,18 @@ export const diffLines = (state) => (file, unifiedDiffComponents) => {
...
@@ -154,3 +155,18 @@ export const diffLines = (state) => (file, unifiedDiffComponents) => {
state
.
diffViewType
===
INLINE_DIFF_VIEW_TYPE
,
state
.
diffViewType
===
INLINE_DIFF_VIEW_TYPE
,
);
);
};
};
export
function
suggestionCommitMessage
(
state
)
{
return
(
values
=
{})
=>
computeSuggestionCommitMessage
({
message
:
state
.
defaultSuggestionCommitMessage
,
values
:
{
branch_name
:
state
.
branchName
,
project_path
:
state
.
projectPath
,
project_name
:
state
.
projectName
,
username
:
state
.
username
,
user_full_name
:
state
.
userFullName
,
...
values
,
},
});
}
app/assets/javascripts/diffs/utils/suggestions.js
0 → 100644
View file @
8ce24304
function
removeEmptyProperties
(
dict
)
{
const
noBlanks
=
Object
.
entries
(
dict
).
reduce
((
final
,
[
key
,
value
])
=>
{
const
upd
=
{
...
final
};
// The number 0 shouldn't be falsey when we're printing variables
if
(
value
||
value
===
0
)
{
upd
[
key
]
=
value
;
}
return
upd
;
},
{});
return
noBlanks
;
}
export
function
computeSuggestionCommitMessage
({
message
,
values
=
{}
}
=
{})
{
const
noEmpties
=
removeEmptyProperties
(
values
);
const
matchPhrases
=
Object
.
keys
(
noEmpties
)
.
map
((
key
)
=>
`%{
${
key
}
}`
)
.
join
(
'
|
'
);
const
replacementExpression
=
new
RegExp
(
`(
${
matchPhrases
}
)`
,
'
gm
'
);
return
message
.
replace
(
replacementExpression
,
(
match
)
=>
{
const
key
=
match
.
replace
(
/
(
^%{|}$
)
/gm
,
''
);
return
noEmpties
[
key
];
});
}
app/assets/javascripts/notes/components/note_body.vue
View file @
8ce24304
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
/* eslint-disable vue/no-v-html */
/* eslint-disable vue/no-v-html */
import
{
mapActions
,
mapGetters
,
mapState
}
from
'
vuex
'
;
import
{
mapActions
,
mapGetters
,
mapState
}
from
'
vuex
'
;
import
$
from
'
jquery
'
;
import
$
from
'
jquery
'
;
import
{
escape
}
from
'
lodash
'
;
import
'
~/behaviors/markdown/render_gfm
'
;
import
'
~/behaviors/markdown/render_gfm
'
;
import
Suggestions
from
'
~/vue_shared/components/markdown/suggestions.vue
'
;
import
Suggestions
from
'
~/vue_shared/components/markdown/suggestions.vue
'
;
import
autosave
from
'
../mixins/autosave
'
;
import
autosave
from
'
../mixins/autosave
'
;
...
@@ -29,6 +31,11 @@ export default {
...
@@ -29,6 +31,11 @@ export default {
required
:
false
,
required
:
false
,
default
:
null
,
default
:
null
,
},
},
file
:
{
type
:
Object
,
required
:
false
,
default
:
null
,
},
canEdit
:
{
canEdit
:
{
type
:
Boolean
,
type
:
Boolean
,
required
:
true
,
required
:
true
,
...
@@ -46,6 +53,7 @@ export default {
...
@@ -46,6 +53,7 @@ export default {
},
},
computed
:
{
computed
:
{
...
mapGetters
([
'
getDiscussion
'
,
'
suggestionsCount
'
]),
...
mapGetters
([
'
getDiscussion
'
,
'
suggestionsCount
'
]),
...
mapGetters
(
'
diffs
'
,
[
'
suggestionCommitMessage
'
]),
discussion
()
{
discussion
()
{
if
(
!
this
.
note
.
isDraft
)
return
{};
if
(
!
this
.
note
.
isDraft
)
return
{};
...
@@ -54,7 +62,6 @@ export default {
...
@@ -54,7 +62,6 @@ 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
;
},
},
...
@@ -64,6 +71,21 @@ export default {
...
@@ -64,6 +71,21 @@ export default {
lineType
()
{
lineType
()
{
return
this
.
line
?
this
.
line
.
type
:
null
;
return
this
.
line
?
this
.
line
.
type
:
null
;
},
},
commitMessage
()
{
// Please see this issue comment for why these
// are hard-coded to 1:
// https://gitlab.com/gitlab-org/gitlab/-/issues/291027#note_468308022
const
suggestionsCount
=
1
;
const
filesCount
=
1
;
const
filePaths
=
this
.
file
?
[
this
.
file
.
file_path
]
:
[];
const
suggestion
=
this
.
suggestionCommitMessage
({
file_paths
:
filePaths
.
join
(
'
,
'
),
suggestions_count
:
suggestionsCount
,
files_count
:
filesCount
,
});
return
escape
(
suggestion
);
},
},
},
mounted
()
{
mounted
()
{
this
.
renderGFM
();
this
.
renderGFM
();
...
@@ -135,7 +157,7 @@ export default {
...
@@ -135,7 +157,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=
"
defaultSuggestionC
ommitMessage"
:default-commit-message=
"
c
ommitMessage"
@
apply=
"applySuggestion"
@
apply=
"applySuggestion"
@
applyBatch=
"applySuggestionBatch"
@
applyBatch=
"applySuggestionBatch"
@
addToBatch=
"addSuggestionToBatch"
@
addToBatch=
"addSuggestionToBatch"
...
...
app/assets/javascripts/notes/components/noteable_note.vue
View file @
8ce24304
...
@@ -431,6 +431,7 @@ export default {
...
@@ -431,6 +431,7 @@ export default {
ref=
"noteBody"
ref=
"noteBody"
:note=
"note"
:note=
"note"
:line=
"line"
:line=
"line"
:file=
"diffFile"
:can-edit=
"note.current_user.can_edit"
:can-edit=
"note.current_user.can_edit"
:is-editing=
"isEditing"
:is-editing=
"isEditing"
:help-page-path=
"helpPagePath"
:help-page-path=
"helpPagePath"
...
...
changelogs/unreleased/231173-gl-button.yml
0 → 100644
View file @
8ce24304
---
title
:
Apply GitLab UI button styles to buttons in gitlab_slack_application file
merge_request
:
53478
author
:
Yogi (@yo)
type
:
other
changelogs/unreleased/tor-defect-commit-message-placeholders.yml
0 → 100644
View file @
8ce24304
---
title
:
Fill default commit message values in the placeholder instead of showing the
variable slugs
merge_request
:
52851
author
:
type
:
fixed
ee/app/views/projects/services/gitlab_slack_application/_slack_integration_form.html.haml
View file @
8ce24304
...
@@ -23,8 +23,8 @@
...
@@ -23,8 +23,8 @@
%td
%td
.controls
.controls
-
project
=
@service
.
project
-
project
=
@service
.
project
=
link_to
'Edit'
,
edit_project_settings_slack_path
(
project
),
class:
'btn btn-sm'
=
link_to
'Edit'
,
edit_project_settings_slack_path
(
project
),
class:
'btn
gl-button btn-default
btn-sm'
=
link_to
'Remove'
,
project_settings_slack_path
(
project
),
method: :delete
,
class:
'btn btn-danger btn-sm'
,
data:
{
confirm:
'Are you sure?'
}
=
link_to
'Remove'
,
project_settings_slack_path
(
project
),
method: :delete
,
class:
'btn
gl-button
btn-danger btn-sm'
,
data:
{
confirm:
'Are you sure?'
}
-
else
-
else
%p
To set up this service press "Add to Slack"
%p
To set up this service press "Add to Slack"
=
render
"projects/services/
#{
@service
.
to_param
}
/slack_button"
,
project:
@project
=
render
"projects/services/
#{
@service
.
to_param
}
/slack_button"
,
project:
@project
spec/frontend/diffs/store/getters_spec.js
View file @
8ce24304
...
@@ -375,4 +375,64 @@ describe('Diffs Module Getters', () => {
...
@@ -375,4 +375,64 @@ describe('Diffs Module Getters', () => {
});
});
});
});
});
});
describe
(
'
suggestionCommitMessage
'
,
()
=>
{
beforeEach
(()
=>
{
Object
.
assign
(
localState
,
{
defaultSuggestionCommitMessage
:
'
%{branch_name}%{project_path}%{project_name}%{username}%{user_full_name}%{file_paths}%{suggestions_count}%{files_count}
'
,
branchName
:
'
branch
'
,
projectPath
:
'
/path
'
,
projectName
:
'
name
'
,
username
:
'
user
'
,
userFullName
:
'
user userton
'
,
});
});
it
.
each
`
specialState | output
${{}}
|
$
{
'
branch/pathnameuseruser userton%{file_paths}%{suggestions_count}%{files_count}
'
}
${{
userFullName
:
null
}
} |
${
'
branch/pathnameuser%{user_full_name}%{file_paths}%{suggestions_count}%{files_count}
'
}
${{
username
:
null
}
} |
${
'
branch/pathname%{username}user userton%{file_paths}%{suggestions_count}%{files_count}
'
}
${{
projectName
:
null
}
} |
${
'
branch/path%{project_name}useruser userton%{file_paths}%{suggestions_count}%{files_count}
'
}
${{
projectPath
:
null
}
} |
${
'
branch%{project_path}nameuseruser userton%{file_paths}%{suggestions_count}%{files_count}
'
}
${{
branchName
:
null
}
} |
${
'
%{branch_name}/pathnameuseruser userton%{file_paths}%{suggestions_count}%{files_count}
'
}
`
(
'
provides the correct "base" default commit message based on state ($specialState)
'
,
({
specialState
,
output
})
=>
{
Object
.
assign
(
localState
,
specialState
);
expect
(
getters
.
suggestionCommitMessage
(
localState
)()).
toBe
(
output
);
},
);
it
.
each
`
stateOverrides | output
${{}}
|
$
{
'
branch/pathnameuseruser userton%{file_paths}%{suggestions_count}%{files_count}
'
}
${{
user_full_name
:
null
}
} |
${
'
branch/pathnameuser%{user_full_name}%{file_paths}%{suggestions_count}%{files_count}
'
}
${{
username
:
null
}
} |
${
'
branch/pathname%{username}user userton%{file_paths}%{suggestions_count}%{files_count}
'
}
${{
project_name
:
null
}
} |
${
'
branch/path%{project_name}useruser userton%{file_paths}%{suggestions_count}%{files_count}
'
}
${{
project_path
:
null
}
} |
${
'
branch%{project_path}nameuseruser userton%{file_paths}%{suggestions_count}%{files_count}
'
}
${{
branch_name
:
null
}
} |
${
'
%{branch_name}/pathnameuseruser userton%{file_paths}%{suggestions_count}%{files_count}
'
}
`
(
"
properly overrides state values ($stateOverrides) if they're provided
"
,
({
stateOverrides
,
output
})
=>
{
expect
(
getters
.
suggestionCommitMessage
(
localState
)(
stateOverrides
)).
toBe
(
output
);
},
);
it
.
each
`
providedValues | output
${{
file_paths
:
'
path1, path2
'
,
suggestions_count
:
1
,
files_count
:
1
}
} |
${
'
branch/pathnameuseruser usertonpath1, path211
'
}
${{
suggestions_count
:
1
,
files_count
:
1
}
} |
${
'
branch/pathnameuseruser userton%{file_paths}11
'
}
${{
file_paths
:
'
path1, path2
'
,
files_count
:
1
}
} |
${
'
branch/pathnameuseruser usertonpath1, path2%{suggestions_count}1
'
}
${{
file_paths
:
'
path1, path2
'
,
suggestions_count
:
1
}
} |
${
'
branch/pathnameuseruser usertonpath1, path21%{files_count}
'
}
${{
something_unused
:
'
CrAzY TeXt
'
}
} |
${
'
branch/pathnameuseruser userton%{file_paths}%{suggestions_count}%{files_count}
'
}
`
(
"
fills in any missing interpolations ($providedValues) when they're provided at the getter callsite
"
,
({
providedValues
,
output
})
=>
{
expect
(
getters
.
suggestionCommitMessage
(
localState
)(
providedValues
)).
toBe
(
output
);
},
);
});
});
});
spec/frontend/diffs/utils/suggestions_spec.js
0 → 100644
View file @
8ce24304
import
{
computeSuggestionCommitMessage
}
from
'
~/diffs/utils/suggestions
'
;
describe
(
'
Diff Suggestions utilities
'
,
()
=>
{
describe
(
'
computeSuggestionCommitMessage
'
,
()
=>
{
it
.
each
`
description | input | values | output
${
'
makes the appropriate replacements
'
}
|
${
'
%{foo} %{bar}
'
}
|
${{
foo
:
'
foo
'
,
bar
:
'
bar
'
}
} |
${
'
foo bar
'
}
${
"
skips replacing values that aren't passed
"
}
|
${
'
%{foo} %{bar}
'
}
|
${{
foo
:
'
foo
'
}
} |
${
'
foo %{bar}
'
}
${
'
treats the number 0 as a valid value (not falsey)
'
}
|
${
'
%{foo} %{bar}
'
}
|
${{
foo
:
'
foo
'
,
bar
:
0
}
} |
${
'
foo 0
'
}
${
"
works when the variables don't have any space between them
"
}
|
${
'
%{foo}%{bar}
'
}
|
${{
foo
:
'
foo
'
,
bar
:
'
bar
'
}
} |
${
'
foobar
'
}
`
(
'
$description
'
,
({
input
,
output
,
values
})
=>
{
expect
(
computeSuggestionCommitMessage
({
message
:
input
,
values
})).
toBe
(
output
);
});
});
});
spec/frontend/notes/components/note_body_spec.js
View file @
8ce24304
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
Vuex
from
'
vuex
'
;
import
notes
from
'
~/notes/stores/modules/index
'
;
import
createStore
from
'
~/notes/stores
'
;
import
createStore
from
'
~/notes/stores
'
;
import
{
suggestionCommitMessage
}
from
'
~/diffs/store/getters
'
;
import
Suggestions
from
'
~/vue_shared/components/markdown/suggestions.vue
'
;
import
noteBody
from
'
~/notes/components/note_body.vue
'
;
import
noteBody
from
'
~/notes/components/note_body.vue
'
;
import
{
noteableDataMock
,
notesDataMock
,
note
}
from
'
../mock_data
'
;
import
{
noteableDataMock
,
notesDataMock
,
note
}
from
'
../mock_data
'
;
describe
(
'
issue_note_body component
'
,
()
=>
{
describe
(
'
issue_note_body component
'
,
()
=>
{
...
@@ -54,4 +62,50 @@ describe('issue_note_body component', () => {
...
@@ -54,4 +62,50 @@ describe('issue_note_body component', () => {
expect
(
vm
.
autosave
.
key
).
toEqual
(
autosaveKey
);
expect
(
vm
.
autosave
.
key
).
toEqual
(
autosaveKey
);
});
});
});
});
describe
(
'
commitMessage
'
,
()
=>
{
let
wrapper
;
Vue
.
use
(
Vuex
);
beforeEach
(()
=>
{
const
notesStore
=
notes
();
notesStore
.
state
.
notes
=
{};
store
=
new
Vuex
.
Store
({
modules
:
{
notes
:
notesStore
,
diffs
:
{
namespaced
:
true
,
state
:
{
defaultSuggestionCommitMessage
:
'
%{branch_name}%{project_path}%{project_name}%{username}%{user_full_name}%{file_paths}%{suggestions_count}%{files_count}
'
,
branchName
:
'
branch
'
,
projectPath
:
'
/path
'
,
projectName
:
'
name
'
,
username
:
'
user
'
,
userFullName
:
'
user userton
'
,
},
getters
:
{
suggestionCommitMessage
},
},
},
});
wrapper
=
shallowMount
(
noteBody
,
{
store
,
propsData
:
{
note
:
{
...
note
,
suggestions
:
[
12345
]
},
canEdit
:
true
,
file
:
{
file_path
:
'
abc
'
},
},
});
});
it
(
'
passes the correct default placeholder commit message for a suggestion to the suggestions component
'
,
()
=>
{
const
commitMessage
=
wrapper
.
find
(
Suggestions
).
attributes
(
'
defaultcommitmessage
'
);
expect
(
commitMessage
).
toBe
(
'
branch/pathnameuseruser usertonabc11
'
);
});
});
});
});
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