Add initial support for tracking current FM directory for creating a folder (and other stuff eventually)
This commit is contained in:
parent
767e466fd8
commit
be7f7d8da8
|
@ -33,7 +33,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="action">New File</div>
|
<div class="action">New File</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="context-row">
|
<div class="context-row" v-on:click="openFolderModal">
|
||||||
<div class="icon">
|
<div class="icon">
|
||||||
<Icon name="folder-plus" class="h-4"/>
|
<Icon name="folder-plus" class="h-4"/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -58,5 +58,12 @@
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
name: 'FileContextMenu',
|
name: 'FileContextMenu',
|
||||||
components: {Icon},
|
components: {Icon},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
openFolderModal: function () {
|
||||||
|
window.events.$emit('server:files:open-directory-modal');
|
||||||
|
this.$emit('close');
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -10,7 +10,12 @@
|
||||||
<div class="flex-1 text-right text-neutral-600">{{formatDate(file.modified)}}</div>
|
<div class="flex-1 text-right text-neutral-600">{{formatDate(file.modified)}}</div>
|
||||||
<div class="flex-none w-1/6"></div>
|
<div class="flex-none w-1/6"></div>
|
||||||
</div>
|
</div>
|
||||||
<FileContextMenu class="context-menu" v-show="contextMenuVisible" ref="contextMenu"/>
|
<FileContextMenu
|
||||||
|
class="context-menu"
|
||||||
|
v-show="contextMenuVisible"
|
||||||
|
v-on:close="contextMenuVisible = false"
|
||||||
|
ref="contextMenu"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
<template>
|
||||||
|
<Modal :show="visible" v-on:close="visible = false">
|
||||||
|
<div>
|
||||||
|
<h2 class="font-medium text-neutral-900 mb-6">{{ fm.currentDirectory }}</h2>
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import Vue from 'vue';
|
||||||
|
import Modal from '@/components/core/Modal.vue';
|
||||||
|
import {mapState} from "vuex";
|
||||||
|
|
||||||
|
export default Vue.extend({
|
||||||
|
name: 'CreateFolderModal',
|
||||||
|
components: {Modal},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
...mapState('server', ['fm']),
|
||||||
|
},
|
||||||
|
|
||||||
|
data: function () {
|
||||||
|
return {
|
||||||
|
visible: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
mounted: function () {
|
||||||
|
window.events.$on('server:files:open-directory-modal', () => {
|
||||||
|
this.visible = true;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -42,12 +42,13 @@
|
||||||
<div class="flex mt-6" v-if="!loading && !errorMessage">
|
<div class="flex mt-6" v-if="!loading && !errorMessage">
|
||||||
<div class="flex-1"></div>
|
<div class="flex-1"></div>
|
||||||
<div class="mr-4">
|
<div class="mr-4">
|
||||||
<a href="#" class="block btn btn-secondary btn-sm">New Folder</a>
|
<a href="#" class="block btn btn-secondary btn-sm" v-on:click.prevent="openNewFolderModal">New Folder</a>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<a href="#" class="block btn btn-primary btn-sm">New File</a>
|
<a href="#" class="block btn btn-primary btn-sm">New File</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<CreateFolderModal/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -58,6 +59,7 @@
|
||||||
import getDirectoryContents from "@/api/server/getDirectoryContents";
|
import getDirectoryContents from "@/api/server/getDirectoryContents";
|
||||||
import FileRow from "@/components/server/components/filemanager/FileRow.vue";
|
import FileRow from "@/components/server/components/filemanager/FileRow.vue";
|
||||||
import FolderRow from "@/components/server/components/filemanager/FolderRow.vue";
|
import FolderRow from "@/components/server/components/filemanager/FolderRow.vue";
|
||||||
|
import CreateFolderModal from '../components/filemanager/modals/CreateFolderModal.vue';
|
||||||
|
|
||||||
type DataStructure = {
|
type DataStructure = {
|
||||||
loading: boolean,
|
loading: boolean,
|
||||||
|
@ -70,7 +72,7 @@
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
name: 'FileManager',
|
name: 'FileManager',
|
||||||
components: {FileRow, FolderRow},
|
components: {CreateFolderModal, FileRow, FolderRow},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState('server', ['server', 'credentials']),
|
...mapState('server', ['server', 'credentials']),
|
||||||
...mapState('socket', ['connected']),
|
...mapState('socket', ['connected']),
|
||||||
|
@ -110,6 +112,8 @@
|
||||||
* Watch the current directory setting and when it changes update the file listing.
|
* Watch the current directory setting and when it changes update the file listing.
|
||||||
*/
|
*/
|
||||||
currentDirectory: function () {
|
currentDirectory: function () {
|
||||||
|
this.$store.dispatch('server/updateCurrentDirectory', this.currentDirectory);
|
||||||
|
|
||||||
this.listDirectory();
|
this.listDirectory();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -167,6 +171,10 @@
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
openNewFolderModal: function () {
|
||||||
|
window.events.$emit('server:files:open-directory-modal');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import route from '../../../../../vendor/tightenco/ziggy/src/js/route';
|
import route from '../../../../../vendor/tightenco/ziggy/src/js/route';
|
||||||
import {ActionContext} from "vuex";
|
import {ActionContext} from "vuex";
|
||||||
import {ServerData} from "../../models/server";
|
import {ServerData} from "@/models/server";
|
||||||
import {ServerApplicationCredentials, ServerState} from "../types";
|
import {FileManagerState, ServerApplicationCredentials, ServerState} from "../types";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
|
@ -10,6 +10,9 @@ export default {
|
||||||
server: {},
|
server: {},
|
||||||
credentials: {node: '', key: ''},
|
credentials: {node: '', key: ''},
|
||||||
console: [],
|
console: [],
|
||||||
|
fm: {
|
||||||
|
currentDirectory: '/',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
getters: {},
|
getters: {},
|
||||||
actions: {
|
actions: {
|
||||||
|
@ -63,8 +66,20 @@ export default {
|
||||||
.catch(reject);
|
.catch(reject);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the last viewed directory for the server the user is currently viewing. This allows
|
||||||
|
* us to quickly navigate back to that directory, as well as ensure that actions taken are
|
||||||
|
* performed aganist the correct directory without having to pass that mess everywhere.
|
||||||
|
*/
|
||||||
|
updateCurrentDirectory: ({commit}: ActionContext<ServerState, any>, directory: string) => {
|
||||||
|
commit('SET_CURRENT_DIRECTORY', directory);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
|
SET_CURRENT_DIRECTORY: function (state: ServerState, directory: string) {
|
||||||
|
state.fm.currentDirectory = directory;
|
||||||
|
},
|
||||||
SERVER_DATA: function (state: ServerState, data: ServerData) {
|
SERVER_DATA: function (state: ServerState, data: ServerData) {
|
||||||
state.server = data;
|
state.server = data;
|
||||||
},
|
},
|
||||||
|
|
|
@ -19,10 +19,15 @@ export type ServerApplicationCredentials = {
|
||||||
key: string,
|
key: string,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type FileManagerState = {
|
||||||
|
currentDirectory: string,
|
||||||
|
}
|
||||||
|
|
||||||
export type ServerState = {
|
export type ServerState = {
|
||||||
server: ServerData,
|
server: ServerData,
|
||||||
credentials: ServerApplicationCredentials,
|
credentials: ServerApplicationCredentials,
|
||||||
console: Array<string>,
|
console: Array<string>,
|
||||||
|
fm: FileManagerState,
|
||||||
};
|
};
|
||||||
|
|
||||||
export type DashboardState = {
|
export type DashboardState = {
|
||||||
|
|
Loading…
Reference in New Issue