Skip to content

Commit

Permalink
fix: appProviders capability check
Browse files Browse the repository at this point in the history
  • Loading branch information
kulmann committed Mar 24, 2023
1 parent 504e1fe commit ae6b443
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/bugfix-open-external-apps
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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,
Expand Down Expand Up @@ -39,6 +38,10 @@ export const useFileActions = ({ store }: { store?: Store<any> } = {}) => {
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 })
Expand Down Expand Up @@ -257,11 +260,7 @@ export const useFileActions = ({ store }: { store?: Store<any> } = {}) => {
}

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 []
}

Expand Down
15 changes: 8 additions & 7 deletions packages/web-client/src/ocs/capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions packages/web-pkg/src/composables/capability/useCapability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <T>(
store: Store<any>,
Expand Down Expand Up @@ -73,6 +74,10 @@ export const useCapabilityPrivateLinks = createCapabilityComposable<boolean>(
'files.privateLinks',
false
)
export const useCapabilityFilesAppProviders = createCapabilityComposable<AppProviderCapability[]>(
'files.app_providers',
[]
)
export const useCapabilityFilesSharingCanDenyAccess = createCapabilityComposable(
'files_sharing.deny_access',
false
Expand Down

0 comments on commit ae6b443

Please sign in to comment.