BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
82 additions
and
38 deletions
+82
-38
repo.vue
app/assets/javascripts/repo/components/repo.vue
+11
-2
repo_edit_button.vue
app/assets/javascripts/repo/components/repo_edit_button.vue
+3
-2
repo_editor.vue
app/assets/javascripts/repo/components/repo_editor.vue
+13
-16
repo_preview.vue
app/assets/javascripts/repo/components/repo_preview.vue
+11
-0
repo_helper.js
app/assets/javascripts/repo/helpers/repo_helper.js
+23
-16
repo_service.js
app/assets/javascripts/repo/services/repo_service.js
+3
-1
repo_store.js
app/assets/javascripts/repo/stores/repo_store.js
+13
-0
repo.scss
app/assets/stylesheets/pages/repo.scss
+4
-0
_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';
import
RepoTabs
from
'./repo_tabs.vue'
;
import
RepoFileButtons
from
'./repo_file_buttons.vue'
;
import
RepoBinaryViewer
from
'./repo_binary_viewer.vue'
;
import
RepoPreview
from
'./repo_preview.vue'
;
import
RepoMixin
from
'../mixins/repo_mixin'
;
import
PopupDialog
from
'../../vue_shared/components/popup_dialog.vue'
;
import
Store
from
'../stores/repo_store'
;
import
RepoHelper
from
'../helpers/repo_helper'
;
import
MonacoLoaderHelper
from
'../helpers/monaco_loader_helper'
;
export
default
{
...
...
@@ -20,6 +22,11 @@ export default {
'repo-editor'
:
MonacoLoaderHelper
.
repoEditorLoader
,
'repo-commit-section'
:
RepoCommitSection
,
'popup-dialog'
:
PopupDialog
,
'repo-preview'
:
RepoPreview
,
},
mounted
()
{
RepoHelper
.
getContent
().
catch
(
RepoHelper
.
loadingError
);
},
methods
:
{
...
...
@@ -31,6 +38,8 @@ export default {
this
.
dialog
.
open
=
false
;
this
.
dialog
.
status
=
status
;
},
toggleBlobView
:
Store
.
toggleBlobView
,
},
};
</
script
>
...
...
@@ -40,8 +49,8 @@ export default {
<repo-sidebar/><div
class=
"panel-right"
:class=
"
{'edit-mode': editMode}">
<repo-tabs/>
<repo-file-buttons/>
<
repo-editor/
>
<
repo-binary-viewer/
>
<
component
:is=
"currentBlobView"
></component
>
<
!--
<repo-binary-viewer/>
soon™ --
>
</div>
<repo-commit-section/>
<popup-dialog
...
...
app/assets/javascripts/repo/components/repo_edit_button.vue
View file @
b1f30151
...
...
@@ -21,14 +21,15 @@ export default {
return
;
}
this
.
editMode
=
!
this
.
editMode
;
Store
.
toggleBlobView
();
},
},
}
</
script
>
<
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>
<span>
{{
buttonLabel
}}
</span>
</
a
>
</
button
>
</
template
>
app/assets/javascripts/repo/components/repo_editor.vue
View file @
b1f30151
<
script
>
/* global monaco */
import
Store
from
'../stores/repo_store'
;
import
Service
from
'../services/repo_service'
;
import
Helper
from
'../helpers/repo_helper'
;
const
RepoEditor
=
{
data
:
()
=>
Store
,
mounted
()
{
const
monacoInstance
=
this
.
monaco
.
editor
.
create
(
this
.
$el
,
{
model
:
null
,
readOnly
:
true
,
contextmenu
:
false
,
});
Service
.
getRaw
(
this
.
activeFile
.
raw_path
)
.
then
((
rawResponse
)
=>
{
Store
.
blobRaw
=
rawResponse
.
data
;
const
monacoInstance
=
this
.
monaco
.
editor
.
create
(
this
.
$el
,
{
model
:
null
,
readOnly
:
true
,
contextmenu
:
false
,
});
Store
.
monacoInstance
=
monacoInstance
;
Store
.
monacoInstance
=
monacoInstance
;
this
.
addMonacoEvents
();
this
.
addMonacoEvents
();
Helper
.
getContent
().
then
(()
=>
{
const
languages
=
this
.
monaco
.
languages
.
getLanguages
();
const
languageID
=
Helper
.
getLanguageIDForFile
(
this
.
activeFile
,
languages
);
this
.
showHide
();
const
newModel
=
this
.
monaco
.
editor
.
createModel
(
this
.
blobRaw
,
languageID
);
this
.
monacoInstance
.
setModel
(
newModel
);
}).
catch
(
Helper
.
loadingError
);
},
...
...
@@ -62,14 +67,6 @@ const RepoEditor = {
},
editMode
()
{
const
readOnly
=
!
this
.
editMode
;
Store
.
readOnly
=
readOnly
;
this
.
monacoInstance
.
updateOptions
({
readOnly
,
});
if
(
this
.
editMode
)
{
$
(
'.project-refs-form'
).
addClass
(
'disabled'
);
$
(
'.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 = {
Store
.
binaryMimeType
=
data
.
mime_type
;
// file might be undefined
RepoHelper
.
setBinaryDataAsBase64
(
data
);
data
.
binary
=
true
;
}
else
{
const
rawUrl
=
RepoHelper
.
getRawURLFromBlobURL
(
file
.
url
||
Service
.
url
);
RepoHelper
.
setBinaryDataAsBase64
(
rawUrl
,
data
);
Store
.
setViewToPreview
();
}
else
if
(
!
Store
.
isPreviewView
())
{
Service
.
getRaw
(
data
.
raw_path
)
.
then
(
response
=>
{
Store
.
blobRaw
=
response
.
data
;
})
// Store.blobRaw = data.plain;
data
.
binary
=
false
;
}
if
(
!
file
.
url
)
file
.
url
=
location
.
pathname
;
.
then
((
rawResponse
)
=>
{
Store
.
blobRaw
=
rawResponse
.
data
;
data
.
plain
=
rawResponse
.
data
;
data
.
url
=
file
.
url
;
data
.
newContent
=
''
;
RepoHelper
.
setFile
(
data
,
file
);
}).
catch
(
RepoHelper
.
loadingError
);
}
Store
.
addToOpenedFiles
(
data
);
Store
.
setActiveFiles
(
data
);
if
(
Store
.
isPreviewView
())
RepoHelper
.
setFile
(
data
,
file
);
// if the file tree is empty
if
(
Store
.
files
.
length
===
0
)
{
...
...
@@ -192,8 +189,18 @@ const RepoHelper = {
Store
.
addFilesToDirectory
(
file
,
Store
.
files
,
newDirectory
);
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
)
{
...
...
app/assets/javascripts/repo/services/repo_service.js
View file @
b1f30151
...
...
@@ -19,7 +19,9 @@ const RepoService = {
},
getRaw
(
url
)
{
return
axios
.
get
(
url
);
return
axios
.
get
(
url
,
{
transformResponse
:
[
res
=>
res
],
});
},
buildParams
(
url
=
this
.
url
)
{
...
...
app/assets/javascripts/repo/stores/repo_store.js
View file @
b1f30151
...
...
@@ -20,6 +20,7 @@ const RepoStore = {
submodules
:
[],
blobRaw
:
''
,
blobRendered
:
''
,
currentBlobView
:
'repo-preview'
,
openedFiles
:
[],
tabSize
:
100
,
defaultTabSize
:
100
,
...
...
@@ -211,10 +212,22 @@ const RepoStore = {
currentFile
.
newContent
=
contents
;
},
toggleBlobView
()
{
RepoStore
.
currentBlobView
=
RepoStore
.
isPreviewView
()
?
'repo-editor'
:
'repo-preview'
;
},
setViewToPreview
()
{
RepoStore
.
currentBlobView
=
'repo-preview'
;
},
// getters
isActiveFile
(
file
)
{
return
file
&&
file
.
url
===
RepoStore
.
activeFile
.
url
;
},
isPreviewView
()
{
return
RepoStore
.
currentBlobView
===
'repo-preview'
;
},
};
export
default
RepoStore
;
app/assets/stylesheets/pages/repo.scss
View file @
b1f30151
...
...
@@ -38,6 +38,10 @@
@include
truncate
(
250px
);
}
#editable-mode
{
display
:
inline-block
;
}
.tree-content-holder
{
border
:
1px
solid
$border-color
;
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
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