From c8b35fa22f076a8d961c1296f44d83321040ab3f Mon Sep 17 00:00:00 2001 From: Andrey Borysenko Date: Mon, 21 Oct 2024 15:39:49 +0300 Subject: WIP: migrate to Pinia, minor fixes Signed-off-by: Andrey Borysenko --- apps/settings/src/components/AppList.vue | 12 +- apps/settings/src/components/AppList/AppItem.vue | 6 +- .../AppStoreSidebar/AppDeployDaemonTab.vue | 8 +- .../components/AppStoreSidebar/AppDetailsTab.vue | 14 +- apps/settings/src/composables/useAppIcon.ts | 6 +- apps/settings/src/mixins/AppManagement.js | 104 +++++--- apps/settings/src/store/app-api-store.ts | 295 +++++++++++++++++++++ apps/settings/src/store/index.js | 2 - apps/settings/src/views/AppStore.vue | 11 +- apps/settings/src/views/AppStoreSidebar.vue | 4 +- 10 files changed, 396 insertions(+), 66 deletions(-) create mode 100644 apps/settings/src/store/app-api-store.ts diff --git a/apps/settings/src/components/AppList.vue b/apps/settings/src/components/AppList.vue index 6062e61d906..231543fe1cd 100644 --- a/apps/settings/src/components/AppList.vue +++ b/apps/settings/src/components/AppList.vue @@ -143,6 +143,7 @@ import { subscribe, unsubscribe } from '@nextcloud/event-bus' import AppItem from './AppList/AppItem.vue' import pLimit from 'p-limit' import NcButton from '@nextcloud/vue/dist/Components/NcButton.js' +import { useAppApiStore } from '../store/app-api-store' export default { name: 'AppList', @@ -158,6 +159,13 @@ export default { }, }, + setup() { + const appApiStore = useAppApiStore() + return { + appApiStore, + } + }, + data() { return { search: '', @@ -171,7 +179,7 @@ export default { if (!this.$store.getters['appApiApps/isAppApiEnabled']) { return this.$store.getters.loading('list') } - return this.$store.getters.loading('list') || this.$store.getters['appApiApps/loading']('list') + return this.$store.getters.loading('list') || this.appApiStore.getLoading('list') }, hasPendingUpdate() { return this.apps.filter(app => app.update).length > 0 @@ -181,7 +189,7 @@ export default { }, apps() { // Exclude ExApps from the list if AppAPI is disabled - const exApps = this.$store.getters.isAppApiEnabled ? this.$store.getters['appApiApps/getAllApps'] : [] + const exApps = this.$store.getters.isAppApiEnabled ? this.appApiStore.getAllApps : [] const apps = [...this.$store.getters.getAllApps, ...exApps] .filter(app => app.name.toLowerCase().search(this.search.toLowerCase()) !== -1) .sort(function(a, b) { diff --git a/apps/settings/src/components/AppList/AppItem.vue b/apps/settings/src/components/AppList/AppItem.vue index ffb17dc958f..31a57ea5c73 100644 --- a/apps/settings/src/components/AppList/AppItem.vue +++ b/apps/settings/src/components/AppList/AppItem.vue @@ -83,7 +83,7 @@ @click.stop="update(app.id)"> {{ t('settings', 'Update to {update}', {update:app.update}) }} - {{ disableButtonText }} @@ -184,7 +184,7 @@ export default { return !!this.$route.params.id }, shouldDisplayDefaultIcon() { - return this.listView && !this.app.preview || !this.listView && !this.screenshotLoaded + return (this.listView && !this.app.preview) || (!this.listView && !this.screenshotLoaded) }, }, watch: { diff --git a/apps/settings/src/components/AppStoreSidebar/AppDeployDaemonTab.vue b/apps/settings/src/components/AppStoreSidebar/AppDeployDaemonTab.vue index 36087cdd617..a082ab326cc 100644 --- a/apps/settings/src/components/AppStoreSidebar/AppDeployDaemonTab.vue +++ b/apps/settings/src/components/AppStoreSidebar/AppDeployDaemonTab.vue @@ -16,7 +16,8 @@

{{ t('settings', 'Type') }}: {{ app?.daemon.accepts_deploy_id }}

{{ t('settings', 'Name') }}: {{ app?.daemon.name }}

{{ t('settings', 'Display Name') }}: {{ app?.daemon.display_name }}

-

{{ t('settings', 'GPUs support') }}: {{ app?.daemon.deploy_config?.computeDevice?.id !== 'cpu' || 'false' }}

+

{{ t('settings', 'GPUs support') }}: {{ gpuSupport }}

+

{{ t('settings', 'Compute device') }}: {{ app?.daemon?.deploy_config?.computeDevice?.label }}

@@ -28,10 +29,13 @@ import NcAppSidebarTab from '@nextcloud/vue/dist/Components/NcAppSidebarTab.js' import NcIconSvgWrapper from '@nextcloud/vue/dist/Components/NcIconSvgWrapper.js' import { mdiFileChart } from '@mdi/js' +import { ref } from 'vue' -defineProps<{ +const props = defineProps<{ app: IAppstoreExApp, }>() + +const gpuSupport = ref(props.app?.daemon?.deploy_config?.computeDevice?.id !== 'cpu' || false)