From 7c4df8d81cf6aaafe6cfb250c14ea33812c5e390 Mon Sep 17 00:00:00 2001 From: Andrey Borysenko Date: Wed, 20 Dec 2023 22:30:03 +0200 Subject: [PATCH 1/4] ui fixes Signed-off-by: Andrey Borysenko --- lib/Controller/ExAppsPageController.php | 17 ++++-- src/components/Apps/AppDetails.vue | 2 +- src/components/Apps/AppItem.vue | 2 +- src/components/DaemonConfig/DaemonConfig.vue | 59 +++++++++++++++---- .../RegisterDaemonConfigModal.vue | 31 +++++++--- src/constants/AppsConstants.js | 10 ++-- src/mixins/AppManagement.js | 14 ++++- src/store/apps.js | 17 +++++- 8 files changed, 117 insertions(+), 35 deletions(-) diff --git a/lib/Controller/ExAppsPageController.php b/lib/Controller/ExAppsPageController.php index 80ee8fe7..8c42eaf9 100644 --- a/lib/Controller/ExAppsPageController.php +++ b/lib/Controller/ExAppsPageController.php @@ -380,14 +380,14 @@ private function buildLocalAppsList(array $apps, array $exApps): array { 'level' => 100, 'missingMaxOwnCloudVersion' => false, 'missingMinOwnCloudVersion' => false, - 'canInstall' => true, - 'canUnInstall' => false, + 'canInstall' => true, // to allow "remove" command for manual-install + 'canUnInstall' => !($exApp->getEnabled() === 1), 'isCompatible' => true, 'screenshot' => '', 'score' => 0, 'ratingNumOverall' => 0, 'ratingNumThresholdReached' => false, - 'removable' => false, + 'removable' => true, // to allow "remove" command for manual-install 'active' => $exApp->getEnabled() === 1, 'needsDownload' => false, 'groups' => [], @@ -468,15 +468,16 @@ public function enableApps(array $appIds, array $groups = []): JSONResponse { ], Http::STATUS_INTERNAL_SERVER_ERROR); } - //if (!$this->service->enableExApp($exApp)) { - // return new JSONResponse(['data' => ['message' => $this->l10n->t('Failed to enable ExApp')]], Http::STATUS_INTERNAL_SERVER_ERROR); - //} + $scopes = $this->exAppApiScopeService->mapScopeGroupsToNames(array_map(function (ExAppScope $exAppScope) { + return $exAppScope->getScopeGroup(); + }, $this->exAppScopeService->getExAppScopes($exApp))); return new JSONResponse([ 'data' => [ 'daemon_config' => $daemonConfig, 'systemApp' => $this->exAppUsersService->exAppUserExists($exApp->getAppid(), ''), 'exAppUrl' => AppAPIService::getExAppUrl($exApp->getProtocol(), $exApp->getHost(), $exApp->getPort()), 'status' => json_decode($exApp->getStatus(), true), + 'scopes' => $scopes, ] ]); } @@ -662,12 +663,16 @@ public function updateApp(string $appId): JSONResponse { } } + $scopes = $this->exAppApiScopeService->mapScopeGroupsToNames(array_map(function (ExAppScope $exAppScope) { + return $exAppScope->getScopeGroup(); + }, $this->exAppScopeService->getExAppScopes($exApp))); return new JSONResponse([ 'data' => [ 'appid' => $appId, 'status' => ['progress' => 0], 'systemApp' => filter_var($exAppInfo['system_app'], FILTER_VALIDATE_BOOLEAN), 'exAppUrl' => AppAPIService::getExAppUrl($exAppInfo['protocol'], $exAppInfo['host'], (int) $exAppInfo['port']), + 'scopes' => $scopes, ] ]); } diff --git a/src/components/Apps/AppDetails.vue b/src/components/Apps/AppDetails.vue index 11449331..99264a22 100644 --- a/src/components/Apps/AppDetails.vue +++ b/src/components/Apps/AppDetails.vue @@ -17,7 +17,7 @@ - {{ t('settings','Disable') }} + {{ disableButtonText }} {{ !isDefault ? t('app_api', 'Set as default') : t('app_api', 'Default') }} - + {{ t('app_api', 'Delete') }} @@ -39,6 +68,11 @@ import axios from '@nextcloud/axios' import { generateUrl } from '@nextcloud/router' import { showError } from '@nextcloud/dialogs' import NcListItem from '@nextcloud/vue/dist/Components/NcListItem.js' +import NcDialog from '@nextcloud/vue/dist/Components/NcDialog.js' +import NcDialogButton from '@nextcloud/vue/dist/Components/NcDialogButton.js' +import Cancel from 'vue-material-design-icons/Cancel.vue' +import Check from 'vue-material-design-icons/Check.vue' +import NcNoteCard from '@nextcloud/vue/dist/Components/NcNoteCard.js' import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js' import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js' @@ -53,6 +87,11 @@ export default { NcActionButton, NcLoadingIcon, CheckBold, + NcDialog, + NcDialogButton, + Cancel, + Check, + NcNoteCard, DaemonConfigDetailsModal, }, props: { @@ -80,6 +119,7 @@ export default { showDetailsModal: false, settingDefault: false, deleting: false, + showDeleteDialog: false, } }, computed: { @@ -109,16 +149,7 @@ export default { }) }, deleteDaemonConfig(daemon) { - const self = this - OC.dialogs.confirm( - t('app_api', 'Are you sure you want delete Deploy Daemon?'), - t('app_api', 'Confirm Deploy daemon deletion'), - function(success) { - if (success) { - self._deleteDaemonConfig(daemon) - } - }, - ) + this.showDeleteDialog = true }, _deleteDaemonConfig(daemon) { this.deleting = true @@ -128,10 +159,12 @@ export default { this.getAllDaemons() } this.deleting = false + this.showDetailsModal = false }) .catch(err => { console.debug(err) this.deleting = false + this.showDetailsModal = false }) }, }, @@ -143,4 +176,8 @@ export default { background-color: var(--color-background-dark); border-radius: var(--border-radius-pill); } + +.confirm-delete-dialog { + padding: 20px; +} diff --git a/src/components/DaemonConfig/RegisterDaemonConfigModal.vue b/src/components/DaemonConfig/RegisterDaemonConfigModal.vue index f11c77be..842290fa 100644 --- a/src/components/DaemonConfig/RegisterDaemonConfigModal.vue +++ b/src/components/DaemonConfig/RegisterDaemonConfigModal.vue @@ -71,7 +71,7 @@ :placeholder="t('app_api', 'Set daemon as default')" :aria-label="t('app_api', 'Set daemon as default')" style="margin-top: 1rem;"> - {{ t('app_api', 'Default daemon') }} + {{ t('app_api', 'Set as default daemon') }}