mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 15:51:05 +08:00

This allows users who entered a typo or invalid email address when signing up an opportunity to fix it and resending the confirmation email to that address.
46 lines
1.4 KiB
JavaScript
46 lines
1.4 KiB
JavaScript
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 modalController = route.controllerFor('modal');
|
|
|
|
modalController.set('modalClass', null);
|
|
|
|
const controllerName = opts.admin ? `modals/${name}` : name;
|
|
|
|
let controller = container.lookup('controller:' + controllerName);
|
|
const templateName = opts.templateName || Ember.String.dasherize(name);
|
|
|
|
const renderArgs = { into: 'modal', outlet: 'modalBody'};
|
|
if (controller) {
|
|
renderArgs.controller = controllerName;
|
|
} else {
|
|
// use a basic controller
|
|
renderArgs.controller = 'basic-modal-body';
|
|
controller = container.lookup(`controller:${renderArgs.controller}`);
|
|
}
|
|
|
|
|
|
if (opts.addModalBodyView) {
|
|
renderArgs.view = 'modal-body';
|
|
}
|
|
|
|
const modalName = `modal/${templateName}`;
|
|
const fullName = opts.admin ? `admin/templates/${modalName}` : modalName;
|
|
route.render(fullName, renderArgs);
|
|
if (opts.title) {
|
|
modalController.set('title', I18n.t(opts.title));
|
|
}
|
|
|
|
controller.set('modal', modalController);
|
|
const model = opts.model;
|
|
if (model) { controller.set('model', model); }
|
|
if (controller.onShow) { controller.onShow(); }
|
|
controller.set('flashMessage', null);
|
|
|
|
return controller;
|
|
};
|