mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 00:51:03 +08:00
DEV: Error if invalid @flashType
passed to modal (#22414)
This commit is contained in:
parent
9ee1972a2c
commit
1122454904
|
@ -63,6 +63,7 @@
|
|||
|
||||
{{yield to="belowHeader"}}
|
||||
|
||||
{{this.validateFlashType @flashType}}
|
||||
{{#if @flash}}
|
||||
<div
|
||||
id="modal-alert"
|
||||
|
|
|
@ -8,6 +8,8 @@ export const CLOSE_INITIATED_BY_ESC = "initiatedByESC";
|
|||
export const CLOSE_INITIATED_BY_CLICK_OUTSIDE = "initiatedByClickOut";
|
||||
export const CLOSE_INITIATED_BY_MODAL_SHOW = "initiatedByModalShow";
|
||||
|
||||
const FLASH_TYPES = ["success", "error", "warning", "info"];
|
||||
|
||||
export default class DModal extends Component {
|
||||
@service modal;
|
||||
@tracked wrapperElement;
|
||||
|
@ -161,4 +163,11 @@ export default class DModal extends Component {
|
|||
handleCloseButton() {
|
||||
this.args.closeModal({ initiatedBy: CLOSE_INITIATED_BY_BUTTON });
|
||||
}
|
||||
|
||||
@action
|
||||
validateFlashType(type) {
|
||||
if (type && !FLASH_TYPES.includes(type)) {
|
||||
throw `@flashType must be one of ${FLASH_TYPES.join(", ")}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user