Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[full-ci] fix: appProviders capability check #8705

Merged
merged 1 commit into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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