Push the user into the newly created directory once made

This commit is contained in:
Dane Everitt 2019-03-10 14:28:24 -07:00
parent 66320972be
commit 25621f4c1c
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
2 changed files with 34 additions and 29 deletions

View File

@ -1,9 +1,8 @@
<template> <template>
<Modal :show="visible" v-on:close="onModalClose" :showCloseIcon="false" :dismissable="!isLoading"> <Modal :show="visible" v-on:close="onModalClose" :showCloseIcon="false" :dismissable="!isLoading">
<div class="flex items-end"> <div>
<div class="flex-1">
<label class="input-label"> <label class="input-label">
Folder Name Directory Name
</label> </label>
<input <input
type="text" class="input" name="folder_name" type="text" class="input" name="folder_name"
@ -14,20 +13,21 @@
data-vv-as="Folder Name" data-vv-as="Folder Name"
v-on:keyup.enter="submit" v-on:keyup.enter="submit"
/> />
<p class="input-help">A new directory with this name will be created in the current directory.</p>
</div> </div>
<div class="ml-4"> <div class="mt-8 text-right">
<button class="btn btn-secondary btn-sm" v-on:click="onModalClose">Cancel</button>
<button type="submit" <button type="submit"
class="btn btn-primary btn-sm" class="ml-2 btn btn-primary btn-sm"
v-on:click.prevent="submit" v-on:click.prevent="submit"
:disabled="errors.any() || isLoading" :disabled="errors.any() || isLoading"
> >
<span class="spinner white" v-bind:class="{ hidden: !isLoading }">&nbsp;</span> <span class="spinner white" v-bind:class="{ hidden: !isLoading }">&nbsp;</span>
<span :class="{ hidden: isLoading }"> <span :class="{ hidden: isLoading }">
Create Create Directory
</span> </span>
</button> </button>
</div> </div>
</div>
<p class="input-help error"> <p class="input-help error">
{{ errors.first('folder_name') }} {{ errors.first('folder_name') }}
</p> </p>
@ -85,7 +85,7 @@
this.isLoading = true; this.isLoading = true;
createFolder(this.server.uuid, this.credentials, `${this.fm.currentDirectory}/${this.folderName.replace(/^\//, '')}`) createFolder(this.server.uuid, this.credentials, `${this.fm.currentDirectory}/${this.folderName.replace(/^\//, '')}`)
.then(() => { .then(() => {
this.$emit('close'); this.$emit('created', this.folderName.replace(/^\//, ''));
this.onModalClose(); this.onModalClose();
}) })
.catch(console.error.bind(this)) .catch(console.error.bind(this))

View File

@ -48,7 +48,7 @@
<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 v-on:close="listDirectory"/> <CreateFolderModal v-on:created="directoryCreated"/>
<RenameModal/> <RenameModal/>
</div> </div>
</template> </template>
@ -56,6 +56,7 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import {mapState} from "vuex"; import {mapState} from "vuex";
import { join } from 'path';
import {map} from 'lodash'; import {map} from 'lodash';
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";
@ -183,6 +184,10 @@
fileRowDeleted: function (file: DirectoryContentObject) { fileRowDeleted: function (file: DirectoryContentObject) {
this.files = this.files.filter(data => data !== file); this.files = this.files.filter(data => data !== file);
}, },
directoryCreated: function (directory: string) {
this.$router.push({ name: 'server-files', params: { path: join(this.currentDirectory, directory) }});
},
}, },
}); });
</script> </script>