From d8aa828c85b002a55bdd566ba5a2e110165002af Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 6 Dec 2024 08:32:28 +0100 Subject: [PATCH] Fix bug where translations were missing on the share type filters (#12013) --- .../bugfix-missing-translations-share-type-filters | 6 ++++++ .../web-app-files/src/views/shares/SharedWithMe.vue | 8 +++++++- .../src/views/shares/SharedWithOthers.vue | 10 +++++++++- .../tests/unit/views/shares/SharedWithMe.spec.ts | 8 +++++--- .../tests/unit/views/shares/SharedWithOthers.spec.ts | 11 +++++++++-- 5 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 changelog/unreleased/bugfix-missing-translations-share-type-filters diff --git a/changelog/unreleased/bugfix-missing-translations-share-type-filters b/changelog/unreleased/bugfix-missing-translations-share-type-filters new file mode 100644 index 00000000000..aea4be1c307 --- /dev/null +++ b/changelog/unreleased/bugfix-missing-translations-share-type-filters @@ -0,0 +1,6 @@ +Bugfix: Missing translations for share type filters + +We've fixed a bug, where the translations for the share type filters were missing. +This was the case for the "Shared with me" and "Shared with others" page. + +https://github.com/owncloud/web/pull/12013 \ No newline at end of file diff --git a/packages/web-app-files/src/views/shares/SharedWithMe.vue b/packages/web-app-files/src/views/shares/SharedWithMe.vue index f25ea5b845d..f49517ccf00 100644 --- a/packages/web-app-files/src/views/shares/SharedWithMe.vue +++ b/packages/web-app-files/src/views/shares/SharedWithMe.vue @@ -252,7 +252,13 @@ export default defineComponent({ uniqueShareTypes.push(ShareTypes.remote.value) } - return ShareTypes.getByValues(uniqueShareTypes) + return ShareTypes.getByValues(uniqueShareTypes).map((shareType) => { + return { + key: shareType.key, + value: shareType.value, + label: $gettext(shareType.label) + } + }) }) const fileOwners = computed(() => { diff --git a/packages/web-app-files/src/views/shares/SharedWithOthers.vue b/packages/web-app-files/src/views/shares/SharedWithOthers.vue index 5e3980ef3a1..c87ef9dbf75 100644 --- a/packages/web-app-files/src/views/shares/SharedWithOthers.vue +++ b/packages/web-app-files/src/views/shares/SharedWithOthers.vue @@ -106,6 +106,7 @@ import { useGetMatchingSpace } from '@ownclouders/web-pkg' import SharesNavigation from '../../components/AppBar/SharesNavigation.vue' import { OutgoingShareResource, ShareTypes } from '@ownclouders/web-client' import { storeToRefs } from 'pinia' +import { useGettext } from 'vue3-gettext' export default defineComponent({ components: { @@ -128,6 +129,7 @@ export default defineComponent({ const configStore = useConfigStore() const appsStore = useAppsStore() const { options: configOptions } = storeToRefs(configStore) + const { $gettext } = useGettext() const resourcesStore = useResourcesStore() @@ -150,7 +152,13 @@ export default defineComponent({ uniqueShareTypes.push(ShareTypes.remote.value) } - return ShareTypes.getByValues(uniqueShareTypes) + return ShareTypes.getByValues(uniqueShareTypes).map((shareType) => { + return { + key: shareType.key, + value: shareType.value, + label: $gettext(shareType.label) + } + }) }) const selectedShareTypesQuery = useRouteQuery('q_shareType') const filteredItems = computed(() => { diff --git a/packages/web-app-files/tests/unit/views/shares/SharedWithMe.spec.ts b/packages/web-app-files/tests/unit/views/shares/SharedWithMe.spec.ts index 52057573e4f..552efa744f1 100644 --- a/packages/web-app-files/tests/unit/views/shares/SharedWithMe.spec.ts +++ b/packages/web-app-files/tests/unit/views/shares/SharedWithMe.spec.ts @@ -13,7 +13,7 @@ import { defaultStubs, RouteLocation } from '@ownclouders/web-test-helpers' import { useSortMock } from '../../../../tests/mocks/useSortMock' import { mock } from 'vitest-mock-extended' import { defaultPlugins, mount, defaultComponentMocks } from '@ownclouders/web-test-helpers' -import { ShareTypes, IncomingShareResource } from '@ownclouders/web-client' +import { ShareTypes, IncomingShareResource, ShareType } from '@ownclouders/web-client' import SharedWithMeSection from '../../../../src/components/Shares/SharedWithMeSection.vue' vi.mock('../../../../src/composables/resourcesViewDefaults') @@ -96,9 +96,11 @@ describe('SharedWithMe view', () => { }) const filterItems = wrapper .findComponent('.share-type-filter') - .props('items') + .props('items') as ShareType[] + expect(wrapper.find('.share-type-filter').exists()).toBeTruthy() - expect(filterItems).toEqual([shareType1, shareType2]) + expect(filterItems[0].value).toEqual(shareType1.value) + expect(filterItems[1].value).toEqual(shareType2.value) }) }) describe('shared by', () => { diff --git a/packages/web-app-files/tests/unit/views/shares/SharedWithOthers.spec.ts b/packages/web-app-files/tests/unit/views/shares/SharedWithOthers.spec.ts index 6bd10bb039b..4d6c4bd5d4c 100644 --- a/packages/web-app-files/tests/unit/views/shares/SharedWithOthers.spec.ts +++ b/packages/web-app-files/tests/unit/views/shares/SharedWithOthers.spec.ts @@ -39,7 +39,10 @@ describe('SharedWithOthers view', () => { expect(wrapper.find('.no-content-message').exists()).toBeTruthy() }) it('shows the files table when files are available', () => { - const mockedFiles = [mockDeep(), mockDeep()] + const mockedFiles = [ + mockDeep({ shareTypes: [ShareTypes.user.value] }), + mockDeep({ shareTypes: [ShareTypes.user.value] }) + ] const { wrapper } = getMountedWrapper({ files: mockedFiles }) expect(wrapper.find('.no-content-message').exists()).toBeFalsy() expect(wrapper.find('resource-table-stub').exists()).toBeTruthy() @@ -73,7 +76,11 @@ function getMountedWrapper({ mocks = {}, files = [], loading = false -}: { mocks?: Record; files?: IncomingShareResource[]; loading?: boolean } = {}) { +}: { + mocks?: Record + files?: IncomingShareResource[] + loading?: boolean +} = {}) { vi.mocked(useResourcesViewDefaults).mockImplementation(() => useResourcesViewDefaultsMock({ paginatedResources: ref(files),