Skip to content

Commit e51c643

Browse files
Don't use deprecated globals
Signed-off-by: Raimund Schlüßler <raimund.schluessler@mailbox.org> See nextcloud/documentation#1950
1 parent b05dd7e commit e51c643

10 files changed

Lines changed: 50 additions & 19 deletions

File tree

package-lock.json

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

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
"contributors": [],
2727
"dependencies": {
2828
"@nextcloud/axios": "^1.3.2",
29+
"@nextcloud/dialogs": "1.2.2",
30+
"@nextcloud/router": "1.0.2",
2931
"@nextcloud/vue": "1.4.1",
3032
"@vue/test-utils": "^1.0.0-beta.32",
3133
"cdav-library": "github:nextcloud/cdav-library",

src/components/AppNavigation/CalendarSharee.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ import ActionButton from '@nextcloud/vue/dist/Components/ActionButton'
6161
import ActionCheckbox from '@nextcloud/vue/dist/Components/ActionCheckbox'
6262
import AppNavigationItem from '@nextcloud/vue/dist/Components/AppNavigationItem'
6363
import Avatar from '@nextcloud/vue/dist/Components/Avatar'
64+
import { showError } from '@nextcloud/dialogs'
6465
6566
export default {
6667
name: 'CalendarSharee',
@@ -107,7 +108,7 @@ export default {
107108
})
108109
} catch (error) {
109110
console.error(error)
110-
this.$OC.Notification.showTemporary(this.$t('tasks', 'Unable to delete the share.'))
111+
showError(this.$t('tasks', 'Unable to delete the share.'))
111112
} finally {
112113
this.loading = false
113114
}
@@ -125,7 +126,7 @@ export default {
125126
})
126127
} catch (error) {
127128
console.error(error)
128-
this.$OC.Notification.showTemporary(this.$t('tasks', 'Unable to change permissions.'))
129+
showError(this.$t('tasks', 'Unable to change permissions.'))
129130
} finally {
130131
this.loading = false
131132
}

