DEV: Clean up showModal() calls (#20442)

This commit is contained in:
Jarek Radosz 2023-02-24 15:53:04 +01:00 committed by GitHub
parent d5cf128dbd
commit 5a384e60ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 21 deletions

View File

@ -67,7 +67,6 @@ export default DiscourseRoute.extend({
actions: { actions: {
showStartBackupModal() { showStartBackupModal() {
showModal("admin-start-backup", { admin: true }); showModal("admin-start-backup", { admin: true });
this.controllerFor("modal").set("modalClass", "start-backup-modal");
}, },
startBackup(withUploads) { startBackup(withUploads) {

View File

@ -437,10 +437,9 @@ export default Controller.extend(ModalFunctionality, {
return; return;
} }
const skipConfirmation = const skipConfirmation = this.siteSettings.auth_skip_create_confirm;
options && this.siteSettings.auth_skip_create_confirm;
const createAccountController = this.createAccount; const createAccountController = this.createAccount;
createAccountController.setProperties({ createAccountController.setProperties({
accountEmail: options.email, accountEmail: options.email,
accountUsername: options.username, accountUsername: options.username,
@ -450,7 +449,7 @@ export default Controller.extend(ModalFunctionality, {
}); });
next(() => { next(() => {
showModal("createAccount", { showModal("create-account", {
modalClass: "create-account", modalClass: "create-account",
titleAriaElementId: "create-account-title", titleAriaElementId: "create-account-title",
}); });

View File

@ -139,7 +139,7 @@ const ApplicationRoute = DiscourseRoute.extend(OpenComposer, {
offerHelp: null, offerHelp: null,
helpSeen: false, helpSeen: false,
}); });
showModal("forgotPassword", { title: "forgot_password.title" }); showModal("forgot-password", { title: "forgot_password.title" });
}, },
showNotActivated(props) { showNotActivated(props) {
@ -266,7 +266,7 @@ const ApplicationRoute = DiscourseRoute.extend(OpenComposer, {
const returnPath = encodeURIComponent(window.location.pathname); const returnPath = encodeURIComponent(window.location.pathname);
window.location = getURL("/session/sso?return_path=" + returnPath); window.location = getURL("/session/sso?return_path=" + returnPath);
} else { } else {
this._autoLogin("login", "login-modal", { this._autoLogin("login", {
notAuto: () => this.controllerFor("login").resetForm(), notAuto: () => this.controllerFor("login").resetForm(),
}); });
} }
@ -277,7 +277,8 @@ const ApplicationRoute = DiscourseRoute.extend(OpenComposer, {
const returnPath = encodeURIComponent(window.location.pathname); const returnPath = encodeURIComponent(window.location.pathname);
window.location = getURL("/session/sso?return_path=" + returnPath); window.location = getURL("/session/sso?return_path=" + returnPath);
} else { } else {
this._autoLogin("createAccount", "create-account", { this._autoLogin("create-account", {
modalClass: "create-account",
signup: true, signup: true,
titleAriaElementId: "create-account-title", titleAriaElementId: "create-account-title",
}); });
@ -286,8 +287,12 @@ const ApplicationRoute = DiscourseRoute.extend(OpenComposer, {
_autoLogin( _autoLogin(
modal, modal,
modalClass, {
{ notAuto = null, signup = false, titleAriaElementId = null } = {} modalClass = undefined,
notAuto = null,
signup = false,
titleAriaElementId = null,
} = {}
) { ) {
const methods = findAll(); const methods = findAll();
@ -296,11 +301,8 @@ const ApplicationRoute = DiscourseRoute.extend(OpenComposer, {
signup, signup,
}); });
} else { } else {
showModal(modal, { titleAriaElementId }); showModal(modal, { modalClass, titleAriaElementId });
this.controllerFor("modal").set("modalClass", modalClass); notAuto?.();
if (notAuto) {
notAuto();
}
} }
}, },

View File

@ -150,7 +150,7 @@ const DiscoveryCategoriesRoute = DiscourseRoute.extend(OpenComposer, {
@action @action
reorderCategories() { reorderCategories() {
showModal("reorderCategories"); showModal("reorder-categories");
}, },
@action @action

View File

@ -113,13 +113,11 @@ const TopicRoute = DiscourseRoute.extend({
showTopicTimerModal() { showTopicTimerModal() {
const model = this.modelFor("topic"); const model = this.modelFor("topic");
const topicTimer = model.get("topic_timer"); if (!model.get("topic_timer")) {
if (!topicTimer) {
model.set("topic_timer", {}); model.set("topic_timer", {});
} }
showModal("edit-topic-timer", { model }); showModal("edit-topic-timer", { model });
this.controllerFor("modal").set("modalClass", "edit-topic-timer-modal");
}, },
@action @action
@ -139,11 +137,10 @@ const TopicRoute = DiscourseRoute.extend({
@action @action
showFeatureTopic() { showFeatureTopic() {
showModal("featureTopic", { showModal("feature-topic", {
model: this.modelFor("topic"), model: this.modelFor("topic"),
title: "topic.feature_topic.title", title: "topic.feature_topic.title",
}); });
this.controllerFor("modal").set("modalClass", "feature-topic-modal");
this.controllerFor("feature_topic").reset(); this.controllerFor("feature_topic").reset();
}, },