diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 183759b5..acb8ff7a 100644 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -200,5 +200,22 @@ "/js/main.de28ca938da3825e62b3.hot-update.js": "/js/main.de28ca938da3825e62b3.hot-update.js", "/js/main.be91e0ed3d68ecb1af06.hot-update.js": "/js/main.be91e0ed3d68ecb1af06.hot-update.js", "/chunks/settings.91678a5fa053e1ee00a7.hot-update.js": "/chunks/settings.91678a5fa053e1ee00a7.hot-update.js", - "/js/main.000dc4eab65b819bb1e4.hot-update.js": "/js/main.000dc4eab65b819bb1e4.hot-update.js" + "/js/main.000dc4eab65b819bb1e4.hot-update.js": "/js/main.000dc4eab65b819bb1e4.hot-update.js", + "/js/main.116ea0e969f28f2e3317.hot-update.js": "/js/main.116ea0e969f28f2e3317.hot-update.js", + "/js/main.d5f72367ca387e8f88cb.hot-update.js": "/js/main.d5f72367ca387e8f88cb.hot-update.js", + "/js/main.e139d856a64d830e75f9.hot-update.js": "/js/main.e139d856a64d830e75f9.hot-update.js", + "/js/main.0b0a92c85a5ddddcdd92.hot-update.js": "/js/main.0b0a92c85a5ddddcdd92.hot-update.js", + "/js/main.2f9d8dd0af03586e9684.hot-update.js": "/js/main.2f9d8dd0af03586e9684.hot-update.js", + "/js/main.99e190ade21b090439a6.hot-update.js": "/js/main.99e190ade21b090439a6.hot-update.js", + "/js/main.ea2d431b51a8f35de10e.hot-update.js": "/js/main.ea2d431b51a8f35de10e.hot-update.js", + "/js/main.07af7a330df3dde83ee0.hot-update.js": "/js/main.07af7a330df3dde83ee0.hot-update.js", + "/js/main.f7c4174463f274fa781c.hot-update.js": "/js/main.f7c4174463f274fa781c.hot-update.js", + "/js/main.52062fffd84321cad2d6.hot-update.js": "/js/main.52062fffd84321cad2d6.hot-update.js", + "/js/main.90534c5ed92728291a82.hot-update.js": "/js/main.90534c5ed92728291a82.hot-update.js", + "/js/main.48702d509d5cf27a0fb6.hot-update.js": "/js/main.48702d509d5cf27a0fb6.hot-update.js", + "/js/main.6546f4fadc91e708018c.hot-update.js": "/js/main.6546f4fadc91e708018c.hot-update.js", + "/js/main.fcf019dfae2cac8e0432.hot-update.js": "/js/main.fcf019dfae2cac8e0432.hot-update.js", + "/js/main.b99796b9cd80dfca9231.hot-update.js": "/js/main.b99796b9cd80dfca9231.hot-update.js", + "/js/main.ff162a01c1b21836ee9f.hot-update.js": "/js/main.ff162a01c1b21836ee9f.hot-update.js", + "/js/main.7a46e4ea987d72347892.hot-update.js": "/js/main.7a46e4ea987d72347892.hot-update.js" } diff --git a/resources/js/helpers/AlertHelpers.js b/resources/js/helpers/AlertHelpers.js new file mode 100644 index 00000000..c4826dd6 --- /dev/null +++ b/resources/js/helpers/AlertHelpers.js @@ -0,0 +1,37 @@ +import {events} from "../bus"; +import i18n from "../i18n"; + +const AlertHelpers = { + install(Vue) { + + Vue.prototype.$temporarilyDisabledUpload = function () { + events.$emit('alert:open', { + title: i18n.t('Upload is temporarily disabled'), + message: i18n.t('Please review your billing settings.') + }) + } + + Vue.prototype.$temporarilyDisabledFolderCreate = function () { + events.$emit('alert:open', { + title: i18n.t('Folder creation is temporarily disabled'), + message: i18n.t('Please review your billing settings.') + }) + } + + Vue.prototype.$temporarilyDisabledDownload = function () { + events.$emit('alert:open', { + title: i18n.t('File download is temporarily disabled'), + message: i18n.t('Please review your billing settings.') + }) + } + + Vue.prototype.$isSomethingWrong = function () { + events.$emit('alert:open', { + title: i18n.t('popup_error.title'), + message: i18n.t('popup_error.message') + }) + } + } +} + +export default AlertHelpers \ No newline at end of file diff --git a/resources/js/helpers/functionHelpers.js b/resources/js/helpers/functionHelpers.js index cdfb1747..9ab55f80 100644 --- a/resources/js/helpers/functionHelpers.js +++ b/resources/js/helpers/functionHelpers.js @@ -149,6 +149,12 @@ const FunctionHelpers = { } Vue.prototype.$uploadFiles = async function (files) { + // Show alert message when upload is disabled + if (! store.getters.user.data.meta.restrictions.canUpload) { + Vue.prototype.$temporarilyDisabledUpload() + + return + } if (files.length === 0) return @@ -171,6 +177,12 @@ const FunctionHelpers = { } Vue.prototype.$uploadDraggedFiles = async function (event, parent_id) { + // Show alert message when upload is disabled + if (! store.getters.user.data.meta.restrictions.canUpload) { + Vue.prototype.$temporarilyDisabledUpload() + + return + } // Prevent submit empty files if (event.dataTransfer.items.length === 0) return @@ -258,6 +270,13 @@ const FunctionHelpers = { } Vue.prototype.$downloadFile = function (url, filename) { + // Show alert message when download is disabled + if (! store.getters.user.data.meta.restrictions.canDownload) { + Vue.prototype.$temporarilyDisabledDownload() + + return + } + var anchor = document.createElement('a') anchor.href = url @@ -416,13 +435,6 @@ const FunctionHelpers = { } } - Vue.prototype.$isSomethingWrong = function () { - events.$emit('alert:open', { - title: i18n.t('popup_error.title'), - message: i18n.t('popup_error.message') - }) - } - Vue.prototype.$checkFileMimetype = function (files) { let validated = true let mimetypesBlacklist = store.getters.config.mimetypesBlacklist diff --git a/resources/js/helpers/itemHelpers.js b/resources/js/helpers/itemHelpers.js index eef0e6a4..7db13852 100644 --- a/resources/js/helpers/itemHelpers.js +++ b/resources/js/helpers/itemHelpers.js @@ -24,12 +24,26 @@ const itemHelpers = { } Vue.prototype.$createFolder = function () { + // Show alert message when create folder is disabled + if (! store.getters.user.data.meta.restrictions.canCreateFolder) { + Vue.prototype.$temporarilyDisabledFolderCreate() + + return + } + store.dispatch('createFolder', { name: i18n.t('popup_create_folder.folder_default_name') }) } Vue.prototype.$downloadSelection = function (item) { + // Show alert message when download is disabled + if (! store.getters.user.data.meta.restrictions.canDownload) { + Vue.prototype.$temporarilyDisabledDownload() + + return + } + let clipboard = store.getters.clipboard if (clipboard.length > 1 || (clipboard.length === 1 && clipboard[0].data.type === 'folder')) @@ -62,6 +76,13 @@ const itemHelpers = { }, Vue.prototype.$createTeamFolder = function () { + // Show alert message when create folder is disabled + if (! store.getters.user.data.meta.restrictions.canCreateTeamFolder) { + Vue.prototype.$temporarilyDisabledFolderCreate() + + return + } + events.$emit('popup:open', {name: 'create-team-folder'}) } diff --git a/resources/js/main.js b/resources/js/main.js index 8720b1c4..ab0e359a 100644 --- a/resources/js/main.js +++ b/resources/js/main.js @@ -10,12 +10,14 @@ import {events} from "./bus"; import SubscriptionHelpers from "./helpers/SubscriptionHelpers"; import ValidatorHelpers from "./helpers/ValidatorHelpers"; import functionHelpers from "./helpers/functionHelpers"; +import AlertHelpers from "./helpers/AlertHelpers"; import itemHelpers from "./helpers/itemHelpers" Vue.use(VueRouter); Vue.use(SubscriptionHelpers); Vue.use(ValidatorHelpers); Vue.use(functionHelpers); +Vue.use(AlertHelpers); Vue.use(itemHelpers); Vue.config.productionTip = false; diff --git a/src/App/Restrictions/Engines/DefaultRestrictionsEngine.php b/src/App/Restrictions/Engines/DefaultRestrictionsEngine.php index 3cad7935..63e218b1 100644 --- a/src/App/Restrictions/Engines/DefaultRestrictionsEngine.php +++ b/src/App/Restrictions/Engines/DefaultRestrictionsEngine.php @@ -39,7 +39,7 @@ class DefaultRestrictionsEngine implements RestrictionsEngine return true; } - public function canInviteTeamMembers(User $user, array $newInvites): bool + public function canInviteTeamMembers(User $user, array $newInvites = []): bool { return resolve(CheckMaxTeamMembersLimitAction::class)($user, $newInvites); } diff --git a/src/App/Restrictions/Engines/FixedBillingRestrictionsEngine.php b/src/App/Restrictions/Engines/FixedBillingRestrictionsEngine.php index b255ec98..cf8a70e7 100644 --- a/src/App/Restrictions/Engines/FixedBillingRestrictionsEngine.php +++ b/src/App/Restrictions/Engines/FixedBillingRestrictionsEngine.php @@ -34,7 +34,7 @@ class FixedBillingRestrictionsEngine implements RestrictionsEngine return true; } - public function canInviteTeamMembers(User $user, array $newInvites): bool + public function canInviteTeamMembers(User $user, array $newInvites = []): bool { return resolve(CheckMaxTeamMembersLimitAction::class)($user, $newInvites); } diff --git a/src/App/Restrictions/Engines/MeteredBillingRestrictionsEngine.php b/src/App/Restrictions/Engines/MeteredBillingRestrictionsEngine.php index 4bea5eef..548ead7e 100644 --- a/src/App/Restrictions/Engines/MeteredBillingRestrictionsEngine.php +++ b/src/App/Restrictions/Engines/MeteredBillingRestrictionsEngine.php @@ -30,7 +30,7 @@ class MeteredBillingRestrictionsEngine implements RestrictionsEngine return ! ($user->failedPayments()->count() >= 3); } - public function canInviteTeamMembers(User $user, array $newInvites): bool + public function canInviteTeamMembers(User $user, array $newInvites = []): bool { return true; } diff --git a/src/App/Restrictions/RestrictionsEngine.php b/src/App/Restrictions/RestrictionsEngine.php index d91e5876..1d91280e 100644 --- a/src/App/Restrictions/RestrictionsEngine.php +++ b/src/App/Restrictions/RestrictionsEngine.php @@ -13,5 +13,5 @@ interface RestrictionsEngine public function canCreateTeamFolder(User $user): bool; - public function canInviteTeamMembers(User $user, array $newInvites): bool; + public function canInviteTeamMembers(User $user, array $newInvites = []): bool; } diff --git a/src/App/Users/Resources/UserResource.php b/src/App/Users/Resources/UserResource.php index 1e3c94f6..2862537a 100644 --- a/src/App/Users/Resources/UserResource.php +++ b/src/App/Users/Resources/UserResource.php @@ -58,6 +58,13 @@ class UserResource extends JsonResource ]), ], 'meta' => [ + 'restrictions' => [ + 'canUpload' => $this->canUpload(), + 'canDownload' => $this->canDownload(), + 'canCreateFolder' => $this->canCreateFolder(), + 'canCreateTeamFolder' => $this->canCreateTeamFolder(), + 'canInviteTeamMembers' => $this->canInviteTeamMembers(), + ], $this->mergeWhen($isFixedSubscription, fn () => [ 'limitations' => $this->limitations->summary(), ]),