Add initial support for tracking current FM directory for creating a folder (and other stuff eventually)

This commit is contained in:
Dane Everitt 2019-02-16 17:54:15 -08:00
parent 767e466fd8
commit be7f7d8da8
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
6 changed files with 80 additions and 6 deletions

View file

@ -1,8 +1,8 @@
// @ts-ignore
import route from '../../../../../vendor/tightenco/ziggy/src/js/route';
import {ActionContext} from "vuex";
import {ServerData} from "../../models/server";
import {ServerApplicationCredentials, ServerState} from "../types";
import {ServerData} from "@/models/server";
import {FileManagerState, ServerApplicationCredentials, ServerState} from "../types";
export default {
namespaced: true,
@ -10,6 +10,9 @@ export default {
server: {},
credentials: {node: '', key: ''},
console: [],
fm: {
currentDirectory: '/',
},
},
getters: {},
actions: {
@ -63,8 +66,20 @@ export default {
.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: {
SET_CURRENT_DIRECTORY: function (state: ServerState, directory: string) {
state.fm.currentDirectory = directory;
},
SERVER_DATA: function (state: ServerState, data: ServerData) {
state.server = data;
},

View file

@ -19,10 +19,15 @@ export type ServerApplicationCredentials = {
key: string,
};
export type FileManagerState = {
currentDirectory: string,
}
export type ServerState = {
server: ServerData,
credentials: ServerApplicationCredentials,
console: Array<string>,
fm: FileManagerState,
};
export type DashboardState = {