okay then
This commit is contained in:
parent
ddeef1acae
commit
83c28e2649
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -78,7 +78,7 @@ BdApi.getCore = function () {
|
|||
* @param {string} content - a string of text to display in the modal
|
||||
*/
|
||||
BdApi.alert = function (title, content) {
|
||||
Utils.showConfirmationModal(title, content, {cancelText: null});
|
||||
return Utils.showConfirmationModal(title, content, {cancelText: null});
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -91,9 +91,11 @@ BdApi.alert = function (title, content) {
|
|||
* @param {string} [options.cancelText=Cancel] - text for the cancel button
|
||||
* @param {callable} [options.onConfirm=NOOP] - callback to occur when clicking the submit button
|
||||
* @param {callable} [options.onCancel=NOOP] - callback to occur when clicking the cancel button
|
||||
* @param {string} [options.key] - key used to identify the modal. If not provided, one is generated and returned
|
||||
* @returns {string} - the key used for this modal
|
||||
*/
|
||||
BdApi.showConfirmationModal = function (title, content, options = {}) {
|
||||
Utils.showConfirmationModal(title, content, options);
|
||||
return Utils.showConfirmationModal(title, content, options);
|
||||
};
|
||||
|
||||
//Show toast alert
|
||||
|
|
|
@ -360,7 +360,7 @@ export default class Utils {
|
|||
return ce(FlexChild.Child, {grow: 1, shrink: 1}, footer ? footer : defaultFooter);
|
||||
};
|
||||
|
||||
ModalStack.push(function(props) {
|
||||
return ModalStack.push(function(props) {
|
||||
return ce(Changelog, Object.assign({
|
||||
className: ChangelogClasses.container,
|
||||
selectable: true,
|
||||
|
@ -383,6 +383,8 @@ export default class Utils {
|
|||
* @param {string} [options.cancelText=Cancel] - text for the cancel button
|
||||
* @param {callable} [options.onConfirm=NOOP] - callback to occur when clicking the submit button
|
||||
* @param {callable} [options.onCancel=NOOP] - callback to occur when clicking the cancel button
|
||||
* @param {string} [options.key] - key used to identify the modal. If not provided, one is generated and returned
|
||||
* @returns {string} - the key used for this modal
|
||||
*/
|
||||
static showConfirmationModal(title, content, options = {}) {
|
||||
const ModalStack = WebpackModules.findByProps("push", "update", "pop", "popWithKey");
|
||||
|
@ -391,21 +393,19 @@ export default class Utils {
|
|||
if (!ModalStack || !ConfirmationModal || !Markdown) return Utils.alert(title, content);
|
||||
|
||||
const emptyFunction = () => {};
|
||||
const {onConfirm = emptyFunction, onCancel = emptyFunction, confirmText = "Okay", cancelText = "Cancel", danger = false} = options;
|
||||
const {onConfirm = emptyFunction, onCancel = emptyFunction, confirmText = "Okay", cancelText = "Cancel", danger = false, key = undefined} = options;
|
||||
|
||||
if (!Array.isArray(content)) content = [content];
|
||||
content = content.map(c => typeof(c) === "string" ? BDV2.React.createElement(Markdown, null, c) : c);
|
||||
ModalStack.push(function(props) {
|
||||
return BDV2.React.createElement(ConfirmationModal, Object.assign({
|
||||
header: title,
|
||||
children: content,
|
||||
red: danger,
|
||||
confirmText: confirmText,
|
||||
cancelText: cancelText,
|
||||
onConfirm: onConfirm,
|
||||
onCancel: onCancel
|
||||
}, props));
|
||||
});
|
||||
return ModalStack.push(ConfirmationModal, {
|
||||
header: title,
|
||||
children: content,
|
||||
red: danger,
|
||||
confirmText: confirmText,
|
||||
cancelText: cancelText,
|
||||
onConfirm: onConfirm,
|
||||
onCancel: onCancel
|
||||
}, key);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue