- Frontend restriction alerts

This commit is contained in:
Čarodej
2022-01-05 18:57:02 +01:00
parent 29a954e21b
commit 05f6023053
10 changed files with 108 additions and 12 deletions
+37
View File
@@ -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
+19 -7
View File
@@ -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
+21
View File
@@ -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'})
}