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: {
showStartBackupModal() {
showModal("admin-start-backup", { admin: true });
this.controllerFor("modal").set("modalClass", "start-backup-modal");
},
startBackup(withUploads) {

View File

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

View File

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

View File

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

View File

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