src/components/AppNavigation/ListItemCalendar.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ import AppNavigationIconBullet from '@nextcloud/vue/dist/Components/AppNavigatio
136136
import Actions from '@nextcloud/vue/dist/Components/Actions'
137137
import ActionButton from '@nextcloud/vue/dist/Components/ActionButton'
138138
import ActionLink from '@nextcloud/vue/dist/Components/ActionLink'
139+
import { generateRemoteUrl } from '@nextcloud/router'
140+
import { showSuccess, showError } from '@nextcloud/dialogs'
139141
140142
const CD_DURATION = 7
141143
@@ -227,7 +229,7 @@ export default {
227229
return url
228230
},
229231
url() {
230-
const rootURL = this.$OC.linkToRemote('dav')
232+
const rootURL = generateRemoteUrl('dav')
231233
return new URL(this.calendar.url, rootURL)
232234
},
233235
hasShares() {
@@ -400,11 +402,11 @@ export default {
400402
this.copySuccess = true
401403
this.copied = true
402404
// Notify calendar url was copied
403-
this.$OC.Notification.showTemporary(this.$t('tasks', 'Calendar link copied to clipboard.'))
405+
showSuccess(this.$t('tasks', 'Calendar link copied to clipboard.'))
404406
}, e => {
405407
this.copySuccess = false
406408
this.copied = true
407-
this.$OC.Notification.showTemporary(this.$t('tasks', 'Calendar link could not be copied to clipboard.'))
409+
showError(this.$t('tasks', 'Calendar link could not be copied to clipboard.'))
408410
}).then(() => {
409411
setTimeout(() => {
410412
// stop loading status regardless of outcome
@@ -473,7 +475,7 @@ export default {
473475
try {
474476
await this.deleteCalendar(this.calendar)
475477
} catch (error) {
476-
this.$toast.error(this.$t('tasks', 'An error occurred, unable to delete the calendar.'))
478+
showError(this.$t('tasks', 'An error occurred, unable to delete the calendar.'))
477479
console.error(error)
478480
} finally {
479481
clearInterval(this.deleteInterval)

src/components/TaskBody.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ import TaskDragContainer from './TaskDragContainer'
160160
161161
import Actions from '@nextcloud/vue/dist/Components/Actions'
162162
import ActionButton from '@nextcloud/vue/dist/Components/ActionButton'
163+
import { showError } from '@nextcloud/dialogs'
163164
164165
const CD_DURATION = 7
165166
@@ -402,7 +403,7 @@ export default {
402403
}
403404
await this.deleteTask({ task: this.task, dav: true })
404405
} catch (error) {
405-
this.$toast.error(this.$t('tasks', 'An error occurred, unable to delete the task.'))
406+
showError(this.$t('tasks', 'An error occurred, unable to delete the task.'))
406407
console.error(error)
407408
} finally {
408409
clearInterval(this.deleteInterval)

src/main.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import store from './store/store'
2929
import { sync } from 'vuex-router-sync'
3030
import VTooltip from 'v-tooltip'
3131
import VueClipboard from 'vue-clipboard2'
32+
import { linkTo } from '@nextcloud/router'
3233

3334
// Disable on production
3435
Vue.config.devtools = true
@@ -39,11 +40,11 @@ Vue.config.performance = true
3940
__webpack_nonce__ = btoa(OC.requestToken)
4041

4142
// Correct the root of the app for chunk loading
42-
// OC.linkTo matches the apps folders
43-
// OC.generateUrl ensure the index.php (or not)
43+
// linkTo matches the apps folders
44+
// generateUrl ensure the index.php (or not)
4445
// We do not want the index.php since we're loading files
4546
// eslint-disable-next-line
46-
__webpack_public_path__ = OC.linkTo('tasks', 'js/')
47+
__webpack_public_path__ = linkTo('tasks', 'js/')
4748

4849
sync(store, router)
4950

@@ -68,7 +69,6 @@ Vue.prototype.n = Vue.prototype.$n
6869
Vue.prototype.$OC = OC
6970
Vue.prototype.$OCA = OCA
7071
Vue.prototype.$appVersion = $appVersion
71-
Vue.prototype.$toast = OCP.Toast // eslint-disable-line no-undef
7272

7373
OCA.Tasks.$t = Vue.prototype.$t
7474
OCA.Tasks.$n = Vue.prototype.$n

src/services/cdav.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
*/
2222

2323
import DavClient from 'cdav-library'
24+
import { generateRemoteUrl } from '@nextcloud/router'
2425

2526
function xhrProvider() {
2627
const headers = {
@@ -43,5 +44,5 @@ function xhrProvider() {
4344
}
4445

4546
export default new DavClient({
46-
rootUrl: OC.linkToRemote('dav'),
47+
rootUrl: generateRemoteUrl('dav'),
4748
}, xhrProvider)

src/store/collections.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import Vue from 'vue'
2424
import Vuex from 'vuex'
25+
import { generateUrl } from '@nextcloud/router'
2526
import Requests from '../services/requests'
2627

2728
import { isTaskInList, searchSubTasks } from './storeHelper'
@@ -100,7 +101,7 @@ const actions = {
100101
*/
101102
loadCollections({ commit }) {
102103
return new Promise(function(resolve) {
103-
Requests.get(OC.generateUrl('apps/tasks/collections'))
104+
Requests.get(generateUrl('apps/tasks/collections'))
104105
.then(response => {
105106
commit('setCollections', {
106107
collections: response.data.data.collections,
@@ -120,7 +121,7 @@ const actions = {
120121
setVisibility(context, collection) {
121122
context.commit('setVisibility', collection)
122123
return new Promise(function() {
123-
Requests.post(OC.generateUrl('apps/tasks/collection/{id}/visibility/{show}', collection), {})
124+
Requests.post(generateUrl('apps/tasks/collection/{id}/visibility/{show}', collection), {})
124125
})
125126
},
126127
}

src/store/settings.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import Vue from 'vue'
2525
import Vuex from 'vuex'
2626
import Requests from '../services/requests'
27+
import { generateUrl } from '@nextcloud/router'
2728

2829
Vue.use(Vuex)
2930

@@ -90,7 +91,7 @@ const actions = {
9091
setSetting(context, payload) {
9192
context.commit('setSetting', payload)
9293
return new Promise(function() {
93-
Requests.post(OC.generateUrl('apps/tasks/settings/{type}/{value}', payload), {})
94+
Requests.post(generateUrl('apps/tasks/settings/{type}/{value}', payload), {})
9495
})
9596
},
9697

@@ -102,7 +103,7 @@ const actions = {
102103
*/
103104
loadSettings({ commit }) {
104105
return new Promise(function(resolve) {
105-
Requests.get(OC.generateUrl('apps/tasks/settings'))
106+
Requests.get(generateUrl('apps/tasks/settings'))
106107
.then(response => {
107108
commit('setSettings', {
108109
settings: response.data.data.settings,

src/store/tasks.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import ICAL from 'ical.js'
2828
import TaskStatus from '../models/taskStatus'
2929
import router from '../router'
3030
import { findVTODObyUid } from './cdav-requests'
31+
import { showError } from '@nextcloud/dialogs'
3132

3233
Vue.use(Vuex)
3334

@@ -1205,7 +1206,7 @@ const actions = {
12051206
})
12061207
.catch((error) => {
12071208
console.error(error)
1208-
OC.Notification.showTemporary(OCA.Tasks.$t('tasks', 'An error occurred'))
1209+
showError(OCA.Tasks.$t('tasks', 'An error occurred'))
12091210
})
12101211
}
12111212

0 commit comments

Comments
 (0)