Commit 1180b74b authored by Phil Hughes's avatar Phil Hughes

hide edit/preview tabs in review & commit mode

only make diff mode editable in review mode
parent 9f889531
...@@ -20,7 +20,12 @@ export default { ...@@ -20,7 +20,12 @@ export default {
}, },
computed: { computed: {
...mapState(['rightPanelCollapsed', 'viewer', 'panelResizing']), ...mapState(['rightPanelCollapsed', 'viewer', 'panelResizing']),
...mapGetters(['currentMergeRequest', 'getStagedFile']), ...mapGetters([
'currentMergeRequest',
'getStagedFile',
'isReviewModeActive',
'isCommitModeActive',
]),
shouldHideEditor() { shouldHideEditor() {
return this.file && this.file.binary && !this.file.content; return this.file && this.file.binary && !this.file.content;
}, },
...@@ -102,7 +107,7 @@ export default { ...@@ -102,7 +107,7 @@ export default {
if (this.viewer === 'editor') { if (this.viewer === 'editor') {
this.editor.createInstance(this.$refs.editor); this.editor.createInstance(this.$refs.editor);
} else { } else {
this.editor.createDiffInstance(this.$refs.editor); this.editor.createDiffInstance(this.$refs.editor, !this.isReviewModeActive);
} }
this.setupEditor(); this.setupEditor();
...@@ -167,7 +172,10 @@ export default { ...@@ -167,7 +172,10 @@ export default {
id="ide" id="ide"
class="blob-viewer-container blob-editor-container" class="blob-viewer-container blob-editor-container"
> >
<div class="ide-mode-tabs clearfix"> <div
v-show="!isReviewModeActive && !isCommitModeActive"
class="ide-mode-tabs clearfix"
>
<ul <ul
class="nav-links pull-left" class="nav-links pull-left"
v-if="!shouldHideEditor"> v-if="!shouldHideEditor">
...@@ -203,6 +211,9 @@ export default { ...@@ -203,6 +211,9 @@ export default {
v-show="!shouldHideEditor && file.viewMode === 'edit'" v-show="!shouldHideEditor && file.viewMode === 'edit'"
ref="editor" ref="editor"
class="multi-file-editor-holder" class="multi-file-editor-holder"
:class="{
'is-readonly': isCommitModeActive,
}"
> >
</div> </div>
<content-viewer <content-viewer
......
...@@ -61,7 +61,7 @@ export default class Editor { ...@@ -61,7 +61,7 @@ export default class Editor {
} }
} }
createDiffInstance(domElement) { createDiffInstance(domElement, readOnly = true) {
if (!this.instance) { if (!this.instance) {
clearDomElement(domElement); clearDomElement(domElement);
...@@ -71,6 +71,9 @@ export default class Editor { ...@@ -71,6 +71,9 @@ export default class Editor {
quickSuggestions: false, quickSuggestions: false,
occurrencesHighlight: false, occurrencesHighlight: false,
renderSideBySide: Editor.renderSideBySide(domElement), renderSideBySide: Editor.renderSideBySide(domElement),
readOnly,
renderLineHighlight: readOnly ? 'all' : 'none',
hideCursorInOverviewRuler: !readOnly,
})), })),
); );
......
import { activityBarViews } from '../constants';
export const activeFile = state => state.openFiles.find(file => file.active) || null; export const activeFile = state => state.openFiles.find(file => file.active) || null;
export const addedFiles = state => state.changedFiles.filter(f => f.tempFile); export const addedFiles = state => state.changedFiles.filter(f => f.tempFile);
...@@ -52,5 +54,8 @@ export const allBlobs = state => ...@@ -52,5 +54,8 @@ export const allBlobs = state =>
export const getStagedFile = state => path => state.stagedFiles.find(f => f.path === path); export const getStagedFile = state => path => state.stagedFiles.find(f => f.path === path);
export const isReviewModeActive = state => state.currentActivityView === activityBarViews.review;
export const isCommitModeActive = state => state.currentActivityView === activityBarViews.commit;
// prevent babel-plugin-rewire from generating an invalid default during karma tests // prevent babel-plugin-rewire from generating an invalid default during karma tests
export default () => {}; export default () => {};
...@@ -227,6 +227,17 @@ ...@@ -227,6 +227,17 @@
display: none; display: none;
} }
.is-readonly,
.editor.original {
.view-lines {
cursor: default;
}
.cursors-layer {
display: none;
}
}
.monaco-diff-editor.vs { .monaco-diff-editor.vs {
.editor.modified { .editor.modified {
box-shadow: none; box-shadow: none;
...@@ -285,16 +296,6 @@ ...@@ -285,16 +296,6 @@
.margin-view-overlays .delete-sign { .margin-view-overlays .delete-sign {
opacity: 0.4; opacity: 0.4;
} }
.editor.original {
.view-lines {
cursor: default;
}
.cursors-layer {
display: none;
}
}
} }
} }
......
...@@ -70,12 +70,14 @@ describe('Multi-file editor library', () => { ...@@ -70,12 +70,14 @@ describe('Multi-file editor library', () => {
minimap: { minimap: {
enabled: false, enabled: false,
}, },
readOnly: false, readOnly: true,
scrollBeyondLastLine: false, scrollBeyondLastLine: false,
quickSuggestions: false, quickSuggestions: false,
occurrencesHighlight: false, occurrencesHighlight: false,
wordWrap: 'on', wordWrap: 'on',
renderSideBySide: true, renderSideBySide: true,
renderLineHighlight: 'all',
hideCursorInOverviewRuler: false,
}); });
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment