Added review mode to new IDE sidebar

#44846
This commit is contained in:
Phil Hughes 2018-04-20 09:09:19 +01:00
parent 34d5d1fa80
commit 4924e4edb2
No known key found for this signature in database
GPG Key ID: 32245528C52E0F9F
11 changed files with 98 additions and 56 deletions

View File

@ -50,6 +50,20 @@ export default {
/>
</button>
</li>
<li>
<button
type="button"
class="ide-sidebar-link js-ide-review-mode"
:class="{
active: currentActivityView === $options.ActivityBarViews.review
}"
@click.prevent="updateActivityBarView($options.ActivityBarViews.review)"
>
<icon
name="file-modified"
/>
</button>
</li>
<li>
<button
type="button"

View File

@ -0,0 +1,64 @@
<script>
import { mapActions, mapGetters, mapState } from 'vuex';
import Icon from '~/vue_shared/components/icon.vue';
import SkeletonLoadingContainer from '~/vue_shared/components/skeleton_loading_container.vue';
import RepoFile from './repo_file.vue';
import NewDropdown from './new_dropdown/index.vue';
export default {
components: {
Icon,
RepoFile,
SkeletonLoadingContainer,
NewDropdown,
},
computed: {
...mapState(['currentBranchId']),
...mapGetters(['currentProject', 'currentTree']),
},
mounted() {
this.updateViewer('diff');
},
methods: {
...mapActions(['updateViewer']),
},
};
</script>
<template>
<div
class="ide-file-list"
>
<template v-if="!currentTree || currentTree.loading">
<div
class="multi-file-loading-container"
v-for="n in 3"
:key="n"
>
<skeleton-loading-container />
</div>
</template>
<template v-else>
<header class="ide-tree-header ide-review-header">
{{ __('Review') }}
<div class="prepend-top-5 clgray">
{{ __('Lastest changed') }}
</div>
</header>
<repo-file
v-for="file in currentTree.tree"
:key="file.key"
:file="file"
:level="0"
:disable-action-dropdown="true"
/>
</template>
</div>
</template>
<style>
.ide-review-header {
flex-direction: column;
align-items: flex-start;
}
</style>

View File

