mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 15:06:26 +08:00
REFACTOR: Remove Discourse
constant from showModal
This commit is contained in:
parent
98e5e1cd53
commit
02e8d84e30
|
@ -1,13 +1,17 @@
|
|||
import I18n from "I18n";
|
||||
import { dasherize } from "@ember/string";
|
||||
|
||||
let _container;
|
||||
export function setModalContainer(container) {
|
||||
_container = container;
|
||||
}
|
||||
|
||||
export default function(name, opts) {
|
||||
opts = opts || {};
|
||||
const container = Discourse.__container__;
|
||||
|
||||
// We use the container here because modals are like singletons
|
||||
// in Discourse. Only one can be shown with a particular state.
|
||||
const route = container.lookup("route:application");
|
||||
const route = _container.lookup("route:application");
|
||||
const modalController = route.controllerFor("modal");
|
||||
|
||||
modalController.set(
|
||||
|
@ -18,7 +22,7 @@ export default function(name, opts) {
|
|||
const controllerName = opts.admin ? `modals/${name}` : name;
|
||||
modalController.set("name", controllerName);
|
||||
|
||||
let controller = container.lookup("controller:" + controllerName);
|
||||
let controller = _container.lookup("controller:" + controllerName);
|
||||
const templateName = opts.templateName || dasherize(name);
|
||||
|
||||
const renderArgs = { into: "modal", outlet: "modalBody" };
|
||||
|
@ -27,7 +31,7 @@ export default function(name, opts) {
|
|||
} else {
|
||||
// use a basic controller
|
||||
renderArgs.controller = "basic-modal-body";
|
||||
controller = container.lookup(`controller:${renderArgs.controller}`);
|
||||
controller = _container.lookup(`controller:${renderArgs.controller}`);
|
||||
}
|
||||
|
||||
if (opts.addModalBodyView) {
|
||||
|
|
|
@ -13,6 +13,7 @@ import deprecated from "discourse-common/lib/deprecated";
|
|||
import { setIconList } from "discourse-common/lib/icon-library";
|
||||
import { setPluginContainer } from "discourse/lib/plugin-api";
|
||||
import { setURLContainer } from "discourse/lib/url";
|
||||
import { setModalContainer } from "discourse/lib/show-modal";
|
||||
|
||||
export default {
|
||||
name: "discourse-bootstrap",
|
||||
|
@ -21,6 +22,7 @@ export default {
|
|||
initialize(container, app) {
|
||||
setPluginContainer(container);
|
||||
setURLContainer(container);
|
||||
setModalContainer(container);
|
||||
|
||||
// Our test environment has its own bootstrap code
|
||||
if (isTesting()) {
|
||||
|
|
|
@ -29,6 +29,7 @@ import { currentSettings, mergeSettings } from "helpers/site-settings";
|
|||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
import { setTopicList } from "discourse/lib/topic-list-tracker";
|
||||
import { setURLContainer } from "discourse/lib/url";
|
||||
import { setModalContainer } from "discourse/lib/show-modal";
|
||||
|
||||
export function currentUser() {
|
||||
return User.create(sessionFixtures["/session/current.json"].current_user);
|
||||
|
@ -176,6 +177,7 @@ export function acceptance(name, options) {
|
|||
this.container = getOwner(this);
|
||||
setPluginContainer(this.container);
|
||||
setURLContainer(this.container);
|
||||
setModalContainer(this.container);
|
||||
if (options.beforeEach) {
|
||||
options.beforeEach.call(this);
|
||||
}
|
||||
|
@ -205,6 +207,7 @@ export function acceptance(name, options) {
|
|||
setTopicList(null);
|
||||
_clearSnapshots();
|
||||
setURLContainer(null);
|
||||
setModalContainer(null);
|
||||
Discourse._runInitializer(
|
||||
"instanceInitializers",
|
||||
(initName, initializer) => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user