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

154 lines
4.7 KiB
Vue
Raw Normal View History

2018-05-09 12:01:36 +05:30
<script>
2020-03-13 15:44:24 +05:30
import { mapActions, mapGetters, mapState } from 'vuex';
2020-04-22 19:07:51 +05:30
import { GlDeprecatedButton, GlLoadingIcon } from '@gitlab/ui';
2018-11-18 11:00:15 +05:30
import { __ } from '~/locale';
2020-05-24 23:13:21 +05:30
import { modalTypes } from '../constants';
2019-03-02 22:35:43 +05:30
import FindFile from '~/vue_shared/components/file_finder/index.vue';
2018-11-18 11:00:15 +05:30
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';
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';
2020-05-24 23:13:21 +05:30
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
2018-10-15 14:42:47 +05:30
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,
2020-04-22 19:07:51 +05:30
GlDeprecatedButton,
2019-09-04 21:01:54 +05:30
GlLoadingIcon,
2020-06-23 00:09:42 +05:30
RightPane,
2018-05-09 12:01:36 +05:30
},
2020-05-24 23:13:21 +05:30
mixins: [glFeatureFlagsMixin()],
2018-05-09 12:01:36 +05:30
computed: {
2018-10-15 14:42:47 +05:30
...mapState([
'openFiles',
'viewer',
'fileFindVisible',
'emptyStateSvgPath',
2018-11-08 19:23:39 +05:30
'currentProjectId',
'errorMessage',
2019-03-02 22:35:43 +05:30
'loading',
]),
...mapGetters([
'activeFile',
'someUncommittedChanges',
'isCommitModeActive',
'allBlobs',
2019-09-04 21:01:54 +05:30
'emptyRepo',
'currentTree',
2020-05-24 23:13:21 +05:30
'editorTheme',
2018-10-15 14:42:47 +05:30
]),
2020-05-24 23:13:21 +05:30
themeName() {
return window.gon?.user_color_scheme;
},
2018-05-09 12:01:36 +05:30
},
mounted() {
2018-11-18 11:00:15 +05:30
window.onbeforeunload = e => this.onBeforeUnload(e);
2020-05-24 23:13:21 +05:30
if (this.themeName)
document.querySelector('.navbar-gitlab').classList.add(`theme-${this.themeName}`);
2018-10-15 14:42:47 +05:30
},
methods: {
2020-05-24 23:13:21 +05:30
...mapActions(['toggleFileFinder']),
2018-11-18 11:00:15 +05:30
onBeforeUnload(e = {}) {
const returnValue = __('Are you sure you want to lose unsaved changes?');
2018-12-13 13:39:08 +05:30
if (!this.someUncommittedChanges) return undefined;
2018-11-18 11:00:15 +05:30
Object.assign(e, {
returnValue,
});
return returnValue;
},
2019-03-02 22:35:43 +05:30
openFile(file) {
this.$router.push(`/project${file.url}`);
2018-10-15 14:42:47 +05:30
},
2020-05-24 23:13:21 +05:30
createNewFile() {
this.$refs.newModal.open(modalTypes.blob);
},
2018-05-09 12:01:36 +05:30
},
};
</script>
<template>
2020-05-24 23:13:21 +05:30
<article
class="ide position-relative d-flex flex-column align-items-stretch"
:class="{ [`theme-${themeName}`]: themeName }"
>
2019-02-15 15:39:39 +05:30
<error-message v-if="errorMessage" :message="errorMessage" />
<div class="ide-view flex-grow d-flex">
2019-03-02 22:35:43 +05:30
<find-file
v-show="fileFindVisible"
:files="allBlobs"
:visible="fileFindVisible"
:loading="loading"
@toggle="toggleFileFinder"
@click="openFile"
/>
2018-10-15 14:42:47 +05:30
<ide-sidebar />
2019-02-15 15:39:39 +05:30
<div class="multi-file-edit-pane">
<template v-if="activeFile">
<commit-editor-header v-if="isCommitModeActive" :active-file="activeFile" />
2020-06-23 00:09:42 +05:30
<repo-tabs v-else :active-file="activeFile" :files="openFiles" :viewer="viewer" />
2019-02-15 15:39:39 +05:30
<repo-editor :file="activeFile" class="multi-file-edit-pane-content" />
2018-10-15 14:42:47 +05:30
</template>
2019-02-15 15:39:39 +05:30
<template v-else>
2019-09-04 21:01:54 +05:30
<div class="ide-empty-state">
2018-10-15 14:42:47 +05:30
<div class="row js-empty-state">
2018-11-08 19:23:39 +05:30
<div class="col-12">
2019-02-15 15:39:39 +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">
2019-09-04 21:01:54 +05:30
<h4>
{{ __('Make and review changes in the browser with the Web IDE') }}
</h4>
<template v-if="emptyRepo">
<p>
{{
__(
"Create a new file as there are no files yet. Afterwards, you'll be able to commit your changes.",
)
}}
</p>
2020-04-22 19:07:51 +05:30
<gl-deprecated-button
2019-09-04 21:01:54 +05:30
variant="success"
:title="__('New file')"
:aria-label="__('New file')"
2020-06-23 00:09:42 +05:30
data-qa-selector="first_file_button"
2020-05-24 23:13:21 +05:30
@click="createNewFile()"
2019-09-04 21:01:54 +05:30
>
{{ __('New file') }}
2020-04-22 19:07:51 +05:30
</gl-deprecated-button>
2019-09-04 21:01:54 +05:30
</template>
<gl-loading-icon v-else-if="!currentTree || currentTree.loading" size="md" />
<p v-else>
{{
__(
"Select a file from the left sidebar to begin editing. Afterwards, you'll be able to commit your changes.",
)
}}
2018-10-15 14:42:47 +05:30
</p>
</div>
2018-05-09 12:01:36 +05:30
</div>
</div>
</div>
2018-10-15 14:42:47 +05:30
</template>
</div>
2020-06-23 00:09:42 +05:30
<right-pane v-if="currentProjectId" />
2018-05-09 12:01:36 +05:30
</div>
2019-09-04 21:01:54 +05:30
<ide-status-bar />
2020-05-24 23:13:21 +05:30
<new-modal ref="newModal" />
2018-10-15 14:42:47 +05:30
</article>
2018-05-09 12:01:36 +05:30
</template>