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
e7fe50bf
Commit
e7fe50bf
authored
Jul 27, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename files
not working for folders yet
parent
73473dfc
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
9 deletions
+66
-9
app/assets/javascripts/ide/components/new_dropdown/modal.vue
app/assets/javascripts/ide/components/new_dropdown/modal.vue
+14
-7
app/assets/javascripts/ide/stores/actions.js
app/assets/javascripts/ide/stores/actions.js
+5
-0
app/assets/javascripts/ide/stores/mutation_types.js
app/assets/javascripts/ide/stores/mutation_types.js
+1
-0
app/assets/javascripts/ide/stores/mutations.js
app/assets/javascripts/ide/stores/mutations.js
+37
-0
app/assets/javascripts/ide/stores/utils.js
app/assets/javascripts/ide/stores/utils.js
+9
-2
No files found.
app/assets/javascripts/ide/components/new_dropdown/modal.vue
View file @
e7fe50bf
...
@@ -44,12 +44,19 @@ export default {
...
@@ -44,12 +44,19 @@ export default {
},
},
},
},
methods
:
{
methods
:
{
...
mapActions
([
'
createTempEntry
'
]),
...
mapActions
([
'
createTempEntry
'
,
'
renameEntry
'
]),
createEntryInStore
()
{
submitForm
()
{
this
.
createTempEntry
({
if
(
this
.
entryModal
.
type
===
'
rename
'
)
{
name
:
this
.
name
,
this
.
renameEntry
({
type
:
this
.
entryModal
.
type
,
path
:
this
.
entryModal
.
entry
.
path
,
});
name
:
this
.
entryName
,
});
}
else
{
this
.
createTempEntry
({
name
:
this
.
name
,
type
:
this
.
entryModal
.
type
,
});
}
},
},
focusInput
()
{
focusInput
()
{
setTimeout
(()
=>
{
setTimeout
(()
=>
{
...
@@ -66,7 +73,7 @@ export default {
...
@@ -66,7 +73,7 @@ export default {
:header-title-text=
"modalTitle"
:header-title-text=
"modalTitle"
:footer-primary-button-text=
"buttonLabel"
:footer-primary-button-text=
"buttonLabel"
footer-primary-button-variant=
"success"
footer-primary-button-variant=
"success"
@
submit=
"
createEntryInStore
"
@
submit=
"
submitForm
"
@
open=
"focusInput"
@
open=
"focusInput"
>
>
<div
<div
...
...
app/assets/javascripts/ide/stores/actions.js
View file @
e7fe50bf
...
@@ -193,6 +193,11 @@ export const deleteEntry = ({ commit, dispatch, state }, path) => {
...
@@ -193,6 +193,11 @@ export const deleteEntry = ({ commit, dispatch, state }, path) => {
export
const
resetOpenFiles
=
({
commit
})
=>
commit
(
types
.
RESET_OPEN_FILES
);
export
const
resetOpenFiles
=
({
commit
})
=>
commit
(
types
.
RESET_OPEN_FILES
);
export
const
renameEntry
=
({
dispatch
,
commit
},
{
path
,
name
})
=>
{
commit
(
types
.
RENAME_ENTRY
,
{
path
,
name
});
dispatch
(
'
deleteEntry
'
,
path
);
};
export
*
from
'
./actions/tree
'
;
export
*
from
'
./actions/tree
'
;
export
*
from
'
./actions/file
'
;
export
*
from
'
./actions/file
'
;
export
*
from
'
./actions/project
'
;
export
*
from
'
./actions/project
'
;
...
...
app/assets/javascripts/ide/stores/mutation_types.js
View file @
e7fe50bf
...
@@ -77,3 +77,4 @@ export const SET_ERROR_MESSAGE = 'SET_ERROR_MESSAGE';
...
@@ -77,3 +77,4 @@ export const SET_ERROR_MESSAGE = 'SET_ERROR_MESSAGE';
export
const
OPEN_NEW_ENTRY_MODAL
=
'
OPEN_NEW_ENTRY_MODAL
'
;
export
const
OPEN_NEW_ENTRY_MODAL
=
'
OPEN_NEW_ENTRY_MODAL
'
;
export
const
DELETE_ENTRY
=
'
DELETE_ENTRY
'
;
export
const
DELETE_ENTRY
=
'
DELETE_ENTRY
'
;
export
const
RENAME_ENTRY
=
'
RENAME_ENTRY
'
;
app/assets/javascripts/ide/stores/mutations.js
View file @
e7fe50bf
...
@@ -131,11 +131,14 @@ export default {
...
@@ -131,11 +131,14 @@ export default {
},
},
[
types
.
UPDATE_FILE_AFTER_COMMIT
](
state
,
{
file
,
lastCommit
})
{
[
types
.
UPDATE_FILE_AFTER_COMMIT
](
state
,
{
file
,
lastCommit
})
{
const
changedFile
=
state
.
changedFiles
.
find
(
f
=>
f
.
path
===
file
.
path
);
const
changedFile
=
state
.
changedFiles
.
find
(
f
=>
f
.
path
===
file
.
path
);
const
{
prevPath
}
=
file
;
Object
.
assign
(
state
.
entries
[
file
.
path
],
{
Object
.
assign
(
state
.
entries
[
file
.
path
],
{
raw
:
file
.
content
,
raw
:
file
.
content
,
changed
:
!!
changedFile
,
changed
:
!!
changedFile
,
staged
:
false
,
staged
:
false
,
prevPath
:
''
,
moved
:
false
,
lastCommit
:
Object
.
assign
(
state
.
entries
[
file
.
path
].
lastCommit
,
{
lastCommit
:
Object
.
assign
(
state
.
entries
[
file
.
path
].
lastCommit
,
{
id
:
lastCommit
.
commit
.
id
,
id
:
lastCommit
.
commit
.
id
,
url
:
lastCommit
.
commit_path
,
url
:
lastCommit
.
commit_path
,
...
@@ -144,6 +147,18 @@ export default {
...
@@ -144,6 +147,18 @@ export default {
updatedAt
:
lastCommit
.
commit
.
authored_date
,
updatedAt
:
lastCommit
.
commit
.
authored_date
,
}),
}),
});
});
if
(
prevPath
)
{
// Update URLs after file has moved
const
regex
=
new
RegExp
(
`
${
prevPath
}
$`
);
Object
.
assign
(
state
.
entries
[
file
.
path
],
{
rawPath
:
file
.
rawPath
.
replace
(
regex
,
file
.
name
),
permalink
:
file
.
permalink
.
replace
(
regex
,
file
.
name
),
commitsPath
:
file
.
commitsPath
.
replace
(
regex
,
file
.
name
),
blamePath
:
file
.
blamePath
.
replace
(
regex
,
file
.
name
),
});
}
},
},
[
types
.
BURST_UNUSED_SEAL
](
state
)
{
[
types
.
BURST_UNUSED_SEAL
](
state
)
{
Object
.
assign
(
state
,
{
Object
.
assign
(
state
,
{
...
@@ -186,6 +201,28 @@ export default {
...
@@ -186,6 +201,28 @@ export default {
state
.
changedFiles
=
state
.
changedFiles
.
concat
(
entry
);
state
.
changedFiles
=
state
.
changedFiles
.
concat
(
entry
);
parent
.
tree
=
parent
.
tree
.
filter
(
f
=>
f
.
path
!==
entry
.
path
);
parent
.
tree
=
parent
.
tree
.
filter
(
f
=>
f
.
path
!==
entry
.
path
);
},
},
[
types
.
RENAME_ENTRY
](
state
,
{
path
,
name
})
{
const
oldEntry
=
state
.
entries
[
path
];
const
parent
=
oldEntry
.
parentPath
?
state
.
entries
[
oldEntry
.
parentPath
]
:
state
.
trees
[
`
${
state
.
currentProjectId
}
/
${
state
.
currentBranchId
}
`
];
const
nameRegex
=
new
RegExp
(
`
${
oldEntry
.
name
}
$`
);
const
newPath
=
path
.
replace
(
nameRegex
,
name
);
state
.
entries
[
newPath
]
=
{
...
oldEntry
,
id
:
newPath
,
key
:
`
${
name
}
-
${
oldEntry
.
type
}
-
${
oldEntry
.
id
}
`
,
path
:
newPath
,
name
,
tempFile
:
true
,
prevPath
:
path
,
url
:
oldEntry
.
url
.
replace
(
nameRegex
,
name
),
};
oldEntry
.
moved
=
true
;
parent
.
tree
=
parent
.
tree
.
concat
(
state
.
entries
[
newPath
]);
state
.
changedFiles
=
state
.
changedFiles
.
concat
(
state
.
entries
[
newPath
]);
},
...
projectMutations
,
...
projectMutations
,
...
mergeRequestMutation
,
...
mergeRequestMutation
,
...
fileMutations
,
...
fileMutations
,
...
...
app/assets/javascripts/ide/stores/utils.js
View file @
e7fe50bf
...
@@ -47,6 +47,8 @@ export const dataStructure = () => ({
...
@@ -47,6 +47,8 @@ export const dataStructure = () => ({
lastOpenedAt
:
0
,
lastOpenedAt
:
0
,
mrChange
:
null
,
mrChange
:
null
,
deleted
:
false
,
deleted
:
false
,
prevPath
:
''
,
moved
:
false
,
});
});
export
const
decorateData
=
entity
=>
{
export
const
decorateData
=
entity
=>
{
...
@@ -107,7 +109,9 @@ export const setPageTitle = title => {
...
@@ -107,7 +109,9 @@ export const setPageTitle = title => {
};
};
export
const
commitActionForFile
=
file
=>
{
export
const
commitActionForFile
=
file
=>
{
if
(
file
.
deleted
)
{
if
(
file
.
prevPath
!==
''
)
{
return
'
move
'
;
}
else
if
(
file
.
deleted
)
{
return
'
delete
'
;
return
'
delete
'
;
}
else
if
(
file
.
tempFile
)
{
}
else
if
(
file
.
tempFile
)
{
return
'
create
'
;
return
'
create
'
;
...
@@ -118,6 +122,8 @@ export const commitActionForFile = file => {
...
@@ -118,6 +122,8 @@ export const commitActionForFile = file => {
export
const
getCommitFiles
=
(
stagedFiles
,
deleteTree
=
false
)
=>
export
const
getCommitFiles
=
(
stagedFiles
,
deleteTree
=
false
)
=>
stagedFiles
.
reduce
((
acc
,
file
)
=>
{
stagedFiles
.
reduce
((
acc
,
file
)
=>
{
if
(
file
.
moved
)
return
acc
;
if
((
file
.
deleted
||
deleteTree
)
&&
file
.
type
===
'
tree
'
)
{
if
((
file
.
deleted
||
deleteTree
)
&&
file
.
type
===
'
tree
'
)
{
return
acc
.
concat
(
getCommitFiles
(
file
.
tree
,
true
));
return
acc
.
concat
(
getCommitFiles
(
file
.
tree
,
true
));
}
}
...
@@ -134,9 +140,10 @@ export const createCommitPayload = ({ branch, getters, newBranch, state, rootSta
...
@@ -134,9 +140,10 @@ export const createCommitPayload = ({ branch, getters, newBranch, state, rootSta
actions
:
getCommitFiles
(
rootState
.
stagedFiles
).
map
(
f
=>
({
actions
:
getCommitFiles
(
rootState
.
stagedFiles
).
map
(
f
=>
({
action
:
commitActionForFile
(
f
),
action
:
commitActionForFile
(
f
),
file_path
:
f
.
path
,
file_path
:
f
.
path
,
previous_path
:
f
.
prevPath
===
''
?
undefined
:
f
.
prevPath
,
content
:
f
.
content
,
content
:
f
.
content
,
encoding
:
f
.
base64
?
'
base64
'
:
'
text
'
,
encoding
:
f
.
base64
?
'
base64
'
:
'
text
'
,
last_commit_id
:
newBranch
||
f
.
deleted
?
undefined
:
f
.
lastCommitSha
,
last_commit_id
:
newBranch
||
f
.
deleted
||
f
.
prevPath
?
undefined
:
f
.
lastCommitSha
,
})),
})),
start_branch
:
newBranch
?
rootState
.
currentBranchId
:
undefined
,
start_branch
:
newBranch
?
rootState
.
currentBranchId
:
undefined
,
});
});
...
...
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