Skip to content

Commit

Permalink
Merge pull request #5956 from owncloud/translations-search-app
Browse files Browse the repository at this point in the history
Export translations of search app
  • Loading branch information
Pascal Wengerter authored Nov 11, 2021
2 parents 906584f + 2a4645c commit 2f544d5
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 29 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/bugfix-search-app-translations
Original file line number Diff line number Diff line change
@@ -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
3 changes: 1 addition & 2 deletions packages/web-app-draw-io/src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import translationsJson from '../l10n/translations'
import translations from '../l10n/translations'
import App from './App.vue'

const routes = [
Expand Down Expand Up @@ -49,7 +49,6 @@ const appInfo = {
]
}

const translations = translationsJson
export default {
appInfo,
routes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<div class="uk-flex">
<oc-button
v-for="action in filteredActions"
:key="action.label"
v-oc-tooltip="$gettext(action.label)"
:aria-label="$gettext(action.label)"
:key="action.label($gettext)"
v-oc-tooltip="action.label($gettext)"
:aria-label="action.label($gettext)"
appearance="raw"
class="oc-mr-xs"
:class="`files-quick-action-${action.id}`"
@click="action.handler({ item, client: $client, store: $store })"
@click="action.handler({ item, client: $client, store: $store, $gettext })"
>
<oc-icon :name="action.icon" class="uk-flex" />
</oc-button>
Expand Down
9 changes: 2 additions & 7 deletions packages/web-app-files/src/index.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}
}
}
15 changes: 5 additions & 10 deletions packages/web-app-files/src/quickActions.js
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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',
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ const collaboratorAction = {
handler: jest.fn(),
icon: 'group-add',
id: 'collaborators',
label: 'Add people'
label: () => 'Add people'
}

const publicLinkAction = {
displayed: jest.fn(() => false),
handler: jest.fn(),
icon: 'link-add',
id: 'public-link',
label: 'Create and copy public link'
label: () => 'Create and copy public link'
}

const testItem = {
Expand Down Expand Up @@ -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])
})
})
})
Expand Down
4 changes: 4 additions & 0 deletions packages/web-app-search/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ 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 translations from '../l10n/translations.json'

// just a dummy function to trick gettext tools
const $gettext = (msg) => {
Expand Down Expand Up @@ -39,6 +42,7 @@ export default {
]
}
],
translations,
mounted({
portal
}: {
Expand Down

0 comments on commit 2f544d5

Please sign in to comment.