DesktopToolbar.vue refactoring

This commit is contained in:
Peter Papp
2021-08-20 16:49:51 +02:00
parent 15fba236d7
commit fb6dfbe7b4
6 changed files with 117 additions and 103 deletions

View File

@@ -56,7 +56,7 @@
"/chunks/plan-settings.js": "/chunks/plan-settings.js?id=17469545c5b6a16c3bbf",
"/chunks/plan-subscribers.js": "/chunks/plan-subscribers.js?id=0dd0a5efe0e3cb511c48",
"/chunks/plans.js": "/chunks/plans.js?id=5a3c28288952fcad96e5",
"/chunks/platform.js": "/chunks/platform.js?id=6b3eb780969c508cbb61",
"/chunks/platform.js": "/chunks/platform.js?id=ac3117837560f59645c5",
"/chunks/platform~chunks/shared.js": "/chunks/platform~chunks/shared.js?id=3434322e91f37e1887a6",
"/chunks/profile.js": "/chunks/profile.js?id=658aa03af778cc2cc100",
"/chunks/profile~chunks/settings-password.js": "/chunks/profile~chunks/settings-password.js?id=ddb7be518c092ed392ca",
@@ -113,7 +113,7 @@
"/chunks/app-language~chunks/dashboard~chunks/invoices~chunks/pages~chunks/plans~chunks/platform~chunk~4546fed3.js": "/chunks/app-language~chunks/dashboard~chunks/invoices~chunks/pages~chunks/plans~chunks/platform~chunk~4546fed3.js?id=dcb0f3eb29f9bb036a83",
"/chunks/app-language~chunks/dashboard~chunks/invoices~chunks/pages~chunks/plans~chunks/settings~chunk~4e1df859.js": "/chunks/app-language~chunks/dashboard~chunks/invoices~chunks/pages~chunks/plans~chunks/settings~chunk~4e1df859.js?id=ce01da2eb15ee1ebede4",
"/chunks/files.61f541e551bb6ae551ff.hot-update.js": "/chunks/files.61f541e551bb6ae551ff.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.js": "/chunks/platform~chunks/shared/file-browser.js?id=3f11d3ce9b514da8ee77",
"/chunks/platform~chunks/shared/file-browser.js": "/chunks/platform~chunks/shared/file-browser.js?id=f615296acb04c58b1941",
"/chunks/platform~chunks/shared~chunks/shared/file-browser.js": "/chunks/platform~chunks/shared~chunks/shared/file-browser.js?id=6ba92eab6a45cbab3af5",
"/chunks/platform~chunks/shared~chunks/shared/file-browser~chunks/shared/single-file.js": "/chunks/platform~chunks/shared~chunks/shared/file-browser~chunks/shared/single-file.js?id=c9e60ce6e02af680eeaa",
"/chunks/settings-subscription~chunks/shared/file-browser~chunks/user-subscription.js": "/chunks/settings-subscription~chunks/shared/file-browser~chunks/user-subscription.js?id=439e216b216fc2572483",
@@ -341,5 +341,57 @@
"/js/main.cb31c8e951615eb1e3a1.hot-update.js": "/js/main.cb31c8e951615eb1e3a1.hot-update.js",
"/js/main.e123ff26f3f3f227b8fe.hot-update.js": "/js/main.e123ff26f3f3f227b8fe.hot-update.js",
"/chunks/admin~chunks/platform.068c46bd7c6b6bbeef39.hot-update.js": "/chunks/admin~chunks/platform.068c46bd7c6b6bbeef39.hot-update.js",
"/chunks/admin~chunks/platform.5bca50650c704e335f3d.hot-update.js": "/chunks/admin~chunks/platform.5bca50650c704e335f3d.hot-update.js"
"/chunks/admin~chunks/platform.5bca50650c704e335f3d.hot-update.js": "/chunks/admin~chunks/platform.5bca50650c704e335f3d.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.81a4a0c4265d11836cd3.hot-update.js": "/chunks/platform~chunks/shared/file-browser.81a4a0c4265d11836cd3.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.800217d4ad22f50667af.hot-update.js": "/chunks/platform~chunks/shared/file-browser.800217d4ad22f50667af.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.703fadf87f83f74d1a92.hot-update.js": "/chunks/platform~chunks/shared/file-browser.703fadf87f83f74d1a92.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.74455257d5204840b3c7.hot-update.js": "/chunks/platform~chunks/shared/file-browser.74455257d5204840b3c7.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.dfad226ef06cbbe0c4b5.hot-update.js": "/chunks/platform~chunks/shared/file-browser.dfad226ef06cbbe0c4b5.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.9ae4d81fae707d9710fc.hot-update.js": "/chunks/platform~chunks/shared/file-browser.9ae4d81fae707d9710fc.hot-update.js",
"/js/main.4068697b323c3409a72d.hot-update.js": "/js/main.4068697b323c3409a72d.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.20a7b0f5cb8819bb6a10.hot-update.js": "/chunks/platform~chunks/shared/file-browser.20a7b0f5cb8819bb6a10.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.a357f0733f38a22865cb.hot-update.js": "/chunks/platform~chunks/shared/file-browser.a357f0733f38a22865cb.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.de1f7c6ff6707374236f.hot-update.js": "/chunks/platform~chunks/shared/file-browser.de1f7c6ff6707374236f.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.a152f2b58898438412f8.hot-update.js": "/chunks/platform~chunks/shared/file-browser.a152f2b58898438412f8.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.63e642d119be863fa918.hot-update.js": "/chunks/platform~chunks/shared/file-browser.63e642d119be863fa918.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.f35b09f6b17f016e66d5.hot-update.js": "/chunks/platform~chunks/shared/file-browser.f35b09f6b17f016e66d5.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.68ffb41173a4e7bc0d9e.hot-update.js": "/chunks/platform~chunks/shared/file-browser.68ffb41173a4e7bc0d9e.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.1599a1861545cb20db7b.hot-update.js": "/chunks/platform~chunks/shared/file-browser.1599a1861545cb20db7b.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.c103ad01032007ee897e.hot-update.js": "/chunks/platform~chunks/shared/file-browser.c103ad01032007ee897e.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.fc94ef3f0f85f6c6a4c9.hot-update.js": "/chunks/platform~chunks/shared/file-browser.fc94ef3f0f85f6c6a4c9.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.02804e1991b5f7099fc7.hot-update.js": "/chunks/platform~chunks/shared/file-browser.02804e1991b5f7099fc7.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.3d9671bb0e803e65e41f.hot-update.js": "/chunks/platform~chunks/shared/file-browser.3d9671bb0e803e65e41f.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.3134a6abfad5a7ba7631.hot-update.js": "/chunks/platform~chunks/shared/file-browser.3134a6abfad5a7ba7631.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.e48050ba6c1b226da029.hot-update.js": "/chunks/platform~chunks/shared/file-browser.e48050ba6c1b226da029.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.4f35431e744ed66774a2.hot-update.js": "/chunks/platform~chunks/shared/file-browser.4f35431e744ed66774a2.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.b8cc2c5aded88db7d706.hot-update.js": "/chunks/platform~chunks/shared/file-browser.b8cc2c5aded88db7d706.hot-update.js",
"/js/main.46480f5b3108b998bd4e.hot-update.js": "/js/main.46480f5b3108b998bd4e.hot-update.js",
"/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/shared~738b0c2f.js": "/chunks/admin~chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/shared~738b0c2f.js?id=1cfe4349f2fbc54a6884",
"/chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/shared/file-browser~d426c4eb.46480f5b3108b998bd4e.hot-update.js": "/chunks/files~chunks/my-shared-items~chunks/platform~chunks/recent-uploads~chunks/shared/file-browser~d426c4eb.46480f5b3108b998bd4e.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.46480f5b3108b998bd4e.hot-update.js": "/chunks/platform~chunks/shared/file-browser.46480f5b3108b998bd4e.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.9302f42000c71a07b1a7.hot-update.js": "/chunks/platform~chunks/shared/file-browser.9302f42000c71a07b1a7.hot-update.js",
"/js/main.7d649514b25888f62eeb.hot-update.js": "/js/main.7d649514b25888f62eeb.hot-update.js",
"/chunks/files~chunks/my-shared-items~chunks/recent-uploads~chunks/shared/file-browser~chunks/trash.7d649514b25888f62eeb.hot-update.js": "/chunks/files~chunks/my-shared-items~chunks/recent-uploads~chunks/shared/file-browser~chunks/trash.7d649514b25888f62eeb.hot-update.js",
"/chunks/platform.7d649514b25888f62eeb.hot-update.js": "/chunks/platform.7d649514b25888f62eeb.hot-update.js",
"/chunks/platform~chunks/shared.7d649514b25888f62eeb.hot-update.js": "/chunks/platform~chunks/shared.7d649514b25888f62eeb.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.7d649514b25888f62eeb.hot-update.js": "/chunks/platform~chunks/shared/file-browser.7d649514b25888f62eeb.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.d2b2536646288e30adbe.hot-update.js": "/chunks/platform~chunks/shared/file-browser.d2b2536646288e30adbe.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.d6a6c6935aa6d7394a5c.hot-update.js": "/chunks/platform~chunks/shared/file-browser.d6a6c6935aa6d7394a5c.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.a1361f1c22837f277e52.hot-update.js": "/chunks/platform~chunks/shared/file-browser.a1361f1c22837f277e52.hot-update.js",
"/chunks/platform.4228da40812dd15ec2b3.hot-update.js": "/chunks/platform.4228da40812dd15ec2b3.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.1af64fc60480a60df720.hot-update.js": "/chunks/platform~chunks/shared/file-browser.1af64fc60480a60df720.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.0d4da0bc70d9412b8407.hot-update.js": "/chunks/platform~chunks/shared/file-browser.0d4da0bc70d9412b8407.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.ad1e633589b088c11c80.hot-update.js": "/chunks/platform~chunks/shared/file-browser.ad1e633589b088c11c80.hot-update.js",
"/js/main.bc69e270e1dc6aa30593.hot-update.js": "/js/main.bc69e270e1dc6aa30593.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.fe90422ef85b8f968ebd.hot-update.js": "/chunks/platform~chunks/shared/file-browser.fe90422ef85b8f968ebd.hot-update.js",
"/js/main.f6d7cfa798c5cddc99fc.hot-update.js": "/js/main.f6d7cfa798c5cddc99fc.hot-update.js",
"/js/main.6797ed2e048689016fa0.hot-update.js": "/js/main.6797ed2e048689016fa0.hot-update.js",
"/js/main.f3618b12ca29c7424833.hot-update.js": "/js/main.f3618b12ca29c7424833.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.b05762595cd4ada1e620.hot-update.js": "/chunks/platform~chunks/shared/file-browser.b05762595cd4ada1e620.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.3b84dd2bbbb80717ca7a.hot-update.js": "/chunks/platform~chunks/shared/file-browser.3b84dd2bbbb80717ca7a.hot-update.js",
"/js/main.3452784753f8b4ce665d.hot-update.js": "/js/main.3452784753f8b4ce665d.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.3940ff662d65d2b25d1d.hot-update.js": "/chunks/platform~chunks/shared/file-browser.3940ff662d65d2b25d1d.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.6a8d6f3ca45769e8b39a.hot-update.js": "/chunks/platform~chunks/shared/file-browser.6a8d6f3ca45769e8b39a.hot-update.js",
"/chunks/platform~chunks/shared/file-browser.64f2e9e80a9fbccc1a4e.hot-update.js": "/chunks/platform~chunks/shared/file-browser.64f2e9e80a9fbccc1a4e.hot-update.js",
"/js/main.f98f44157b78a5a1d656.hot-update.js": "/js/main.f98f44157b78a5a1d656.hot-update.js"
}

