Compare commits

...

3 commits

Author SHA1 Message Date
Christoph Wurst
efe52c96e3
fixup! Use external Toast implementation and deprecate the OCP API
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2020-03-03 10:01:10 +01:00
Christoph Wurst
f83c11e923
Inline usages of OCP.Toast in bundled files
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2020-02-14 18:09:55 +01:00
Christoph Wurst
efec045afe
Use external Toast implementation and deprecate the OCP API
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2020-02-14 18:06:20 +01:00
25 changed files with 84 additions and 84 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -70,7 +70,7 @@
import axios from '@nextcloud/axios'
import debounce from 'debounce'
import { generateOcsUrl } from '@nextcloud/router'
import { getFilePickerBuilder } from '@nextcloud/dialogs'
import { getFilePickerBuilder, showSuccess } from '@nextcloud/dialogs'
import { Multiselect } from '@nextcloud/vue/dist/Components/Multiselect'
import Vue from 'vue'
@ -210,7 +210,7 @@ export default {
this.directory = undefined
this.selectedUser = null
OCP.Toast.success(t('files', 'Ownership transfer request sent'))
showSuccess(t('files', 'Ownership transfer request sent'))
})
.catch(error => {
logger.error('Could not send ownership transfer request', { error })

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -28,6 +28,7 @@
<script>
import { Multiselect } from '@nextcloud/vue/dist/Components/Multiselect'
import { showWarning } from '@nextcloud/dialogs'
export default {
name: 'Event',
@ -57,7 +58,7 @@ export default {
methods: {
updateEvent(events) {
if (events.length === 0) {
window.OCP.Toast.warning(t('workflowengine', 'At least one event must be selected'))
showWarning(t('workflowengine', 'At least one event must be selected'))
return
}
const existingEntity = this.rule.entity

BIN
core/js/dist/login.js vendored

Binary file not shown.

Binary file not shown.

BIN
core/js/dist/main.js vendored

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -21,10 +21,11 @@
import _ from 'underscore'
import $ from 'jquery'
import { showMessage } from '@nextcloud/dialogs'
/**
* @todo Write documentation
* @deprecated 17.0.0 use OCP.Toast
* @deprecated 17.0.0 use the `@nextcloud/dialogs` package instead
* @namespace OC.Notification
*/
export default {
@ -35,7 +36,7 @@ export default {
/**
* @param {Function} callback callback function
* @deprecated 17.0.0 use OCP.Toast
* @deprecated 17.0.0 use the `@nextcloud/dialogs` package
*/
setDefault: function(callback) {
this.getDefaultNotificationFunction = callback
@ -49,7 +50,7 @@ export default {
*
* @param {jQuery} [$row] notification row
* @param {Function} [callback] callback
* @deprecated 17.0.0 use OCP.Toast
* @deprecated 17.0.0 use the `@nextcloud/dialogs` package
*/
hide: function($row, callback) {
if (_.isFunction($row)) {
@ -88,13 +89,13 @@ export default {
* @param {string} [options.type] notification type
* @param {int} [options.timeout=0] timeout value, defaults to 0 (permanent)
* @returns {jQuery} jQuery element for notification row
* @deprecated 17.0.0 use OCP.Toast
* @deprecated 17.0.0 use the `@nextcloud/dialogs` package
*/
showHtml: function(html, options) {
options = options || {}
options.isHTML = true
options.timeout = (!options.timeout) ? -1 : options.timeout
const toast = window.OCP.Toast.message(html, options)
const toast = showMessage(html, options)
return $(toast.toastElement)
},
@ -106,12 +107,12 @@ export default {
* @param {string} [options.type] notification type
* @param {int} [options.timeout=0] timeout value, defaults to 0 (permanent)
* @returns {jQuery} jQuery element for notification row
* @deprecated 17.0.0 use OCP.Toast
* @deprecated 17.0.0 use the `@nextcloud/dialogs` package
*/
show: function(text, options) {
options = options || {}
options.timeout = (!options.timeout) ? -1 : options.timeout
const toast = window.OCP.Toast.message(text, options)
const toast = showMessage(text, options)
return $(toast.toastElement)
},
@ -120,13 +121,13 @@ export default {
*
* @param {string} text Message to display
* @returns {jQuery} JQuery element for notificaiton row
* @deprecated 17.0.0 use OCP.Toast
* @deprecated 17.0.0 use the `@nextcloud/dialogs` package
*/
showUpdate: function(text) {
if (this.updatableNotification) {
this.updatableNotification.hideToast()
}
this.updatableNotification = OCP.Toast.message(text, { timeout: -1 })
this.updatableNotification = showMessage(text, { timeout: -1 })
return $(this.updatableNotification.toastElement)
},
@ -140,19 +141,19 @@ export default {
* @param {boolean} [options.isHTML=false] an indicator for HTML notifications (true) or text (false)
* @param {string} [options.type] notification type
* @returns {JQuery<any>} the toast element
* @deprecated 17.0.0 use OCP.Toast
* @deprecated 17.0.0 use the `@nextcloud/dialogs` package
*/
showTemporary: function(text, options) {
options = options || {}
options.timeout = options.timeout || 7
const toast = window.OCP.Toast.message(text, options)
const toast = showMessage(text, options)
return $(toast.toastElement)
},
/**
* Returns whether a notification is hidden.
* @returns {boolean}
* @deprecated 17.0.0 use OCP.Toast
* @deprecated 17.0.0 use the `@nextcloud/dialogs` package
*/
isHidden: function() {
return !$('#content').find('.toastify').length

View file

@ -1,13 +1,10 @@
/**
*
*/
import * as AppConfig from './appconfig'
import * as Comments from './comments'
import Loader from './loader'
import { loadState } from '@nextcloud/initial-state'
import Collaboration from './collaboration'
import Toast from './toast'
import * as WhatsNew from './whatsnew'
import Toast from './toast'
/** @namespace OCP */
export default {
@ -21,6 +18,9 @@ export default {
loadState,
},
Loader,
/**
* @deprecated 19.0.0 use the `@nextcloud/dialogs` package instead
*/
Toast,
WhatsNew,
}

View file

@ -20,70 +20,67 @@
*
*/
import Toastify from 'toastify-js'
import {
showError,
showInfo, showMessage,
showSuccess,
showWarning,
} from '@nextcloud/dialogs'
const TOAST_TYPE_CLASES = {
error: 'toast-error',
info: 'toast-info',
warning: 'toast-warning',
success: 'toast-success',
permanent: 'permanent',
const defaultOptions = {
selector: !window.TESTING ? 'content' : 'testArea',
}
const Toast = {
success(text, options = {}) {
options.type = 'success'
return this.message(text, options)
export default {
/**
* @deprecated 19.0.0 use `showSuccess` from the `@nextcloud/dialogs` package instead
*
* @param {string} text the toast text
* @param {object} options options
* @returns {Toast}
*/
success(text, options) {
return showSuccess(text, Object.assign({}, defaultOptions, options))
},
warning(text, options = {}) {
options.type = 'warning'
return this.message(text, options)
/**
* @deprecated 19.0.0 use `showWarning` from the `@nextcloud/dialogs` package instead
*
* @param {string} text the toast text
* @param {object} options options
* @returns {Toast}
*/
warning(text, options) {
return showWarning(text, Object.assign({}, defaultOptions, options))
},
error(text, options = {}) {
options.type = 'error'
return this.message(text, options)
/**
* @deprecated 19.0.0 use `showError` from the `@nextcloud/dialogs` package instead
*
* @param {string} text the toast text
* @param {object} options options
* @returns {Toast}
*/
error(text, options) {
return showError(text, Object.assign({}, defaultOptions, options))
},
info(text, options = {}) {
options.type = 'info'
return this.message(text, options)
/**
* @deprecated 19.0.0 use `showInfo` from the `@nextcloud/dialogs` package instead
*
* @param {string} text the toast text
* @param {object} options options
* @returns {Toast}
*/
info(text, options) {
return showInfo(text, Object.assign({}, defaultOptions, options))
},
/**
* @deprecated 19.0.0 use `showMessage` from the `@nextcloud/dialogs` package instead
*
* @param {string} text the toast text
* @param {object} options options
* @returns {Toast}
*/
message(text, options) {
options = options || {}
_.defaults(options, {
timeout: 7,
isHTML: false,
type: undefined,
close: true,
callback: () => {},
})
if (!options.isHTML) {
text = $('<div/>').text(text).html()
}
let classes = ''
if (options.type) {
classes = TOAST_TYPE_CLASES[options.type]
}
const toast = Toastify({
text: text,
duration: options.timeout ? options.timeout * 1000 : null,
callback: options.callback,
close: options.close,
gravity: 'top',
selector: !window.TESTING ? 'content' : 'testArea',
positionLeft: false,
backgroundColor: '',
className: 'toast ' + classes,
})
toast.showToast()
// add toastify object to the element for reference in legacy OC.Notification
toast.toastElement.toastify = toast
return toast
return showMessage(text, Object.assign({}, defaultOptions, options))
},
}
export default Toast

15
package-lock.json generated
View file

@ -3003,17 +3003,18 @@
"integrity": "sha512-f+sKpdLZXkODV+OY39K1M+Spmd4RgxmtEXmNn4Bviv4R7uBFHXuw+JX9ZdfDeOryfHjJ/TRQxQEp0GMpBwZFUw=="
},
"@nextcloud/dialogs": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@nextcloud/dialogs/-/dialogs-1.0.0.tgz",
"integrity": "sha512-CV7sCJg37866j4ilNnf4PwvN2jNq6qZu+/cIdXLUZHUmK4HOfsSCqBmVqsf83Nq95VR6p/lCF1K1YbCvQG/P+g==",
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@nextcloud/dialogs/-/dialogs-1.2.0.tgz",
"integrity": "sha512-yB2GRzgiIlGg02XAD9A9yTKhPhI6MTqHdOc6T6xIs8IBmlHJrCRcL1e6kBKUTQ4GXVzYDU8JFZ5b88RSiEwS1w==",
"requires": {
"core-js": "3.5.0"
"core-js": "3.6.4",
"toastify-js": "^1.6.2"
},
"dependencies": {
"core-js": {
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.5.0.tgz",
"integrity": "sha512-Ifh3kj78gzQ7NAoJXeTu+XwzDld0QRIwjBLRqAMhuLhP3d2Av5wmgE9ycfnvK6NAEjTkQ1sDPeoEZAWO3Hx1Uw=="
"version": "3.6.4",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.6.4.tgz",
"integrity": "sha512-4paDGScNgZP2IXXilaffL9X7968RuvwlkK3xWtZRVqgd8SYNiVKRJvkFd1aqqEuPfN7E68ZHEp9hDj6lHj4Hyw=="
}
}
},

View file

@ -29,7 +29,7 @@
"@chenfengyuan/vue-qrcode": "^1.0.2",
"@nextcloud/auth": "^1.2.1",
"@nextcloud/axios": "^1.3.1",
"@nextcloud/dialogs": "^1.0.0",
"@nextcloud/dialogs": "^1.2.0",
"@nextcloud/event-bus": "^1.1.2",
"@nextcloud/initial-state": "^1.1.0",
"@nextcloud/l10n": "^1.0.1",