Skip to content

Commit 2d15604

Browse files
Merge pull request #763 from nextcloud/feat/vue3
feat: migrate to vue 3
2 parents 30f5668 + 387dca8 commit 2d15604

9 files changed

Lines changed: 2481 additions & 3004 deletions

File tree

package-lock.json

Lines changed: 2432 additions & 2934 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,25 @@
99
"@nextcloud/initial-state": "^2.2.0",
1010
"@nextcloud/logger": "^3.0.2",
1111
"@nextcloud/moment": "^1.3.2",
12-
"@nextcloud/password-confirmation": "^5.3.1",
12+
"@nextcloud/password-confirmation": "^6.0.0-rc.0",
1313
"@nextcloud/router": "^3.0.1",
14-
"@nextcloud/vue": "^8.26.0",
14+
"@nextcloud/vue": "^9.0.0-rc.1",
1515
"@simplewebauthn/browser": "^13.1.0",
16-
"pinia": "^2.3.1",
17-
"vue": "^2.7.16",
18-
"vue-click-outside": "^1.1.0",
16+
"pinia": "^3.0.1",
17+
"vue": "^3.5.13",
1918
"vue-material-design-icons": "^5.3.1"
2019
},
2120
"devDependencies": {
2221
"@nextcloud/babel-config": "^1.2.0",
2322
"@nextcloud/eslint-config": "^8.4.2",
2423
"@nextcloud/webpack-vue-config": "^6.3.0",
2524
"@playwright/test": "^1.50.1",
26-
"@vue/test-utils": "^1.3.6",
25+
"@vue/test-utils": "^2.4.6",
2726
"chai": "^4.5.0",
2827
"jsdom": "^21.1.2",
2928
"jsdom-global": "^3.0.2",
3029
"mocha": "^10.8.2",
31-
"mochapack": "^2.1.5",
32-
"vue-template-compiler": "^2.7.16"
30+
"mochapack": "^2.1.5"
3331
},
3432
"scripts": {
3533
"dev": "webpack --node-env development --progress",

src/components/AddDeviceDialog.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
type="text"
3131
:placeholder="t('twofactor_webauthn', 'Name your security key')">
3232
<NcButton class="new-webauthn-device__button"
33-
native-type="submit"
33+
type="submit"
3434
:disabled="!name.length">
3535
{{ t('twofactor_webauthn', 'Add') }}
3636
</NcButton>

src/main-challenge.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6-
import Vue from 'vue'
7-
import { createPinia, PiniaVuePlugin } from 'pinia'
6+
import { createApp } from 'vue'
7+
import { createPinia } from 'pinia'
88
import Nextcloud from './mixins/Nextcloud.js'
99
import Challenge from './components/Challenge.vue'
1010
import { loadState } from '@nextcloud/initial-state'
1111
import { useMainStore } from './store.js'
1212

13-
Vue.mixin(Nextcloud)
14-
15-
Vue.use(PiniaVuePlugin)
1613
const pinia = createPinia()
1714

1815
const credentialRequestOptions = loadState('twofactor_webauthn', 'credential-request-options')
@@ -21,8 +18,7 @@ mainStore.$patch({
2118
credentialRequestOptions,
2219
})
2320

24-
export default new Vue({
25-
el: '#twofactor-webauthn-challenge',
26-
pinia,
27-
render: h => h(Challenge),
28-
})
21+
const app = createApp(Challenge)
22+
app.mixin(Nextcloud)
23+
app.use(pinia)
24+
app.mount('#twofactor-webauthn-challenge')

src/main-login-setup.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6-
import Vue from 'vue'
7-
import { createPinia, PiniaVuePlugin } from 'pinia'
6+
import { createApp } from 'vue'
7+
import { createPinia } from 'pinia'
88

99
import Nextcloud from './mixins/Nextcloud.js'
1010

1111
import LoginSetup from './components/LoginSetup.vue'
1212

13-
Vue.mixin(Nextcloud)
14-
15-
Vue.use(PiniaVuePlugin)
1613
const pinia = createPinia()
1714

18-
const View = Vue.extend(LoginSetup)
19-
new View({ pinia }).$mount('#twofactor-webauthn-login-setup')
15+
const app = createApp(LoginSetup)
16+
app.mixin(Nextcloud)
17+
app.use(pinia)
18+
app.mount('#twofactor-webauthn-login-setup')

src/main-settings.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,15 @@
44
*/
55

66
import { loadState } from '@nextcloud/initial-state'
7-
import Vue from 'vue'
8-
import { createPinia, PiniaVuePlugin } from 'pinia'
7+
import { createApp } from 'vue'
8+
import { createPinia } from 'pinia'
99

1010
import Nextcloud from './mixins/Nextcloud.js'
1111
import PersonalSettings from './components/PersonalSettings.vue'
1212
import { useMainStore } from './store.js'
1313

14-
import '@nextcloud/password-confirmation/dist/style.css'
14+
import '@nextcloud/password-confirmation/style.css'
1515

16-
Vue.mixin(Nextcloud)
17-
18-
Vue.use(PiniaVuePlugin)
1916
const pinia = createPinia()
2017

2118
const devices = loadState('twofactor_webauthn', 'devices')
@@ -33,10 +30,9 @@ mainStore.$patch({
3330
devices,
3431
})
3532

36-
const View = Vue.extend(PersonalSettings)
37-
new View({
38-
propsData: {
39-
httpWarning: document.location.protocol !== 'https:',
40-
},
41-
pinia,
42-
}).$mount('#twofactor-webauthn-settings')
33+
const app = createApp(PersonalSettings, {
34+
httpWarning: document.location.protocol !== 'https:',
35+
})
36+
app.mixin(Nextcloud)
37+
app.use(pinia)
38+
app.mount('#twofactor-webauthn-settings')

src/tests/unit/components/Device.spec.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,12 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6-
import { shallowMount, createLocalVue } from '@vue/test-utils'
6+
import { shallowMount } from '@vue/test-utils'
77
import Nextcloud from '../../../mixins/Nextcloud.js'
88
import Device from '../../../components/Device.vue'
9-
import { createPinia, PiniaVuePlugin, setActivePinia } from 'pinia'
9+
import { createPinia, setActivePinia } from 'pinia'
1010
import { useMainStore } from '../../../store.js'
1111

12-
const localVue = createLocalVue()
13-
14-
localVue.mixin(Nextcloud)
15-
localVue.use(PiniaVuePlugin)
16-
1712
describe('Device', () => {
1813
let pinia
1914

@@ -32,8 +27,10 @@ describe('Device', () => {
3227
})
3328

3429
const device = shallowMount(Device, {
35-
pinia,
36-
localVue,
30+
global: {
31+
plugins: [pinia],
32+
mixins: [Nextcloud],
33+
},
3734
})
3835

3936
expect(device.text()).to.have.string('Unnamed key')

src/tests/unit/components/PersonalSettings.spec.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,12 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6-
import { shallowMount, createLocalVue } from '@vue/test-utils'
7-
import { createPinia, PiniaVuePlugin, setActivePinia } from 'pinia'
6+
import { shallowMount } from '@vue/test-utils'
7+
import { createPinia, setActivePinia } from 'pinia'
88
import Nextcloud from '../../../mixins/Nextcloud.js'
99
import PersonalSettings from '../../../components/PersonalSettings.vue'
1010
import { useMainStore } from '../../../store.js'
1111

12-
const localVue = createLocalVue()
13-
14-
localVue.mixin(Nextcloud)
15-
localVue.use(PiniaVuePlugin)
16-
1712
describe('PersonalSettings', () => {
1813
let pinia
1914

@@ -24,8 +19,10 @@ describe('PersonalSettings', () => {
2419

2520
it('shows text if no devices are configured', () => {
2621
const settings = shallowMount(PersonalSettings, {
27-
pinia,
28-
localVue,
22+
global: {
23+
plugins: [pinia],
24+
mixins: [Nextcloud],
25+
},
2926
})
3027

3128
expect(settings.text()).to.contain('No security keys configured. You are not using WebAuthn as second factor at the moment.')
@@ -41,17 +38,21 @@ describe('PersonalSettings', () => {
4138
})
4239

4340
const settings = shallowMount(PersonalSettings, {
44-
pinia,
45-
localVue,
41+
global: {
42+
plugins: [pinia],
43+
mixins: [Nextcloud],
44+
},
4645
})
4746

4847
expect(settings.text()).to.not.contain('No security keys configured. You are not using WebAuthn as second factor at the moment.')
4948
})
5049

5150
it('shows a HTTP warning', () => {
5251
const settings = shallowMount(PersonalSettings, {
53-
pinia,
54-
localVue,
52+
global: {
53+
plugins: [pinia],
54+
mixins: [Nextcloud],
55+
},
5556
propsData: {
5657
httpWarning: true,
5758
},

src/tests/unit/setup.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@ require('jsdom-global')('', {
1111
})
1212
global.SVGElement = window.SVGElement
1313

14-
const t = (app, str) => str
15-
16-
require('vue').mixin({
17-
methods: {
18-
t,
19-
},
20-
})
21-
2214
global.expect = require('chai').expect
2315
global.OC = {
2416
getCurrentUser: () => {
@@ -34,7 +26,7 @@ global.OC = {
3426
return 'en'
3527
},
3628
}
37-
global.t = t
29+
global.t = (app, str) => str
3830

3931
// https://github.com/vuejs/vue-test-utils/issues/936
4032
// better fix for "TypeError: Super expression must either be null or

0 commit comments

Comments
 (0)