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
Jérome Perrin
gitlab-ce
Commits
fe1871b5
Commit
fe1871b5
authored
Oct 23, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved to eventHub to manage creating new files
removed an ID from the CSS
parent
5f988a72
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
71 additions
and
50 deletions
+71
-50
app/assets/javascripts/repo/components/new_dropdown/index.vue
...assets/javascripts/repo/components/new_dropdown/index.vue
+16
-0
app/assets/javascripts/repo/components/new_dropdown/modal.vue
...assets/javascripts/repo/components/new_dropdown/modal.vue
+7
-41
app/assets/javascripts/repo/components/repo.vue
app/assets/javascripts/repo/components/repo.vue
+2
-1
app/assets/javascripts/repo/components/repo_file_buttons.vue
app/assets/javascripts/repo/components/repo_file_buttons.vue
+1
-1
app/assets/javascripts/repo/helpers/repo_helper.js
app/assets/javascripts/repo/helpers/repo_helper.js
+44
-4
app/assets/javascripts/repo/stores/repo_store.js
app/assets/javascripts/repo/stores/repo_store.js
+0
-2
app/assets/stylesheets/pages/repo.scss
app/assets/stylesheets/pages/repo.scss
+1
-1
No files found.
app/assets/javascripts/repo/components/new_dropdown/index.vue
View file @
fe1871b5
<
script
>
import
RepoHelper
from
'
../../helpers/repo_helper
'
;
import
RepoStore
from
'
../../stores/repo_store
'
;
import
eventHub
from
'
../../event_hub
'
;
import
newModal
from
'
./modal.vue
'
;
export
default
{
...
...
@@ -9,6 +12,7 @@
return
{
openModal
:
false
,
modalType
:
''
,
currentPath
:
RepoStore
.
path
,
};
},
methods
:
{
...
...
@@ -19,6 +23,17 @@
toggleModalOpen
()
{
this
.
openModal
=
!
this
.
openModal
;
},
createNewEntryInStore
(
name
,
type
)
{
RepoHelper
.
createNewEntry
(
name
,
type
);
this
.
toggleModalOpen
();
},
},
created
()
{
eventHub
.
$on
(
'
createNewEntry
'
,
this
.
createNewEntryInStore
);
},
beforeDestroy
()
{
eventHub
.
$off
(
'
createNewEntry
'
,
this
.
createNewEntryInStore
);
},
};
</
script
>
...
...
@@ -64,6 +79,7 @@
<new-modal
v-if=
"openModal"
:type=
"modalType"
:current-path=
"currentPath"
@
toggle=
"toggleModalOpen"
/>
</div>
...
...
app/assets/javascripts/repo/components/new_dropdown/modal.vue
View file @
fe1871b5
<
script
>
import
{
__
}
from
'
../../../locale
'
;
import
popupDialog
from
'
../../../vue_shared/components/popup_dialog.vue
'
;
import
RepoStore
from
'
../../stores/repo_store
'
;
import
RepoHelper
from
'
../../helpers/repo_helper
'
;
import
eventHub
from
'
../../event_hub
'
;
export
default
{
props
:
{
currentPath
:
{
type
:
String
,
required
:
true
,
},
type
:
{
type
:
String
,
required
:
true
,
...
...
@@ -13,7 +16,7 @@
},
data
()
{
return
{
entryName
:
RepoStore
.
path
!==
''
?
`
${
RepoStore
.
p
ath
}
/`
:
''
,
entryName
:
this
.
currentPath
!==
''
?
`
${
this
.
currentP
ath
}
/`
:
''
,
};
},
components
:
{
...
...
@@ -21,44 +24,7 @@
},
methods
:
{
createEntryInStore
()
{
const
originalPath
=
RepoStore
.
path
;
let
entryName
=
this
.
entryName
;
if
(
entryName
.
indexOf
(
`
${
RepoStore
.
path
}
/`
)
!==
0
)
{
RepoStore
.
path
=
''
;
}
else
{
entryName
=
entryName
.
replace
(
`
${
RepoStore
.
path
}
/`
,
''
);
}
if
(
entryName
===
''
)
return
;
const
fileName
=
this
.
type
===
'
tree
'
?
'
.gitkeep
'
:
entryName
;
let
tree
=
RepoStore
;
if
(
this
.
type
===
'
tree
'
)
{
const
dirNames
=
entryName
.
split
(
'
/
'
);
dirNames
.
forEach
((
dirName
)
=>
{
if
(
dirName
===
''
)
return
;
tree
=
RepoHelper
.
findOrCreateEntry
(
'
tree
'
,
tree
,
dirName
).
entry
;
});
}
if
((
this
.
type
===
'
tree
'
&&
tree
.
tempFile
)
||
this
.
type
===
'
blob
'
)
{
const
file
=
RepoHelper
.
findOrCreateEntry
(
'
blob
'
,
tree
,
fileName
);
if
(
!
file
.
exists
)
{
RepoHelper
.
setFile
(
file
.
entry
,
file
.
entry
);
RepoStore
.
editMode
=
true
;
RepoStore
.
currentBlobView
=
'
repo-editor
'
;
}
}
this
.
toggleModalOpen
();
RepoStore
.
path
=
originalPath
;
eventHub
.
$emit
(
'
createNewEntry
'
,
this
.
entryName
,
this
.
type
);
},
toggleModalOpen
()
{
this
.
$emit
(
'
toggle
'
);
...
...
app/assets/javascripts/repo/components/repo.vue
View file @
fe1871b5
...
...
@@ -39,7 +39,8 @@ export default {
this
.
dialog
.
status
=
status
;
// remove tmp files
Helper
.
removeAllTmpFiles
();
Helper
.
removeAllTmpFiles
(
'
openedFiles
'
);
Helper
.
removeAllTmpFiles
(
'
files
'
);
},
toggleBlobView
:
Store
.
toggleBlobView
,
...
...
app/assets/javascripts/repo/components/repo_file_buttons.vue
View file @
fe1871b5
...
...
@@ -37,7 +37,7 @@ export default RepoFileButtons;
<
template
>
<div
v-if=
"showButtons"
id
=
"repo-file-buttons"
class
=
"repo-file-buttons"
>
<a
:href=
"activeFile.raw_path"
...
...
app/assets/javascripts/repo/helpers/repo_helper.js
View file @
fe1871b5
...
...
@@ -242,7 +242,13 @@ const RepoHelper = {
loadingError
()
{
Flash
(
'
Unable to load this content at this time.
'
);
},
openEditMode
()
{
Store
.
editMode
=
true
;
Store
.
currentBlobView
=
'
repo-editor
'
;
},
updateStorePath
(
path
)
{
Store
.
path
=
path
;
},
findOrCreateEntry
(
type
,
tree
,
name
)
{
let
exists
=
true
;
let
foundEntry
=
tree
.
files
.
find
(
dir
=>
dir
.
type
===
type
&&
dir
.
name
===
name
);
...
...
@@ -267,10 +273,44 @@ const RepoHelper = {
exists
,
};
},
removeAllTmpFiles
(
storeFilesKey
)
{
Store
[
storeFilesKey
]
=
Store
[
storeFilesKey
].
filter
(
f
=>
!
f
.
tempFile
);
},
createNewEntry
(
name
,
type
)
{
const
originalPath
=
Store
.
path
;
let
entryName
=
name
;
if
(
entryName
.
indexOf
(
`
${
originalPath
}
/`
)
!==
0
)
{
this
.
updateStorePath
(
''
);
}
else
{
entryName
=
entryName
.
replace
(
`
${
originalPath
}
/`
,
''
);
}
if
(
entryName
===
''
)
return
;
const
fileName
=
type
===
'
tree
'
?
'
.gitkeep
'
:
entryName
;
let
tree
=
Store
;
if
(
type
===
'
tree
'
)
{
const
dirNames
=
entryName
.
split
(
'
/
'
);
dirNames
.
forEach
((
dirName
)
=>
{
if
(
dirName
===
''
)
return
;
tree
=
this
.
findOrCreateEntry
(
'
tree
'
,
tree
,
dirName
).
entry
;
});
}
if
((
type
===
'
tree
'
&&
tree
.
tempFile
)
||
type
===
'
blob
'
)
{
const
file
=
this
.
findOrCreateEntry
(
'
blob
'
,
tree
,
fileName
);
if
(
!
file
.
exists
)
{
this
.
setFile
(
file
.
entry
,
file
.
entry
);
this
.
openEditMode
();
}
}
removeAllTmpFiles
()
{
Store
.
openedFiles
=
Store
.
openedFiles
.
filter
(
f
=>
!
f
.
tempFile
);
Store
.
files
=
Store
.
files
.
filter
(
f
=>
!
f
.
tempFile
);
this
.
updateStorePath
(
originalPath
);
},
};
...
...
app/assets/javascripts/repo/stores/repo_store.js
View file @
fe1871b5
...
...
@@ -185,6 +185,4 @@ const RepoStore = {
},
};
window
.
RepoStore
=
RepoStore
;
export
default
RepoStore
;
app/assets/stylesheets/pages/repo.scss
View file @
fe1871b5
...
...
@@ -201,7 +201,7 @@
}
}
#
repo-file-buttons
{
.
repo-file-buttons
{
background-color
:
$white-light
;
padding
:
5px
10px
;
border-top
:
1px
solid
$white-normal
;
...
...
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