Skip to content

Commit c47e71b

Browse files
committed
lazy load dashboard widget and reference widget
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
1 parent efb444e commit c47e71b

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

src/dashboard.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* jshint esversion: 6 */
2-
31
/**
42
* Nextcloud - zammad
53
*
@@ -11,17 +9,17 @@
119
* @copyright Julien Veyssier 2020
1210
*/
1311

14-
import Vue from 'vue'
15-
import './bootstrap.js'
16-
import Dashboard from './views/Dashboard.vue'
17-
18-
document.addEventListener('DOMContentLoaded', function() {
12+
__webpack_nonce__ = btoa(OC.requestToken) // eslint-disable-line
13+
__webpack_public_path__ = OC.linkTo('integration_zammad', 'js/') // eslint-disable-line
1914

20-
OCA.Dashboard.register('zammad_notifications', (el, { widget }) => {
15+
document.addEventListener('DOMContentLoaded', () => {
16+
OCA.Dashboard.register('zammad_notifications', async (el, { widget }) => {
17+
const { default: Vue } = await import(/* webpackChunkName: "dashboard-lazy" */'vue')
18+
const { default: Dashboard } = await import(/* webpackChunkName: "dashboard-lazy" */'./views/Dashboard.vue')
19+
Vue.mixin({ methods: { t, n } })
2120
const View = Vue.extend(Dashboard)
2221
new View({
2322
propsData: { title: widget.title },
2423
}).$mount(el)
2524
})
26-
2725
})

src/reference.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@
2020
*/
2121

2222
import { registerWidget } from '@nextcloud/vue-richtext'
23-
import './bootstrap.js'
24-
import Vue from 'vue'
25-
import ReferenceZammadWidget from './views/ReferenceZammadWidget.vue'
2623

27-
registerWidget('integration_zammad', (el, { richObjectType, richObject, accessible }) => {
24+
__webpack_nonce__ = btoa(OC.requestToken) // eslint-disable-line
25+
__webpack_public_path__ = OC.linkTo('integration_zammad', 'js/') // eslint-disable-line
26+
27+
registerWidget('integration_zammad', async (el, { richObjectType, richObject, accessible }) => {
28+
const { default: Vue } = await import(/* webpackChunkName: "reference-lazy" */'vue')
29+
const { default: ReferenceZammadWidget } = await import(/* webpackChunkName: "reference-lazy" */'./views/ReferenceZammadWidget.vue')
30+
Vue.mixin({ methods: { t, n } })
2831
const Widget = Vue.extend(ReferenceZammadWidget)
2932
new Widget({
3033
propsData: {

0 commit comments

Comments
 (0)