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
Boxiang Sun
gitlab-ce
Commits
e08ce52a
Commit
e08ce52a
authored
Jun 15, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve Web IDE commit form
Closes #47307
parent
e055cb47
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
55 deletions
+13
-55
app/assets/javascripts/ide/components/commit_sidebar/form.vue
...assets/javascripts/ide/components/commit_sidebar/form.vue
+5
-3
app/assets/javascripts/ide/components/repo_commit_section.vue
...assets/javascripts/ide/components/repo_commit_section.vue
+1
-1
app/assets/javascripts/ide/stores/modules/commit/actions.js
app/assets/javascripts/ide/stores/modules/commit/actions.js
+5
-2
app/assets/javascripts/ide/stores/modules/commit/getters.js
app/assets/javascripts/ide/stores/modules/commit/getters.js
+0
-3
spec/javascripts/ide/stores/modules/commit/getters_spec.js
spec/javascripts/ide/stores/modules/commit/getters_spec.js
+2
-46
No files found.
app/assets/javascripts/ide/components/commit_sidebar/form.vue
View file @
e08ce52a
...
...
@@ -24,7 +24,7 @@ export default {
...
mapState
([
'
changedFiles
'
,
'
stagedFiles
'
,
'
currentActivityView
'
,
'
lastCommitMsg
'
]),
...
mapState
(
'
commit
'
,
[
'
commitMessage
'
,
'
submitCommitLoading
'
]),
...
mapGetters
([
'
hasChanges
'
]),
...
mapGetters
(
'
commit
'
,
[
'
commitButtonDisabled
'
,
'
discardDraftButtonDisabled
'
]),
...
mapGetters
(
'
commit
'
,
[
'
discardDraftButtonDisabled
'
]),
overviewText
()
{
return
sprintf
(
__
(
...
...
@@ -36,6 +36,9 @@ export default {
},
);
},
commitButtonText
()
{
return
this
.
stagedFiles
.
length
?
__
(
'
Commit
'
)
:
__
(
'
Stage & Commit
'
);
},
},
watch
:
{
currentActivityView
()
{
...
...
@@ -142,8 +145,7 @@ export default {
<actions
/>
<loading-button
:loading=
"submitCommitLoading"
:disabled=
"commitButtonDisabled"
:label=
"__('Commit')"
:label=
"commitButtonText"
container-class=
"btn btn-success btn-sm float-left"
@
click=
"commitChanges"
/>
...
...
app/assets/javascripts/ide/components/repo_commit_section.vue
View file @
e08ce52a
...
...
@@ -28,7 +28,7 @@ export default {
]),
...
mapState
(
'
commit
'
,
[
'
commitMessage
'
,
'
submitCommitLoading
'
]),
...
mapGetters
([
'
lastOpenedFile
'
,
'
hasChanges
'
,
'
someUncommitedChanges
'
,
'
activeFile
'
]),
...
mapGetters
(
'
commit
'
,
[
'
commitButtonDisabled
'
,
'
discardDraftButtonDisabled
'
]),
...
mapGetters
(
'
commit
'
,
[
'
discardDraftButtonDisabled
'
]),
showStageUnstageArea
()
{
return
!!
(
this
.
someUncommitedChanges
||
this
.
lastCommitMsg
||
!
this
.
unusedSeal
);
},
...
...
app/assets/javascripts/ide/stores/modules/commit/actions.js
View file @
e08ce52a
...
...
@@ -109,11 +109,14 @@ export const commitChanges = ({ commit, state, getters, dispatch, rootState, roo
state
,
rootState
,
});
const
stageFilesPromise
=
rootState
.
stagedFiles
.
length
?
Promise
.
resolve
()
:
dispatch
(
'
stageAllChanges
'
,
null
,
{
root
:
true
});
commit
(
types
.
UPDATE_LOADING
,
true
);
return
s
ervic
e
.
commit
(
rootState
.
currentProjectId
,
payload
)
return
s
tageFilesPromis
e
.
then
(()
=>
service
.
commit
(
rootState
.
currentProjectId
,
payload
)
)
.
then
(({
data
})
=>
{
commit
(
types
.
UPDATE_LOADING
,
false
);
...
...
app/assets/javascripts/ide/stores/modules/commit/getters.js
View file @
e08ce52a
...
...
@@ -5,9 +5,6 @@ const BRANCH_SUFFIX_COUNT = 5;
export
const
discardDraftButtonDisabled
=
state
=>
state
.
commitMessage
===
''
||
state
.
submitCommitLoading
;
export
const
commitButtonDisabled
=
(
state
,
getters
,
rootState
)
=>
getters
.
discardDraftButtonDisabled
||
!
rootState
.
stagedFiles
.
length
;
export
const
newBranchName
=
(
state
,
_
,
rootState
)
=>
`
${
gon
.
current_username
}
-
${
rootState
.
currentBranchId
}
-patch-
${
`
${
new
Date
().
getTime
()}
`
.
substr
(
-
BRANCH_SUFFIX_COUNT
,
...
...
spec/javascripts/ide/stores/modules/commit/getters_spec.js
View file @
e08ce52a
...
...
@@ -29,46 +29,6 @@ describe('IDE commit module getters', () => {
});
});
describe
(
'
commitButtonDisabled
'
,
()
=>
{
const
localGetters
=
{
discardDraftButtonDisabled
:
false
,
};
const
rootState
=
{
stagedFiles
:
[
'
a
'
],
};
it
(
'
returns false when discardDraftButtonDisabled is false & stagedFiles is not empty
'
,
()
=>
{
expect
(
getters
.
commitButtonDisabled
(
state
,
localGetters
,
rootState
),
).
toBeFalsy
();
});
it
(
'
returns true when discardDraftButtonDisabled is false & stagedFiles is empty
'
,
()
=>
{
rootState
.
stagedFiles
.
length
=
0
;
expect
(
getters
.
commitButtonDisabled
(
state
,
localGetters
,
rootState
),
).
toBeTruthy
();
});
it
(
'
returns true when discardDraftButtonDisabled is true
'
,
()
=>
{
localGetters
.
discardDraftButtonDisabled
=
true
;
expect
(
getters
.
commitButtonDisabled
(
state
,
localGetters
,
rootState
),
).
toBeTruthy
();
});
it
(
'
returns true when discardDraftButtonDisabled is false & changedFiles is not empty
'
,
()
=>
{
localGetters
.
discardDraftButtonDisabled
=
false
;
rootState
.
stagedFiles
.
length
=
0
;
expect
(
getters
.
commitButtonDisabled
(
state
,
localGetters
,
rootState
),
).
toBeTruthy
();
});
});
describe
(
'
newBranchName
'
,
()
=>
{
it
(
'
includes username, currentBranchId, patch & random number
'
,
()
=>
{
gon
.
current_username
=
'
username
'
;
...
...
@@ -108,9 +68,7 @@ describe('IDE commit module getters', () => {
});
it
(
'
uses newBranchName when not empty
'
,
()
=>
{
expect
(
getters
.
branchName
(
state
,
localGetters
,
rootState
)).
toBe
(
'
state-newBranchName
'
,
);
expect
(
getters
.
branchName
(
state
,
localGetters
,
rootState
)).
toBe
(
'
state-newBranchName
'
);
});
it
(
'
uses getters newBranchName when state newBranchName is empty
'
,
()
=>
{
...
...
@@ -118,9 +76,7 @@ describe('IDE commit module getters', () => {
newBranchName
:
''
,
});
expect
(
getters
.
branchName
(
state
,
localGetters
,
rootState
)).
toBe
(
'
newBranchName
'
,
);
expect
(
getters
.
branchName
(
state
,
localGetters
,
rootState
)).
toBe
(
'
newBranchName
'
);
});
});
});
...
...
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