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] Vue 3: Use vue3-gettext #8257

Merged
merged 7 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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
1 change: 1 addition & 0 deletions changelog/unreleased/change-update-vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ https://github.com/owncloud/web/pull/8213
https://github.com/owncloud/web/pull/8214
https://github.com/owncloud/web/pull/8221
https://github.com/owncloud/web/pull/8256
https://github.com/owncloud/web/pull/8257
https://github.com/owncloud/web/pull/8258
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
"url-search-params-polyfill": "8.1.1",
"vite": "4.0.4",
"vite-plugin-environment": "^1.1.3",
"vue-gettext": "2.1.12",
"vue3-gettext": "^2.3.3",
"vue-tsc": "1.0.20",
"wait-for-expect": "3.0.2"
},
Expand Down Expand Up @@ -146,7 +146,6 @@
"patchedDependencies": {
"@adobe/[email protected]": "patches/@[email protected]",
"[email protected]": "patches/[email protected]",
"[email protected]": "patches/[email protected]",
"[email protected]": "patches/[email protected]",
"[email protected]": "patches/[email protected]"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/design-system/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"typescript": "^4.3.2",
"url-loader": "^4.1.1",
"v-calendar": "github:dschmidt/v-calendar#3ce6e3b8afd5491cb53ee811281d5fa8a45b044d",
"vue-gettext": "^2.1.12",
"vue3-gettext": "^2.3.3",
"vue-inline-svg": "^3.1.0",
"vue-jest": "^3.0.4",
"vue-loader": "^15.9.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,5 +228,10 @@ function getWrapper(props = {}) {
})
}
function getMountedWrapper() {
return mount(OcSearchBar, { props: { label: 'abc' } })
return mount(OcSearchBar, {
props: { label: 'abc' },
global: {
plugins: [...defaultPlugins()]
}
})
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import StatusIndicators from './OcStatusIndicators.vue'
import { mount } from 'web-test-helpers'
import { defaultPlugins, mount } from 'web-test-helpers'

const fileResource = {
name: 'forest.jpg',
Expand All @@ -24,6 +24,9 @@ describe('OcStatusIndicators', () => {
resource: fileResource,
indicators: [indicator],
target: 'test'
},
global: {
plugins: [...defaultPlugins()]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why spreading? unnecessary [Symbol.iterator]call.

defaultPlugins()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically all tests have it this way, just because it is easier to add more plugins. We think the overhead can be neglect in the test suite.

}
})
wrapper.find('.oc-status-indicators-indicator').trigger('click')
Expand All @@ -35,6 +38,9 @@ describe('OcStatusIndicators', () => {
resource: fileResource,
indicators: [indicator],
target: 'test'
},
global: {
plugins: [...defaultPlugins()]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

}
})
expect(wrapper.find(`#${indicator.id}`).exists()).toBeTruthy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
v-if="hasHandler(indicator)"
:id="indicator.id"
:key="indicator.id"
v-oc-tooltip="indicator.label"
v-oc-tooltip="$gettext(indicator.label)"
class="oc-status-indicators-indicator oc-background-primary-gradient oc-p-xs oc-ml-xs"
:aria-label="indicator.label"
:aria-label="$gettext(indicator.label)"
:aria-describedby="getIndicatorDescriptionId(indicator)"
appearance="raw"
variation="inverse"
Expand All @@ -21,13 +21,13 @@
v-else
:id="indicator.id"
:key="indicator.id"
v-oc-tooltip="indicator.label"
v-oc-tooltip="$gettext(indicator.label)"
tabindex="-1"
size="small"
class="oc-status-indicators-indicator"
:name="indicator.icon"
:fill-type="indicator.fillType"
:accessible-label="indicator.label"
:accessible-label="$gettext(indicator.label)"
:aria-describedby="getIndicatorDescriptionId(indicator)"
:data-testid="indicator.id"
:data-test-indicator-type="indicator.type"
Expand All @@ -37,7 +37,7 @@
:id="getIndicatorDescriptionId(indicator)"
:key="getIndicatorDescriptionId(indicator)"
class="oc-invisible-sr"
v-text="indicator.accessibleDescription"
v-text="$gettext(indicator.accessibleDescription)"
/>
</template>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ describe('OcTable.sort', () => {
data
},
global: {
plugins: [...defaultPlugins()],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

stubs: {
'oc-icon': true
}
Expand Down Expand Up @@ -175,6 +176,7 @@ describe('OcTable.sort', () => {
sortDir: sortDirOld
},
global: {
plugins: [...defaultPlugins()],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same ...

stubs: {
'oc-icon': true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ describe('OcTextInput', () => {
}

function getMountedWrapper(options = {}) {
return mount(OcTextInput, options)
return mount(OcTextInput, {
...options,
global: {
plugins: [...defaultPlugins()]
}
})
}

const selectors = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ import {
} from 'web-pkg/src/helpers'
import { computed, defineComponent, nextTick, onMounted, PropType, ref, unref, watch } from 'vue'
import { extractDomSelector, SpaceResource } from 'web-client/src/helpers'
import { useTranslations } from 'web-pkg/src/composables'
import { spaceRoleEditor, spaceRoleManager, spaceRoleViewer } from 'web-client/src/helpers/share'
import Mark from 'mark.js'
import Fuse from 'fuse.js'
import { useGettext } from 'vue3-gettext'

export default defineComponent({
name: 'SpacesList',
Expand All @@ -159,7 +159,7 @@ export default defineComponent({
},
emits: ['toggleSelectSpace', 'toggleSelectAllSpaces', 'toggleUnSelectAllSpaces'],
setup: function (props, { emit }) {
const { $gettext, $gettextInterpolate, $language } = useTranslations()
const { $gettext, interpolate: $gettextInterpolate, current: currentLanguage } = useGettext()
const contextMenuButton = ref(undefined)
const sortBy = ref('name')
const sortDir = ref('asc')
Expand Down Expand Up @@ -321,25 +321,25 @@ export default defineComponent({
return managerStr
}
const formatDate = (date) => {
return formatDateFromJSDate(new Date(date), $language.current)
return formatDateFromJSDate(new Date(date), currentLanguage)
}
const formatDateRelative = (date) => {
return formatRelativeDateFromJSDate(new Date(date), $language.current)
return formatRelativeDateFromJSDate(new Date(date), currentLanguage)
}
const getTotalQuota = (space: SpaceResource) => {
return formatFileSize(space.spaceQuota.total, $language.current)
return formatFileSize(space.spaceQuota.total, currentLanguage)
}
const getUsedQuota = (space: SpaceResource) => {
if (space.spaceQuota.used === undefined) {
return '-'
}
return formatFileSize(space.spaceQuota.used, $language.current)
return formatFileSize(space.spaceQuota.used, currentLanguage)
}
const getRemainingQuota = (space: SpaceResource) => {
if (space.spaceQuota.remaining === undefined) {
return '-'
}
return formatFileSize(space.spaceQuota.remaining, $language.current)
return formatFileSize(space.spaceQuota.remaining, currentLanguage)
}
const getMemberCount = (space: SpaceResource) => {
return (
Expand Down
5 changes: 3 additions & 2 deletions packages/web-app-admin-settings/src/views/Spaces.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

<script lang="ts">
import NoContentMessage from 'web-pkg/src/components/NoContentMessage.vue'
import { useAccessToken, useGraphClient, useStore, useTranslations } from 'web-pkg/src/composables'
import { useAccessToken, useGraphClient, useStore } from 'web-pkg/src/composables'
import { computed, defineComponent, onBeforeUnmount, onMounted, ref, unref } from 'vue'
import { useTask } from 'vue-concurrency'
import { eventBus } from 'web-pkg/src/services/eventBus'
Expand All @@ -78,6 +78,7 @@ import ContextActions from '../components/Spaces/ContextActions.vue'
import MembersPanel from '../components/Spaces/SideBar/MembersPanel.vue'
import SpaceInfo from 'web-pkg/src/components/sideBar/Spaces/SpaceInfo.vue'
import { useSideBar } from 'web-pkg/src/composables/sideBar'
import { useGettext } from 'vue3-gettext'

export default defineComponent({
name: 'SpacesView',
Expand All @@ -93,7 +94,7 @@ export default defineComponent({
const accessToken = useAccessToken({ store })
const spaces = ref([])
const { graphClient } = useGraphClient()
const { $gettext } = useTranslations()
const { $gettext } = useGettext()

const loadResourcesEventToken = ref(null)
const template = ref(null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ function getWrapper({ propsData = {} } = {}) {
},
mocks: {
...defaultComponentMocks({
gettext: false,
currentRoute: mock<RouteLocation>({ query: { app: 'admin-settings' } })
})
}
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-external/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "AGPL-3.0",
"peerDependencies": {
"uuid": "^9.0.0",
"vue-gettext": "2.1.12",
"vue3-gettext": "^2.3.3",
"vuex": "4.1.0",
"web-client": "npm:@ownclouders/web-client",
"web-pkg": "npm:@ownclouders/web-pkg"
Expand Down
1 change: 0 additions & 1 deletion packages/web-app-external/tests/unit/app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ function createShallowMountWrapper(makeRequest = jest.fn().mockResolvedValue({ s
stubs: componentStubs,
mocks: {
...defaultComponentMocks({
gettext: false,
currentRoute: mock<RouteLocation>({ query: { app: 'exampleApp' } })
})
}
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"semver": "^7.3.8",
"uuid": "^9.0.0",
"vue-concurrency": "4.0.0",
"vue-gettext": "2.1.12",
"vue3-gettext": "^2.3.3",
"vue-router": "4.1.6",
"vuex": "4.1.0",
"web-app-files": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-files/src/components/AppBar/AppBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export default defineComponent({
...mapState('Files', ['areHiddenFilesShown', 'areFileExtensionsShown']),

pageTitle() {
const title = this.$route.meta.title
const title = this.$route.meta.title || ''
return this.$gettext(title)
},
showContextActions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,21 @@ export default defineComponent({
}

if (key === keycode('c') && ctrl) {
return this.copySelectedFiles({ space: this.space, resources: this.selectedFiles })
return this.copySelectedFiles({
...this.$language,
space: this.space,
resources: this.selectedFiles
})
}
if (key === keycode('v') && ctrl) {
return this.handlePasteAction()
}
if (key === keycode('x') && ctrl) {
return this.cutSelectedFiles({ space: this.space, resources: this.selectedFiles })
return this.cutSelectedFiles({
...this.$language,
space: this.space,
resources: this.selectedFiles
})
}
if (key === keycode('down') && !shift) {
return this.handleNavigateAction(event)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
appearance="raw"
class="oc-mr-xs quick-action-button oc-p-xs"
:class="`files-quick-action-${action.id}`"
@click="action.handler({ item, client: $client, store: $store, $gettext })"
@click="action.handler({ ...$language, item, client: $client, store: $store })"
>
<oc-icon :name="action.icon" fill-type="line" />
</oc-button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@

<script lang="ts">
import { defineComponent, PropType } from 'vue'
import { useGettext } from 'vue3-gettext'
import { createLocationSpaces } from 'web-app-files/src/router'
import { Resource, SpaceResource } from 'web-client'
import { createFileRouteOptions } from 'web-pkg/src/helpers/router'
import { useStore, useTranslations } from 'web-pkg/src/composables'
import { useStore } from 'web-pkg/src/composables'
// Constants should match what is being used in OcTable/ResourceTable
// Alignment regarding naming would be an API-breaking change and can
Expand All @@ -48,7 +49,7 @@ export default defineComponent({
},
setup() {
const store = useStore()
const { $gettext } = useTranslations()
const { $gettext } = useGettext()
const getRoute = (resource) => {
if (resource.type === 'space') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ import {
useClientService,
usePublicLinkContext,
useStore,
useTranslations,
useUserContext
} from 'web-pkg/src/composables'
import { getIndicators } from '../../../helpers/statusIndicators'
Expand All @@ -185,12 +184,13 @@ import { buildShareSpaceResource } from 'web-client/src/helpers'
import { configurationManager } from 'web-pkg/src/configuration'
import { createFileRouteOptions } from 'web-pkg/src/helpers/router'
import { useTask } from 'vue-concurrency'
import { useGettext } from 'vue3-gettext'
export default defineComponent({
name: 'FileDetails',
setup() {
const store = useStore()
const { $gettext } = useTranslations()
const { $gettext } = useGettext()
const copiedDirect = ref(false)
const copiedEos = ref(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
import { computed, defineComponent, inject, unref } from 'vue'
import { useClipboard } from '@vueuse/core'
import { Resource } from 'web-client'
import { useStore, useTranslations } from 'web-pkg/src'
import { useStore } from 'web-pkg/src'
import { useGettext } from 'vue3-gettext'
export default defineComponent({
name: 'PrivateLinkItem',
setup() {
const { $gettext } = useTranslations()
const { $gettext } = useGettext()
const store = useStore<any>()
const displayedItem = inject<Resource>('displayedItem')
const privateLink = computed(() => unref(displayedItem))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,10 @@ export default defineComponent({

const addMethod = this.resourceIsSpace ? this.addSpaceMember : this.addShare
addMethod({
...this.$language,
client: this.$client,
graphClient: this.graphClient,
path,
$gettext: this.$gettext,
shareWith: collaborator.value.shareWith,
displayName: collaborator.label,
shareType: collaborator.value.shareType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ export default defineComponent({
: SharePermissions.permissionsToBitmask(role.permissions(this.hasResharing || this.isSpace))
const changeMethod = this.isSpace ? this.changeSpaceMember : this.changeShare
changeMethod({
...this.$language,
client: this.$client,
graphClient: this.graphClient,
share: this.share,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ export default defineComponent({
const paramsToCreate = this.getParamsForLink(link)

if (this.isPasswordEnforcedFor(link)) {
showQuickLinkPasswordModal({ store: this.$store }, (newPassword) => {
showQuickLinkPasswordModal({ ...this.$language, store: this.$store }, (newPassword) => {
this.createLink({ params: { ...paramsToCreate, password: newPassword }, onError })
})
} else {
Expand All @@ -415,7 +415,7 @@ export default defineComponent({
const params = this.getParamsForLink(link)

if (!link.password && this.isPasswordEnforcedFor(link)) {
showQuickLinkPasswordModal({ store: this.$store }, (newPassword) => {
showQuickLinkPasswordModal({ ...this.$language, store: this.$store }, (newPassword) => {
this.updatePublicLink({ params: { ...params, password: newPassword }, onSuccess })
})
} else {
Expand Down
Loading