From ae6b443d7234032779881ad284fda5a3b51eee28 Mon Sep 17 00:00:00 2001 From: Benedikt Kulmann Date: Fri, 24 Mar 2023 11:54:22 +0100 Subject: [PATCH] fix: appProviders capability check --- changelog/unreleased/bugfix-open-external-apps | 6 ++++++ .../composables/actions/files/useFileActions.ts | 13 ++++++------- packages/web-client/src/ocs/capabilities.ts | 15 ++++++++------- .../src/composables/capability/useCapability.ts | 5 +++++ 4 files changed, 25 insertions(+), 14 deletions(-) create mode 100644 changelog/unreleased/bugfix-open-external-apps diff --git a/changelog/unreleased/bugfix-open-external-apps b/changelog/unreleased/bugfix-open-external-apps new file mode 100644 index 00000000000..cdbaca44628 --- /dev/null +++ b/changelog/unreleased/bugfix-open-external-apps @@ -0,0 +1,6 @@ +Bugfix: Open files in external app + +We've fixed a bug that caused office documents not to be opened in app provider editors anymore. + +https://github.com/owncloud/web/pull/8705 +https://github.com/owncloud/web/issues/8695 diff --git a/packages/web-app-files/src/composables/actions/files/useFileActions.ts b/packages/web-app-files/src/composables/actions/files/useFileActions.ts index 009fb2f3f6d..5ad534d7dde 100644 --- a/packages/web-app-files/src/composables/actions/files/useFileActions.ts +++ b/packages/web-app-files/src/composables/actions/files/useFileActions.ts @@ -1,4 +1,3 @@ -import get from 'lodash-es/get' import kebabCase from 'lodash-es/kebabCase' import { Store } from 'vuex' import { ShareStatus } from 'web-client/src/helpers/share' @@ -7,7 +6,7 @@ import { configurationManager } from 'web-pkg/src/configuration' import { isLocationSharesActive, isLocationTrashActive } from '../../../router' import { computed, unref } from 'vue' -import { useRouter, useStore } from 'web-pkg/src/composables' +import { useCapabilityFilesAppProviders, useRouter, useStore } from 'web-pkg/src/composables' import { useGettext } from 'vue3-gettext' import { Action, @@ -39,6 +38,10 @@ export const useFileActions = ({ store }: { store?: Store } = {}) => { const router = useRouter() const { $gettext, interpolate: $gettextInterpolate } = useGettext() const isSearchActive = useIsSearchActive() + const appProviders = useCapabilityFilesAppProviders() + const appProvidersEnabled = computed(() => { + return !!unref(appProviders).find((appProvider) => appProvider.enabled) + }) const { actions: acceptShareActions } = useFileActionsAcceptShare({ store }) const { actions: copyActions } = useFileActionsCopy({ store }) @@ -257,11 +260,7 @@ export const useFileActions = ({ store }: { store?: Store } = {}) => { } const mimeTypes = store.getters['External/mimeTypes'] || [] - if ( - mimeType === undefined || - !get(this, 'capabilities.files.app_providers') || - !mimeTypes.length - ) { + if (mimeType === undefined || !unref(appProvidersEnabled) || !mimeTypes.length) { return [] } diff --git a/packages/web-client/src/ocs/capabilities.ts b/packages/web-client/src/ocs/capabilities.ts index 88257615a45..b5ccaad69f5 100644 --- a/packages/web-client/src/ocs/capabilities.ts +++ b/packages/web-client/src/ocs/capabilities.ts @@ -2,6 +2,13 @@ import { AxiosInstance } from 'axios' import get from 'lodash-es/get' /* eslint-disable camelcase */ +export interface AppProviderCapability { + apps_url: string + enabled: boolean + new_url: string + open_url: string + version: string +} export interface Capabilities { capabilities: { notifications: { @@ -27,13 +34,7 @@ export interface Capabilities { reports: string[] } files: { - app_providers?: { - apps_url: string - enabled: boolean - new_url: string - open_url: string - version: string - }[] + app_providers?: AppProviderCapability[] archivers?: { archiver_url: string enabled: boolean diff --git a/packages/web-pkg/src/composables/capability/useCapability.ts b/packages/web-pkg/src/composables/capability/useCapability.ts index 36c7dd26af9..70318a6627b 100644 --- a/packages/web-pkg/src/composables/capability/useCapability.ts +++ b/packages/web-pkg/src/composables/capability/useCapability.ts @@ -2,6 +2,7 @@ import { Store } from 'vuex' import get from 'lodash-es/get' import { computed, ComputedRef } from 'vue' import { useStore } from '../store' +import { AppProviderCapability } from 'web-client/src/ocs/capabilities' export const useCapability = ( store: Store, @@ -73,6 +74,10 @@ export const useCapabilityPrivateLinks = createCapabilityComposable( 'files.privateLinks', false ) +export const useCapabilityFilesAppProviders = createCapabilityComposable( + 'files.app_providers', + [] +) export const useCapabilityFilesSharingCanDenyAccess = createCapabilityComposable( 'files_sharing.deny_access', false