Use external Toast implementation and deprecate the OCP API
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
parent
1d62b9786f
commit
01a70e5d0f
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,13 +1,10 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
import * as AppConfig from './appconfig'
|
import * as AppConfig from './appconfig'
|
||||||
import * as Comments from './comments'
|
import * as Comments from './comments'
|
||||||
import Loader from './loader'
|
import Loader from './loader'
|
||||||
import { loadState } from '@nextcloud/initial-state'
|
import { loadState } from '@nextcloud/initial-state'
|
||||||
import Collaboration from './collaboration'
|
import Collaboration from './collaboration'
|
||||||
import Toast from './toast'
|
|
||||||
import * as WhatsNew from './whatsnew'
|
import * as WhatsNew from './whatsnew'
|
||||||
|
import Toast from './toast'
|
||||||
|
|
||||||
/** @namespace OCP */
|
/** @namespace OCP */
|
||||||
export default {
|
export default {
|
||||||
|
@ -21,6 +18,9 @@ export default {
|
||||||
loadState,
|
loadState,
|
||||||
},
|
},
|
||||||
Loader,
|
Loader,
|
||||||
|
/**
|
||||||
|
* @deprecated 19.0.0 use the `@nextcloud/dialogs` package instead
|
||||||
|
*/
|
||||||
Toast,
|
Toast,
|
||||||
WhatsNew,
|
WhatsNew,
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,70 +20,63 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Toastify from 'toastify-js'
|
import {
|
||||||
|
showError,
|
||||||
|
showInfo, showMessage,
|
||||||
|
showSuccess,
|
||||||
|
showWarning,
|
||||||
|
} from '@nextcloud/dialogs'
|
||||||
|
|
||||||
const TOAST_TYPE_CLASES = {
|
export default {
|
||||||
error: 'toast-error',
|
/**
|
||||||
info: 'toast-info',
|
* @deprecated 19.0.0 use `showSuccess` from the `@nextcloud/dialogs` package instead
|
||||||
warning: 'toast-warning',
|
*
|
||||||
success: 'toast-success',
|
* @param {string} text the toast text
|
||||||
permanent: 'permanent',
|
* @param {object} options options
|
||||||
}
|
* @returns {Toast}
|
||||||
|
*/
|
||||||
const Toast = {
|
success(text, options) {
|
||||||
|
return showSuccess(text, options)
|
||||||
success(text, options = {}) {
|
|
||||||
options.type = 'success'
|
|
||||||
return this.message(text, options)
|
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
warning(text, options = {}) {
|
* @deprecated 19.0.0 use `showWarning` from the `@nextcloud/dialogs` package instead
|
||||||
options.type = 'warning'
|
*
|
||||||
return this.message(text, options)
|
* @param {string} text the toast text
|
||||||
|
* @param {object} options options
|
||||||
|
* @returns {Toast}
|
||||||
|
*/
|
||||||
|
warning(text, options) {
|
||||||
|
return showWarning(text, options)
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
error(text, options = {}) {
|
* @deprecated 19.0.0 use `showError` from the `@nextcloud/dialogs` package instead
|
||||||
options.type = 'error'
|
*
|
||||||
return this.message(text, options)
|
* @param {string} text the toast text
|
||||||
|
* @param {object} options options
|
||||||
|
* @returns {Toast}
|
||||||
|
*/
|
||||||
|
error(text, options) {
|
||||||
|
return showError(text, options)
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
info(text, options = {}) {
|
* @deprecated 19.0.0 use `showInfo` from the `@nextcloud/dialogs` package instead
|
||||||
options.type = 'info'
|
*
|
||||||
return this.message(text, options)
|
* @param {string} text the toast text
|
||||||
|
* @param {object} options options
|
||||||
|
* @returns {Toast}
|
||||||
|
*/
|
||||||
|
info(text, options) {
|
||||||
|
return showInfo(text, 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) {
|
message(text, options) {
|
||||||
options = options || {}
|
return showMessage(text, 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
|
|
||||||
},
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
export default Toast
|
|
||||||
|
|
|
@ -1816,11 +1816,6 @@
|
||||||
"toastify-js": "^1.7.0"
|
"toastify-js": "^1.7.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core-js": {
|
|
||||||
"version": "3.6.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.6.4.tgz",
|
|
||||||
"integrity": "sha512-4paDGScNgZP2IXXilaffL9X7968RuvwlkK3xWtZRVqgd8SYNiVKRJvkFd1aqqEuPfN7E68ZHEp9hDj6lHj4Hyw=="
|
|
||||||
},
|
|
||||||
"toastify-js": {
|
"toastify-js": {
|
||||||
"version": "1.7.0",
|
"version": "1.7.0",
|
||||||
"resolved": "https://registry.npmjs.org/toastify-js/-/toastify-js-1.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/toastify-js/-/toastify-js-1.7.0.tgz",
|
||||||
|
|
Loading…
Reference in New Issue