diff options
Diffstat (limited to 'apps/settings/src/mixins/AppManagement.js')
-rw-r--r-- | apps/settings/src/mixins/AppManagement.js | 179 |
1 files changed, 151 insertions, 28 deletions
diff --git a/apps/settings/src/mixins/AppManagement.js b/apps/settings/src/mixins/AppManagement.js index c63041f45c9..3822658589d 100644 --- a/apps/settings/src/mixins/AppManagement.js +++ b/apps/settings/src/mixins/AppManagement.js @@ -12,16 +12,76 @@ 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) { @@ -30,7 +90,7 @@ export default { 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 null @@ -42,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() { @@ -61,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: [] }) } @@ -76,17 +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(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) { @@ -95,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) + }) + } }, }, } |