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
377afd65
Commit
377afd65
authored
Jul 25, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable renaming files & folders in the Web IDE
Closes #44845
parent
2ca8219a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
66 additions
and
11 deletions
+66
-11
app/assets/javascripts/ide/components/new_dropdown/index.vue
app/assets/javascripts/ide/components/new_dropdown/index.vue
+9
-0
app/assets/javascripts/ide/components/new_dropdown/modal.vue
app/assets/javascripts/ide/components/new_dropdown/modal.vue
+11
-5
app/assets/javascripts/ide/components/repo_file.vue
app/assets/javascripts/ide/components/repo_file.vue
+1
-3
app/assets/javascripts/ide/stores/mutations.js
app/assets/javascripts/ide/stores/mutations.js
+5
-1
app/assets/javascripts/ide/stores/state.js
app/assets/javascripts/ide/stores/state.js
+2
-1
changelogs/unreleased/ide-rename-files.yml
changelogs/unreleased/ide-rename-files.yml
+5
-0
spec/javascripts/ide/components/new_dropdown/modal_spec.js
spec/javascripts/ide/components/new_dropdown/modal_spec.js
+33
-1
No files found.
app/assets/javascripts/ide/components/new_dropdown/index.vue
View file @
377afd65
...
...
@@ -109,6 +109,15 @@ export default {
</li>
<li
class=
"divider"
></li>
</
template
>
<li>
<item-button
:label=
"__('Rename')"
class=
"d-flex"
icon=
"pencil"
icon-classes=
"mr-2"
@
click=
"createNewItem('rename')"
/>
</li>
<li>
<item-button
:label=
"__('Delete')"
...
...
app/assets/javascripts/ide/components/new_dropdown/modal.vue
View file @
377afd65
...
...
@@ -13,24 +13,30 @@ export default {
};
},
computed
:
{
...
mapState
([
'
newE
ntryModal
'
]),
...
mapState
([
'
e
ntryModal
'
]),
entryName
:
{
get
()
{
return
this
.
name
||
(
this
.
newEntryModal
.
path
!==
''
?
`
${
this
.
newEntryModal
.
path
}
/`
:
''
);
if
(
this
.
entryModal
.
type
===
'
rename
'
)
return
this
.
name
||
this
.
entryModal
.
entry
.
name
;
return
this
.
name
||
(
this
.
entryModal
.
path
!==
''
?
`
${
this
.
entryModal
.
path
}
/`
:
''
);
},
set
(
val
)
{
this
.
name
=
val
;
},
},
modalTitle
()
{
if
(
this
.
newEntryModal
.
type
===
'
tree
'
)
{
if
(
this
.
entryModal
.
type
===
'
rename
'
)
return
__
(
'
Rename
'
);
if
(
this
.
entryModal
.
type
===
'
tree
'
)
{
return
__
(
'
Create new directory
'
);
}
return
__
(
'
Create new file
'
);
},
buttonLabel
()
{
if
(
this
.
newEntryModal
.
type
===
'
tree
'
)
{
if
(
this
.
entryModal
.
type
===
'
rename
'
)
return
__
(
'
Update
'
);
if
(
this
.
entryModal
.
type
===
'
tree
'
)
{
return
__
(
'
Create directory
'
);
}
...
...
@@ -42,7 +48,7 @@ export default {
createEntryInStore
()
{
this
.
createTempEntry
({
name
:
this
.
name
,
type
:
this
.
newE
ntryModal
.
type
,
type
:
this
.
e
ntryModal
.
type
,
});
},
focusInput
()
{
...
...
app/assets/javascripts/ide/components/repo_file.vue
View file @
377afd65
...
...
@@ -134,8 +134,7 @@ export default {
.
replace
(
/
[/]
$/g
,
''
);
// - strip ending "/"
const
filePath
=
this
.
file
.
path
.
replace
(
/
[/]
$/g
,
''
);
const
filePath
=
this
.
file
.
path
.
replace
(
/
[/]
$/g
,
''
);
return
filePath
===
routePath
;
},
...
...
@@ -208,7 +207,6 @@ export default {
</span>
<new-dropdown
:type=
"file.type"
:branch=
"file.branchId"
:path=
"file.path"
:mouse-over=
"mouseOver"
class=
"float-right prepend-left-8"
...
...
app/assets/javascripts/ide/stores/mutations.js
View file @
377afd65
...
...
@@ -169,7 +169,11 @@ export default {
},
[
types
.
OPEN_NEW_ENTRY_MODAL
](
state
,
{
type
,
path
})
{
Object
.
assign
(
state
,
{
newEntryModal
:
{
type
,
path
},
entryModal
:
{
type
,
path
,
entry
:
{
...
state
.
entries
[
path
]
},
},
});
},
[
types
.
DELETE_ENTRY
](
state
,
path
)
{
...
...
app/assets/javascripts/ide/stores/state.js
View file @
377afd65
...
...
@@ -26,8 +26,9 @@ export default () => ({
rightPane
:
null
,
links
:
{},
errorMessage
:
null
,
newE
ntryModal
:
{
e
ntryModal
:
{
type
:
''
,
path
:
''
,
entry
:
{},
},
});
changelogs/unreleased/ide-rename-files.yml
0 → 100644
View file @
377afd65
---
title
:
Enable renaming files and folders in Web IDE
merge_request
:
author
:
type
:
added
spec/javascripts/ide/components/new_dropdown/modal_spec.js
View file @
377afd65
...
...
@@ -15,7 +15,7 @@ describe('new file modal component', () => {
describe
(
type
,
()
=>
{
beforeEach
(()
=>
{
const
store
=
createStore
();
store
.
state
.
newE
ntryModal
=
{
store
.
state
.
e
ntryModal
=
{
type
,
path
:
''
,
};
...
...
@@ -55,4 +55,36 @@ describe('new file modal component', () => {
});
});
});
describe
(
'
rename entry
'
,
()
=>
{
beforeEach
(()
=>
{
const
store
=
createStore
();
store
.
state
.
entryModal
=
{
type
:
'
rename
'
,
path
:
''
,
entry
:
{
name
:
'
test
'
,
},
};
vm
=
createComponentWithStore
(
Component
,
store
).
$mount
();
});
it
(
'
renders title and button for renaming
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.modal-title
'
).
textContent
.
trim
()).
toBe
(
'
Rename
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.btn-success
'
).
textContent
.
trim
()).
toBe
(
'
Update
'
);
});
describe
(
'
entryName
'
,
()
=>
{
it
(
'
returns entries name
'
,
()
=>
{
expect
(
vm
.
entryName
).
toBe
(
'
test
'
);
});
it
(
'
updated name
'
,
()
=>
{
vm
.
name
=
'
index.js
'
;
expect
(
vm
.
entryName
).
toBe
(
'
index.js
'
);
});
});
});
});
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