feat: moved folder creation into FileList component (#2659)
This commit is contained in:
parent
7c16e795e2
commit
d676d5d7f6
@ -21,6 +21,16 @@
|
|||||||
{{ $t("prompts.currentlyNavigating") }} <code>{{ nav }}</code
|
{{ $t("prompts.currentlyNavigating") }} <code>{{ nav }}</code
|
||||||
>.
|
>.
|
||||||
</p>
|
</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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -133,6 +143,17 @@ export default {
|
|||||||
this.selected = event.currentTarget.dataset.url;
|
this.selected = event.currentTarget.dataset.url;
|
||||||
this.$emit("update:selected", this.selected);
|
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>
|
</script>
|
||||||
|
|||||||
@ -9,16 +9,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-action">
|
<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
|
<button
|
||||||
class="button button--flat button--grey"
|
class="button button--flat button--grey"
|
||||||
@click="$store.commit('closeHovers')"
|
@click="$store.commit('closeHovers')"
|
||||||
@ -108,16 +98,6 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
action(overwrite, rename);
|
action(overwrite, rename);
|
||||||
},
|
|
||||||
createDir: async function (){
|
|
||||||
this.$store.commit('showHover', {
|
|
||||||
prompt: 'newDir',
|
|
||||||
action: null,
|
|
||||||
confirm: null,
|
|
||||||
props:{
|
|
||||||
redirect: false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@ -44,7 +44,14 @@ import url from "@/utils/url";
|
|||||||
export default {
|
export default {
|
||||||
name: "new-dir",
|
name: "new-dir",
|
||||||
props: {
|
props: {
|
||||||
redirect: Boolean,
|
redirect: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
base: {
|
||||||
|
type: [String, null],
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
@ -60,7 +67,14 @@ export default {
|
|||||||
if (this.new === "") return;
|
if (this.new === "") return;
|
||||||
|
|
||||||
// Build the path of the new directory.
|
// 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) {
|
if (!this.isListing) {
|
||||||
uri = url.removeLastDir(uri) + "/";
|
uri = url.removeLastDir(uri) + "/";
|
||||||
@ -73,7 +87,8 @@ export default {
|
|||||||
await api.post(uri);
|
await api.post(uri);
|
||||||
if (this.redirect) {
|
if (this.redirect) {
|
||||||
this.$router.push({ path: uri });
|
this.$router.push({ path: uri });
|
||||||
}else{
|
}
|
||||||
|
else if (!this.base){
|
||||||
const res = await api.fetch(url.removeLastDir(uri) + "/");
|
const res = await api.fetch(url.removeLastDir(uri) + "/");
|
||||||
this.$store.commit("updateRequest", res);
|
this.$store.commit("updateRequest", res);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user