From 4a51f89a19b9f2ad73aa0d77b28e9de36433bf3b Mon Sep 17 00:00:00 2001 From: Diogo Castro Date: Wed, 22 Jun 2022 16:56:26 +0200 Subject: [PATCH 1/5] External app name in the title --- packages/web-app-external/src/App.vue | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/web-app-external/src/App.vue b/packages/web-app-external/src/App.vue index f58b64e56f9..2420da36615 100644 --- a/packages/web-app-external/src/App.vue +++ b/packages/web-app-external/src/App.vue @@ -103,6 +103,17 @@ export default { return this.$route.query.fileId } }, + mounted() { + if (this.appName) { + document.title = [ + this.currentFileContext.fileName, + this.appName, + this.configuration.currentTheme.general.name + ] + .filter(Boolean) + .join(' - ') + } + }, async created() { await unauthenticatedUserReady(this.$router, this.$store) From c4ddaf6076ab68bc90336a95a97b016a50700829 Mon Sep 17 00:00:00 2001 From: Diogo Castro Date: Wed, 22 Jun 2022 16:52:17 +0200 Subject: [PATCH 2/5] external apps fix: use the new make request method --- packages/web-app-external/src/App.vue | 10 ++++------ .../src/composables/appDefaults/useAppDefaults.ts | 5 +++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/web-app-external/src/App.vue b/packages/web-app-external/src/App.vue index 2420da36615..2b40a285eaa 100644 --- a/packages/web-app-external/src/App.vue +++ b/packages/web-app-external/src/App.vue @@ -141,9 +141,7 @@ export default { return } - const data = await response.json() - - if (!data.app_url || !data.method) { + if (!response.data.app_url || !response.data.method) { this.errorMessage = this.$gettext('Error in app server response') this.loading = false this.loadingError = true @@ -151,9 +149,9 @@ export default { return } - this.appUrl = data.app_url - this.method = data.method - if (data.form_parameters) this.formParameters = data.form_parameters + this.appUrl = response.data.app_url + this.method = response.data.method + if (response.data.form_parameters) this.formParameters = response.data.form_parameters if (this.method === 'POST' && this.formParameters) { this.$nextTick(() => this.$refs.subm.click()) diff --git a/packages/web-pkg/src/composables/appDefaults/useAppDefaults.ts b/packages/web-pkg/src/composables/appDefaults/useAppDefaults.ts index 6bda258deb4..fb39d45906c 100644 --- a/packages/web-pkg/src/composables/appDefaults/useAppDefaults.ts +++ b/packages/web-pkg/src/composables/appDefaults/useAppDefaults.ts @@ -15,7 +15,7 @@ import { useAppConfig, AppConfigResult } from './useAppConfig' import { useAppFileHandling, AppFileHandlingResult } from './useAppFileHandling' import { useAppFolderHandling, AppFolderHandlingResult } from './useAppFolderHandling' import { useAppDocumentTitle } from './useAppDocumentTitle' -import { usePublicLinkPassword, usePublicLinkContext } from '../authContext' +import { usePublicLinkPassword, usePublicLinkContext, useRequest } from '../authContext' import { useClientService } from '../clientService' // TODO: this file/folder contains file/folder loading logic extracted from preview and drawio extensions @@ -76,6 +76,7 @@ export function useAppDefaults(options: AppDefaultsOptions): AppDefaultsResult { isPublicLinkContext, publicLinkPassword }), - ...useAppFolderHandling({ clientService, store, isPublicLinkContext, publicLinkPassword }) + ...useAppFolderHandling({ clientService, store, isPublicLinkContext, publicLinkPassword }), + ...useRequest({ clientService, store, currentRoute: unref(currentRoute) }) } } From 68b2b492f27c7c4d022e55f7c804c64ffe1f8ecc Mon Sep 17 00:00:00 2001 From: Benedikt Kulmann Date: Thu, 23 Jun 2022 09:36:13 +0200 Subject: [PATCH 3/5] Override app name in document title composable --- packages/web-app-external/src/App.vue | 33 +++++++------------ .../composables/appDefaults/useAppDefaults.ts | 21 ++++++------ .../appDefaults/useAppDocumentTitle.ts | 9 ++++- .../appDefaults/useAppNavigation.ts | 2 +- 4 files changed, 32 insertions(+), 33 deletions(-) diff --git a/packages/web-app-external/src/App.vue b/packages/web-app-external/src/App.vue index 2b40a285eaa..9b95c59373a 100644 --- a/packages/web-app-external/src/App.vue +++ b/packages/web-app-external/src/App.vue @@ -37,8 +37,9 @@ import { mapGetters } from 'vuex' import ErrorScreen from './components/ErrorScreen.vue' import LoadingScreen from './components/LoadingScreen.vue' import { DavProperties } from 'web-pkg/src/constants' -import { buildResource } from '../../web-app-files/src/helpers/resources' -import { useAppDefaults } from 'web-pkg/src/composables' +import { buildResource } from 'files/src/helpers/resources' +import { computed, unref } from '@vue/composition-api' +import { queryItemAsString, useAppDefaults, useRouteQuery } from 'web-pkg/src/composables' // FIXME: hacky, get rid asap, just a workaround // same as packages/web-app-files/src/views/PublicFiles.vue @@ -66,10 +67,14 @@ export default { LoadingScreen }, setup() { + const appName = useRouteQuery('app') + const applicationName = computed(() => queryItemAsString(unref(appName))) return { ...useAppDefaults({ - applicationId: 'external' - }) + applicationId: 'external', + applicationName + }), + applicationName } }, @@ -87,33 +92,19 @@ export default { pageTitle() { const translated = this.$gettext('"%{appName}" app page') return this.$gettextInterpolate(translated, { - appName: this.appName + appName: this.applicationName }) }, iFrameTitle() { const translated = this.$gettext('"%{appName}" app content area') return this.$gettextInterpolate(translated, { - appName: this.appName + appName: this.applicationName }) }, - appName() { - return this.$route.query.app - }, fileId() { return this.$route.query.fileId } }, - mounted() { - if (this.appName) { - document.title = [ - this.currentFileContext.fileName, - this.appName, - this.configuration.currentTheme.general.name - ] - .filter(Boolean) - .join(' - ') - } - }, async created() { await unauthenticatedUserReady(this.$router, this.$store) @@ -129,7 +120,7 @@ export default { configUrl + appOpenUrl + `?file_id=${fileId}` + - (this.appName ? `&app_name=${this.appName}` : '') + (this.applicationName ? `&app_name=${this.applicationName}` : '') const response = await this.makeRequest('POST', url) diff --git a/packages/web-pkg/src/composables/appDefaults/useAppDefaults.ts b/packages/web-pkg/src/composables/appDefaults/useAppDefaults.ts index fb39d45906c..92dcdade0e4 100644 --- a/packages/web-pkg/src/composables/appDefaults/useAppDefaults.ts +++ b/packages/web-pkg/src/composables/appDefaults/useAppDefaults.ts @@ -9,7 +9,8 @@ import { useAppNavigation, AppNavigationResult, contextQueryToFileContextProps, - contextRouteNameKey + contextRouteNameKey, + queryItemAsString } from './useAppNavigation' import { useAppConfig, AppConfigResult } from './useAppConfig' import { useAppFileHandling, AppFileHandlingResult } from './useAppFileHandling' @@ -17,6 +18,7 @@ import { useAppFolderHandling, AppFolderHandlingResult } from './useAppFolderHan import { useAppDocumentTitle } from './useAppDocumentTitle' import { usePublicLinkPassword, usePublicLinkContext, useRequest } from '../authContext' import { useClientService } from '../clientService' +import { MaybeRef } from '../../utils' // TODO: this file/folder contains file/folder loading logic extracted from preview and drawio extensions // Discussion how to progress from here can be found in this issue: @@ -24,6 +26,7 @@ import { useClientService } from '../clientService' interface AppDefaultsOptions { applicationId: string + applicationName?: MaybeRef clientService?: ClientService } @@ -46,14 +49,6 @@ export function useAppDefaults(options: AppDefaultsOptions): AppDefaultsResult { const publicLinkPassword = usePublicLinkPassword({ store }) const currentFileContext = computed((): FileContext => { - const queryItemAsString = (queryItem: string | string[]) => { - if (Array.isArray(queryItem)) { - return queryItem[0] - } - - return queryItem - } - const path = `/${unref(currentRoute).params.filePath?.split('/').filter(Boolean).join('/')}` return { @@ -64,7 +59,13 @@ export function useAppDefaults(options: AppDefaultsOptions): AppDefaultsResult { } }) - useAppDocumentTitle({ store, document, applicationId, currentFileContext }) + useAppDocumentTitle({ + store, + document, + applicationId, + applicationName: options.applicationName, + currentFileContext + }) return { isPublicLinkContext, diff --git a/packages/web-pkg/src/composables/appDefaults/useAppDocumentTitle.ts b/packages/web-pkg/src/composables/appDefaults/useAppDocumentTitle.ts index c9b023561aa..893967a7c23 100644 --- a/packages/web-pkg/src/composables/appDefaults/useAppDocumentTitle.ts +++ b/packages/web-pkg/src/composables/appDefaults/useAppDocumentTitle.ts @@ -4,11 +4,13 @@ import { FileContext } from './types' import { useAppMeta } from './useAppMeta' import { useDocumentTitle } from './useDocumentTitle' import { Store } from 'vuex' +import { MaybeRef } from '../../utils' interface AppDocumentTitleOptions { store: Store document: Document applicationId: string + applicationName?: MaybeRef currentFileContext: Ref } @@ -16,6 +18,7 @@ export function useAppDocumentTitle({ store, document, applicationId, + applicationName, currentFileContext }: AppDocumentTitleOptions): void { const appMeta = useAppMeta({ applicationId, store }) @@ -24,7 +27,11 @@ export function useAppDocumentTitle({ const fileName = basename(unref(unref(currentFileContext).fileName)) const meta = unref(unref(appMeta).applicationMeta) - return [fileName, meta.name || meta.id, store.getters.configuration.currentTheme.general.name] + return [ + fileName, + unref(applicationName) || meta.name || meta.id, + store.getters.configuration.currentTheme.general.name + ] .filter(Boolean) .join(' - ') }) diff --git a/packages/web-pkg/src/composables/appDefaults/useAppNavigation.ts b/packages/web-pkg/src/composables/appDefaults/useAppNavigation.ts index 4343e8698d1..a7be245e616 100644 --- a/packages/web-pkg/src/composables/appDefaults/useAppNavigation.ts +++ b/packages/web-pkg/src/composables/appDefaults/useAppNavigation.ts @@ -51,7 +51,7 @@ export const contextQueryToFileContextProps = ( } } -const queryItemAsString = (queryItem: string | string[]) => { +export const queryItemAsString = (queryItem: string | string[]) => { if (Array.isArray(queryItem)) { return queryItem[0] } From 9d269c9ef762fce1512d6ab85f520d91ac1209bf Mon Sep 17 00:00:00 2001 From: Benedikt Kulmann Date: Thu, 23 Jun 2022 09:38:15 +0200 Subject: [PATCH 4/5] Fix duplicate keys in CreateAndUpload --- .../web-app-files/src/components/AppBar/CreateAndUpload.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/web-app-files/src/components/AppBar/CreateAndUpload.vue b/packages/web-app-files/src/components/AppBar/CreateAndUpload.vue index 5286d5f98e2..eb27cf283d4 100644 --- a/packages/web-app-files/src/components/AppBar/CreateAndUpload.vue +++ b/packages/web-app-files/src/components/AppBar/CreateAndUpload.vue @@ -30,7 +30,7 @@
  • Date: Thu, 23 Jun 2022 09:44:57 +0200 Subject: [PATCH 5/5] Changelog and test fix --- changelog/unreleased/bugfix-external-app-title | 5 +++++ changelog/unreleased/bugfix-external-apps | 6 ++++++ packages/web-app-external/tests/unit/app.spec.js | 7 ++++--- 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 changelog/unreleased/bugfix-external-app-title create mode 100644 changelog/unreleased/bugfix-external-apps diff --git a/changelog/unreleased/bugfix-external-app-title b/changelog/unreleased/bugfix-external-app-title new file mode 100644 index 00000000000..861f57c6449 --- /dev/null +++ b/changelog/unreleased/bugfix-external-app-title @@ -0,0 +1,5 @@ +Bugfix: Re-introduce dynamic app name in document title + +The `external` app was missing the dynamic app name after some recent refactoring. It has been reintroduced. + +https://github.com/owncloud/web/pull/7173 diff --git a/changelog/unreleased/bugfix-external-apps b/changelog/unreleased/bugfix-external-apps new file mode 100644 index 00000000000..55be7a62833 --- /dev/null +++ b/changelog/unreleased/bugfix-external-apps @@ -0,0 +1,6 @@ +Bugfix: External apps fixes + +Bug introduced in #6870. A method used to communicate with the backend was not properly added to the extension after being moved to a different location. + +https://github.com/owncloud/web/pull/7166 +https://github.com/owncloud/web/pull/7173 diff --git a/packages/web-app-external/tests/unit/app.spec.js b/packages/web-app-external/tests/unit/app.spec.js index 91b3315c953..0bb4d3e204a 100644 --- a/packages/web-app-external/tests/unit/app.spec.js +++ b/packages/web-app-external/tests/unit/app.spec.js @@ -143,7 +143,7 @@ describe('The app provider extension', () => { Promise.resolve({ ok: true, status: 200, - json: () => providerSuccessResponseGet + data: providerSuccessResponseGet }) ) @@ -158,7 +158,7 @@ describe('The app provider extension', () => { Promise.resolve({ ok: true, status: 200, - json: () => providerSuccessResponsePost + data: providerSuccessResponsePost }) ) const wrapper = createShallowMountWrapper(makeRequest) @@ -178,7 +178,8 @@ function createShallowMountWrapper(makeRequest, options = {}) { $route }, computed: { - currentFileContext: () => $route.params + currentFileContext: () => $route.params, + applicationName: () => $route.query.app }, methods: { getFileInfo: mockFileInfo,