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
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 {
...
@@ -109,6 +109,15 @@ export default {
</li>
</li>
<li
class=
"divider"
></li>
<li
class=
"divider"
></li>
</
template
>
</
template
>
<li>
<item-button
:label=
"__('Rename')"
class=
"d-flex"
icon=
"pencil"
icon-classes=
"mr-2"
@
click=
"createNewItem('rename')"
/>
</li>
<li>
<li>
<item-button
<item-button
:label=
"__('Delete')"
:label=
"__('Delete')"
...
...
app/assets/javascripts/ide/components/new_dropdown/modal.vue
View file @
377afd65
...
@@ -13,24 +13,30 @@ export default {
...
@@ -13,24 +13,30 @@ export default {
};
};
},
},
computed
:
{
computed
:
{
...
mapState
([
'
newE
ntryModal
'
]),
...
mapState
([
'
e
ntryModal
'
]),
entryName
:
{
entryName
:
{
get
()
{
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
)
{
set
(
val
)
{
this
.
name
=
val
;
this
.
name
=
val
;
},
},
},
},
modalTitle
()
{
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 directory
'
);
}
}
return
__
(
'
Create new file
'
);
return
__
(
'
Create new file
'
);
},
},
buttonLabel
()
{
buttonLabel
()
{
if
(
this
.
newEntryModal
.
type
===
'
tree
'
)
{
if
(
this
.
entryModal
.
type
===
'
rename
'
)
return
__
(
'
Update
'
);
if
(
this
.
entryModal
.
type
===
'
tree
'
)
{
return
__
(
'
Create directory
'
);
return
__
(
'
Create directory
'
);
}
}
...
@@ -42,7 +48,7 @@ export default {
...
@@ -42,7 +48,7 @@ export default {
createEntryInStore
()
{
createEntryInStore
()
{
this
.
createTempEntry
({
this
.
createTempEntry
({
name
:
this
.
name
,
name
:
this
.
name
,
type
:
this
.
newE
ntryModal
.
type
,
type
:
this
.
e
ntryModal
.
type
,
});
});
},
},
focusInput
()
{
focusInput
()
{
...
...
app/assets/javascripts/ide/components/repo_file.vue
View file @
377afd65
...
@@ -134,8 +134,7 @@ export default {
...
@@ -134,8 +134,7 @@ export default {
.
replace
(
/
[/]
$/g
,
''
);
.
replace
(
/
[/]
$/g
,
''
);
// - strip ending "/"
// - strip ending "/"
const
filePath
=
this
.
file
.
path
const
filePath
=
this
.
file
.
path
.
replace
(
/
[/]
$/g
,
''
);
.
replace
(
/
[/]
$/g
,
''
);
return
filePath
===
routePath
;
return
filePath
===
routePath
;
},
},
...
@@ -208,7 +207,6 @@ export default {
...
@@ -208,7 +207,6 @@ export default {
</span>
</span>
<new-dropdown
<new-dropdown
:type=
"file.type"
:type=
"file.type"
:branch=
"file.branchId"
:path=
"file.path"
:path=
"file.path"
:mouse-over=
"mouseOver"
:mouse-over=
"mouseOver"
class=
"float-right prepend-left-8"
class=
"float-right prepend-left-8"
...
...
app/assets/javascripts/ide/stores/mutations.js
View file @
377afd65
...
@@ -169,7 +169,11 @@ export default {
...
@@ -169,7 +169,11 @@ export default {
},
},
[
types
.
OPEN_NEW_ENTRY_MODAL
](
state
,
{
type
,
path
})
{
[
types
.
OPEN_NEW_ENTRY_MODAL
](
state
,
{
type
,
path
})
{
Object
.
assign
(
state
,
{
Object
.
assign
(
state
,
{
newEntryModal
:
{
type
,
path
},
entryModal
:
{
type
,
path
,
entry
:
{
...
state
.
entries
[
path
]
},
},
});
});
},
},
[
types
.
DELETE_ENTRY
](
state
,
path
)
{
[
types
.
DELETE_ENTRY
](
state
,
path
)
{
...
...
app/assets/javascripts/ide/stores/state.js
View file @
377afd65
...
@@ -26,8 +26,9 @@ export default () => ({
...
@@ -26,8 +26,9 @@ export default () => ({
rightPane
:
null
,
rightPane
:
null
,
links
:
{},
links
:
{},
errorMessage
:
null
,
errorMessage
:
null
,
newE
ntryModal
:
{
e
ntryModal
:
{
type
:
''
,
type
:
''
,
path
:
''
,
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', () => {
...
@@ -15,7 +15,7 @@ describe('new file modal component', () => {
describe
(
type
,
()
=>
{
describe
(
type
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
const
store
=
createStore
();
const
store
=
createStore
();
store
.
state
.
newE
ntryModal
=
{
store
.
state
.
e
ntryModal
=
{
type
,
type
,
path
:
''
,
path
:
''
,
};
};
...
@@ -55,4 +55,36 @@ describe('new file modal component', () => {
...
@@ -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