From 4aa2d14e2cf061c7a2fb24b20cb20db8d500dcdf Mon Sep 17 00:00:00 2001 From: Benedikt Kulmann Date: Fri, 29 Oct 2021 00:34:46 +0200 Subject: [PATCH 1/3] Export translations of search app --- changelog/unreleased/bugfix-search-app-translations | 6 ++++++ packages/web-app-search/src/index.ts | 3 +++ 2 files changed, 9 insertions(+) create mode 100644 changelog/unreleased/bugfix-search-app-translations diff --git a/changelog/unreleased/bugfix-search-app-translations b/changelog/unreleased/bugfix-search-app-translations new file mode 100644 index 00000000000..378da542afc --- /dev/null +++ b/changelog/unreleased/bugfix-search-app-translations @@ -0,0 +1,6 @@ +Bugfix: Use search app translations + +We fixed that the search app was not using its translations properly. + +https://github.com/owncloud/web/issues/5955 +https://github.com/owncloud/web/pull/5956 diff --git a/packages/web-app-search/src/index.ts b/packages/web-app-search/src/index.ts index 0d4dd979b0a..7bc3dc4178f 100644 --- a/packages/web-app-search/src/index.ts +++ b/packages/web-app-search/src/index.ts @@ -6,6 +6,8 @@ import { providerStore } from './service' import { bus } from 'web-pkg/src/instance' import { SearchProvider } from './types' import { Component } from 'vue' +// @ts-ignore +import translationsJson from '../l10n/translations.json' // just a dummy function to trick gettext tools const $gettext = (msg) => { @@ -39,6 +41,7 @@ export default { ] } ], + translations: translationsJson, mounted({ portal }: { From 07cae842f0cf557b4becce85659e9003b815bedd Mon Sep 17 00:00:00 2001 From: Benedikt Kulmann Date: Fri, 29 Oct 2021 00:43:24 +0200 Subject: [PATCH 2/3] Translate quick action link name --- .../src/components/FilesList/QuickActions.vue | 8 ++++---- .../src/mixins/actions/createPublicLink.js | 7 ++++++- packages/web-app-files/src/quickActions.js | 15 +++++---------- .../components/FilesList/QuickActions.spec.js | 4 ++-- packages/web-app-search/src/index.ts | 1 + 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/packages/web-app-files/src/components/FilesList/QuickActions.vue b/packages/web-app-files/src/components/FilesList/QuickActions.vue index 93f57eef6b3..f696f007157 100644 --- a/packages/web-app-files/src/components/FilesList/QuickActions.vue +++ b/packages/web-app-files/src/components/FilesList/QuickActions.vue @@ -2,13 +2,13 @@
diff --git a/packages/web-app-files/src/mixins/actions/createPublicLink.js b/packages/web-app-files/src/mixins/actions/createPublicLink.js index 1f7f91cad03..3defbf8f293 100644 --- a/packages/web-app-files/src/mixins/actions/createPublicLink.js +++ b/packages/web-app-files/src/mixins/actions/createPublicLink.js @@ -17,7 +17,12 @@ export default { }, methods: { $_createPublicLink_trigger(resource) { - createPublicLink({ item: resource, client: this.$client, store: this.$store }) + createPublicLink({ + item: resource, + client: this.$client, + store: this.$store, + $gettext: this.$gettext + }) } } } diff --git a/packages/web-app-files/src/quickActions.js b/packages/web-app-files/src/quickActions.js index 07b9ee60c04..905513a7b45 100644 --- a/packages/web-app-files/src/quickActions.js +++ b/packages/web-app-files/src/quickActions.js @@ -1,14 +1,9 @@ import { DateTime } from 'luxon' import copyToClipboard from 'copy-to-clipboard' -// just a dummy function to trick gettext tools -function $gettext(msg) { - return msg -} - export function createPublicLink(ctx) { // FIXME: Translate name - const params = { name: $gettext('Quick action link'), permissions: 1 } + const params = { name: ctx.$gettext('Quick action link'), permissions: 1 } const capabilities = ctx.store.state.user.capabilities const expirationDate = capabilities.files_sharing.public.expire_date @@ -26,8 +21,8 @@ export function createPublicLink(ctx) { ctx.store.dispatch('Files/sidebar/openWithPanel', 'links-item').then(() => { copyToClipboard(link.url) ctx.store.dispatch('showMessage', { - title: $gettext('Public link created'), - desc: $gettext( + title: ctx.$gettext('Public link created'), + desc: ctx.$gettext( 'Public link has been successfully created and copied into your clipboard.' ), status: 'success', @@ -59,14 +54,14 @@ export function canShare(item, store) { export default { collaborators: { id: 'collaborators', - label: $gettext('Add people'), + label: ($gettext) => $gettext('Add people'), icon: 'group-add', handler: openNewCollaboratorsPanel, displayed: canShare }, publicLink: { id: 'public-link', - label: $gettext('Create and copy public link'), + label: ($gettext) => $gettext('Create and copy public link'), icon: 'link-add', handler: createPublicLink, displayed: canShare diff --git a/packages/web-app-files/tests/unit/components/FilesList/QuickActions.spec.js b/packages/web-app-files/tests/unit/components/FilesList/QuickActions.spec.js index 912731ea4d6..2f8978db9f9 100644 --- a/packages/web-app-files/tests/unit/components/FilesList/QuickActions.spec.js +++ b/packages/web-app-files/tests/unit/components/FilesList/QuickActions.spec.js @@ -8,7 +8,7 @@ const collaboratorAction = { handler: jest.fn(), icon: 'group-add', id: 'collaborators', - label: 'Add people' + label: () => 'Add people' } const publicLinkAction = { @@ -16,7 +16,7 @@ const publicLinkAction = { handler: jest.fn(), icon: 'link-add', id: 'public-link', - label: 'Create and copy public link' + label: () => 'Create and copy public link' } const testItem = { diff --git a/packages/web-app-search/src/index.ts b/packages/web-app-search/src/index.ts index 7bc3dc4178f..78c0af1a50e 100644 --- a/packages/web-app-search/src/index.ts +++ b/packages/web-app-search/src/index.ts @@ -6,6 +6,7 @@ import { providerStore } from './service' import { bus } from 'web-pkg/src/instance' import { SearchProvider } from './types' import { Component } from 'vue' +// eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore import translationsJson from '../l10n/translations.json' From 2a4645cf1f8d25bab7c3fca38896d8ae33bb6c03 Mon Sep 17 00:00:00 2001 From: pwengerter Date: Thu, 11 Nov 2021 15:20:07 +0100 Subject: [PATCH 3/3] Fix Quickaction unit test, streamline translations import/export --- packages/web-app-draw-io/src/index.js | 3 +-- packages/web-app-files/src/index.js | 9 ++------- .../tests/unit/components/FilesList/QuickActions.spec.js | 5 ++--- packages/web-app-search/src/index.ts | 4 ++-- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/packages/web-app-draw-io/src/index.js b/packages/web-app-draw-io/src/index.js index 49c189b4b2e..283c08e8b6a 100644 --- a/packages/web-app-draw-io/src/index.js +++ b/packages/web-app-draw-io/src/index.js @@ -1,4 +1,4 @@ -import translationsJson from '../l10n/translations' +import translations from '../l10n/translations' import App from './App.vue' const routes = [ @@ -49,7 +49,6 @@ const appInfo = { ] } -const translations = translationsJson export default { appInfo, routes, diff --git a/packages/web-app-files/src/index.js b/packages/web-app-files/src/index.js index 8a88dacedab..a29d09cc184 100644 --- a/packages/web-app-files/src/index.js +++ b/packages/web-app-files/src/index.js @@ -1,5 +1,5 @@ -import translationsJson from '../l10n/translations.json' -import quickActionsImport from './quickActions' +import translations from '../l10n/translations.json' +import quickActions from './quickActions' import store from './store' import { FilterSearch, SDKSearch } from './search' import { bus } from 'web-pkg/src/instance' @@ -78,11 +78,6 @@ const navItems = [ } ] -// Prepare imported modules to be exported -// If we do not define these constants, the export will be undefined -const translations = translationsJson -const quickActions = quickActionsImport - export default { appInfo, store, diff --git a/packages/web-app-files/tests/unit/components/FilesList/QuickActions.spec.js b/packages/web-app-files/tests/unit/components/FilesList/QuickActions.spec.js index 2f8978db9f9..b4fe3ed37a5 100644 --- a/packages/web-app-files/tests/unit/components/FilesList/QuickActions.spec.js +++ b/packages/web-app-files/tests/unit/components/FilesList/QuickActions.spec.js @@ -108,9 +108,8 @@ describe('QuickActions', () => { const actionButton = wrapper.find('button') await actionButton.trigger('click') expect(handlerAction).toHaveBeenCalledTimes(1) - expect(handlerAction).toHaveBeenCalledWith({ - item: testItem, - store: undefined // undefined because not provided with wrapper + Object.keys(testItem).forEach((key) => { + expect(handlerAction.mock.calls[0][0].item[key]).toBe(testItem[key]) }) }) }) diff --git a/packages/web-app-search/src/index.ts b/packages/web-app-search/src/index.ts index 78c0af1a50e..80f69ed2df4 100644 --- a/packages/web-app-search/src/index.ts +++ b/packages/web-app-search/src/index.ts @@ -8,7 +8,7 @@ import { SearchProvider } from './types' import { Component } from 'vue' // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore -import translationsJson from '../l10n/translations.json' +import translations from '../l10n/translations.json' // just a dummy function to trick gettext tools const $gettext = (msg) => { @@ -42,7 +42,7 @@ export default { ] } ], - translations: translationsJson, + translations, mounted({ portal }: {