Skip to content

Commit 25621f4

Browse files
committed
Push the user into the newly created directory once made
1 parent 6632097 commit 25621f4

File tree

2 files changed

+34
-29
lines changed

2 files changed

+34
-29
lines changed

resources/assets/scripts/components/server/components/filemanager/modals/CreateFolderModal.vue

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
<template>
22
<Modal :show="visible" v-on:close="onModalClose" :showCloseIcon="false" :dismissable="!isLoading">
3-
<div class="flex items-end">
4-
<div class="flex-1">
5-
<label class="input-label">
6-
Folder Name
7-
</label>
8-
<input
9-
type="text" class="input" name="folder_name"
10-
ref="folderNameField"
11-
v-model="folderName"
12-
v-validate.disabled="'required'"
13-
v-validate="'alpha_dash'"
14-
data-vv-as="Folder Name"
15-
v-on:keyup.enter="submit"
16-
/>
17-
</div>
18-
<div class="ml-4">
19-
<button type="submit"
20-
class="btn btn-primary btn-sm"
21-
v-on:click.prevent="submit"
22-
:disabled="errors.any() || isLoading"
23-
>
24-
<span class="spinner white" v-bind:class="{ hidden: !isLoading }">&nbsp;</span>
25-
<span :class="{ hidden: isLoading }">
26-
Create
27-
</span>
28-
</button>
29-
</div>
3+
<div>
4+
<label class="input-label">
5+
Directory Name
6+
</label>
7+
<input
8+
type="text" class="input" name="folder_name"
9+
ref="folderNameField"
10+
v-model="folderName"
11+
v-validate.disabled="'required'"
12+
v-validate="'alpha_dash'"
13+
data-vv-as="Folder Name"
14+
v-on:keyup.enter="submit"
15+
/>
16+
<p class="input-help">A new directory with this name will be created in the current directory.</p>
17+
</div>
18+
<div class="mt-8 text-right">
19+
<button class="btn btn-secondary btn-sm" v-on:click="onModalClose">Cancel</button>
20+
<button type="submit"
21+
class="ml-2 btn btn-primary btn-sm"
22+
v-on:click.prevent="submit"
23+
:disabled="errors.any() || isLoading"
24+
>
25+
<span class="spinner white" v-bind:class="{ hidden: !isLoading }">&nbsp;</span>
26+
<span :class="{ hidden: isLoading }">
27+
Create Directory
28+
</span>
29+
</button>
3030
</div>
3131
<p class="input-help error">
3232
{{ errors.first('folder_name') }}
@@ -85,7 +85,7 @@
8585
this.isLoading = true;
8686
createFolder(this.server.uuid, this.credentials, `${this.fm.currentDirectory}/${this.folderName.replace(/^\//, '')}`)
8787
.then(() => {
88-
this.$emit('close');
88+
this.$emit('created', this.folderName.replace(/^\//, ''));
8989
this.onModalClose();
9090
})
9191
.catch(console.error.bind(this))

resources/assets/scripts/components/server/subpages/FileManager.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,15 @@
4848
<a href="#" class="block btn btn-primary btn-sm">New File</a>
4949
</div>
5050
</div>
51-
<CreateFolderModal v-on:close="listDirectory"/>
51+
<CreateFolderModal v-on:created="directoryCreated"/>
5252
<RenameModal/>
5353
</div>
5454
</template>
5555

5656
<script lang="ts">
5757
import Vue from 'vue';
5858
import {mapState} from "vuex";
59+
import { join } from 'path';
5960
import {map} from 'lodash';
6061
import getDirectoryContents from "@/api/server/getDirectoryContents";
6162
import FileRow from "@/components/server/components/filemanager/FileRow.vue";
@@ -183,6 +184,10 @@
183184
fileRowDeleted: function (file: DirectoryContentObject) {
184185
this.files = this.files.filter(data => data !== file);
185186
},
187+
188+
directoryCreated: function (directory: string) {
189+
this.$router.push({ name: 'server-files', params: { path: join(this.currentDirectory, directory) }});
190+
},
186191
},
187192
});
188193
</script>

0 commit comments

Comments
 (0)