Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/OCP/toast.js')
-rw-r--r--core/src/OCP/toast.js114
1 files changed, 54 insertions, 60 deletions
diff --git a/core/src/OCP/toast.js b/core/src/OCP/toast.js
index 6bb3b130287..9fde3884987 100644
--- a/core/src/OCP/toast.js
+++ b/core/src/OCP/toast.js
@@ -1,6 +1,7 @@
-/*
+/**
* @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net>
*
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
@@ -20,70 +21,63 @@
*
*/
-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 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, 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, 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, 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, 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, options)
},
+
}
-export default Toast