@ -9,6 +9,7 @@ import IdeTree from './ide_tree.vue';
import ResizablePanel from './resizable_panel.vue';
import ActivityBar from './activity_bar.vue';
import CommitSection from './repo_commit_section.vue';
import IdeReview from './ide_review.vue';
export default {
components: {
@ -21,6 +22,7 @@ export default {
Identicon,
CommitSection,
IdeTree,
IdeReview,
},
computed: {
...mapState(['loading', 'currentBranchId', 'currentActivityView']),

View File

@ -1,5 +1,5 @@
<script>
import { mapGetters, mapState } from 'vuex';
import { mapActions, mapGetters, mapState } from 'vuex';
import Icon from '~/vue_shared/components/icon.vue';
import SkeletonLoadingContainer from '~/vue_shared/components/skeleton_loading_container.vue';
import RepoFile from './repo_file.vue';
@ -16,6 +16,12 @@ export default {
...mapState(['currentBranchId']),
...mapGetters(['currentProject', 'currentTree']),
},
mounted() {
this.updateViewer('editor');
},
methods: {
...mapActions(['updateViewer']),
},
};
</script>

View File

@ -19,7 +19,7 @@ export default {
},
},
computed: {
...mapState(['rightPanelCollapsed', 'viewer', 'delayViewerUpdated', 'panelResizing']),
...mapState(['rightPanelCollapsed', 'viewer', 'panelResizing']),
...mapGetters(['currentMergeRequest', 'getStagedFile']),
shouldHideEditor() {
return this.file && this.file.binary && !this.file.content;
@ -77,7 +77,6 @@ export default {
'setFileViewMode',
'setFileEOL',
'updateViewer',
'updateDelayViewerUpdated',
]),
initMonaco() {
if (this.shouldHideEditor) return;
@ -89,14 +88,6 @@ export default {
baseSha: this.currentMergeRequest ? this.currentMergeRequest.baseCommitSha : '',
})
.then(() => {
const viewerPromise = this.delayViewerUpdated
? this.updateViewer(this.file.pending ? 'diff' : 'editor')
: Promise.resolve();
return viewerPromise;
})
.then(() => {
this.updateDelayViewerUpdated(false);
this.createEditorInstance();
})
.catch(err => {

View File

@ -27,6 +27,11 @@ export default {
type: Number,
required: true,
},
disableActionDropdown: {
type: Boolean,
required: false,
default: false,
},
},
computed: {
isTree() {
@ -55,16 +60,14 @@ export default {
}
},
methods: {
...mapActions(['toggleTreeOpen', 'updateDelayViewerUpdated']),
...mapActions(['toggleTreeOpen']),
clickFile() {
// Manual Action if a tree is selected/opened
if (this.isTree && this.$router.currentRoute.path === `/project${this.file.url}`) {
this.toggleTreeOpen(this.file.path);
}
return this.updateDelayViewerUpdated(true).then(() => {
router.push(`/project${this.file.url}`);
});
router.push(`/project${this.file.url}`);
},
},
};
@ -110,7 +113,7 @@ export default {
/>
</span>
<new-dropdown
v-if="isTree"
v-if="isTree && !disableActionDropdown"
:project-id="file.projectId"
:branch="file.branchId"
:path="file.path"

View File

@ -32,16 +32,6 @@ export default {
default: '',
},
},
data() {
return {
showShadow: false,
};
},
updated() {
if (!this.$refs.tabsScroller) return;
this.showShadow = this.$refs.tabsScroller.scrollWidth > this.$refs.tabsScroller.offsetWidth;
},
methods: {
...mapActions(['updateViewer', 'removePendingTab']),
openFileViewer(viewer) {
@ -71,12 +61,5 @@ export default {
:tab="tab"
/>
</ul>
<editor-mode
:viewer="viewer"
:show-shadow="showShadow"
:has-changes="hasChanges"
:merge-request-id="mergeRequestId"
@click="openFileViewer"
/>
</div>
</template>

View File

@ -5,4 +5,5 @@ export const MAX_BODY_LENGTH = 72;
export const ActivityBarViews = {
edit: 'ide-tree',
commit: 'commit-section',
review: 'ide-review',
};

View File

@ -64,11 +64,8 @@ export default class Editor {
this.disposable.add(
(this.instance = this.monaco.editor.createDiffEditor(domElement, {
...defaultEditorOptions,
readOnly: true,
quickSuggestions: false,
occurrencesHighlight: false,
renderLineHighlight: 'none',
hideCursorInOverviewRuler: true,
renderSideBySide: Editor.renderSideBySide(domElement),
})),
);

View File

@ -29,7 +29,6 @@ export const closeFile = ({ commit, state, dispatch }, file) => {
keyPrefix: nextFileToOpen.staged ? 'staged' : 'unstaged',
});
} else {
dispatch('updateDelayViewerUpdated', true);
router.push(`/project${nextFileToOpen.url}`);
}
} else if (!state.openFiles.length) {

View File

@ -153,24 +153,6 @@
border-bottom-color: $white-light;
}
}
.dropdown {
display: flex;
margin-left: auto;
margin-bottom: 1px;
padding: 0 $grid-size;
border-left: 1px solid $white-dark;
background-color: $white-light;
&.shadow {
box-shadow: 0 0 10px $dropdown-shadow-color;
}
.btn {
margin-top: auto;
margin-bottom: auto;
}
}
}
.multi-file-tab {
@ -298,7 +280,7 @@
opacity: 0.4;
}
.cursors-layer {
.editor.original .cursors-layer {
display: none;
}
}