debian-mirror-gitlab/app/assets/javascripts/ide/components/ide.vue

162 lines
4.1 KiB
Vue
Raw Normal View History

2018-05-09 12:01:36 +05:30
<script>
2018-12-05 23:21:45 +05:30
import Vue from 'vue';
2018-10-15 14:42:47 +05:30
import Mousetrap from 'mousetrap';
import { mapActions, mapState, mapGetters } from 'vuex';
2018-11-18 11:00:15 +05:30
import { __ } from '~/locale';
import NewModal from './new_dropdown/modal.vue';
2018-10-15 14:42:47 +05:30
import IdeSidebar from './ide_side_bar.vue';
import RepoTabs from './repo_tabs.vue';
import IdeStatusBar from './ide_status_bar.vue';
import RepoEditor from './repo_editor.vue';
import FindFile from './file_finder/index.vue';
2018-11-08 19:23:39 +05:30
import RightPane from './panes/right.vue';
import ErrorMessage from './error_message.vue';
2018-11-20 20:47:30 +05:30
import CommitEditorHeader from './commit_sidebar/editor_header.vue';
2018-10-15 14:42:47 +05:30
const originalStopCallback = Mousetrap.stopCallback;
2018-05-09 12:01:36 +05:30
export default {
components: {
2018-11-18 11:00:15 +05:30
NewModal,
2018-10-15 14:42:47 +05:30
IdeSidebar,
RepoTabs,
IdeStatusBar,
RepoEditor,
FindFile,
2018-11-08 19:23:39 +05:30
ErrorMessage,
2018-11-20 20:47:30 +05:30
CommitEditorHeader,
2018-05-09 12:01:36 +05:30
},
2018-12-05 23:21:45 +05:30
props: {
rightPaneComponent: {
type: Vue.Component,
required: false,
default: () => RightPane,
},
},
2018-05-09 12:01:36 +05:30
computed: {
2018-10-15 14:42:47 +05:30
...mapState([
'openFiles',
'viewer',
'currentMergeRequestId',
'fileFindVisible',
'emptyStateSvgPath',
2018-11-08 19:23:39 +05:30
'currentProjectId',
'errorMessage',
2018-10-15 14:42:47 +05:30
]),
2018-11-20 20:47:30 +05:30
...mapGetters(['activeFile', 'hasChanges', 'someUncommitedChanges', 'isCommitModeActive']),
2018-05-09 12:01:36 +05:30
},
mounted() {
2018-11-18 11:00:15 +05:30
window.onbeforeunload = e => this.onBeforeUnload(e);
2018-10-15 14:42:47 +05:30
Mousetrap.bind(['t', 'command+p', 'ctrl+p'], e => {
if (e.preventDefault) {
e.preventDefault();
}
this.toggleFileFinder(!this.fileFindVisible);
});
Mousetrap.stopCallback = (e, el, combo) => this.mousetrapStopCallback(e, el, combo);
},
methods: {
...mapActions(['toggleFileFinder']),
2018-11-18 11:00:15 +05:30
onBeforeUnload(e = {}) {
const returnValue = __('Are you sure you want to lose unsaved changes?');
if (!this.someUncommitedChanges) return undefined;
Object.assign(e, {
returnValue,
});
return returnValue;
},
2018-10-15 14:42:47 +05:30
mousetrapStopCallback(e, el, combo) {
if (
(combo === 't' && el.classList.contains('dropdown-input-field')) ||
el.classList.contains('inputarea')
) {
return true;
} else if (combo === 'command+p' || combo === 'ctrl+p') {
return false;
}
return originalStopCallback(e, el, combo);
},
2018-05-09 12:01:36 +05:30
},
};
</script>
<template>
2018-11-20 20:47:30 +05:30
<article class="ide position-relative d-flex flex-column align-items-stretch">
2018-11-08 19:23:39 +05:30
<error-message
v-if="errorMessage"
:message="errorMessage"
/>
2018-05-09 12:01:36 +05:30
<div
2018-11-20 20:47:30 +05:30
class="ide-view flex-grow d-flex"
2018-05-09 12:01:36 +05:30
>
2018-10-15 14:42:47 +05:30
<find-file
v-show="fileFindVisible"
/>
<ide-sidebar />
<div
class="multi-file-edit-pane"
2018-05-09 12:01:36 +05:30
>
2018-10-15 14:42:47 +05:30
<template
v-if="activeFile"
>
2018-11-20 20:47:30 +05:30
<commit-editor-header
v-if="isCommitModeActive"
:active-file="activeFile"
/>
2018-10-15 14:42:47 +05:30
<repo-tabs
2018-11-20 20:47:30 +05:30
v-else
2018-10-15 14:42:47 +05:30
:active-file="activeFile"
:files="openFiles"
:viewer="viewer"
:has-changes="hasChanges"
:merge-request-id="currentMergeRequestId"
/>
<repo-editor
:file="activeFile"
2018-11-08 19:23:39 +05:30
class="multi-file-edit-pane-content"
2018-10-15 14:42:47 +05:30
/>
</template>
<template
v-else
2018-05-09 12:01:36 +05:30
>
2018-10-15 14:42:47 +05:30
<div
v-once
class="ide-empty-state"
>
<div class="row js-empty-state">
2018-11-08 19:23:39 +05:30
<div class="col-12">
2018-10-15 14:42:47 +05:30
<div class="svg-content svg-250">
<img :src="emptyStateSvgPath" />
</div>
2018-05-09 12:01:36 +05:30
</div>
2018-11-08 19:23:39 +05:30
<div class="col-12">
2018-10-15 14:42:47 +05:30
<div class="text-content text-center">
<h4>
Welcome to the GitLab IDE
</h4>
<p>
Select a file from the left sidebar to begin editing.
Afterwards, you'll be able to commit your changes.
</p>
</div>
2018-05-09 12:01:36 +05:30
</div>
</div>
</div>
2018-10-15 14:42:47 +05:30
</template>
</div>
2018-12-05 23:21:45 +05:30
<component
:is="rightPaneComponent"
2018-11-08 19:23:39 +05:30
v-if="currentProjectId"
/>
2018-05-09 12:01:36 +05:30
</div>
2018-11-08 19:23:39 +05:30
<ide-status-bar :file="activeFile"/>
2018-11-18 11:00:15 +05:30
<new-modal />
2018-10-15 14:42:47 +05:30
</article>
2018-05-09 12:01:36 +05:30
</template>