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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
64a32d6c
Commit
64a32d6c
authored
Jul 23, 2019
by
Chris Toynbee
Committed by
Paul Slaughter
Jul 23, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Encapsulate file view modes with constants
parent
43626526
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
15 deletions
+27
-15
app/assets/javascripts/ide/components/repo_editor.vue
app/assets/javascripts/ide/components/repo_editor.vue
+14
-7
app/assets/javascripts/ide/constants.js
app/assets/javascripts/ide/constants.js
+4
-0
app/assets/javascripts/ide/stores/utils.js
app/assets/javascripts/ide/stores/utils.js
+2
-2
spec/javascripts/ide/components/repo_editor_spec.js
spec/javascripts/ide/components/repo_editor_spec.js
+4
-4
spec/javascripts/ide/stores/mutations/file_spec.js
spec/javascripts/ide/stores/mutations/file_spec.js
+3
-2
No files found.
app/assets/javascripts/ide/components/repo_editor.vue
View file @
64a32d6c
...
@@ -4,7 +4,12 @@ import { viewerInformationForPath } from '~/vue_shared/components/content_viewer
...
@@ -4,7 +4,12 @@ import { viewerInformationForPath } from '~/vue_shared/components/content_viewer
import
flash
from
'
~/flash
'
;
import
flash
from
'
~/flash
'
;
import
ContentViewer
from
'
~/vue_shared/components/content_viewer/content_viewer.vue
'
;
import
ContentViewer
from
'
~/vue_shared/components/content_viewer/content_viewer.vue
'
;
import
DiffViewer
from
'
~/vue_shared/components/diff_viewer/diff_viewer.vue
'
;
import
DiffViewer
from
'
~/vue_shared/components/diff_viewer/diff_viewer.vue
'
;
import
{
activityBarViews
,
viewerTypes
}
from
'
../constants
'
;
import
{
activityBarViews
,
viewerTypes
,
FILE_VIEW_MODE_EDITOR
,
FILE_VIEW_MODE_PREVIEW
,
}
from
'
../constants
'
;
import
Editor
from
'
../lib/editor
'
;
import
Editor
from
'
../lib/editor
'
;
import
ExternalLink
from
'
./external_link.vue
'
;
import
ExternalLink
from
'
./external_link.vue
'
;
import
FileTemplatesBar
from
'
./file_templates/bar.vue
'
;
import
FileTemplatesBar
from
'
./file_templates/bar.vue
'
;
...
@@ -49,10 +54,10 @@ export default {
...
@@ -49,10 +54,10 @@ export default {
return
this
.
shouldHideEditor
&&
this
.
file
.
mrChange
&&
this
.
viewer
===
viewerTypes
.
mr
;
return
this
.
shouldHideEditor
&&
this
.
file
.
mrChange
&&
this
.
viewer
===
viewerTypes
.
mr
;
},
},
isEditorViewMode
()
{
isEditorViewMode
()
{
return
this
.
file
.
viewMode
===
'
editor
'
;
return
this
.
file
.
viewMode
===
FILE_VIEW_MODE_EDITOR
;
},
},
isPreviewViewMode
()
{
isPreviewViewMode
()
{
return
this
.
file
.
viewMode
===
'
preview
'
;
return
this
.
file
.
viewMode
===
FILE_VIEW_MODE_PREVIEW
;
},
},
editTabCSS
()
{
editTabCSS
()
{
return
{
return
{
...
@@ -85,7 +90,7 @@ export default {
...
@@ -85,7 +90,7 @@ export default {
if
(
this
.
currentActivityView
!==
activityBarViews
.
edit
)
{
if
(
this
.
currentActivityView
!==
activityBarViews
.
edit
)
{
this
.
setFileViewMode
({
this
.
setFileViewMode
({
file
:
this
.
file
,
file
:
this
.
file
,
viewMode
:
'
editor
'
,
viewMode
:
FILE_VIEW_MODE_EDITOR
,
});
});
}
}
}
}
...
@@ -94,7 +99,7 @@ export default {
...
@@ -94,7 +99,7 @@ export default {
if
(
this
.
currentActivityView
!==
activityBarViews
.
edit
)
{
if
(
this
.
currentActivityView
!==
activityBarViews
.
edit
)
{
this
.
setFileViewMode
({
this
.
setFileViewMode
({
file
:
this
.
file
,
file
:
this
.
file
,
viewMode
:
'
editor
'
,
viewMode
:
FILE_VIEW_MODE_EDITOR
,
});
});
}
}
},
},
...
@@ -244,6 +249,8 @@ export default {
...
@@ -244,6 +249,8 @@ export default {
},
},
},
},
viewerTypes
,
viewerTypes
,
FILE_VIEW_MODE_EDITOR
,
FILE_VIEW_MODE_PREVIEW
,
};
};
</
script
>
</
script
>
...
@@ -255,7 +262,7 @@ export default {
...
@@ -255,7 +262,7 @@ export default {
<a
<a
href=
"javascript:void(0);"
href=
"javascript:void(0);"
role=
"button"
role=
"button"
@
click.prevent=
"setFileViewMode(
{ file, viewMode:
'editor'
})"
@
click.prevent=
"setFileViewMode(
{ file, viewMode:
$options.FILE_VIEW_MODE_EDITOR
})"
>
>
<template
v-if=
"viewer === $options.viewerTypes.edit"
>
{{
__
(
'
Edit
'
)
}}
</
template
>
<template
v-if=
"viewer === $options.viewerTypes.edit"
>
{{
__
(
'
Edit
'
)
}}
</
template
>
<
template
v-else
>
{{
__
(
'
Review
'
)
}}
</
template
>
<
template
v-else
>
{{
__
(
'
Review
'
)
}}
</
template
>
...
@@ -265,7 +272,7 @@ export default {
...
@@ -265,7 +272,7 @@ export default {
<a
<a
href=
"javascript:void(0);"
href=
"javascript:void(0);"
role=
"button"
role=
"button"
@
click.prevent=
"setFileViewMode({ file, viewMode:
'preview'
})"
@
click.prevent=
"setFileViewMode({ file, viewMode:
$options.FILE_VIEW_MODE_PREVIEW
})"
>
{{ file.previewMode.previewTitle }}
</a
>
{{ file.previewMode.previewTitle }}
</a
>
>
</li>
</li>
...
...
app/assets/javascripts/ide/constants.js
View file @
64a32d6c
...
@@ -4,6 +4,10 @@ export const MAX_WINDOW_HEIGHT_COMPACT = 750;
...
@@ -4,6 +4,10 @@ export const MAX_WINDOW_HEIGHT_COMPACT = 750;
export
const
MAX_TITLE_LENGTH
=
50
;
export
const
MAX_TITLE_LENGTH
=
50
;
export
const
MAX_BODY_LENGTH
=
72
;
export
const
MAX_BODY_LENGTH
=
72
;
// File view modes
export
const
FILE_VIEW_MODE_EDITOR
=
'
editor
'
;
export
const
FILE_VIEW_MODE_PREVIEW
=
'
preview
'
;
export
const
activityBarViews
=
{
export
const
activityBarViews
=
{
edit
:
'
ide-tree
'
,
edit
:
'
ide-tree
'
,
commit
:
'
commit-section
'
,
commit
:
'
commit-section
'
,
...
...
app/assets/javascripts/ide/stores/utils.js
View file @
64a32d6c
import
{
commitActionTypes
}
from
'
../constants
'
;
import
{
commitActionTypes
,
FILE_VIEW_MODE_EDITOR
}
from
'
../constants
'
;
export
const
dataStructure
=
()
=>
({
export
const
dataStructure
=
()
=>
({
id
:
''
,
id
:
''
,
...
@@ -43,7 +43,7 @@ export const dataStructure = () => ({
...
@@ -43,7 +43,7 @@ export const dataStructure = () => ({
editorColumn
:
1
,
editorColumn
:
1
,
fileLanguage
:
''
,
fileLanguage
:
''
,
eol
:
''
,
eol
:
''
,
viewMode
:
'
editor
'
,
viewMode
:
FILE_VIEW_MODE_EDITOR
,
previewMode
:
null
,
previewMode
:
null
,
size
:
0
,
size
:
0
,
parentPath
:
null
,
parentPath
:
null
,
...
...
spec/javascripts/ide/components/repo_editor_spec.js
View file @
64a32d6c
...
@@ -5,7 +5,7 @@ import axios from '~/lib/utils/axios_utils';
...
@@ -5,7 +5,7 @@ import axios from '~/lib/utils/axios_utils';
import
store
from
'
~/ide/stores
'
;
import
store
from
'
~/ide/stores
'
;
import
repoEditor
from
'
~/ide/components/repo_editor.vue
'
;
import
repoEditor
from
'
~/ide/components/repo_editor.vue
'
;
import
Editor
from
'
~/ide/lib/editor
'
;
import
Editor
from
'
~/ide/lib/editor
'
;
import
{
activityBarViews
}
from
'
~/ide/constants
'
;
import
{
activityBarViews
,
FILE_VIEW_MODE_EDITOR
,
FILE_VIEW_MODE_PREVIEW
}
from
'
~/ide/constants
'
;
import
{
createComponentWithStore
}
from
'
../../helpers/vue_mount_component_helper
'
;
import
{
createComponentWithStore
}
from
'
../../helpers/vue_mount_component_helper
'
;
import
setTimeoutPromise
from
'
../../helpers/set_timeout_promise_helper
'
;
import
setTimeoutPromise
from
'
../../helpers/set_timeout_promise_helper
'
;
import
{
file
,
resetStore
}
from
'
../helpers
'
;
import
{
file
,
resetStore
}
from
'
../helpers
'
;
...
@@ -16,7 +16,7 @@ describe('RepoEditor', () => {
...
@@ -16,7 +16,7 @@ describe('RepoEditor', () => {
beforeEach
(
done
=>
{
beforeEach
(
done
=>
{
const
f
=
{
const
f
=
{
...
file
(),
...
file
(),
viewMode
:
'
editor
'
,
viewMode
:
FILE_VIEW_MODE_EDITOR
,
};
};
const
RepoEditor
=
Vue
.
extend
(
repoEditor
);
const
RepoEditor
=
Vue
.
extend
(
repoEditor
);
...
@@ -370,7 +370,7 @@ describe('RepoEditor', () => {
...
@@ -370,7 +370,7 @@ describe('RepoEditor', () => {
describe
(
'
when files view mode is preview
'
,
()
=>
{
describe
(
'
when files view mode is preview
'
,
()
=>
{
beforeEach
(
done
=>
{
beforeEach
(
done
=>
{
spyOn
(
vm
.
editor
,
'
updateDimensions
'
);
spyOn
(
vm
.
editor
,
'
updateDimensions
'
);
vm
.
file
.
viewMode
=
'
preview
'
;
vm
.
file
.
viewMode
=
FILE_VIEW_MODE_PREVIEW
;
vm
.
$nextTick
(
done
);
vm
.
$nextTick
(
done
);
});
});
...
@@ -392,7 +392,7 @@ describe('RepoEditor', () => {
...
@@ -392,7 +392,7 @@ describe('RepoEditor', () => {
describe
(
'
when file view mode changes to editor
'
,
()
=>
{
describe
(
'
when file view mode changes to editor
'
,
()
=>
{
beforeEach
(
done
=>
{
beforeEach
(
done
=>
{
vm
.
file
.
viewMode
=
'
editor
'
;
vm
.
file
.
viewMode
=
FILE_VIEW_MODE_EDITOR
;
// one tick to trigger watch
// one tick to trigger watch
vm
.
$nextTick
()
vm
.
$nextTick
()
...
...
spec/javascripts/ide/stores/mutations/file_spec.js
View file @
64a32d6c
import
mutations
from
'
~/ide/stores/mutations/file
'
;
import
mutations
from
'
~/ide/stores/mutations/file
'
;
import
state
from
'
~/ide/stores/state
'
;
import
state
from
'
~/ide/stores/state
'
;
import
{
FILE_VIEW_MODE_PREVIEW
}
from
'
~/ide/constants
'
;
import
{
file
}
from
'
../../helpers
'
;
import
{
file
}
from
'
../../helpers
'
;
describe
(
'
IDE store file mutations
'
,
()
=>
{
describe
(
'
IDE store file mutations
'
,
()
=>
{
...
@@ -425,10 +426,10 @@ describe('IDE store file mutations', () => {
...
@@ -425,10 +426,10 @@ describe('IDE store file mutations', () => {
it
(
'
updates file view mode
'
,
()
=>
{
it
(
'
updates file view mode
'
,
()
=>
{
mutations
.
SET_FILE_VIEWMODE
(
localState
,
{
mutations
.
SET_FILE_VIEWMODE
(
localState
,
{
file
:
localFile
,
file
:
localFile
,
viewMode
:
'
preview
'
,
viewMode
:
FILE_VIEW_MODE_PREVIEW
,
});
});
expect
(
localFile
.
viewMode
).
toBe
(
'
preview
'
);
expect
(
localFile
.
viewMode
).
toBe
(
FILE_VIEW_MODE_PREVIEW
);
});
});
});
});
...
...
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