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
d0378125
Commit
d0378125
authored
Apr 05, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update staged files to correctly use pending tab
parent
c02d344c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
42 additions
and
62 deletions
+42
-62
app/assets/javascripts/ide/components/commit_sidebar/list_item.vue
...s/javascripts/ide/components/commit_sidebar/list_item.vue
+4
-1
app/assets/javascripts/ide/components/repo_editor.vue
app/assets/javascripts/ide/components/repo_editor.vue
+1
-5
app/assets/javascripts/ide/lib/common/model.js
app/assets/javascripts/ide/lib/common/model.js
+2
-2
app/assets/javascripts/ide/stores/actions/file.js
app/assets/javascripts/ide/stores/actions/file.js
+17
-5
app/assets/javascripts/ide/stores/modules/commit/actions.js
app/assets/javascripts/ide/stores/modules/commit/actions.js
+9
-29
spec/javascripts/ide/stores/modules/commit/actions_spec.js
spec/javascripts/ide/stores/modules/commit/actions_spec.js
+9
-20
No files found.
app/assets/javascripts/ide/components/commit_sidebar/list_item.vue
View file @
d0378125
...
...
@@ -31,7 +31,10 @@ export default {
methods
:
{
...
mapActions
([
'
discardFileChanges
'
,
'
updateViewer
'
,
'
openPendingTab
'
]),
openFileInEditor
()
{
return
this
.
openPendingTab
(
this
.
file
).
then
(
changeViewer
=>
{
return
this
.
openPendingTab
({
file
:
this
.
file
,
keyPrefix
:
this
.
file
.
staged
?
'
staged
'
:
'
unstaged
'
,
}).
then
(
changeViewer
=>
{
if
(
changeViewer
)
{
this
.
updateViewer
(
'
diff
'
);
}
...
...
app/assets/javascripts/ide/components/repo_editor.vue
View file @
d0378125
...
...
@@ -70,11 +70,7 @@ export default {
baseSha
:
this
.
currentMergeRequest
?
this
.
currentMergeRequest
.
baseCommitSha
:
''
,
})
.
then
(()
=>
{
const
viewerPromise
=
this
.
delayViewerUpdated
?
this
.
updateViewer
(
this
.
file
.
pending
?
'
diff
'
:
'
editor
'
)
:
Promise
.
resolve
();
return
viewerPromise
;
return
this
.
updateViewer
(
this
.
file
.
pending
?
'
diff
'
:
'
editor
'
);
})
.
then
(()
=>
{
this
.
updateDelayViewerUpdated
(
false
);
...
...
app/assets/javascripts/ide/lib/common/model.js
View file @
d0378125
...
...
@@ -37,7 +37,7 @@ export default class Model {
this
.
dispose
=
this
.
dispose
.
bind
(
this
);
eventHub
.
$on
(
`editor.update.model.dispose.
${
this
.
file
.
key
}
`
,
this
.
dispose
);
eventHub
.
$on
(
`editor.update.model.content.
${
this
.
file
.
path
}
`
,
this
.
updateContent
);
eventHub
.
$on
(
`editor.update.model.content.
${
this
.
file
.
key
}
`
,
this
.
updateContent
);
}
get
url
()
{
...
...
@@ -92,6 +92,6 @@ export default class Model {
this
.
events
.
clear
();
eventHub
.
$off
(
`editor.update.model.dispose.
${
this
.
file
.
key
}
`
,
this
.
dispose
);
eventHub
.
$off
(
`editor.update.model.content.
${
this
.
file
.
path
}
`
,
this
.
updateContent
);
eventHub
.
$off
(
`editor.update.model.content.
${
this
.
file
.
key
}
`
,
this
.
updateContent
);
}
}
app/assets/javascripts/ide/stores/actions/file.js
View file @
d0378125
...
...
@@ -24,7 +24,10 @@ export const closeFile = ({ commit, state, dispatch }, file) => {
if
(
nextFileToOpen
.
pending
)
{
dispatch
(
'
updateViewer
'
,
'
diff
'
);
dispatch
(
'
openPendingTab
'
,
nextFileToOpen
);
dispatch
(
'
openPendingTab
'
,
{
file
:
nextFileToOpen
,
keyPrefix
:
nextFileToOpen
.
staged
?
'
staged
'
:
'
unstaged
'
,
});
}
else
{
dispatch
(
'
updateDelayViewerUpdated
'
,
true
);
router
.
push
(
`/project
${
nextFileToOpen
.
url
}
`
);
...
...
@@ -159,26 +162,35 @@ export const discardFileChanges = ({ state, commit }, path) => {
commit
(
types
.
TOGGLE_FILE_OPEN
,
path
);
}
eventHub
.
$emit
(
`editor.update.model.content.
${
path
}
`
,
{
eventHub
.
$emit
(
`editor.update.model.content.
${
file
.
key
}
`
,
{
content
:
file
.
raw
,
changed
:
false
,
});
};
export
const
stageChange
=
({
commit
},
path
)
=>
{
export
const
stageChange
=
({
commit
,
state
},
path
)
=>
{
const
stagedFile
=
state
.
stagedFiles
.
find
(
f
=>
f
.
path
===
path
);
commit
(
types
.
STAGE_CHANGE
,
path
);
if
(
stagedFile
)
{
eventHub
.
$emit
(
`editor.update.model.content.staged-
${
stagedFile
.
key
}
`
,
{
content
:
stagedFile
.
content
,
changed
:
false
,
});
}
};
export
const
unstageChange
=
({
commit
},
path
)
=>
{
commit
(
types
.
UNSTAGE_CHANGE
,
path
);
};
export
const
openPendingTab
=
({
commit
,
getters
,
dispatch
,
state
},
file
)
=>
{
export
const
openPendingTab
=
({
commit
,
getters
,
dispatch
,
state
},
{
file
,
keyPrefix
}
)
=>
{
if
(
getters
.
activeFile
&&
getters
.
activeFile
.
path
===
file
.
path
&&
state
.
viewer
===
'
diff
'
)
{
return
false
;
}
commit
(
types
.
ADD_PENDING_TAB
,
{
file
});
commit
(
types
.
ADD_PENDING_TAB
,
{
file
,
keyPrefix
});
dispatch
(
'
scrollToTab
'
);
...
...
app/assets/javascripts/ide/stores/modules/commit/actions.js
View file @
d0378125
...
...
@@ -37,9 +37,9 @@ export const setLastCommitMessage = ({ rootState, commit }, data) => {
const
commitMsg
=
sprintf
(
__
(
'
Your changes have been committed. Commit %{commitId} %{commitStats}
'
),
{
commitId
:
`<a href="
${
currentProject
.
web_url
}
/commit/
${
commitId
:
`<a href="
${
currentProject
.
web_url
}
/commit/
${
data
.
short_id
}
" class="commit-sha">
${
data
.
short_id
}
" class="commit-sha">
${
data
.
short_id
}
</a>`
,
}
</a>`
,
commitStats
,
},
false
,
...
...
@@ -54,9 +54,7 @@ export const checkCommitStatus = ({ rootState }) =>
.
then
(({
data
})
=>
{
const
{
id
}
=
data
.
commit
;
const
selectedBranch
=
rootState
.
projects
[
rootState
.
currentProjectId
].
branches
[
rootState
.
currentBranchId
];
rootState
.
projects
[
rootState
.
currentProjectId
].
branches
[
rootState
.
currentBranchId
];
if
(
selectedBranch
.
workingReference
!==
id
)
{
return
true
;
...
...
@@ -112,43 +110,25 @@ export const updateFilesAfterCommit = (
{
root
:
true
},
);
eventHub
.
$emit
(
`editor.update.model.content.
${
file
.
path
}
`
,
{
eventHub
.
$emit
(
`editor.update.model.content.
${
file
.
key
}
`
,
{
content
:
file
.
content
,
changed
:
!!
changedFile
,
});
});
if
(
state
.
commitAction
===
consts
.
COMMIT_TO_NEW_BRANCH
&&
rootGetters
.
activeFile
)
{
if
(
state
.
commitAction
===
consts
.
COMMIT_TO_NEW_BRANCH
&&
rootGetters
.
activeFile
)
{
router
.
push
(
`/project/
${
rootState
.
currentProjectId
}
/blob/
${
branch
}
/
${
rootGetters
.
activeFile
.
path
}
`
,
`/project/
${
rootState
.
currentProjectId
}
/blob/
${
branch
}
/
${
rootGetters
.
activeFile
.
path
}
`
,
);
}
dispatch
(
'
updateCommitAction
'
,
consts
.
COMMIT_TO_CURRENT_BRANCH
);
};
export
const
commitChanges
=
({
commit
,
state
,
getters
,
dispatch
,
rootState
,
})
=>
{
export
const
commitChanges
=
({
commit
,
state
,
getters
,
dispatch
,
rootState
})
=>
{
const
newBranch
=
state
.
commitAction
!==
consts
.
COMMIT_TO_CURRENT_BRANCH
;
const
payload
=
createCommitPayload
(
getters
.
branchName
,
newBranch
,
state
,
rootState
,
);
const
getCommitStatus
=
newBranch
?
Promise
.
resolve
(
false
)
:
dispatch
(
'
checkCommitStatus
'
);
const
payload
=
createCommitPayload
(
getters
.
branchName
,
newBranch
,
state
,
rootState
);
const
getCommitStatus
=
newBranch
?
Promise
.
resolve
(
false
)
:
dispatch
(
'
checkCommitStatus
'
);
commit
(
types
.
UPDATE_LOADING
,
true
);
...
...
spec/javascripts/ide/stores/modules/commit/actions_spec.js
View file @
d0378125
...
...
@@ -133,10 +133,7 @@ describe('IDE commit module actions', () => {
store
.
dispatch
(
'
commit/checkCommitStatus
'
)
.
then
(()
=>
{
expect
(
service
.
getBranchData
).
toHaveBeenCalledWith
(
'
abcproject
'
,
'
master
'
,
);
expect
(
service
.
getBranchData
).
toHaveBeenCalledWith
(
'
abcproject
'
,
'
master
'
);
done
();
})
...
...
@@ -230,9 +227,7 @@ describe('IDE commit module actions', () => {
branch
,
})
.
then
(()
=>
{
expect
(
store
.
state
.
projects
.
abcproject
.
branches
.
master
.
workingReference
,
).
toBe
(
data
.
id
);
expect
(
store
.
state
.
projects
.
abcproject
.
branches
.
master
.
workingReference
).
toBe
(
data
.
id
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
...
...
@@ -286,10 +281,10 @@ describe('IDE commit module actions', () => {
branch
,
})
.
then
(()
=>
{
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
`editor.update.model.content.
${
f
.
path
}
`
,
{
content
:
f
.
content
,
changed
:
false
}
,
);
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
`editor.update.model.content.
${
f
.
key
}
`
,
{
content
:
f
.
content
,
changed
:
false
,
}
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
...
...
@@ -304,9 +299,7 @@ describe('IDE commit module actions', () => {
branch
,
})
.
then
(()
=>
{
expect
(
router
.
push
).
toHaveBeenCalledWith
(
`/project/abcproject/blob/master/
${
f
.
path
}
`
,
);
expect
(
router
.
push
).
toHaveBeenCalledWith
(
`/project/abcproject/blob/master/
${
f
.
path
}
`
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
...
...
@@ -321,9 +314,7 @@ describe('IDE commit module actions', () => {
branch
,
})
.
then
(()
=>
{
expect
(
store
.
state
.
commit
.
commitAction
).
not
.
toBe
(
consts
.
COMMIT_TO_NEW_BRANCH
,
);
expect
(
store
.
state
.
commit
.
commitAction
).
not
.
toBe
(
consts
.
COMMIT_TO_NEW_BRANCH
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
...
...
@@ -445,9 +436,7 @@ describe('IDE commit module actions', () => {
store
.
dispatch
(
'
commit/commitChanges
'
)
.
then
(()
=>
{
expect
(
store
.
state
.
openFiles
[
0
].
lastCommit
.
message
).
toBe
(
'
test message
'
,
);
expect
(
store
.
state
.
openFiles
[
0
].
lastCommit
.
message
).
toBe
(
'
test message
'
);
done
();
})
...
...
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