feat: moved folder creation into FileList component (#2659)

This commit is contained in:
ArthurMousatov 2023-08-23 22:34:21 -04:00
parent 7c16e795e2
commit d676d5d7f6
3 changed files with 40 additions and 24 deletions

View File

@ -21,6 +21,16 @@
{{ $t("prompts.currentlyNavigating") }} <code>{{ nav }}</code
>.
</p>
<template v-if="user.perm.create">
<button
class="button button--flat"
@click="createDir()"
:aria-label="$t('sidebar.newFolder')"
:title="$t('sidebar.newFolder')"
>
<span style="vertical-align: bottom;">{{ $t("sidebar.newFolder") }}</span>
</button>
</template>
</div>
</template>
@ -133,6 +143,17 @@ export default {
this.selected = event.currentTarget.dataset.url;
this.$emit("update:selected", this.selected);
},
createDir: async function (){
this.$store.commit('showHover', {
prompt: 'newDir',
action: null,
confirm: null,
props:{
redirect: false,
base: this.current === this.$route.path ? null : this.current,
}
})
}
},
};
</script>

View File

@ -9,16 +9,6 @@
</div>
<div class="card-action">
<template v-if="user.perm.create">
<button
class="button button--flat"
@click="createDir()"
:aria-label="$t('sidebar.newFolder')"
:title="$t('sidebar.newFolder')"
>
<span style="vertical-align: bottom;">{{ $t("sidebar.newFolder") }}</span>
</button>
</template>
<button
class="button button--flat button--grey"
@click="$store.commit('closeHovers')"
@ -108,16 +98,6 @@ export default {
}
action(overwrite, rename);
},
createDir: async function (){
this.$store.commit('showHover', {
prompt: 'newDir',
action: null,
confirm: null,
props:{
redirect: false
}
})
}
},
};

View File

@ -44,7 +44,14 @@ import url from "@/utils/url";
export default {
name: "new-dir",
props: {
redirect: Boolean,
redirect: {
type: Boolean,
default: true,
},
base: {
type: [String, null],
default: null,
},
},
data: function () {
return {
@ -60,7 +67,14 @@ export default {
if (this.new === "") return;
// Build the path of the new directory.
let uri = this.isFiles ? this.$route.path + "/" : "/";
let uri;
if (this.base)
uri = this.base;
else if (this.isFiles)
uri = this.$route.path + "/";
else
uri = "/";
if (!this.isListing) {
uri = url.removeLastDir(uri) + "/";
@ -68,12 +82,13 @@ export default {
uri += encodeURIComponent(this.name) + "/";
uri = uri.replace("//", "/");
try {
await api.post(uri);
if (this.redirect) {
this.$router.push({ path: uri });
}else{
}
else if (!this.base){
const res = await api.fetch(url.removeLastDir(uri) + "/");
this.$store.commit("updateRequest", res);
}