feat: add button to navigate up to .. (parent dir)

This commit is contained in:
Jaroslav Rakhmatoullin 2024-03-31 09:15:34 +02:00
parent ae0af1f996
commit fd04520c5f
2 changed files with 28 additions and 1 deletions

View File

@ -35,6 +35,7 @@
"selectMultiple": "Select multiple", "selectMultiple": "Select multiple",
"share": "Share", "share": "Share",
"shell": "Toggle shell", "shell": "Toggle shell",
"gotoParent": "Open parent dir",
"submit": "Submit", "submit": "Submit",
"switchView": "Switch view", "switchView": "Switch view",
"toggleSidebar": "Toggle sidebar", "toggleSidebar": "Toggle sidebar",

View File

@ -47,6 +47,12 @@
/> />
</template> </template>
<action
v-if="headerButtons.gotoParent || true"
icon="arrow_upward"
:label="t('buttons.gotoParent')"
@action="gotoParent"
/>
<action <action
v-if="headerButtons.shell" v-if="headerButtons.shell"
icon="code" icon="code"
@ -85,6 +91,14 @@
<span v-if="fileStore.selectedCount > 0" <span v-if="fileStore.selectedCount > 0"
>{{ fileStore.selectedCount }} selected</span >{{ fileStore.selectedCount }} selected</span
> >
<action
v-if="headerButtons.gotoParent || true"
icon="arrow_upward"
:label="t('buttons.gotoParent')"
@action="gotoParent"
/>
<action <action
v-if="headerButtons.share" v-if="headerButtons.share"
icon="share" icon="share"
@ -301,9 +315,10 @@ import {
ref, ref,
watch, watch,
} from "vue"; } from "vue";
import { useRoute } from "vue-router"; import { useRoute, useRouter } from "vue-router";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { storeToRefs } from "pinia"; import { storeToRefs } from "pinia";
import { useRouterStore } from "@/stores/router";
const showLimit = ref<number>(50); const showLimit = ref<number>(50);
const columnWidth = ref<number>(280); const columnWidth = ref<number>(280);
@ -321,6 +336,7 @@ const layoutStore = useLayoutStore();
const { req } = storeToRefs(fileStore); const { req } = storeToRefs(fileStore);
const route = useRoute(); const route = useRoute();
const router = useRouter();
const { t } = useI18n(); const { t } = useI18n();
@ -404,6 +420,7 @@ const viewIcon = computed(() => {
const headerButtons = computed(() => { const headerButtons = computed(() => {
return { return {
gotoParent: true,
upload: authStore.user?.perm.create, upload: authStore.user?.perm.create,
download: authStore.user?.perm.download, download: authStore.user?.perm.download,
shell: authStore.user?.perm.execute && enableExec, shell: authStore.user?.perm.execute && enableExec,
@ -890,6 +907,15 @@ const download = () => {
}); });
}; };
const gotoParent = () => {
console.log(route.fullPath)
const url = (route.fullPath || "")
const parts = url.replace(/\/$/, '').split('/');
parts.pop();
const parentUrl = parts.join('/');
router.push({ path: parentUrl });
};
const switchView = async () => { const switchView = async () => {
layoutStore.closeHovers(); layoutStore.closeHovers();