aboutsummaryrefslogtreecommitdiffstats
path: root/apps/settings/src/mixins
diff options
context:
space:
mode:
Diffstat (limited to 'apps/settings/src/mixins')
-rw-r--r--apps/settings/src/mixins/AppManagement.js209
-rw-r--r--apps/settings/src/mixins/UserRowMixin.js132
2 files changed, 203 insertions, 138 deletions
diff --git a/apps/settings/src/mixins/AppManagement.js b/apps/settings/src/mixins/AppManagement.js
index cf44a37a53f..3822658589d 100644
--- a/apps/settings/src/mixins/AppManagement.js
+++ b/apps/settings/src/mixins/AppManagement.js
@@ -1,23 +1,6 @@
/**
- * @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net>
- *
- * @author John Molakvoæ <skjnldsv@protonmail.com>
- *
- * @license AGPL-3.0-or-later
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { showError } from '@nextcloud/dialogs'
@@ -29,28 +12,88 @@ export default {
return this.app.groups.map(group => { return { id: group, name: group } })
},
installing() {
+ if (this.app?.app_api) {
+ return this.app && this?.appApiStore.getLoading('install') === true
+ }
return this.$store.getters.loading('install')
},
isLoading() {
+ if (this.app?.app_api) {
+ return this.app && this?.appApiStore.getLoading(this.app.id) === true
+ }
return this.app && this.$store.getters.loading(this.app.id)
},
+ isInitializing() {
+ if (this.app?.app_api) {
+ return this.app && (this.app?.status?.action === 'init' || this.app?.status?.action === 'healthcheck')
+ }
+ return false
+ },
+ isDeploying() {
+ if (this.app?.app_api) {
+ return this.app && this.app?.status?.action === 'deploy'
+ }
+ return false
+ },
+ isManualInstall() {
+ if (this.app?.app_api) {
+ return this.app?.daemon?.accepts_deploy_id === 'manual-install'
+ }
+ return false
+ },
+ updateButtonText() {
+ if (this.app?.app_api && this.app?.daemon?.accepts_deploy_id === 'manual-install') {
+ return t('settings', 'Manually installed apps cannot be updated')
+ }
+ return t('settings', 'Update to {version}', { version: this.app?.update })
+ },
enableButtonText() {
- if (this.app.needsDownload) {
- return t('settings', 'Download and enable')
+ if (this.app?.app_api) {
+ if (this.app && this.app?.status?.action && this.app?.status?.action === 'deploy') {
+ return t('settings', '{progress}% Deploying …', { progress: this.app?.status?.deploy ?? 0 })
+ }
+ if (this.app && this.app?.status?.action && this.app?.status?.action === 'init') {
+ return t('settings', '{progress}% Initializing …', { progress: this.app?.status?.init ?? 0 })
+ }
+ if (this.app && this.app?.status?.action && this.app?.status?.action === 'healthcheck') {
+ return t('settings', 'Health checking')
+ }
+ if (this.app.needsDownload) {
+ return t('settings', 'Deploy and Enable')
+ }
+ return t('settings', 'Enable')
+ } else {
+ if (this.app.needsDownload) {
+ return t('settings', 'Download and enable')
+ }
+ return t('settings', 'Enable')
+ }
+ },
+ disableButtonText() {
+ if (this.app?.app_api) {
+ if (this.app && this.app?.status?.action && this.app?.status?.action === 'deploy') {
+ return t('settings', '{progress}% Deploying …', { progress: this.app?.status?.deploy })
+ }
+ if (this.app && this.app?.status?.action && this.app?.status?.action === 'init') {
+ return t('settings', '{progress}% Initializing …', { progress: this.app?.status?.init })
+ }
+ if (this.app && this.app?.status?.action && this.app?.status?.action === 'healthcheck') {
+ return t('settings', 'Health checking')
+ }
}
- return t('settings', 'Enable')
+ return t('settings', 'Disable')
},
forceEnableButtonText() {
if (this.app.needsDownload) {
- return t('settings', 'Enable untested app')
+ return t('settings', 'Allow untested app')
}
- return t('settings', 'Enable untested app')
+ return t('settings', 'Allow untested app')
},
enableButtonTooltip() {
- if (this.app.needsDownload) {
+ if (!this.app?.app_api && this.app.needsDownload) {
return t('settings', 'The app will be downloaded from the App Store')
}
- return false
+ return null
},
forceEnableButtonTooltip() {
const base = t('settings', 'This app is not marked as compatible with your Nextcloud version. If you continue you will still be able to install the app. Note that the app might not work as expected.')
@@ -59,6 +102,19 @@ export default {
}
return base
},
+ defaultDeployDaemonAccessible() {
+ if (this.app?.app_api) {
+ if (this.app?.daemon && this.app?.daemon?.accepts_deploy_id === 'manual-install') {
+ return true
+ }
+ if (this.app?.daemon?.accepts_deploy_id === 'docker-install'
+ && this.appApiStore.getDefaultDaemon?.name === this.app?.daemon?.name) {
+ return this?.appApiStore.getDaemonAccessible === true
+ }
+ return this?.appApiStore.getDaemonAccessible
+ }
+ return true
+ },
},
data() {
@@ -78,12 +134,15 @@ export default {
return this.$store.dispatch('getGroups', { search: query, limit: 5, offset: 0 })
},
isLimitedToGroups(app) {
- if (this.app.groups.length || this.groupCheckedAppsData) {
- return true
+ if (this.app?.app_api) {
+ return false
}
- return false
+ return this.app.groups.length || this.groupCheckedAppsData
},
setGroupLimit() {
+ if (this.app?.app_api) {
+ return // not supported for app_api apps
+ }
if (!this.groupCheckedAppsData) {
this.$store.dispatch('enableApp', { appId: this.app.id, groups: [] })
}
@@ -93,16 +152,24 @@ export default {
|| app.types.includes('prelogin')
|| app.types.includes('authentication')
|| app.types.includes('logging')
- || app.types.includes('prevent_group_restriction')) {
+ || app.types.includes('prevent_group_restriction')
+ || app?.app_api) {
return false
}
return true
},
- addGroupLimitation(group) {
+ addGroupLimitation(groupArray) {
+ if (this.app?.app_api) {
+ return // not supported for app_api apps
+ }
+ const group = groupArray.pop()
const groups = this.app.groups.concat([]).concat([group.id])
this.$store.dispatch('enableApp', { appId: this.app.id, groups })
},
removeGroupLimitation(group) {
+ if (this.app?.app_api) {
+ return // not supported for app_api apps
+ }
const currentGroups = this.app.groups.concat([])
const index = currentGroups.indexOf(group.id)
if (index > -1) {
@@ -111,34 +178,74 @@ export default {
this.$store.dispatch('enableApp', { appId: this.app.id, groups: currentGroups })
},
forceEnable(appId) {
- this.$store.dispatch('forceEnableApp', { appId, groups: [] })
- .then((response) => { rebuildNavigation() })
- .catch((error) => { showError(error) })
+ if (this.app?.app_api) {
+ this.appApiStore.forceEnableApp(appId)
+ .then(() => { rebuildNavigation() })
+ .catch((error) => { showError(error) })
+ } else {
+ this.$store.dispatch('forceEnableApp', { appId, groups: [] })
+ .then((response) => { rebuildNavigation() })
+ .catch((error) => { showError(error) })
+ }
},
- enable(appId) {
- this.$store.dispatch('enableApp', { appId, groups: [] })
- .then((response) => { rebuildNavigation() })
- .catch((error) => { showError(error) })
+ enable(appId, daemon = null, deployOptions = {}) {
+ if (this.app?.app_api) {
+ this.appApiStore.enableApp(appId, daemon, deployOptions)
+ .then(() => { rebuildNavigation() })
+ .catch((error) => { showError(error) })
+ } else {
+ this.$store.dispatch('enableApp', { appId, groups: [] })
+ .then((response) => { rebuildNavigation() })
+ .catch((error) => { showError(error) })
+ }
},
disable(appId) {
- this.$store.dispatch('disableApp', { appId })
- .then((response) => { rebuildNavigation() })
- .catch((error) => { showError(error) })
+ if (this.app?.app_api) {
+ this.appApiStore.disableApp(appId)
+ .then(() => { rebuildNavigation() })
+ .catch((error) => { showError(error) })
+ } else {
+ this.$store.dispatch('disableApp', { appId })
+ .then((response) => { rebuildNavigation() })
+ .catch((error) => { showError(error) })
+ }
},
- remove(appId) {
- this.$store.dispatch('uninstallApp', { appId })
- .then((response) => { rebuildNavigation() })
- .catch((error) => { showError(error) })
+ async remove(appId, removeData = false) {
+ try {
+ if (this.app?.app_api) {
+ await this.appApiStore.uninstallApp(appId, removeData)
+ } else {
+ await this.$store.dispatch('uninstallApp', { appId, removeData })
+ }
+ await rebuildNavigation()
+ } catch (error) {
+ showError(error)
+ }
},
install(appId) {
- this.$store.dispatch('enableApp', { appId })
- .then((response) => { rebuildNavigation() })
- .catch((error) => { showError(error) })
+ if (this.app?.app_api) {
+ this.appApiStore.enableApp(appId)
+ .then(() => { rebuildNavigation() })
+ .catch((error) => { showError(error) })
+ } else {
+ this.$store.dispatch('enableApp', { appId })
+ .then((response) => { rebuildNavigation() })
+ .catch((error) => { showError(error) })
+ }
},
update(appId) {
- this.$store.dispatch('updateApp', { appId })
- .then((response) => { rebuildNavigation() })
- .catch((error) => { showError(error) })
+ if (this.app?.app_api) {
+ this.appApiStore.updateApp(appId)
+ .then(() => { rebuildNavigation() })
+ .catch((error) => { showError(error) })
+ } else {
+ this.$store.dispatch('updateApp', { appId })
+ .catch((error) => { showError(error) })
+ .then(() => {
+ rebuildNavigation()
+ this.store.updateCount = Math.max(this.store.updateCount - 1, 0)
+ })
+ }
},
},
}
diff --git a/apps/settings/src/mixins/UserRowMixin.js b/apps/settings/src/mixins/UserRowMixin.js
index 78214339be9..9e46d8e25d7 100644
--- a/apps/settings/src/mixins/UserRowMixin.js
+++ b/apps/settings/src/mixins/UserRowMixin.js
@@ -1,28 +1,10 @@
/**
- * @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com>
- *
- * @author Greta Doci <gretadoci@gmail.com>
- * @author John Molakvoæ <skjnldsv@protonmail.com>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license AGPL-3.0-or-later
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
-import { generateUrl } from '@nextcloud/router'
+import { formatFileSize } from '@nextcloud/files'
+import { useFormatDateTime } from '@nextcloud/vue'
export default {
props: {
@@ -34,22 +16,10 @@ export default {
type: Object,
default: () => ({}),
},
- groups: {
- type: Array,
- default: () => [],
- },
- subAdminsGroups: {
- type: Array,
- default: () => [],
- },
quotaOptions: {
type: Array,
default: () => [],
},
- showConfig: {
- type: Object,
- default: () => ({}),
- },
languages: {
type: Array,
required: true,
@@ -59,41 +29,37 @@ export default {
default: () => [],
},
},
+ setup(props) {
+ const { formattedFullTime } = useFormatDateTime(props.user.firstLoginTimestamp * 1000, {
+ relativeTime: false,
+ format: {
+ timeStyle: 'short',
+ dateStyle: 'short',
+ },
+ })
+ return {
+ formattedFullTime,
+ }
+ },
+ data() {
+ return {
+ selectedGroups: this.user.groups.map(id => ({ id, name: id })),
+ selectedSubAdminGroups: this.user.subadmin.map(id => ({ id, name: id })),
+ userGroups: this.user.groups.map(id => ({ id, name: id })),
+ userSubAdminGroups: this.user.subadmin.map(id => ({ id, name: id })),
+ }
+ },
computed: {
- /* GROUPS MANAGEMENT */
- userGroups() {
- const userGroups = this.groups.filter(group => this.user.groups.includes(group.id))
- return userGroups
- },
- userSubAdminsGroups() {
- const userSubAdminsGroups = this.subAdminsGroups.filter(group => this.user.subadmin.includes(group.id))
- return userSubAdminsGroups
- },
- availableGroups() {
- return this.groups.map((group) => {
- // clone object because we don't want
- // to edit the original groups
- const groupClone = Object.assign({}, group)
-
- // two settings here:
- // 1. user NOT in group but no permission to add
- // 2. user is in group but no permission to remove
- groupClone.$isDisabled
- = (group.canAdd === false
- && !this.user.groups.includes(group.id))
- || (group.canRemove === false
- && this.user.groups.includes(group.id))
- return groupClone
- })
+ showConfig() {
+ return this.$store.getters.getShowConfig
},
/* QUOTA MANAGEMENT */
usedSpace() {
- if (this.user.quota.used) {
- return t('settings', '{size} used', { size: OC.Util.humanFileSize(this.user.quota.used) })
- }
- return t('settings', '{size} used', { size: OC.Util.humanFileSize(0) })
+ const quotaUsed = this.user.quota.used > 0 ? this.user.quota.used : 0
+ return t('settings', '{size} used', { size: formatFileSize(quotaUsed, true) })
},
+
usedQuota() {
let quota = this.user.quota.quota
if (quota > 0) {
@@ -105,11 +71,12 @@ export default {
}
return isNaN(quota) ? 0 : quota
},
+
// Mapping saved values to objects
userQuota() {
if (this.user.quota.quota >= 0) {
// if value is valid, let's map the quotaOptions or return custom quota
- const humanQuota = OC.Util.humanFileSize(this.user.quota.quota)
+ const humanQuota = formatFileSize(this.user.quota.quota)
const userQuota = this.quotaOptions.find(quota => quota.id === humanQuota)
return userQuota || { id: humanQuota, label: humanQuota }
} else if (this.user.quota.quota === 'default') {
@@ -139,37 +106,28 @@ export default {
return userLang
},
+ userFirstLogin() {
+ if (this.user.firstLoginTimestamp > 0) {
+ return this.formattedFullTime
+ }
+ if (this.user.firstLoginTimestamp < 0) {
+ return t('settings', 'Unknown')
+ }
+ return t('settings', 'Never')
+ },
+
/* LAST LOGIN */
userLastLoginTooltip() {
- if (this.user.lastLogin > 0) {
- return OC.Util.formatDate(this.user.lastLogin)
+ if (this.user.lastLoginTimestamp > 0) {
+ return OC.Util.formatDate(this.user.lastLoginTimestamp * 1000)
}
return ''
},
userLastLogin() {
- if (this.user.lastLogin > 0) {
- return OC.Util.relativeModifiedDate(this.user.lastLogin)
+ if (this.user.lastLoginTimestamp > 0) {
+ return OC.Util.relativeModifiedDate(this.user.lastLoginTimestamp * 1000)
}
return t('settings', 'Never')
},
},
- methods: {
- /**
- * Generate avatar url
- *
- * @param {string} user The user name
- * @param {number} size Size integer, default 32
- * @return {string}
- */
- generateAvatar(user, size = 32) {
- return generateUrl(
- '/avatar/{user}/{size}?v={version}',
- {
- user,
- size,
- version: oc_userconfig.avatar.version,
- }
- )
- },
- },
}