View File

@@ -1,15 +1,14 @@
<template>
<div id="desktop-toolbar">
<div class="toolbar-wrapper">
<div v-if="homeDirectory" @click="goBack" class="location">
<chevron-left-icon :class="{'is-active': browseHistory.length > 1 }" class="icon-back" size="17" />
<div @click="goBack" class="location">
<chevron-left-icon :class="{'is-active': canGoBack }" class="icon-back" size="17" />
<span class="location-title">
{{ directoryName }}
</span>
<span @click.stop="folderActions" v-if="browseHistory.length > 1 && $isThisLocation(['base', 'public'])" class="location-more group" id="folder-actions">
<span @click.stop="folderActions" class="location-more group" id="folder-actions">
<more-horizontal-icon size="14" class="icon-more group-hover-text-theme" />
</span>
</div>
@@ -31,14 +30,14 @@
</OptionGroup>
<OptionGroup>
<Option @click.stop.native="$createTeamFolder" :title="$t('Create Team Folder')" icon="users" />
<Option @click.stop.native="createFolder" :class="{'is-inactive': canCreateFolderInView }" :title="$t('actions.create_folder')" icon="folder-plus" />
<Option @click.stop.native="$createFolder" :class="{'is-inactive': canCreateFolderInView }" :title="$t('actions.create_folder')" icon="folder-plus" />
</OptionGroup>
</PopoverItem>
</PopoverWrapper>
</ToolbarGroup>
<!--Share Controls-->
<ToolbarGroup v-if="$checkPermission(['master', 'editor']) && ! $isMobile() && !$isThisLocation(['public'])">
<ToolbarGroup v-if="$checkPermission(['master', 'editor']) && ! $isMobile() && !$isThisRoute($route, ['Public'])">
<!--Team Folder Icon-->
<PopoverWrapper>
@@ -47,19 +46,19 @@
<TeamFolderPreview />
<OptionGroup>
<Option @click.native="$updateTeamFolder(clipboard[0])" :title="$t('Edit Members')" icon="rename" />
<Option @click.native="dissolveTeamFolder(clipboard[0])" :title="$t('Dissolve Team')" icon="trash" />
<Option @click.native="$dissolveTeamFolder(clipboard[0])" :title="$t('Dissolve Team')" icon="trash" />
</OptionGroup>
</PopoverItem>
</PopoverWrapper>
<ToolbarButton v-if="false" @click.native="$createTeamFolder" source="user-plus" :action="$t('actions.convert_into_team_folder')" />
<ToolbarButton @click.native="shareItem" :class="{'is-inactive': canShareInView }" source="share" :action="$t('actions.share')" />
<ToolbarButton @click.native="$shareFileOrFolder(clipboard[0])" :class="{'is-inactive': canShareInView }" source="share" :action="$t('actions.share')" />
</ToolbarGroup>
<!--File Controls-->
<ToolbarGroup v-if="$checkPermission(['master', 'editor']) && ! $isMobile()">
<ToolbarButton @click.native="moveItem" :class="{'is-inactive': canMoveInView }" source="move" :action="$t('actions.move')" />
<ToolbarButton @click.native="deleteItem" :class="{'is-inactive': canDeleteInView }" source="trash" :action="$t('actions.delete')" />
<ToolbarButton @click.native="$moveFileOrFolder(clipboard[0])" :class="{'is-inactive': canMoveInView }" source="move" :action="$t('actions.move')" />
<ToolbarButton @click.native="$deleteFileOrFolder(clipboard[0])" :class="{'is-inactive': canDeleteInView }" source="trash" :action="$t('actions.delete')" />
</ToolbarGroup>
<!--View Controls-->
@@ -99,7 +98,7 @@
import {last} from 'lodash'
export default {
name: 'ToolBar',
name: 'DesktopToolbar',
components: {
TeamMembersPreview,
FileSortingOptions,
@@ -119,6 +118,7 @@
},
computed: {
...mapGetters([
'previousLocation',
'isVisibleSidebar',
'FilePreviewType',
'currentFolder',
@@ -126,6 +126,9 @@
'homeDirectory',
'clipboard',
]),
canGoBack() {
return this.$route.params.id
},
hasCapacity() {
// Check if storage limitation is set
if (!this.$store.getters.config.storageLimit) return true
@@ -137,9 +140,7 @@
return this.$store.getters.user.data.attributes.storage.used <= 100
},
directoryName() {
return this.currentFolder
? this.currentFolder.name
: this.homeDirectory.name
return 'todo'
},
preview() {
return this.FilePreviewType === 'list'
@@ -147,46 +148,45 @@
: 'th-list'
},
canCreateFolderInView() {
return !this.$isThisLocation(['base', 'public'])
return ! this.$isThisRoute(this.$route, ['Files', 'Public'])
},
canDeleteInView() {
let locations = [
'trash-root',
'latest',
'shared',
'public',
'trash',
'base',
let routes = [
'RecentUploads',
'MySharedItems',
'Trash',
'Public',
'Files',
]
return !this.$isThisLocation(locations) || this.clipboard.length === 0
return !this.$isThisRoute(this.$route, routes) || this.clipboard.length === 0
},
canUploadInView() {
return !this.$isThisLocation(['base', 'public'])
return ! this.$isThisRoute(this.$route, ['Files', 'Public'])
},
canMoveInView() {
let locations = [
'latest',
'shared',
'public',
'base',
let routes = [
'RecentUploads',
'MySharedItems',
'Public',
'Files',
]
return !this.$isThisLocation(locations) || this.clipboard.length === 0
return ! this.$isThisRoute(this.$route, routes) || this.clipboard.length === 0
},
canShareInView() {
let locations = [
'latest',
'shared',
'public',
'base',
let routes = [
'RecentUploads',
'MySharedItems',
'Public',
'Files',
]
return !this.$isThisLocation(locations) || this.clipboard.length > 1 || this.clipboard.length === 0
return ! this.$isThisRoute(this.$route, routes) || this.clipboard.length > 1 || this.clipboard.length === 0
},
canCreateTeamFolderInView() {
let locations = [
'shared',
'base',
let routes = [
'MySharedItems',
'Files',
]
return this.$isThisLocation(locations) && this.clipboard.length === 1 && this.clipboard[0].type === 'folder'
return this.$isThisRoute(this.$route, routes) && this.clipboard.length === 1 && this.clipboard[0].type === 'folder'
}
},
data() {
@@ -199,6 +199,9 @@
}
},
methods: {
goBack() {
if (this.canGoBack) this.$router.back()
},
showTeamFolderMenu() {
events.$emit('popover:open', 'team-folder')
},
@@ -208,64 +211,10 @@
showSortingMenu() {
events.$emit('popover:open', 'desktop-sorting')
},
dissolveTeamFolder() {
events.$emit('confirm:open', {
title: this.$t('Are you sure you want to dissolve this team?'),
message: this.$t('All team members will lose access to your files and existing folder will be moved into your "Files" section.'),
action: {
id: 'token.id',
operation: 'dissolve-team-folder'
}
})
},
goBack() {
let previousFolder = last(this.browseHistory)
if (!previousFolder) return
if (previousFolder.location === 'trash-root') {
this.$store.dispatch('getTrash')
} else if (previousFolder.location === 'shared') {
this.$store.dispatch('getShared')
} else {
if (this.$isThisLocation('public')) {
this.$store.dispatch('browseShared', [
{folder: previousFolder, back: true, init: false}
])
} else {
this.$store.dispatch('getFolder', [
{folder: previousFolder, back: true, init: false}
])
}
}
},
folderActions() {
// todo: add current folder
events.$emit('folder:actions', this.currentFolder)
},
deleteItem() {
if (this.clipboard.length > 0)
this.$store.dispatch('deleteItem')
},
createFolder() {
this.$store.dispatch('createFolder', {name: this.$t('popup_create_folder.folder_default_name')})
events.$emit('popover:close', 'desktop-create')
},
moveItem() {
if (this.clipboard.length > 0)
events.$emit('popup:open', {name: 'move', item: this.clipboard})
},
shareItem() {
let event = this.clipboard[0].shared
? 'share-edit'
: 'share-create'
events.$emit('popup:open', {
name: event,
item: this.clipboard[0]
})
}
},
}
</script>

View File

@@ -28,6 +28,17 @@ const itemHelpers = {
})
}
Vue.prototype.$dissolveTeamFolder = function () {
events.$emit('confirm:open', {
title: this.$t('Are you sure you want to dissolve this team?'),
message: this.$t('All team members will lose access to your files and existing folder will be moved into your "Files" section.'),
action: {
id: 'token.id',
operation: 'dissolve-team-folder'
}
})
},
Vue.prototype.$createTeamFolder = function (entry) {
events.$emit('popup:open', {name: 'create-team-folder'})
}

View File

@@ -720,6 +720,8 @@ const router = new Router({
router.beforeEach((to, from, next) => {
store.commit('SET_PREVIOUS_LOCATION', from.name)
if (to.matched.some(record => record.meta.requiresAuth)) {
// this route requires auth, check if logged in
// if not, redirect to login page.

View File

@@ -6,10 +6,10 @@ import i18n from '/resources/js/i18n/index'
const defaultState = {
currentFolder: undefined,
fastPreview: undefined,
navigation: undefined,
isLoading: true,
browseHistory: [],
fastPreview: undefined,
clipboard: [],
entries: [],
}
@@ -180,11 +180,11 @@ const mutations = {
}
const getters = {
fastPreview: state => state.fastPreview,
clipboard: state => state.clipboard,
currentFolder: state => state.currentFolder,
browseHistory: state => state.browseHistory,
fastPreview: state => state.fastPreview,
navigation: state => state.navigation,
clipboard: state => state.clipboard,
isLoading: state => state.isLoading,
entries: state => state.entries,
}

View File

@@ -46,7 +46,7 @@
<!--Locations-->
<ContentGroup :title="$t('Collaboration')" slug="collaboration" :can-collapse="true">
<div class="menu-list-wrapper vertical">
<router-link class="menu-list-item link">
<!-- <router-link class="menu-list-item link">
<div class="icon text-theme">
<users-icon size="17" />
</div>
@@ -61,7 +61,7 @@
<div class="label text-theme">
{{ $t('Shared with Me') }}
</div>
</router-link>
</router-link>-->
</div>
</ContentGroup>