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
b1f30151
Commit
b1f30151
authored
Aug 03, 2017
by
Jacob Schatz
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ide' of gitlab.com:gitlab-org/gitlab-ce into ide
parents
82292316
2fce0c86
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
82 additions
and
38 deletions
+82
-38
app/assets/javascripts/repo/components/repo.vue
app/assets/javascripts/repo/components/repo.vue
+11
-2
app/assets/javascripts/repo/components/repo_edit_button.vue
app/assets/javascripts/repo/components/repo_edit_button.vue
+3
-2
app/assets/javascripts/repo/components/repo_editor.vue
app/assets/javascripts/repo/components/repo_editor.vue
+13
-16
app/assets/javascripts/repo/components/repo_preview.vue
app/assets/javascripts/repo/components/repo_preview.vue
+11
-0
app/assets/javascripts/repo/helpers/repo_helper.js
app/assets/javascripts/repo/helpers/repo_helper.js
+23
-16
app/assets/javascripts/repo/services/repo_service.js
app/assets/javascripts/repo/services/repo_service.js
+3
-1
app/assets/javascripts/repo/stores/repo_store.js
app/assets/javascripts/repo/stores/repo_store.js
+13
-0
app/assets/stylesheets/pages/repo.scss
app/assets/stylesheets/pages/repo.scss
+4
-0
app/views/shared/repo/_editable_mode.html.haml
app/views/shared/repo/_editable_mode.html.haml
+1
-1
No files found.
app/assets/javascripts/repo/components/repo.vue
View file @
b1f30151
...
@@ -4,9 +4,11 @@ import RepoCommitSection from './repo_commit_section.vue';
...
@@ -4,9 +4,11 @@ import RepoCommitSection from './repo_commit_section.vue';
import
RepoTabs
from
'
./repo_tabs.vue
'
;
import
RepoTabs
from
'
./repo_tabs.vue
'
;
import
RepoFileButtons
from
'
./repo_file_buttons.vue
'
;
import
RepoFileButtons
from
'
./repo_file_buttons.vue
'
;
import
RepoBinaryViewer
from
'
./repo_binary_viewer.vue
'
;
import
RepoBinaryViewer
from
'
./repo_binary_viewer.vue
'
;
import
RepoPreview
from
'
./repo_preview.vue
'
;
import
RepoMixin
from
'
../mixins/repo_mixin
'
;
import
RepoMixin
from
'
../mixins/repo_mixin
'
;
import
PopupDialog
from
'
../../vue_shared/components/popup_dialog.vue
'
;
import
PopupDialog
from
'
../../vue_shared/components/popup_dialog.vue
'
;
import
Store
from
'
../stores/repo_store
'
;
import
Store
from
'
../stores/repo_store
'
;
import
RepoHelper
from
'
../helpers/repo_helper
'
;
import
MonacoLoaderHelper
from
'
../helpers/monaco_loader_helper
'
;
import
MonacoLoaderHelper
from
'
../helpers/monaco_loader_helper
'
;
export
default
{
export
default
{
...
@@ -20,6 +22,11 @@ export default {
...
@@ -20,6 +22,11 @@ export default {
'
repo-editor
'
:
MonacoLoaderHelper
.
repoEditorLoader
,
'
repo-editor
'
:
MonacoLoaderHelper
.
repoEditorLoader
,
'
repo-commit-section
'
:
RepoCommitSection
,
'
repo-commit-section
'
:
RepoCommitSection
,
'
popup-dialog
'
:
PopupDialog
,
'
popup-dialog
'
:
PopupDialog
,
'
repo-preview
'
:
RepoPreview
,
},
mounted
()
{
RepoHelper
.
getContent
().
catch
(
RepoHelper
.
loadingError
);
},
},
methods
:
{
methods
:
{
...
@@ -31,6 +38,8 @@ export default {
...
@@ -31,6 +38,8 @@ export default {
this
.
dialog
.
open
=
false
;
this
.
dialog
.
open
=
false
;
this
.
dialog
.
status
=
status
;
this
.
dialog
.
status
=
status
;
},
},
toggleBlobView
:
Store
.
toggleBlobView
,
},
},
};
};
</
script
>
</
script
>
...
@@ -40,8 +49,8 @@ export default {
...
@@ -40,8 +49,8 @@ export default {
<repo-sidebar/><div
class=
"panel-right"
:class=
"
{'edit-mode': editMode}">
<repo-sidebar/><div
class=
"panel-right"
:class=
"
{'edit-mode': editMode}">
<repo-tabs/>
<repo-tabs/>
<repo-file-buttons/>
<repo-file-buttons/>
<
repo-editor/
>
<
component
:is=
"currentBlobView"
></component
>
<
repo-binary-viewer/
>
<
!--
<repo-binary-viewer/>
soon™ --
>
</div>
</div>
<repo-commit-section/>
<repo-commit-section/>
<popup-dialog
<popup-dialog
...
...
app/assets/javascripts/repo/components/repo_edit_button.vue
View file @
b1f30151
...
@@ -21,14 +21,15 @@ export default {
...
@@ -21,14 +21,15 @@ export default {
return
;
return
;
}
}
this
.
editMode
=
!
this
.
editMode
;
this
.
editMode
=
!
this
.
editMode
;
Store
.
toggleBlobView
();
},
},
},
},
}
}
</
script
>
</
script
>
<
template
>
<
template
>
<
a
href=
"#"
@
click.prevent=
"editClicked"
v-cloak
v-if=
"isCommitable
"
>
<
button
class=
"btn btn-default"
@
click.prevent=
"editClicked"
v-cloak
v-if=
"isCommitable"
:disabled=
"binary
"
>
<i
:class=
"buttonIcon"
></i>
<i
:class=
"buttonIcon"
></i>
<span>
{{
buttonLabel
}}
</span>
<span>
{{
buttonLabel
}}
</span>
</
a
>
</
button
>
</
template
>
</
template
>
app/assets/javascripts/repo/components/repo_editor.vue
View file @
b1f30151
<
script
>
<
script
>
/* global monaco */
/* global monaco */
import
Store
from
'
../stores/repo_store
'
;
import
Store
from
'
../stores/repo_store
'
;
import
Service
from
'
../services/repo_service
'
;
import
Helper
from
'
../helpers/repo_helper
'
;
import
Helper
from
'
../helpers/repo_helper
'
;
const
RepoEditor
=
{
const
RepoEditor
=
{
data
:
()
=>
Store
,
data
:
()
=>
Store
,
mounted
()
{
mounted
()
{
Service
.
getRaw
(
this
.
activeFile
.
raw_path
)
.
then
((
rawResponse
)
=>
{
Store
.
blobRaw
=
rawResponse
.
data
;
const
monacoInstance
=
this
.
monaco
.
editor
.
create
(
this
.
$el
,
{
const
monacoInstance
=
this
.
monaco
.
editor
.
create
(
this
.
$el
,
{
model
:
null
,
model
:
null
,
readOnly
:
true
,
readOnly
:
true
,
...
@@ -17,13 +22,13 @@ const RepoEditor = {
...
@@ -17,13 +22,13 @@ const RepoEditor = {
this
.
addMonacoEvents
();
this
.
addMonacoEvents
();
Helper
.
getContent
().
then
(()
=>
{
const
languages
=
this
.
monaco
.
languages
.
getLanguages
();
const
languages
=
this
.
monaco
.
languages
.
getLanguages
();
const
languageID
=
Helper
.
getLanguageIDForFile
(
this
.
activeFile
,
languages
);
const
languageID
=
Helper
.
getLanguageIDForFile
(
this
.
activeFile
,
languages
);
this
.
showHide
();
this
.
showHide
();
const
newModel
=
this
.
monaco
.
editor
.
createModel
(
this
.
blobRaw
,
languageID
);
const
newModel
=
this
.
monaco
.
editor
.
createModel
(
this
.
blobRaw
,
languageID
);
this
.
monacoInstance
.
setModel
(
newModel
);
this
.
monacoInstance
.
setModel
(
newModel
);
}).
catch
(
Helper
.
loadingError
);
}).
catch
(
Helper
.
loadingError
);
},
},
...
@@ -62,14 +67,6 @@ const RepoEditor = {
...
@@ -62,14 +67,6 @@ const RepoEditor = {
},
},
editMode
()
{
editMode
()
{
const
readOnly
=
!
this
.
editMode
;
Store
.
readOnly
=
readOnly
;
this
.
monacoInstance
.
updateOptions
({
readOnly
,
});
if
(
this
.
editMode
)
{
if
(
this
.
editMode
)
{
$
(
'
.project-refs-form
'
).
addClass
(
'
disabled
'
);
$
(
'
.project-refs-form
'
).
addClass
(
'
disabled
'
);
$
(
'
.fa-long-arrow-right
'
).
show
();
$
(
'
.fa-long-arrow-right
'
).
show
();
...
...
app/assets/javascripts/repo/components/repo_preview.vue
0 → 100644
View file @
b1f30151
<
script
>
import
RepoStore
from
'
../stores/repo_store
'
;
export
default
{
data
:
()
=>
RepoStore
,
}
</
script
>
<
template
>
<div
v-html=
"activeFile.html"
></div>
</
template
>
app/assets/javascripts/repo/helpers/repo_helper.js
View file @
b1f30151
...
@@ -160,23 +160,20 @@ const RepoHelper = {
...
@@ -160,23 +160,20 @@ const RepoHelper = {
Store
.
binaryMimeType
=
data
.
mime_type
;
Store
.
binaryMimeType
=
data
.
mime_type
;
// file might be undefined
// file might be undefined
RepoHelper
.
setBinaryDataAsBase64
(
data
);
RepoHelper
.
setBinaryDataAsBase64
(
data
);
data
.
binary
=
true
;
const
rawUrl
=
RepoHelper
.
getRawURLFromBlobURL
(
file
.
url
||
Service
.
url
);
}
else
{
RepoHelper
.
setBinaryDataAsBase64
(
rawUrl
,
data
);
Store
.
setViewToPreview
();
}
else
if
(
!
Store
.
isPreviewView
())
{
Service
.
getRaw
(
data
.
raw_path
)
Service
.
getRaw
(
data
.
raw_path
)
.
then
(
response
=>
{
.
then
((
rawResponse
)
=>
{
Store
.
blobRaw
=
response
.
data
;
Store
.
blobRaw
=
rawResponse
.
data
;
})
data
.
plain
=
rawResponse
.
data
;
// Store.blobRaw = data.plain;
data
.
binary
=
false
;
}
if
(
!
file
.
url
)
file
.
url
=
location
.
pathname
;
RepoHelper
.
setFile
(
data
,
file
);
}).
catch
(
RepoHelper
.
loadingError
);
data
.
url
=
file
.
url
;
}
data
.
newContent
=
''
;
Store
.
addToOpenedFiles
(
data
);
if
(
Store
.
isPreviewView
())
RepoHelper
.
setFile
(
data
,
file
);
Store
.
setActiveFiles
(
data
);
// if the file tree is empty
// if the file tree is empty
if
(
Store
.
files
.
length
===
0
)
{
if
(
Store
.
files
.
length
===
0
)
{
...
@@ -192,8 +189,18 @@ const RepoHelper = {
...
@@ -192,8 +189,18 @@ const RepoHelper = {
Store
.
addFilesToDirectory
(
file
,
Store
.
files
,
newDirectory
);
Store
.
addFilesToDirectory
(
file
,
Store
.
files
,
newDirectory
);
Store
.
prevURL
=
Service
.
blobURLtoParentTree
(
Service
.
url
);
Store
.
prevURL
=
Service
.
blobURLtoParentTree
(
Service
.
url
);
}
}
})
}).
catch
(
RepoHelper
.
loadingError
);
.
catch
(
RepoHelper
.
loadingError
);
},
setFile
(
data
,
file
)
{
const
newFile
=
data
;
newFile
.
url
=
file
.
url
||
location
.
pathname
;
newFile
.
url
=
file
.
url
;
newFile
.
newContent
=
''
;
Store
.
addToOpenedFiles
(
newFile
);
Store
.
setActiveFiles
(
newFile
);
},
},
toFA
(
icon
)
{
toFA
(
icon
)
{
...
...
app/assets/javascripts/repo/services/repo_service.js
View file @
b1f30151
...
@@ -19,7 +19,9 @@ const RepoService = {
...
@@ -19,7 +19,9 @@ const RepoService = {
},
},
getRaw
(
url
)
{
getRaw
(
url
)
{
return
axios
.
get
(
url
);
return
axios
.
get
(
url
,
{
transformResponse
:
[
res
=>
res
],
});
},
},
buildParams
(
url
=
this
.
url
)
{
buildParams
(
url
=
this
.
url
)
{
...
...
app/assets/javascripts/repo/stores/repo_store.js
View file @
b1f30151
...
@@ -20,6 +20,7 @@ const RepoStore = {
...
@@ -20,6 +20,7 @@ const RepoStore = {
submodules
:
[],
submodules
:
[],
blobRaw
:
''
,
blobRaw
:
''
,
blobRendered
:
''
,
blobRendered
:
''
,
currentBlobView
:
'
repo-preview
'
,
openedFiles
:
[],
openedFiles
:
[],
tabSize
:
100
,
tabSize
:
100
,
defaultTabSize
:
100
,
defaultTabSize
:
100
,
...
@@ -211,10 +212,22 @@ const RepoStore = {
...
@@ -211,10 +212,22 @@ const RepoStore = {
currentFile
.
newContent
=
contents
;
currentFile
.
newContent
=
contents
;
},
},
toggleBlobView
()
{
RepoStore
.
currentBlobView
=
RepoStore
.
isPreviewView
()
?
'
repo-editor
'
:
'
repo-preview
'
;
},
setViewToPreview
()
{
RepoStore
.
currentBlobView
=
'
repo-preview
'
;
},
// getters
// getters
isActiveFile
(
file
)
{
isActiveFile
(
file
)
{
return
file
&&
file
.
url
===
RepoStore
.
activeFile
.
url
;
return
file
&&
file
.
url
===
RepoStore
.
activeFile
.
url
;
},
},
isPreviewView
()
{
return
RepoStore
.
currentBlobView
===
'
repo-preview
'
;
},
};
};
export
default
RepoStore
;
export
default
RepoStore
;
app/assets/stylesheets/pages/repo.scss
View file @
b1f30151
...
@@ -38,6 +38,10 @@
...
@@ -38,6 +38,10 @@
@include
truncate
(
250px
);
@include
truncate
(
250px
);
}
}
#editable-mode
{
display
:
inline-block
;
}
.tree-content-holder
{
.tree-content-holder
{
border
:
1px
solid
$border-color
;
border
:
1px
solid
$border-color
;
border-radius
:
$border-radius-default
;
border-radius
:
$border-radius-default
;
...
...
app/views/shared/repo/_editable_mode.html.haml
View file @
b1f30151
%a
.btn.btn-default
#editable-mode
#editable-mode
%repo-edit-button
%repo-edit-button
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