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

83 lines
2.1 KiB
Vue
Raw Normal View History

2018-10-15 14:42:47 +05:30
<script>
import { mapState, mapGetters, mapActions } from 'vuex';
2021-01-03 14:25:43 +05:30
import { modalTypes, viewerTypes } from '../constants';
2018-10-15 14:42:47 +05:30
import IdeTreeList from './ide_tree_list.vue';
2018-11-18 11:00:15 +05:30
import Upload from './new_dropdown/upload.vue';
import NewEntryButton from './new_dropdown/button.vue';
2020-05-24 23:13:21 +05:30
import NewModal from './new_dropdown/modal.vue';
2018-10-15 14:42:47 +05:30
export default {
components: {
2018-11-18 11:00:15 +05:30
Upload,
2018-10-15 14:42:47 +05:30
IdeTreeList,
2018-11-18 11:00:15 +05:30
NewEntryButton,
2020-05-24 23:13:21 +05:30
NewModal,
2018-10-15 14:42:47 +05:30
},
computed: {
...mapState(['currentBranchId']),
2020-11-24 15:15:51 +05:30
...mapGetters(['currentProject', 'currentTree', 'activeFile', 'getUrlForPath']),
2018-10-15 14:42:47 +05:30
},
mounted() {
2021-01-03 14:25:43 +05:30
this.initialize();
},
activated() {
this.initialize();
2018-10-15 14:42:47 +05:30
},
methods: {
2020-05-24 23:13:21 +05:30
...mapActions(['updateViewer', 'createTempEntry', 'resetOpenFiles']),
createNewFile() {
this.$refs.newModal.open(modalTypes.blob);
},
createNewFolder() {
this.$refs.newModal.open(modalTypes.tree);
},
2021-01-03 14:25:43 +05:30
initialize() {
this.$nextTick(() => {
this.updateViewer(viewerTypes.edit);
});
if (!this.activeFile) return;
if (this.activeFile.pending && !this.activeFile.deleted) {
this.$router.push(this.getUrlForPath(this.activeFile.path), () => {
this.updateViewer(viewerTypes.edit);
});
} else if (this.activeFile.deleted) {
this.resetOpenFiles();
}
},
2018-10-15 14:42:47 +05:30
},
};
</script>
<template>
2021-01-03 14:25:43 +05:30
<ide-tree-list>
2020-05-24 23:13:21 +05:30
<template #header>
2018-10-15 14:42:47 +05:30
{{ __('Edit') }}
2021-01-03 14:25:43 +05:30
<div class="ide-tree-actions ml-auto d-flex" data-testid="ide-root-actions">
2018-11-18 11:00:15 +05:30
<new-entry-button
:label="__('New file')"
:show-label="false"
2018-12-13 13:39:08 +05:30
class="d-flex border-0 p-0 mr-3 qa-new-file"
2018-11-18 11:00:15 +05:30
icon="doc-new"
2020-05-24 23:13:21 +05:30
@click="createNewFile()"
2018-11-18 11:00:15 +05:30
/>
<upload
:show-label="false"
class="d-flex mr-3"
button-css-classes="border-0 p-0"
@create="createTempEntry"
/>
<new-entry-button
:label="__('New directory')"
:show-label="false"
class="d-flex border-0 p-0"
icon="folder-new"
2020-05-24 23:13:21 +05:30
@click="createNewFolder()"
2018-11-18 11:00:15 +05:30
/>
</div>
2020-05-24 23:13:21 +05:30
<new-modal ref="newModal" />
2018-10-15 14:42:47 +05:30
</template>
</ide-tree-list>
</template>