Skip to content

Commit 151d809

Browse files
Migrate to vue3
Signed-off-by: Raimund Schlüßler <[email protected]>
1 parent 076c7ba commit 151d809

29 files changed

+1721
-2146
lines changed

package-lock.json

+1,390-1,829
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+13-15
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
"@nextcloud/logger": "^2.3.0",
3838
"@nextcloud/moment": "^1.2.1",
3939
"@nextcloud/router": "^2.0.0",
40-
"@nextcloud/vue": "^6.0.0",
40+
"@nextcloud/vue": "github:nextcloud/nextcloud-vue#vue3",
41+
"click-outside-vue3": "^4.0.1",
4142
"color-convert": "^2.0.1",
4243
"debounce": "^1.2.1",
4344
"ical.js": "^1.5.0",
@@ -51,23 +52,20 @@
5152
"p-limit": "^4.0.0",
5253
"p-queue": "^6.6.2",
5354
"uuid": "^8.3.2",
54-
"v-click-outside": "^3.2.0",
55-
"vue": "^2.7.13",
55+
"vue": "^3.2.39",
5656
"vue-material-design-icons": "^5.1.2",
57-
"vue-router": "^3.6.5",
58-
"vuedraggable": "^2.24.3",
59-
"vuex": "^3.6.2",
60-
"vuex-router-sync": "^5.0.0"
57+
"vue-router": "^4.1.5",
58+
"vuedraggable": "^4.1.0",
59+
"vuex": "^4.0.2"
6160
},
6261
"devDependencies": {
63-
"@nextcloud/babel-config": "^1.0.0-beta.1",
62+
"@nextcloud/babel-config": "^1.0.0",
6463
"@nextcloud/browserslist-config": "^2.3.0",
65-
"@nextcloud/eslint-config": "^8.1.2",
64+
"@nextcloud/eslint-config": "github:nextcloud/eslint-config#vue3",
6665
"@nextcloud/stylelint-config": "^2.3.0",
67-
"@nextcloud/webpack-vue-config": "^5.3.0",
68-
"@vue/test-utils": "^1.3.0",
69-
"@vue/vue2-jest": "^29.1.1",
70-
"babel-core": "^7.0.0-bridge.0",
66+
"@nextcloud/webpack-vue-config": "github:nextcloud/webpack-vue-config#vue3",
67+
"@vue/test-utils": "^2.1.0",
68+
"@vue/vue3-jest": "^29.1.1",
7169
"babel-jest": "^29.2.1",
7270
"jest": "^29.2.1",
7371
"jest-environment-jsdom": "^29.2.1",
@@ -100,11 +98,11 @@
10098
"testEnvironment": "jsdom",
10199
"transform": {
102100
"^.+\\.js$": "<rootDir>/node_modules/babel-jest",
103-
"^.+\\.vue$": "<rootDir>/node_modules/@vue/vue2-jest",
101+
"^.+\\.vue$": "<rootDir>/node_modules/@vue/vue3-jest",
104102
".+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": "jest-transform-stub"
105103
},
106104
"transformIgnorePatterns": [
107-
"/node_modules/(?!(.*vue-material-design-icons)|(uuid))"
105+
"/node_modules/(?!(.*vue-material-design-icons|.*vue-multiselect)|(uuid))"
108106
],
109107
"snapshotSerializers": [
110108
"<rootDir>/node_modules/jest-serializer-vue"

src/App.vue

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
2121

2222
<template>
2323
<NcContent app-name="tasks">
24-
<AppNavigation @click.native="closeAppSidebar($event)" />
24+
<AppNavigation @click="closeAppSidebar($event)" />
2525

26-
<NcAppContent @click.native="closeAppSidebar($event)">
26+
<NcAppContent @click="closeAppSidebar($event)">
2727
<RouterView />
2828
</NcAppContent>
2929

@@ -49,6 +49,7 @@ export default {
4949
NcAppContent,
5050
NcContent,
5151
},
52+
inject: ['$OCA'],
5253
data() {
5354
return {
5455
searchString: '',

src/components/AppNavigation/ListItemCalendar.vue

+6-6
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
2727
:title="calendar.displayName"
2828
:class="{'list--edit': editing, 'list--deleted': !!deleteTimeout}"
2929
class="list reactive"
30-
@drop.native="dropTask"
31-
@dragover.native="dragOver"
32-
@dragenter.native="dragEnter"
33-
@dragleave.native="dragLeave">
30+
@drop="dropTask"
31+
@dragover="dragOver"
32+
@dragenter="dragEnter"
33+
@dragleave="dragLeave">
3434
<template #icon>
3535
<NcAppNavigationIconBullet :color="calendar.color" />
3636
</template>
@@ -111,6 +111,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
111111
<ShareCalendar v-if="shareOpen && !calendar.readOnly && !deleteTimeout" :calendar="calendar" />
112112
<div v-if="!deleteTimeout" :class="{error: nameError}" class="app-navigation-entry-edit">
113113
<NcTextField ref="editListInput"
114+
v-model:value="newCalendarName"
114115
v-tooltip="{
115116
content: tooltipMessage,
116117
shown: showTooltip('list_' + calendar.id),
@@ -119,7 +120,6 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
119120
type="text"
120121
:show-trailing-button="newCalendarName !== ''"
121122
trailing-button-icon="arrowRight"
122-
:value.sync="newCalendarName"
123123
:error="nameError"
124124
:placeholder="t('tasks', 'Save')"
125125
@trailing-button-click="save(calendar)"
@@ -157,7 +157,7 @@ import Pencil from 'vue-material-design-icons/Pencil.vue'
157157
import ShareVariant from 'vue-material-design-icons/ShareVariant.vue'
158158
import Undo from 'vue-material-design-icons/Undo.vue'
159159

160-
import ClickOutside from 'v-click-outside'
160+
import ClickOutside from 'click-outside-vue3'
161161
import { mapGetters, mapActions } from 'vuex'
162162

163163
const CD_DURATION = 7

src/components/AppNavigation/Trashbin.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
5454
<div class="table__header">
5555
&nbsp;
5656
</div>
57-
<template v-for="item in items">
58-
<div :key="`${item.url}desc`" class="table__body">
57+
<template v-for="item in items" :key="`${item.url}body`">
58+
<div class="table__body">
5959
<div class="icon-bullet"
6060
:style="{ 'background-color': item.color }" />
6161
<div class="item-description">
@@ -67,10 +67,10 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
6767
</div>
6868
</div>
6969
</div>
70-
<div :key="`${item.url}date`" class="table__body table__body--deletedAt">
70+
<div class="table__body table__body--deletedAt">
7171
<Moment class="timestamp" :timestamp="item.deletedAt" />
7272
</div>
73-
<div :key="`${item.url}action`" class="table__body">
73+
<div class="table__body">
7474
<NcButton @click="restore(item)">
7575
<template #icon>
7676
<Undo :size="20" />

src/components/AppSidebar/NotesItem.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
3434
<pre><span>{{ newValue }}</span><br><br></pre>
3535
<textarea ref="note__editor"
3636
v-model="newValue"
37-
@keyup.27="setEditing(false)"
37+
@keyup.escape="setEditing(false)"
3838
@keydown.enter.ctrl.prevent="setValue()"
3939
@change="setValue()" />
4040
</div>
@@ -53,7 +53,7 @@ import Mila from 'markdown-it-link-attributes'
5353
import MarkdownItEmoji from 'markdown-it-emoji'
5454
import Mitl from 'markdown-it-task-lists'
5555

56-
import ClickOutside from 'v-click-outside'
56+
import ClickOutside from 'click-outside-vue3'
5757

5858
export default {
5959
name: 'NotesItem',

src/components/AppSidebar/SliderItem.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
3939
type="number"
4040
:min="minValue"
4141
:max="maxValue"
42-
@keyup.27="setEditing(false)"
42+
@keyup.escape="setEditing(false)"
4343
@keydown.enter.prevent="setValue()">
4444
<input v-model="newValue"
4545
type="range"

src/components/HeaderBar.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
2929
:placeholder="placeholder"
3030
autocomplete="off"
3131
class="reactive"
32-
@keyup.27="clearNewTask($event)">
32+
@keyup.escape="clearNewTask($event)">
3333
</form>
3434
</div>
3535
<SortorderDropdown />

src/components/TaskBody.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
151151
v-model="newTaskName"
152152
:placeholder="subtasksCreationPlaceholder"
153153
:disabled="isAddingTask"
154-
@keyup.27="showSubtaskInput = false">
154+
@keyup.escape="showSubtaskInput = false">
155155
</form>
156156
</div>
157157
<TaskDragContainer :tasks="filteredSubtasksShown"
@@ -188,7 +188,7 @@ import CalendarClock from 'vue-material-design-icons/CalendarClock.vue'
188188
import Star from 'vue-material-design-icons/Star.vue'
189189
import Undo from 'vue-material-design-icons/Undo.vue'
190190

191-
import ClickOutside from 'v-click-outside'
191+
import ClickOutside from 'click-outside-vue3'
192192
import { mapGetters, mapActions, mapMutations } from 'vuex'
193193

194194
export default {

src/components/TaskDragContainer.vue

+10-11
Original file line numberDiff line numberDiff line change
@@ -20,41 +20,40 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
2020
-->
2121

2222
<template>
23-
<draggable tag="ol"
23+
<!-- <draggable tag="ol"
2424
:list="['']"
2525
:set-data="setDragData"
2626
v-bind="{group: 'tasks', swapThreshold: 0.30, delay: 500, delayOnTouchOnly: true, touchStartThreshold: 3, disabled: disabled, filter: '.readOnly'}"
2727
:move="onMove"
2828
@add="onAdd"
29-
@end="onEnd">
29+
@end="onEnd"> -->
30+
<ol>
3031
<TaskBody v-for="task in sortedTasks"
3132
:key="task.key"
3233
:task="task"
3334
:collection-string="collectionString" />
34-
</draggable>
35+
</ol>
36+
<!-- </draggable> -->
3537
</template>
3638

3739
<script>
3840
import Task from '../models/task.js'
3941
import { sort } from '../store/storeHelper.js'
4042

41-
import draggable from 'vuedraggable'
43+
// import draggable from 'vuedraggable'
4244
import { mapGetters, mapActions, mapMutations } from 'vuex'
45+
import { defineAsyncComponent } from 'vue'
4346

4447
export default {
4548
name: 'TaskDragContainer',
4649
components: {
4750
/**
4851
* We asynchronously import here, because we have a circular dependency
4952
* between TaskDragContainer and TaskBody which otherwise cannot be resolved.
50-
* See https://vuejs.org/v2/guide/components-edge-cases.html#Circular-References-Between-Components
51-
*
52-
* We load it "eager", because the TaskBody will always be required.
53-
*
54-
* @return {object} The TaskBody component
53+
* See https://vuejs.org/guide/components/async.html#basic-usage
5554
*/
56-
TaskBody: () => import(/* webpackMode: "eager" */ './TaskBody.vue'),
57-
draggable,
55+
TaskBody: defineAsyncComponent(() => import('./TaskBody.vue')),
56+
// draggable,
5857
},
5958
props: {
6059
tasks: {

src/dashboard.js

+5-17
Original file line numberDiff line numberDiff line change
@@ -29,32 +29,20 @@ import './css/dashboard.scss'
2929

3030
import { generateFilePath } from '@nextcloud/router'
3131
import { getRequestToken } from '@nextcloud/auth'
32-
import { translate as t, translatePlural as n } from '@nextcloud/l10n'
3332

34-
import Vue from 'vue'
35-
import Vuex from 'vuex'
36-
37-
Vue.use(Vuex)
33+
import { createApp } from 'vue'
3834

3935
// eslint-disable-next-line
4036
__webpack_nonce__ = btoa(getRequestToken())
4137

4238
// eslint-disable-next-line
4339
__webpack_public_path__ = generateFilePath('tasks', '', 'js/')
4440

45-
Vue.prototype.t = t
46-
Vue.prototype.n = n
47-
Vue.prototype.$OC = OC
48-
Vue.prototype.$OCA = OCA
49-
Vue.prototype.$appVersion = appVersion
50-
5141
document.addEventListener('DOMContentLoaded', () => {
5242
OCA.Dashboard.register('tasks', (el) => {
53-
const View = Vue.extend(Dashboard)
54-
const vm = new View({
55-
propsData: {},
56-
store,
57-
}).$mount(el)
58-
return vm
43+
const item = createApp(Dashboard)
44+
.use(store)
45+
.mount(el)
46+
return item
5947
})
6048
})

src/helpers/selector.js

+9-15
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,21 @@
2525
*/
2626
import store from '../store/store.js'
2727

28-
import Vue from 'vue'
28+
import { createApp } from 'vue'
2929

3030
const buildSelector = (selector, propsData = {}) => {
3131
return new Promise((resolve, reject) => {
3232
const container = document.createElement('div')
3333
document.getElementById('body-user').append(container)
34-
const View = Vue.extend(selector)
35-
const ComponentVM = new View({
36-
propsData,
37-
store,
38-
}).$mount(container)
39-
ComponentVM.$root.$on('close', () => {
40-
ComponentVM.$el.remove()
41-
ComponentVM.$destroy()
42-
reject(new Error('Selection canceled'))
43-
})
44-
ComponentVM.$root.$on('select', (id) => {
45-
ComponentVM.$el.remove()
46-
ComponentVM.$destroy()
47-
resolve(id)
34+
const dialog = createApp(selector, {
35+
...propsData,
36+
onClose() {
37+
dialog.$el.remove()
38+
reject(new Error('Selection canceled'))
39+
},
4840
})
41+
.use(store)
42+
.mount(container)
4943
})
5044
}
5145

0 commit comments

Comments
 (0)