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
Léo-Paul Géneau
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
Show 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 {
...
@@ -24,7 +24,7 @@ export default {
...
mapState
([
'
changedFiles
'
,
'
stagedFiles
'
,
'
currentActivityView
'
,
'
lastCommitMsg
'
]),
...
mapState
([
'
changedFiles
'
,
'
stagedFiles
'
,
'
currentActivityView
'
,
'
lastCommitMsg
'
]),
...
mapState
(
'
commit
'
,
[
'
commitMessage
'
,
'
submitCommitLoading
'
]),
...
mapState
(
'
commit
'
,
[
'
commitMessage
'
,
'
submitCommitLoading
'
]),
...
mapGetters
([
'
hasChanges
'
]),
...
mapGetters
([
'
hasChanges
'
]),
...
mapGetters
(
'
commit
'
,
[
'
commitButtonDisabled
'
,
'
discardDraftButtonDisabled
'
]),
...
mapGetters
(
'
commit
'
,
[
'
discardDraftButtonDisabled
'
]),
overviewText
()
{
overviewText
()
{
return
sprintf
(
return
sprintf
(
__
(
__
(
...
@@ -36,6 +36,9 @@ export default {
...
@@ -36,6 +36,9 @@ export default {
},
},
);
);
},
},
commitButtonText
()
{
return
this
.
stagedFiles
.
length
?
__
(
'
Commit
'
)
:
__
(
'
Stage & Commit
'
);
},
},
},
watch
:
{
watch
:
{
currentActivityView
()
{
currentActivityView
()
{
...
@@ -142,8 +145,7 @@ export default {
...
@@ -142,8 +145,7 @@ export default {
<actions
/>
<actions
/>
<loading-button
<loading-button
:loading=
"submitCommitLoading"
:loading=
"submitCommitLoading"
:disabled=
"commitButtonDisabled"
:label=
"commitButtonText"
:label=
"__('Commit')"
container-class=
"btn btn-success btn-sm float-left"
container-class=
"btn btn-success btn-sm float-left"
@
click=
"commitChanges"
@
click=
"commitChanges"
/>
/>
...
...
app/assets/javascripts/ide/components/repo_commit_section.vue
View file @
e08ce52a
...
@@ -28,7 +28,7 @@ export default {
...
@@ -28,7 +28,7 @@ export default {
]),
]),
...
mapState
(
'
commit
'
,
[
'
commitMessage
'
,
'
submitCommitLoading
'
]),
...
mapState
(
'
commit
'
,
[
'
commitMessage
'
,
'
submitCommitLoading
'
]),
...
mapGetters
([
'
lastOpenedFile
'
,
'
hasChanges
'
,
'
someUncommitedChanges
'
,
'
activeFile
'
]),
...
mapGetters
([
'
lastOpenedFile
'
,
'
hasChanges
'
,
'
someUncommitedChanges
'
,
'
activeFile
'
]),
...
mapGetters
(
'
commit
'
,
[
'
commitButtonDisabled
'
,
'
discardDraftButtonDisabled
'
]),
...
mapGetters
(
'
commit
'
,
[
'
discardDraftButtonDisabled
'
]),
showStageUnstageArea
()
{
showStageUnstageArea
()
{
return
!!
(
this
.
someUncommitedChanges
||
this
.
lastCommitMsg
||
!
this
.
unusedSeal
);
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
...
@@ -109,11 +109,14 @@ export const commitChanges = ({ commit, state, getters, dispatch, rootState, roo
state
,
state
,
rootState
,
rootState
,
});
});
const
stageFilesPromise
=
rootState
.
stagedFiles
.
length
?
Promise
.
resolve
()
:
dispatch
(
'
stageAllChanges
'
,
null
,
{
root
:
true
});
commit
(
types
.
UPDATE_LOADING
,
true
);
commit
(
types
.
UPDATE_LOADING
,
true
);
return
s
ervic
e
return
s
tageFilesPromis
e
.
commit
(
rootState
.
currentProjectId
,
payload
)
.
then
(()
=>
service
.
commit
(
rootState
.
currentProjectId
,
payload
)
)
.
then
(({
data
})
=>
{
.
then
(({
data
})
=>
{
commit
(
types
.
UPDATE_LOADING
,
false
);
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;
...
@@ -5,9 +5,6 @@ const BRANCH_SUFFIX_COUNT = 5;
export
const
discardDraftButtonDisabled
=
state
=>
export
const
discardDraftButtonDisabled
=
state
=>
state
.
commitMessage
===
''
||
state
.
submitCommitLoading
;
state
.
commitMessage
===
''
||
state
.
submitCommitLoading
;
export
const
commitButtonDisabled
=
(
state
,
getters
,
rootState
)
=>
getters
.
discardDraftButtonDisabled
||
!
rootState
.
stagedFiles
.
length
;
export
const
newBranchName
=
(
state
,
_
,
rootState
)
=>
export
const
newBranchName
=
(
state
,
_
,
rootState
)
=>
`
${
gon
.
current_username
}
-
${
rootState
.
currentBranchId
}
-patch-
${
`
${
new
Date
().
getTime
()}
`
.
substr
(
`
${
gon
.
current_username
}
-
${
rootState
.
currentBranchId
}
-patch-
${
`
${
new
Date
().
getTime
()}
`
.
substr
(
-
BRANCH_SUFFIX_COUNT
,
-
BRANCH_SUFFIX_COUNT
,
...
...
spec/javascripts/ide/stores/modules/commit/getters_spec.js
View file @
e08ce52a
...
@@ -29,46 +29,6 @@ describe('IDE commit module getters', () => {
...
@@ -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
'
,
()
=>
{
describe
(
'
newBranchName
'
,
()
=>
{
it
(
'
includes username, currentBranchId, patch & random number
'
,
()
=>
{
it
(
'
includes username, currentBranchId, patch & random number
'
,
()
=>
{
gon
.
current_username
=
'
username
'
;
gon
.
current_username
=
'
username
'
;
...
@@ -108,9 +68,7 @@ describe('IDE commit module getters', () => {
...
@@ -108,9 +68,7 @@ describe('IDE commit module getters', () => {
});
});
it
(
'
uses newBranchName when not empty
'
,
()
=>
{
it
(
'
uses newBranchName when not empty
'
,
()
=>
{
expect
(
getters
.
branchName
(
state
,
localGetters
,
rootState
)).
toBe
(
expect
(
getters
.
branchName
(
state
,
localGetters
,
rootState
)).
toBe
(
'
state-newBranchName
'
);
'
state-newBranchName
'
,
);
});
});
it
(
'
uses getters newBranchName when state newBranchName is empty
'
,
()
=>
{
it
(
'
uses getters newBranchName when state newBranchName is empty
'
,
()
=>
{
...
@@ -118,9 +76,7 @@ describe('IDE commit module getters', () => {
...
@@ -118,9 +76,7 @@ describe('IDE commit module getters', () => {
newBranchName
:
''
,
newBranchName
:
''
,
});
});
expect
(
getters
.
branchName
(
state
,
localGetters
,
rootState
)).
toBe
(
expect
(
getters
.
branchName
(
state
,
localGetters
,
rootState
)).
toBe
(
'
newBranchName
'
);
'
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