REVERT: Ember 2.10 -- it's not building properly

This commit is contained in:
Robin Ward 2016-12-12 16:18:42 -05:00
parent ec5615033d
commit 600541c623
88 changed files with 1192 additions and 1722 deletions

View File

@ -48,7 +48,7 @@ gem 'onebox'
gem 'http_accept_language', '~>2.0.5', require: false
gem 'ember-rails', '0.18.5'
gem 'ember-source', '2.10.0'
gem 'ember-source', '2.4.6'
gem 'barber'
gem 'babel-transpiler'

View File

@ -93,7 +93,7 @@ GEM
ember-source (>= 1.1.0)
jquery-rails (>= 1.0.17)
railties (>= 3.1)
ember-source (2.10.0)
ember-source (2.4.6)
erubis (2.7.0)
eventmachine (1.2.0.1)
excon (0.53.0)
@ -413,7 +413,7 @@ DEPENDENCIES
discourse_fastimage (= 2.0.3)
email_reply_trimmer (= 0.1.6)
ember-rails (= 0.18.5)
ember-source (= 2.10.0)
ember-source (= 2.4.6)
excon
execjs
fabrication (= 2.9.8)

View File

@ -68,7 +68,7 @@ export default Ember.Controller.extend(BufferedContent, {
this.get('model').save(data).then(() => {
if (newBadge) {
const adminBadges = this.get('adminBadges.model');
if (!adminBadges.includes(model)) {
if (!adminBadges.contains(model)) {
adminBadges.pushObject(model);
}
this.transitionToRoute('adminBadges.show', model.get('id'));

View File

@ -23,7 +23,7 @@
{{nav-item route='admin.backups' label='admin.backups.title'}}
{{/if}}
{{nav-item route='adminPlugins' label='admin.plugins.title'}}
{{plugin-outlet name="admin-menu" connectorTagName="li"}}
{{plugin-outlet "admin-menu" tagName="li"}}
</ul>
<div class='boxed white admin-content'>

View File

@ -1,4 +1,4 @@
{{plugin-outlet name="admin-dashboard-top"}}
{{plugin-outlet "admin-dashboard-top"}}
{{#conditional-loading-spinner condition=loading}}
<div class="dashboard-left">

View File

@ -121,7 +121,7 @@
{{#if siteSettings.email_in}}
<label for="incoming_email">{{i18n 'admin.groups.incoming_email'}}</label>
{{text-field name="incoming_email" value=model.incoming_email placeholderKey="admin.groups.incoming_email_placeholder"}}
{{plugin-outlet name="group-email-in" args=(hash model=model)}}
{{plugin-outlet "group-email-in"}}
{{/if}}
{{/unless}}

View File

@ -1,7 +1,7 @@
<div class="dashboard-stats version-check {{if versionCheck.critical_updates 'critical' 'normal'}}">
<table class="table table-condensed table-hover">
<thead>
{{custom-html name="upgrade-header"}}
{{custom-html 'upgrade-header'}}
<tr>
<th>&nbsp;</th>
<th>{{i18n 'admin.dashboard.installed_version'}}</th>

View File

@ -89,6 +89,7 @@
//= require_tree ./discourse/models
//= require_tree ./discourse/components
//= require_tree ./discourse/raw-views
//= require_tree ./discourse/views
//= require_tree ./discourse/helpers
//= require_tree ./discourse/templates
//= require_tree ./discourse/routes

View File

@ -11,18 +11,18 @@ export function setResolverOption(name, value) {
}
function parseName(fullName) {
const nameParts = fullName.split(":");
const type = nameParts[0];
let fullNameWithoutType = nameParts[1];
const namespace = get(this, 'namespace');
const root = namespace;
const nameParts = fullName.split(":"),
type = nameParts[0], fullNameWithoutType = nameParts[1],
name = fullNameWithoutType,
namespace = get(this, 'namespace'),
root = namespace;
return {
fullName,
type,
fullNameWithoutType,
name: fullNameWithoutType,
root,
fullName: fullName,
type: type,
fullNameWithoutType: fullNameWithoutType,
name: name,
root: root,
resolveMethodName: "resolve" + classify(type)
};
}
@ -125,21 +125,12 @@ export function buildResolver(baseName) {
}
},
findConnectorTemplate(parsedName) {
const full = parsedName.fullNameWithoutType.replace('components/', '');
if (full.indexOf('connectors') === 0) {
return Ember.TEMPLATES[`javascripts/${full}`];
}
},
resolveTemplate(parsedName) {
return this.findPluginMobileTemplate(parsedName) ||
this.findPluginTemplate(parsedName) ||
this.findMobileTemplate(parsedName) ||
this.findTemplate(parsedName) ||
this.findLoadingTemplate(parsedName) ||
this.findConnectorTemplate(parsedName) ||
Ember.TEMPLATES.not_found;
},

View File

@ -7,7 +7,6 @@ const Discourse = Ember.Application.extend({
rootElement: '#main',
_docTitle: document.title,
__TAGS_INCLUDED__: true,
RAW_TEMPLATES: {},
getURL(url) {
if (!url) return url;

View File

@ -1,4 +1,5 @@
import { on, observes, default as computed } from 'ember-addons/ember-computed-decorators';
import { getOwner } from 'discourse-common/lib/get-owner';
export default Ember.Component.extend({
@computed('placeholderKey')
@ -17,7 +18,7 @@ export default Ember.Component.extend({
var self = this;
var selectedBadges;
var template = Discourse.RAW_TEMPLATES['badge-selector-autocomplete'];
var template = getOwner(this).lookup('template:badge-selector-autocomplete.raw');
self.$('input').autocomplete({
allowAny: false,
items: _.isArray(this.get('badgeNames')) ? this.get('badgeNames') : [this.get('badgeNames')],

View File

@ -1,6 +1,7 @@
import { categoryBadgeHTML } from 'discourse/helpers/category-link';
import Category from 'discourse/models/category';
import { on, observes } from 'ember-addons/ember-computed-decorators';
import { getOwner } from 'discourse-common/lib/get-owner';
export default Ember.Component.extend({
@observes('categories')
@ -12,7 +13,7 @@ export default Ember.Component.extend({
@on('didInsertElement')
_initializeAutocomplete(opts) {
const self = this,
template = Discourse.RAW_TEMPLATES['category-selector-autocomplete'],
template = getOwner(this).lookup('template:category-selector-autocomplete.raw'),
regexp = new RegExp(`href=['\"]${Discourse.getURL('/c/')}([^'\"]+)`);
this.$('input').autocomplete({

View File

@ -6,6 +6,7 @@ import { linkSeenTagHashtags, fetchUnseenTagHashtags } from 'discourse/lib/link-
import { load } from 'pretty-text/oneboxer';
import { ajax } from 'discourse/lib/ajax';
import InputValidation from 'discourse/models/input-validation';
import { getOwner } from 'discourse-common/lib/get-owner';
import { tinyAvatar,
displayErrorForUpload,
getUploadMarkdown,
@ -61,7 +62,7 @@ export default Ember.Component.extend({
@on('didInsertElement')
_composerEditorInit() {
const topicId = this.get('topic.id');
const template = Discourse.RAW_TEMPLATES['user-selector-autocomplete'];
const template = getOwner(this).lookup('template:user-selector-autocomplete.raw');
const $input = this.$('.d-editor-input');
$input.autocomplete({
template,

View File

@ -51,8 +51,6 @@ export default Ember.Component.extend({
},
_checkForUrl() {
if (!this.element || this.isDestroying || this.isDestroyed) { return; }
if (this.get('isAbsoluteUrl') && (this.get('composer.reply')||"").length === 0) {
// Try to onebox. If success, update post body and title.

View File

@ -1,20 +0,0 @@
import { getCustomHTML } from 'discourse/helpers/custom-html';
import { getOwner } from 'discourse-common/lib/get-owner';
export default Ember.Component.extend({
init() {
this._super();
const name = this.get('name');
const html = getCustomHTML(name);
if (html) {
this.set('html', html);
this.set('layoutName', 'components/custom-html-container');
} else {
const template = getOwner(this).lookup(`template:${name}`);
if (template) {
this.set('layoutName', name);
}
}
}
});

View File

@ -297,7 +297,7 @@ export default Ember.Component.extend({
},
_applyCategoryHashtagAutocomplete() {
const template = Discourse.RAW_TEMPLATES['category-tag-autocomplete'];
const template = this.register.lookup('template:category-tag-autocomplete.raw');
const siteSettings = this.siteSettings;
this.$('.d-editor-input').autocomplete({
@ -323,7 +323,7 @@ export default Ember.Component.extend({
if (!this.siteSettings.enable_emoji) { return; }
const register = this.register;
const template = Discourse.RAW_TEMPLATES['emoji-selector-autocomplete'];
const template = this.register.lookup('template:emoji-selector-autocomplete.raw');
const self = this;
$editorInput.autocomplete({

View File

@ -1,4 +1,6 @@
import { on, observes, default as computed } from 'ember-addons/ember-computed-decorators';
import { getOwner } from 'discourse-common/lib/get-owner';
export default Ember.Component.extend({
@computed('placeholderKey')
placeholder(placeholderKey) {
@ -17,7 +19,7 @@ export default Ember.Component.extend({
var selectedGroups;
var groupNames = this.get('groupNames');
var template = Discourse.RAW_TEMPLATES['group-selector-autocomplete'];
var template = getOwner(this).lookup('template:group-selector-autocomplete.raw');
self.$('input').autocomplete({
allowAny: false,
items: _.isArray(groupNames) ? groupNames : (Ember.isEmpty(groupNames)) ? [] : [groupNames],

View File

@ -23,6 +23,8 @@ export default Ember.Component.extend({
this._super();
const name = this.get('widget');
(this.get('delegated') || []).forEach(m => this.set(m, m));
this.register = getRegister(this);
this._widgetClass = queryRegistry(name) || this.register.lookupFactory(`widget:${name}`);
@ -31,6 +33,7 @@ export default Ember.Component.extend({
console.error(`Error: Could not find widget: ${name}`);
}
this._childEvents = [];
this._connected = [];
this._dispatched = [];

View File

@ -1,22 +0,0 @@
export default Ember.Component.extend({
init() {
this._super();
const connector = this.get('connector');
this.set('layoutName', connector.templateName);
const args = this.get('args') || {};
Object.keys(args).forEach(key => this.set(key, args[key]));
const connectorClass = this.get('connector.connectorClass');
connectorClass.setupComponent.call(this, args, this);
},
send(name, ...args) {
const connectorClass = this.get('connector.connectorClass');
const action = connectorClass.actions[name];
return action ? action.call(this, ...args) : this._super(name, ...args);
}
});

View File

@ -1,51 +0,0 @@
/**
A plugin outlet is an extension point for templates where other templates can
be inserted by plugins.
## Usage
If your handlebars template has:
```handlebars
{{plugin-outlet name="evil-trout"}}
```
Then any handlebars files you create in the `connectors/evil-trout` directory
will automatically be appended. For example:
plugins/hello/assets/javascripts/discourse/templates/connectors/evil-trout/hello.hbs
With the contents:
```handlebars
<b>Hello World</b>
```
Will insert <b>Hello World</b> at that point in the template.
## Disabling
If a plugin returns a disabled status, the outlets will not be wired up for it.
The list of disabled plugins is returned via the `Site` singleton.
**/
import { connectorsFor } from 'discourse/lib/plugin-connectors';
export default Ember.Component.extend({
tagName: 'span',
connectors: null,
init() {
this._super();
const name = this.get('name');
if (name) {
const args = this.get('args');
const connectors = connectorsFor(name).filter(con => {
return con.connectorClass.shouldRender(args, this);
});
this.set('connectors', connectors);
}
}
});

View File

@ -48,15 +48,12 @@ export default Em.Component.extend({
init() {
this._super();
Ember.run.scheduleOnce('afterRender', () => {
this._init();
this._update();
});
this._init();
this._update();
},
@observes('searchTerm')
_updateOptions() {
this._update();
Ember.run.debounce(this, this._update, 250);
},

View File

@ -1,11 +1,17 @@
import computed from 'ember-addons/ember-computed-decorators';
import DelegatedActions from 'discourse/mixins/delegated-actions';
export default Ember.Component.extend({
export default Ember.Component.extend(DelegatedActions, {
elementId: 'topic-footer-buttons',
// Allow us to extend it
layoutName: 'components/topic-footer-buttons',
init() {
this._super();
this.delegateAll(this.get('topicDelegated'));
},
@computed('topic.details.can_invite_to')
canInviteTo(result) {
return !this.site.mobileView && result;

View File

@ -1,5 +1,7 @@
import computed from 'ember-addons/ember-computed-decorators';
import { bufferedRender } from 'discourse-common/lib/buffered-render';
import { getOwner } from 'discourse-common/lib/get-owner';
export function showEntrance(e) {
let target = $(e.target);
@ -30,7 +32,7 @@ export default Ember.Component.extend(bufferedRender({
},
buildBuffer(buffer) {
const template = Discourse.RAW_TEMPLATES['list/topic-list-item'];
const template = getOwner(this).lookup('template:list/topic-list-item.raw');
if (template) {
buffer.push(template(this));
}

View File

@ -3,11 +3,17 @@ import { default as computed, observes } from 'ember-addons/ember-computed-decor
export default Ember.Component.extend({
elementId: 'topic-progress-wrapper',
classNameBindings: ['docked'],
expanded: false,
docked: false,
progressPosition: null,
postStream: Ember.computed.alias('topic.postStream'),
_streamPercentage: null,
init() {
this._super();
(this.get('delegated') || []).forEach(m => this.set(m, m));
},
@computed('progressPosition')
jumpTopDisabled(progressPosition) {
return progressPosition <= 3;

View File

@ -1,6 +1,8 @@
import { observes } from 'ember-addons/ember-computed-decorators';
import TextField from 'discourse/components/text-field';
import userSearch from 'discourse/lib/user-search';
import { getOwner } from 'discourse-common/lib/get-owner';
export default TextField.extend({
@observes('usernames')
_update() {
@ -29,7 +31,7 @@ export default TextField.extend({
}
this.$().val(this.get('usernames')).autocomplete({
template: Discourse.RAW_TEMPLATES['user-selector-autocomplete'],
template: getOwner(this).lookup('template:user-selector-autocomplete.raw'),
disabled: this.get('disabled'),
single: this.get('single'),
allowAny: this.get('allowAny'),

View File

@ -15,10 +15,4 @@ export default Ember.Controller.extend({
loginRequired() {
return Discourse.SiteSettings.login_required && !Discourse.User.current();
},
actions: {
appRouteAction(name) {
return this.send(name);
}
}
});

View File

@ -114,7 +114,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
email = this.get("accountEmail");
if (this.get('rejectedEmails').includes(email)) {
if (this.get('rejectedEmails').contains(email)) {
return InputValidation.create({
failed: true,
reason: I18n.t('user.email.invalid')
@ -314,7 +314,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
});
}
if (this.get('rejectedPasswords').includes(password)) {
if (this.get('rejectedPasswords').contains(password)) {
return InputValidation.create({
failed: true,
reason: I18n.t('user.password.common')

View File

@ -16,7 +16,7 @@ if (customNavItemHref) {
if (navItem.get('tagId')) {
var name = navItem.get('name');
if ( !Discourse.Site.currentProp('filters').includes(name) ) {
if ( !Discourse.Site.currentProp('filters').contains(name) ) {
return null;
}

View File

@ -32,6 +32,30 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
filter: null,
quoteState: null,
topicDelegated: [
'toggleMultiSelect',
'deleteTopic',
'recoverTopic',
'toggleClosed',
'showAutoClose',
'showFeatureTopic',
'showChangeTimestamp',
'toggleArchived',
'toggleVisibility',
'convertToPublicTopic',
'convertToPrivateMessage',
'jumpTop',
'jumpToPost',
'jumpToPostPrompt',
'jumpToIndex',
'jumpBottom',
'replyToPost',
'toggleArchiveMessage',
'showInvite',
'toggleBookmark',
'showFlagTopic'
],
updateQueryParams() {
const postStream = this.get('model.postStream');
this.setProperties(postStream.get('streamFilters'));
@ -151,22 +175,6 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
actions: {
showPostFlags(post) {
return this.send('showFlags', post);
},
topicRouteAction(name) {
return this.send(name);
},
openAutoClose() {
this.send('showAutoClose');
},
openFeatureTopic() {
this.send('showFeatureTopic');
},
deselectText() {
this.get('quoteState').setProperties({ buffer: null, postId: null });
},
@ -810,7 +818,7 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
postSelected(post) {
if (this.get('allPostsSelected')) { return true; }
if (this.get('selectedPosts').includes(post)) { return true; }
if (this.get('selectedPosts').contains(post)) { return true; }
if (this.get('selectedReplies').findBy('post_number', post.get('reply_to_post_number'))) { return true; }
return false;

View File

@ -2,9 +2,6 @@ import { categoryLinkHTML } from 'discourse/helpers/category-link';
import { registerUnbound } from 'discourse-common/lib/helpers';
registerUnbound('category-badge', function(cat, options) {
return categoryLinkHTML(cat, {
hideParent: options.hideParent,
allowUncategorized: options.allowUncategorized,
link: false
});
options.link = false;
return categoryLinkHTML(cat, options);
});

View File

@ -1,3 +1,5 @@
const { registerKeyword } = Ember.__loader.require("ember-htmlbars/keywords");
const { internal } = Ember.__loader.require('htmlbars-runtime');
import PreloadStore from 'preload-store';
let _customizations = {};
@ -22,3 +24,36 @@ export function clearHTMLCache() {
export function setCustomHTML(key, html) {
_customizations[key] = html;
}
registerKeyword('custom-html', {
setupState(state, env, scope, params) {
return { htmlKey: env.hooks.getValue(params[0]) };
},
render(renderNode, env, scope, params, hash, template, inverse, visitor) {
let state = renderNode.getState();
if (!state.htmlKey) { return true; }
const html = getCustomHTML(state.htmlKey);
if (html) {
const htmlHash = { html };
env.hooks.component(renderNode,
env,
scope,
'custom-html-container',
params,
htmlHash,
{ default: template, inverse },
visitor);
return true;
}
template = env.owner.lookup(`template:${state.htmlKey}`);
if (template) {
internal.hostBlock(renderNode, env, scope, template.raw, null, null, visitor, function(options) {
options.templates.template.yield();
});
}
return true;
}
});

View File

@ -0,0 +1,138 @@
/**
A plugin outlet is an extension point for templates where other templates can
be inserted by plugins.
## Usage
If your handlebars template has:
```handlebars
{{plugin-outlet "evil-trout"}}
```
Then any handlebars files you create in the `connectors/evil-trout` directory
will automatically be appended. For example:
plugins/hello/assets/javascripts/discourse/templates/connectors/evil-trout/hello.hbs
With the contents:
```handlebars
<b>Hello World</b>
```
Will insert <b>Hello World</b> at that point in the template.
## Disabling
If a plugin returns a disabled status, the outlets will not be wired up for it.
The list of disabled plugins is returned via the `Site` singleton.
**/
let _connectorCache, _templateCache;
function findOutlets(collection, callback) {
const disabledPlugins = Discourse.Site.currentProp('disabled_plugins') || [];
Object.keys(collection).forEach(function(res) {
if (res.indexOf("/connectors/") !== -1) {
// Skip any disabled plugins
for (let i=0; i<disabledPlugins.length; i++) {
if (res.indexOf("/" + disabledPlugins[i] + "/") !== -1) {
return;
}
}
const segments = res.split("/");
let outletName = segments[segments.length-2];
const uniqueName = segments[segments.length-1];
callback(outletName, res, uniqueName);
}
});
}
export function clearCache() {
_templateCache = null;
_connectorCache = null;
}
function buildConnectorCache() {
_connectorCache = {};
_templateCache = [];
findOutlets(Ember.TEMPLATES, function(outletName, resource, uniqueName) {
_connectorCache[outletName] = _connectorCache[outletName] || [];
_connectorCache[outletName].push({
templateName: resource.replace('javascripts/', ''),
template: Ember.TEMPLATES[resource],
classNames: `${outletName}-outlet ${uniqueName}`
});
});
Object.keys(_connectorCache).forEach(outletName => {
const connector = _connectorCache[outletName];
(connector || []).forEach(s => {
_templateCache.push(s.template);
s.templateId = parseInt(_templateCache.length - 1);
});
});
}
// unbound version of outlets, only has a template
Handlebars.registerHelper('plugin-outlet', function(name) {
if (!_connectorCache) { buildConnectorCache(); }
const connector = _connectorCache[name];
if (connector && connector.length) {
const output = connector.map(c => c.template({context: this}));
return new Handlebars.SafeString(output.join(""));
}
});
const { registerKeyword } = Ember.__loader.require("ember-htmlbars/keywords");
const { internal } = Ember.__loader.require('htmlbars-runtime');
registerKeyword('plugin-outlet', {
setupState(state, env, scope, params) {
if (!_connectorCache) { buildConnectorCache(); }
return { outletName: env.hooks.getValue(params[0]) };
},
render(renderNode, env, scope, params, hash, template, inverse, visitor) {
let state = renderNode.getState();
if (!state.outletName) { return true; }
const connector = _connectorCache[state.outletName];
if (!connector || connector.length === 0) { return true; }
const listTemplate = Ember.TEMPLATES['outlet-list'];
listTemplate.raw.locals = ['templateId', 'outletClasses', 'tagName'];
internal.hostBlock(renderNode, env, scope, listTemplate.raw, null, null, visitor, function(options) {
connector.forEach(source => {
const tid = source.templateId;
options.templates.template.yieldItem(`d-outlet-${tid}`, [
tid,
source.classNames,
hash.tagName || 'div'
]);
});
});
return true;
}
});
registerKeyword('connector', function(morph, env, scope, params, hash, template, inverse, visitor) {
template = _templateCache[parseInt(env.hooks.getValue(hash.templateId))];
env.hooks.component(morph,
env,
scope,
'connector-container',
params,
hash,
{ default: template.raw, inverse },
visitor);
return true;
});

View File

@ -1,9 +0,0 @@
import { connectorsFor } from 'discourse/lib/plugin-connectors';
Handlebars.registerHelper('raw-plugin-outlet', function(args) {
const connectors = connectorsFor(args.hash.name);
if (connectors.length) {
const output = connectors.map(c => c.template({context: this}));
return new Handlebars.SafeString(output.join(""));
}
});

View File

@ -3,7 +3,6 @@ import { registerUnbound } from 'discourse-common/lib/helpers';
let _injections;
function renderRaw(ctx, container, template, templateName, params) {
params = jQuery.extend({}, params);
params.parent = params.parent || ctx;
if (!params.view) {
@ -33,9 +32,9 @@ registerUnbound('raw', function(templateName, params) {
templateName = templateName.replace('.', '/');
const container = Discourse.__container__;
const template = Discourse.RAW_TEMPLATES[templateName];
var template = container.lookup('template:' + templateName + '.raw');
if (!template) {
console.warn('Could not find raw template: ' + templateName);
Ember.warn('Could not find raw template: ' + templateName);
return;
}
return renderRaw(this, container, template, templateName, params);

View File

@ -151,7 +151,7 @@ function render(page, offset, options) {
};
$('.emoji-modal', options.appendTo).remove();
const template = Discourse.RAW_TEMPLATES['emoji-toolbar'];
const template = options.register.lookup('template:emoji-toolbar.raw');
options.appendTo.append(template(model));
bindEvents(page, offset, options);

View File

@ -1,81 +0,0 @@
let _connectorCache;
let _extraConnectorClasses = {};
let _classPaths;
export function resetExtraClasses() {
_extraConnectorClasses = {};
_classPaths = undefined;
}
// Note: In plugins, define a class by path and it will be wired up automatically
// eg: discourse/connectors/<OUTLET NAME>/<CONNECTOR NAME>.js.es6
export function extraConnectorClass(name, obj) {
_extraConnectorClasses[name] = obj;
}
const DefaultConnectorClass = {
actions: {},
shouldRender: () => true,
setupComponent() { }
};
function findOutlets(collection, callback) {
const disabledPlugins = Discourse.Site.currentProp('disabled_plugins') || [];
Object.keys(collection).forEach(function(res) {
if (res.indexOf("/connectors/") !== -1) {
// Skip any disabled plugins
for (let i=0; i<disabledPlugins.length; i++) {
if (res.indexOf("/" + disabledPlugins[i] + "/") !== -1) {
return;
}
}
const segments = res.split("/");
let outletName = segments[segments.length-2];
const uniqueName = segments[segments.length-1];
callback(outletName, res, uniqueName);
}
});
}
export function clearCache() {
_connectorCache = null;
}
function findClass(outletName, uniqueName) {
if (!_classPaths) {
_classPaths = {};
findOutlets(require._eak_seen, (outlet, res, un) => {
_classPaths[`${outlet}/${un}`] = require(res).default;
});
}
const id = `${outletName}/${uniqueName}`;
let foundClass = _extraConnectorClasses[id] || _classPaths[id];
return foundClass ?
jQuery.extend({}, DefaultConnectorClass, foundClass) :
DefaultConnectorClass;
}
function buildConnectorCache() {
_connectorCache = {};
findOutlets(Ember.TEMPLATES, function(outletName, resource, uniqueName) {
_connectorCache[outletName] = _connectorCache[outletName] || [];
_connectorCache[outletName].push({
templateName: resource.replace('javascripts/', ''),
template: Ember.TEMPLATES[resource],
classNames: `${outletName}-outlet ${uniqueName}`,
connectorClass: findClass(outletName, uniqueName)
});
});
}
export function connectorsFor(outletName) {
if (!_connectorCache) { buildConnectorCache(); }
return _connectorCache[outletName] || [];
}

View File

@ -11,22 +11,26 @@ export default function(name, opts) {
const controllerName = opts.admin ? `modals/${name}` : name;
const viewClass = container.lookupFactory('view:' + name);
const controller = container.lookup('controller:' + controllerName);
const templateName = opts.templateName || Ember.String.dasherize(name);
if (viewClass) {
route.render(name, { into: 'modal', outlet: 'modalBody' });
} else {
const templateName = opts.templateName || Ember.String.dasherize(name);
const renderArgs = { into: 'modal', outlet: 'modalBody'};
if (controller) { renderArgs.controller = controllerName; }
const renderArgs = { into: 'modal', outlet: 'modalBody'};
if (controller) { renderArgs.controller = controllerName; }
if (opts.addModalBodyView) {
renderArgs.view = 'modal-body';
}
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));
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));
}
}
if (controller) {

View File

@ -1,14 +1,8 @@
import { defaultHomepage } from 'discourse/lib/utilities';
const rootURL = Discourse.BaseUri;
const BareRouter = Ember.Router.extend({
rootURL,
location: Ember.testing ? 'none': 'discourse-location',
handleURL(url) {
if (url === "/") { url = defaultHomepage(); }
return this._super(url);
}
location: Ember.testing ? 'none': 'discourse-location'
});
// Ember's router can't be extended. We need to allow plugins to add routes to routes that were defined
@ -73,8 +67,7 @@ class RouteNode {
if (paths.length > 1) {
paths.filter(p => p !== this.opts.path).forEach(path => {
const newOpts = jQuery.extend({}, this.opts, { path });
console.log(`warning: we can't have duplicate route names anymore`, newOpts);
// router.route(this.name, newOpts, builder);
router.route(this.name, newOpts, builder);
});
}
}

View File

@ -0,0 +1,6 @@
export default Ember.Mixin.create({
init() {
this._super();
(this.get('delegated') || []).forEach(m => this.set(m, m));
},
});

View File

@ -0,0 +1,12 @@
export default Ember.Mixin.create({
delegateAll(actionNames) {
actionNames = actionNames || [];
this.actions = this.actions || {};
actionNames.forEach(m => {
this.actions[m] = function() { this.sendAction(m); };
this.set(m, m);
});
}
});

View File

@ -86,9 +86,9 @@ NavItem.reopenClass({
testName = name.split("/")[0],
anonymous = !Discourse.User.current();
if (anonymous && !Discourse.Site.currentProp('anonymous_top_menu_items').includes(testName)) return null;
if (anonymous && !Discourse.Site.currentProp('anonymous_top_menu_items').contains(testName)) return null;
if (!Discourse.Category.list() && testName === "categories") return null;
if (!Discourse.Site.currentProp('top_menu_items').includes(testName)) return null;
if (!Discourse.Site.currentProp('top_menu_items').contains(testName)) return null;
var args = { name: name, hasIcon: name === "unread" }, extra = null, self = this;
if (opts.category) { args.category = opts.category; }

View File

@ -168,7 +168,7 @@ export default RestModel.extend({
this.set('summary', false);
let jump = false;
if (userFilters.includes(username)) {
if (userFilters.contains(username)) {
userFilters.removeObject(username);
} else {
userFilters.addObject(username);
@ -256,7 +256,7 @@ export default RestModel.extend({
return this.findPostsByIds(gap).then(posts => {
posts.forEach(p => {
const stored = this.storePost(p);
if (!currentPosts.includes(stored)) {
if (!currentPosts.contains(stored)) {
currentPosts.insertAt(postIdx++, stored);
}
});
@ -410,7 +410,7 @@ export default RestModel.extend({
if (stored) {
const posts = this.get('posts');
if (!posts.includes(stored)) {
if (!posts.contains(stored)) {
if (!this.get('loadingBelow')) {
this.get('postsWithPlaceholders').appendPost(() => posts.pushObject(stored));
} else {

View File

@ -17,7 +17,7 @@ function inject() {
}
function injectAll(app, name) {
inject(app, name, 'controller', 'component', 'route', 'model', 'adapter');
inject(app, name, 'controller', 'component', 'route', 'view', 'model', 'adapter');
}
export default {

View File

@ -1,3 +1,5 @@
import { defaultHomepage } from 'discourse/lib/utilities';
export default function() {
// Error page
this.route('exception', { path: '/exception' });
@ -43,6 +45,9 @@ export default function() {
this.route('categoryNone', { path: '/c/:slug/none' });
this.route('category', { path: '/c/:parentSlug/:slug' });
this.route('categoryWithID', { path: '/c/:parentSlug/:slug/:id' });
// homepage
this.route(defaultHomepage(), { path: '/' });
});
this.route('group', { path: '/groups/:name', resetNamespace: true }, function() {

View File

@ -0,0 +1 @@
{{!-- THIS IS AN EMPTY TEMPLATE THAT NEEDS TO BE OVERWRITTEN --}}

View File

@ -1,17 +1,17 @@
{{plugin-outlet name="above-site-header"}}
{{plugin-outlet "above-site-header"}}
{{site-header canSignUp=canSignUp
showCreateAccount=(action "appRouteAction" "showCreateAccount")
showLogin=(action "appRouteAction" "showLogin")
showKeyboard=(action "appRouteAction" "showKeyboardShortcutsHelp")
toggleMobileView=(action "appRouteAction" "toggleMobileView")
toggleAnonymous=(action "appRouteAction" "toggleAnonymous")
logout=(action "appRouteAction" "logout")}}
{{plugin-outlet name="below-site-header"}}
showCreateAccount="showCreateAccount"
showLogin="showLogin"
showKeyboard="showKeyboardShortcutsHelp"
toggleMobileView="toggleMobileView"
toggleAnonymous="toggleAnonymous"
logout="logout"}}
{{plugin-outlet "below-site-header"}}
<div id="main-outlet" class="wrap">
<div class="container">
{{#if showTop}}
{{custom-html name="top"}}
{{custom-html "top"}}
{{/if}}
{{global-notice}}
{{create-topics-notice}}
@ -20,11 +20,11 @@
{{outlet "user-card"}}
</div>
{{plugin-outlet name="above-footer"}}
{{plugin-outlet "above-footer"}}
{{#if showFooter}}
{{custom-html name="footer"}}
{{custom-html "footer"}}
{{/if}}
{{plugin-outlet name="below-footer"}}
{{plugin-outlet "below-footer"}}
{{outlet "modal"}}
{{topic-entrance}}

View File

@ -8,6 +8,6 @@
{{tag-drop firstCategory=firstCategory secondCategory=secondCategory tagId=tagId}}
{{/if}}
{{plugin-outlet name="bread-crumbs-right" connectorTagName="li"}}
{{plugin-outlet "bread-crumbs-right" tagName="li"}}
<div class='clear'></div>

View File

@ -56,7 +56,7 @@
</label>
</section>
{{plugin-outlet name="category-email-in" args=(hash category=category)}}
{{plugin-outlet "category-email-in"}}
{{/if}}
{{#if showPositionInput}}
@ -82,4 +82,4 @@
</section>
{{/unless}}
{{plugin-outlet name="category-custom-settings" args=(hash category=category)}}
{{plugin-outlet "category-custom-settings"}}

View File

@ -1,5 +1,5 @@
{{#each navItems as |navItem|}}
{{navigation-item content=navItem filterMode=filterMode}}
{{/each}}
{{custom-html name="extraNavItem"}}
{{plugin-outlet name="extra-nav-item" connectorTagName="li"}}
{{custom-html "extraNavItem"}}
{{plugin-outlet "extra-nav-item" tagName="li"}}

View File

@ -1,3 +0,0 @@
{{#each connectors as |c|}}
{{plugin-connector connector=c args=args class=c.classNames tagName=connectorTagName}}
{{/each}}

View File

@ -6,7 +6,7 @@
<a href={{item.postUrl}}>{{{item.title}}}</a>
</span>
<div class="category">{{category-link item.category}}</div>
{{plugin-outlet name="user-stream-item-header" args=(hash item=item)}}
{{plugin-outlet "user-stream-item-header"}}
</div>
{{#if actionDescription}}

View File

@ -14,4 +14,4 @@
{{topic-featured-link topic}}
{{/if}}
</div>
{{plugin-outlet name="topic-category" args=(hash topic=topic category=topic.category)}}
{{plugin-outlet "topic-category"}}

View File

@ -1,18 +1,5 @@
{{#if showAdminButton}}
{{topic-admin-menu-button
topic=topic
openUpwards="true"
toggleMultiSelect=toggleMultiSelect
deleteTopic=deleteTopic
recoverTopic=recoverTopic
toggleClosed=toggleClosed
toggleArchived=toggleArchived
toggleVisibility=toggleVisibility
showAutoClose=showAutoClose
showFeatureTopic=showFeatureTopic
showChangeTimestamp=showChangeTimestamp
convertToPublicTopic=convertToPublicTopic
convertToPrivateMessage=convertToPrivateMessage}}
{{topic-admin-menu-button topic=topic delegated=topicDelegated openUpwards="true"}}
{{/if}}
{{#unless topic.isPrivateMessage}}
@ -23,7 +10,7 @@
title=bookmarkTitle
label=bookmarkLabel
icon="bookmark"
action=toggleBookmark}}
action="toggleBookmark"}}
<button class="btn share" data-share-url={{topic.shareUrl}} title={{i18n "topic.share.help"}}>
{{fa-icon "link"}}
@ -35,7 +22,7 @@
title="topic.flag_topic.help"
label="topic.flag_topic.title"
icon="flag"
action=showFlagTopic}}
action="showFlagTopic"}}
{{/if}}
{{/if}}
@ -46,7 +33,7 @@
title="topic.invite_reply.help"
label="topic.invite_reply.title"
icon="users"
action=showInvite
action="showInvite"
disabled=inviteDisabled}}
{{/if}}
@ -55,23 +42,19 @@
title=archiveTitle
label=archiveLabel
icon=archiveIcon
action=toggleArchiveMessage}}
action="toggleArchiveMessage"}}
{{/if}}
{{#if topic.details.can_create_post}}
{{d-button class="btn-primary create"
icon="reply"
action=replyToPost
action="replyToPost"
label="topic.reply.title"
title="topic.reply.help"}}
{{/if}}
{{plugin-outlet name="after-topic-footer-main-buttons"
args=(hash topic=topic)
connectorTagName="span"}}
{{plugin-outlet "after-topic-footer-main-buttons" tagName="span"}}
{{pinned-button topic=topic}}
{{topic-notifications-button topic=topic}}
{{plugin-outlet name="after-topic-footer-buttons"
args=(hash topic=topic)
connectorTagName="span"}}
{{pinned-button topic=topic topicDelegated=topicDelegated}}
{{topic-notifications-button topic=topic topicDelegated=topicDelegated}}
{{plugin-outlet "after-topic-footer-buttons" tagName="span"}}

View File

@ -4,4 +4,5 @@
<span>/</span>
<h4>{{postStream.filteredPostsCount}}</h4></span>
</div>
<i class="fa {{unless expanded 'fa-sort'}}"></i>
</nav>

View File

@ -30,7 +30,7 @@
<h2>{{user.title}}</h2>
{{/if}}
{{plugin-outlet name="user-card-post-names" args=(hash user=user)}}
{{plugin-outlet "user-card-post-names"}}
</span>
</div>
@ -85,7 +85,7 @@
</span>
{{/if}}
{{plugin-outlet name="user-card-location-and-website" args=(hash user=user)}}
{{plugin-outlet "user-card-location-and-website"}}
</div>
{{/if}}
@ -95,7 +95,7 @@
<h3><span class='desc'>{{i18n 'last_post'}}</span> {{format-date user.last_posted_at leaveAgo="true"}}</h3>
{{/if}}
<h3><span class='desc'>{{i18n 'joined'}}</span> {{format-date user.created_at leaveAgo="true"}}</h3>
{{plugin-outlet name="user-card-metadata" args=(hash user=user)}}
{{plugin-outlet "user-card-metadata"}}
</div>
{{/if}}

View File

@ -30,7 +30,7 @@
{{#if model.viewOpen}}
<div class='control-row reply-area'>
<div class='composer-fields'>
{{plugin-outlet name="composer-open" args=(hash model=model)}}
{{plugin-outlet "composer-open"}}
<div class='reply-to'>
{{{model.actionTitle}}}
@ -78,10 +78,11 @@
{{#if model.archetype.hasOptions}}
<button class='btn' {{action "showOptions"}}>{{i18n 'topic.options'}}</button>
{{/if}}
{{render "additional-composer-buttons" model}}
{{/if}}
</div>
{{/if}}
{{plugin-outlet name="composer-fields" args=(hash model=model)}}
{{plugin-outlet "composer-fields"}}
</div>
{{composer-editor topic=topic
@ -103,7 +104,7 @@
{{#if currentUser}}
<div class='submit-panel'>
{{plugin-outlet name="composer-fields-below" args=(hash model=model)}}
{{plugin-outlet "composer-fields-below"}}
{{#if canEditTags}}
{{tag-chooser tags=model.tags tabIndex="4" categoryId=model.categoryId}}
{{/if}}

View File

@ -21,11 +21,11 @@
<div class="row">
<div class="full-width">
<div id="list-area">
{{plugin-outlet name="discovery-list-container-top"}}
{{plugin-outlet "discovery-list-container-top"}}
{{outlet "list-container"}}
</div>
</div>
</div>
</div>
{{plugin-outlet name="discovery-below"}}
{{plugin-outlet "discovery-below"}}

View File

@ -94,7 +94,7 @@
{{#each result.topic.tags as |tag|}}
{{discourse-tag tag}}
{{/each}}
{{plugin-outlet name="full-page-search-category" args=(hash result=result)}}
{{plugin-outlet "full-page-search-category"}}
</div>
</div>

View File

@ -10,7 +10,7 @@
{{#if topic.featured_link}}
{{topic-featured-link topic}}
{{/if}}
{{raw-plugin-outlet name="topic-list-after-title"}}
{{plugin-outlet "topic-list-after-title"}}
{{#if showTopicPostBadges}}
{{raw "topic-post-badges" unread=topic.unread newPosts=topic.displayNewPosts unseen=topic.unseen url=topic.lastUnreadUrl}}
{{/if}}
@ -21,7 +21,7 @@
{{/each}}
</div>
{{/if}}
{{raw-plugin-outlet name="topic-list-tags"}}
{{plugin-outlet "topic-list-tags"}}
{{#if expandPinned}}
{{raw "list/topic-excerpt" topic=topic}}
{{/if}}

View File

@ -37,7 +37,7 @@
</div>
{{/if}}
{{raw-plugin-outlet name="topic-list-tags"}}
{{plugin-outlet "topic-list-tags"}}
<div class="pull-right">
<div class='num activity last'>

View File

@ -52,11 +52,7 @@
</tr>
{{/if}}
{{plugin-outlet name="create-account-before-password"
args=(hash accountName=accountName
accountUsername=accountUsername
accountPassword=accountPassword
userFields=userFields)}}
{{plugin-outlet "create-account-before-password"}}
{{#if passwordRequired}}
<tr class="input">

View File

@ -94,7 +94,7 @@
</div>
{{/if}}
{{plugin-outlet name="post-revisions" args=(hash model=model)}}
{{plugin-outlet "post-revisions"}}
{{#links-redirect class="row"}}
{{{bodyDiff}}}

View File

@ -248,7 +248,7 @@
{{preference-checkbox labelKey="user.enable_quoting" checked=model.user_option.enable_quoting}}
{{preference-checkbox labelKey="user.dynamic_favicon" checked=model.user_option.dynamic_favicon}}
{{preference-checkbox labelKey="user.disable_jump_reply" checked=model.user_option.disable_jump_reply}}
{{plugin-outlet name="user-custom-preferences" args=(hash model=model)}}
{{plugin-outlet "user-custom-preferences"}}
</div>
<div class="control-group category">
@ -350,7 +350,7 @@
</div>
{{/if}}
{{plugin-outlet name="user-custom-controls" args=(hash model=model)}}
{{plugin-outlet "user-custom-controls"}}
<div class="control-group save-button">
<div class="controls">

View File

@ -1,7 +1,7 @@
{{#d-section bodyClass=bodyClass class="container"}}
{{#watch-read action="markFaqRead" path=model.path}}
<div class='contents clearfix body-page'>
{{plugin-outlet name="above-static"}}
{{plugin-outlet "above-static"}}
{{{model.html}}}
{{#if showSignupButton}}

View File

@ -42,7 +42,7 @@
</div>
</div>
{{plugin-outlet name="discovery-list-container-top"}}
{{plugin-outlet "discovery-list-container-top"}}
<footer class='topic-list-bottom'>
{{conditional-loading-spinner condition=loading}}

View File

@ -6,7 +6,7 @@
</div>
{{/if}}
{{plugin-outlet name="topic-above-post-stream" args=(hash model=model)}}
{{plugin-outlet "topic-above-post-stream"}}
{{#if model.postStream.loaded}}
{{#if model.postStream.firstPostPresent}}
@ -30,7 +30,7 @@
{{tag-chooser tags=buffered.tags categoryId=buffered.category_id}}
{{/if}}
{{plugin-outlet name="edit-topic" args=(hash model=model buffered=buffered)}}
{{plugin-outlet "edit-topic"}}
{{d-button action="finishedEditingTopic" class="btn-primary btn-small submit-edit" icon="check"}}
{{d-button action="cancelEditingTopic" class="btn-small cancel-edit" icon="times"}}
@ -59,7 +59,7 @@
{{/unless}}
{{/if}}
</div>
{{plugin-outlet name="topic-title" args=(hash model=model)}}
{{plugin-outlet "topic-title"}}
</div>
</div>
{{/if}}
@ -70,53 +70,24 @@
</div>
{{#topic-navigation jumpToIndex="jumpToIndex" as |info|}}
{{#if info.renderAdminMenuButton}}
{{topic-admin-menu-button
topic=model
fixed="true"
toggleMultiSelect=(action "toggleMultiSelect")
deleteTopic=(action "deleteTopic")
recoverTopic=(action "recoverTopic")
toggleClosed=(action "toggleClosed")
toggleArchived=(action "toggleArchived")
toggleVisibility=(action "toggleVisibility")
showAutoClose=(action "topicRouteAction" "showAutoClose")
showFeatureTopic=(action "topicRouteAction" "showFeatureTopic")
showChangeTimestamp=(action "topicRouteAction" "showChangeTimestamp")
convertToPublicTopic=(action "convertToPublicTopic")
convertToPrivateMessage=(action "convertToPrivateMessage")}}
{{topic-admin-menu-button topic=model fixed="true" delegated=topicDelegated}}
{{/if}}
{{#if info.renderTimeline}}
{{topic-timeline
topic=model
prevEvent=info.prevEvent
fullscreen=info.topicProgressExpanded
enteredIndex=enteredIndex
loading=model.postStream.loading
jumpToPost=(action "jumpToPost")
jumpTop=(action "jumpTop")
jumpBottom=(action "jumpBottom")
jumpToPostPrompt=(action "jumpToPostPrompt")
jumpToIndex=(action "jumpToIndex")
replyToPost=(action "replyToPost")
toggleMultiSelect=(action "toggleMultiSelect")
deleteTopic=(action "deleteTopic")
recoverTopic=(action "recoverTopic")
toggleClosed=(action "toggleClosed")
toggleArchived=(action "toggleArchived")
toggleVisibility=(action "toggleVisibility")
showAutoClose=(action "topicRouteAction" "showAutoClose")
showFeatureTopic=(action "topicRouteAction" "showFeatureTopic")
showChangeTimestamp=(action "topicRouteAction" "showChangeTimestamp")
convertToPublicTopic=(action "convertToPublicTopic")
convertToPrivateMessage=(action "convertToPrivateMessage")}}
{{topic-timeline topic=model
prevEvent=info.prevEvent
fullscreen=info.topicProgressExpanded
enteredIndex=enteredIndex
loading=model.postStream.loading
delegated=topicDelegated}}
{{else}}
{{topic-progress
prevEvent=info.prevEvent
topic=model
expanded=info.topicProgressExpanded}}
{{topic-progress prevEvent=info.prevEvent topic=model delegated=topicDelegated expanded=info.topicProgressExpanded}}
{{/if}}
{{/topic-navigation}}
<div class="row">
@ -125,7 +96,7 @@
<div class="posts-wrapper">
{{conditional-loading-spinner condition=model.postStream.loadingAbove}}
{{plugin-outlet name="topic-above-posts" args=(hash model=model)}}
{{plugin-outlet "topic-above-posts"}}
{{#unless model.postStream.loadingFilter}}
{{scrolling-post-stream
@ -135,34 +106,35 @@
selectedPostsCount=selectedPostsCount
selectedQuery=selectedQuery
gaps=model.postStream.gaps
showFlags=(action "showPostFlags")
editPost=(action "editPost")
showHistory=(action "topicRouteAction" "showHistory")
showLogin=(action "topicRouteAction" "showLogin")
showRawEmail=(action "topicRouteAction" "showRawEmail")
deletePost=(action "deletePost")
recoverPost=(action "recoverPost")
expandHidden=(action "expandHidden")
newTopicAction=(action "replyAsNewTopic")
toggleBookmark=(action "toggleBookmark")
togglePostType=(action "togglePostType")
rebakePost=(action "rebakePost")
changePostOwner=(action "changePostOwner")
unhidePost=(action "unhidePost")
replyToPost=(action "replyToPost")
toggleWiki=(action "toggleWiki")
toggleSummary=(action "toggleSummary")
removeAllowedUser=(action "removeAllowedUser")
removeAllowedGroup=(action "removeAllowedGroup")
showInvite=(action "topicRouteAction" "showInvite")
topVisibleChanged=(action "topVisibleChanged")
currentPostChanged=(action "currentPostChanged")
currentPostScrolled=(action "currentPostScrolled")
bottomVisibleChanged=(action "bottomVisibleChanged")
selectPost=(action "toggledSelectedPost")
selectReplies=(action "toggledSelectedPostReplies")
fillGapBefore=(action "fillGapBefore")
fillGapAfter=(action "fillGapAfter")}}
showFlags="showFlags"
editPost="editPost"
showHistory="showHistory"
showLogin="showLogin"
showRawEmail="showRawEmail"
deletePost="deletePost"
recoverPost="recoverPost"
expandHidden="expandHidden"
newTopicAction="replyAsNewTopic"
expandFirstPost="expandFirstPost"
toggleBookmark="toggleBookmark"
togglePostType="togglePostType"
rebakePost="rebakePost"
changePostOwner="changePostOwner"
unhidePost="unhidePost"
replyToPost="replyToPost"
toggleWiki="toggleWiki"
toggleSummary="toggleSummary"
removeAllowedUser="removeAllowedUser"
removeAllowedGroup="removeAllowedGroup"
showInvite="showInvite"
topVisibleChanged="topVisibleChanged"
currentPostChanged="currentPostChanged"
currentPostScrolled="currentPostScrolled"
bottomVisibleChanged="bottomVisibleChanged"
selectPost="toggledSelectedPost"
selectReplies="toggledSelectedPostReplies"
fillGapBefore="fillGapBefore"
fillGapAfter="fillGapAfter"}}
{{/unless}}
{{conditional-loading-spinner condition=model.postStream.loadingBelow}}
@ -178,25 +150,7 @@
{{signup-cta}}
{{else}}
{{#if currentUser}}
{{topic-footer-buttons
topic=model
toggleMultiSelect=(action "toggleMultiSelect")
deleteTopic=(action "deleteTopic")
recoverTopic=(action "recoverTopic")
toggleClosed=(action "toggleClosed")
toggleArchived=(action "toggleArchived")
toggleVisibility=(action "toggleVisibility")
showAutoClose=(action "topicRouteAction" "showAutoClose")
showFeatureTopic=(action "topicRouteAction" "showFeatureTopic")
showChangeTimestamp=(action "topicRouteAction" "showChangeTimestamp")
convertToPublicTopic=(action "convertToPublicTopic")
convertToPrivateMessage=(action "convertToPrivateMessage")
toggleBookmark=(action "toggleBookmark")
showFlagTopic=(action "topicRouteAction" "showFlagTopic")
showInvite=(action "topicRouteAction" "showInvite")
toggleArchiveMessage=(action "toggleArchiveMessage")
replyToPost=(action "replyToPost")
}}
{{topic-footer-buttons topic=model topicDelegated=topicDelegated}}
{{else}}
{{d-button icon="reply" class="btn-primary" action="showLogin" label="topic.reply.title"}}
{{/if}}
@ -221,7 +175,7 @@
</div>
{{/if}}
{{plugin-outlet name="topic-above-suggested" args=(hash model=model)}}
{{plugin-outlet "topic-above-suggested"}}
{{#if model.details.suggested_topics.length}}
<div id="suggested-topics">

View File

@ -47,9 +47,7 @@
{{#if currentUser.staff}}
<li><a href={{model.adminPath}} class="btn">{{fa-icon "wrench"}}{{i18n 'admin.user.show_admin_profile'}}</a></li>
{{/if}}
{{plugin-outlet name="user-profile-controls"
connectorTagName="li"
args=(hash model=model)}}
{{plugin-outlet "user-profile-controls" tagName="li"}}
{{#if collapsedInfo}}
{{#if viewingSelf}}
@ -66,7 +64,7 @@
{{#if model.title}}
<h3>{{model.title}}</h3>
{{/if}}
{{plugin-outlet name="user-post-names" args=(hash model=model)}}
{{plugin-outlet "user-post-names"}}
<h3>
{{#if model.location}}{{fa-icon "map-marker"}} {{model.location}}{{/if}}
{{#if model.website_name}}
@ -77,7 +75,7 @@
<span title={{model.website}}>{{model.website_name}}</span>
{{/if}}
{{/if}}
{{plugin-outlet name="user-location-and-website" args=(hash model=model)}}
{{plugin-outlet "user-location-and-website"}}
</h3>
<div class='bio'>
@ -104,13 +102,12 @@
{{/if}}
{{/each}}
{{plugin-outlet name="user-profile-public-fields"
args=(hash publicUserFields=publicUserFields
model=model)}}
{{plugin-outlet "user-profile-public-fields"}}
</div>
{{/if}}
{{plugin-outlet name="user-profile-primary" args=(hash model=model)}}
{{plugin-outlet "user-profile-primary"}}
</div>
</div>
<div style='clear: both'></div>
@ -156,7 +153,7 @@
{{d-button action="adminDelete" icon="exclamation-triangle" label="user.admin_delete" class="btn-danger"}}
{{/if}}
</dl>
{{plugin-outlet name="user-profile-secondary" args=(hash model=model)}}
{{plugin-outlet "user-profile-secondary"}}
</div>
{{/unless}}
</section>

View File

@ -23,9 +23,7 @@
{{/link-to}}
</li>
{{/if}}
{{plugin-outlet name="user-activity-bottom"
connectorTagName='li'
args=(hash model=model)}}
{{plugin-outlet "user-activity-bottom" tagName='li'}}
{{/mobile-nav}}
{{#if viewingSelf}}

View File

@ -37,9 +37,7 @@
<li>
{{user-stat value=model.likes_received label="user.summary.likes_received"}}
</li>
{{plugin-outlet name="user-summary-stat"
connectorTagName="li"
args=(hash model=model)}}
{{plugin-outlet "user-summary-stat" tagName="li"}}
</ul>
</div>

View File

@ -0,0 +1,40 @@
import deprecated from 'discourse-common/lib/deprecated';
export default Ember.View.extend({
focusInput: true,
didInsertElement() {
this._super();
deprecated('ModalBodyView is deprecated. Use the `d-modal-body` component instead');
$('#modal-alert').hide();
$('#discourse-modal').modal('show');
Ember.run.scheduleOnce('afterRender', this, this._afterFirstRender);
this.appEvents.on('modal-body:flash', msg => this._flash(msg));
},
willDestroyElement() {
this._super();
this.appEvents.off('modal-body:flash');
},
_afterFirstRender() {
if (!this.site.mobileView && this.get('focusInput')) {
this.$('input:first').focus();
}
const title = this.get('title');
if (title) {
this.set('controller.modal.title', title);
}
},
_flash(msg) {
$('#modal-alert').hide()
.removeClass('alert-error', 'alert-success')
.addClass(`alert alert-${msg.messageClass || 'success'}`).html(msg.text || '')
.fadeIn();
}
});

View File

@ -11,7 +11,7 @@ function renderParticipants(userFilters, participants) {
userFilters = userFilters || [];
return participants.map(p => {
return this.attach('topic-participant', p, { state: { toggled: userFilters.includes(p.username) } });
return this.attach('topic-participant', p, { state: { toggled: userFilters.contains(p.username) } });
});
}

View File

@ -256,24 +256,31 @@ export default class Widget {
}
_sendComponentAction(name, param) {
let promise;
const view = this._findAncestorWithProperty('_emberView');
const view = this._findView();
let promise;
if (view) {
const method = view.get(name);
if (!method) {
console.warn(`${name} not found`);
// Peek into ember internals to allow us to return promises from actions
const ev = view._emberView;
const target = ev.get('targetObject');
const actionName = ev.get(name);
if (!actionName) {
Ember.warn(`${name} not found`);
return;
}
if (typeof method === "string") {
view.sendAction(method, param);
promise = Ember.RSVP.resolve();
} else {
const target = view.get('targetObject');
promise = method.call(target, param);
if (!promise || !promise.then) {
promise = Ember.RSVP.resolve(promise);
if (target) {
// TODO: Use ember closure actions
const actions = target.actions || target.actionHooks || {};
const method = actions[actionName];
if (method) {
promise = method.call(target, param);
if (!promise || !promise.then) {
promise = Ember.RSVP.resolve(promise);
}
} else {
return ev.sendAction(name, param);
}
}
}

View File

@ -1,3 +1,4 @@
window.ENV = { };
window.EmberENV = window.EmberENV || {};
window.EmberENV.FORCE_JQUERY = true;
window.EmberENV._ENABLE_LEGACY_VIEW_SUPPORT = true;

View File

@ -142,7 +142,7 @@ module Discourse
# Our templates shouldn't start with 'discourse/templates'
config.handlebars.templates_root = 'discourse/templates'
config.handlebars.raw_template_namespace = "Discourse.RAW_TEMPLATES"
config.handlebars.raw_template_namespace = "Ember.TEMPLATES"
require 'discourse_redis'
require 'logster/redis_store'

View File

@ -21,7 +21,6 @@ function initializeDetails(api) {
"details_text",
{ multiline: false }
);
this.set('optionsVisible', false);
}
}
});

View File

@ -36,7 +36,7 @@ test('details button', () => {
equal(
find(".d-editor-input").val(),
`[details=${I18n.t("composer.details_title")}]This is my title[/details]`,
'it should contain the right selected output'
'it should contain the right output'
);
const textarea = findTextarea();

File diff suppressed because one or more lines are too long

View File

@ -1,47 +0,0 @@
import { acceptance } from "helpers/qunit-helpers";
import { extraConnectorClass } from 'discourse/lib/plugin-connectors';
const PREFIX = "javascripts/single-test/connectors";
acceptance("Plugin Outlet - Connector Class", {
setup() {
extraConnectorClass('user-profile-primary/hello', {
actions: {
sayHello() {
this.set('hello', 'hello!');
}
}
});
extraConnectorClass('user-profile-primary/dont-render', {
shouldRender(args) {
return args.model.get('username') !== 'eviltrout';
}
});
Ember.TEMPLATES[`${PREFIX}/user-profile-primary/hello`] = Ember.HTMLBars.compile(
`<span class='hello-username'>{{model.username}}</span>
<button class='say-hello' {{action "sayHello"}}></button>
<span class='hello-result'>{{hello}}</span>`
);
Ember.TEMPLATES[`${PREFIX}/user-profile-primary/dont-render`] = Ember.HTMLBars.compile(
`I'm not rendered!`
);
},
teardown() {
delete Ember.TEMPLATES[`${PREFIX}/user-profile-primary/hello`];
delete Ember.TEMPLATES[`${PREFIX}/user-profile-primary/dont-render`];
}
});
test("Renders a template into the outlet", assert => {
visit("/users/eviltrout");
andThen(() => {
assert.ok(find('.user-profile-primary-outlet.hello').length === 1, 'it has class names');
assert.ok(!find('.user-profile-primary-outlet.dont-render').length, "doesn't render");
});
click('.say-hello');
andThen(() => {
assert.equal(find('.hello-result').text(), 'hello!', 'actions delegate properly');
});
});

View File

@ -1,5 +1,5 @@
import { acceptance } from "helpers/qunit-helpers";
import { clearCache } from 'discourse/lib/plugin-connectors';
import { clearCache } from 'discourse/helpers/plugin-outlet';
const HELLO = 'javascripts/multi-test/connectors/user-profile-primary/hello';
const GOODBYE = 'javascripts/multi-test/connectors/user-profile-primary/goodbye';

View File

@ -4,7 +4,9 @@ const CONNECTOR = 'javascripts/single-test/connectors/user-profile-primary/hello
acceptance("Plugin Outlet - Single Template", {
setup() {
Ember.TEMPLATES[CONNECTOR] = Ember.HTMLBars.compile(
`<span class='hello-username'>{{model.username}}</span>`
`<span class='hello-username'>{{model.username}}</span>
<button class='hello-check-email' {{action "checkEmail" model}}></button>
<span class='hello-email'>{{model.email}}</span>`
);
},
@ -19,4 +21,8 @@ test("Renders a template into the outlet", assert => {
assert.ok(find('.user-profile-primary-outlet.hello').length === 1, 'it has class names');
assert.equal(find('.hello-username').text(), 'eviltrout', 'it renders into the outlet');
});
click('.hello-check-email');
andThen(() => {
assert.equal(find('.hello-email').text(), 'eviltrout@example.com', 'actions delegate properly');
});
});

View File

@ -71,29 +71,27 @@ test("open advanced search", assert => {
andThen(() => assert.ok(visible('.search-advanced .search-advanced-options'), '"search-advanced-options" is visible'));
});
// these tests are screwy with the runloop
test("validate population of advanced search", assert => {
visit("/search");
fillIn('.search input.full-page-search', 'test user:admin #bug group:moderators badge:Reader tags:monkey in:likes in:private in:wiki in:bookmarks status:open after:2016-10-05 min_post_count:10');
click('.search-advanced-btn');
// test("validate population of advanced search", assert => {
// visit("/search");
// fillIn('.search input.full-page-search', 'test user:admin #bug group:moderators badge:Reader tags:monkey in:likes in:private in:wiki in:bookmarks status:open after:2016-10-05 min_post_count:10');
// click('.search-advanced-btn');
//
// andThen(() => {
// assert.ok(exists('.search-advanced-options span:contains("admin")'), 'has "admin" pre-populated');
// assert.ok(exists('.search-advanced-options .badge-category:contains("bug")'), 'has "bug" pre-populated');
// //assert.ok(exists('.search-advanced-options span:contains("moderators")'), 'has "moderators" pre-populated');
// //assert.ok(exists('.search-advanced-options span:contains("Reader")'), 'has "Reader" pre-populated');
// assert.ok(exists('.search-advanced-options .tag-chooser .tag-monkey'), 'has "monkey" pre-populated');
// assert.ok(exists('.search-advanced-options .in-likes:checked'), 'has "I liked" pre-populated');
// assert.ok(exists('.search-advanced-options .in-private:checked'), 'has "are in my messages" pre-populated');
// assert.ok(exists('.search-advanced-options .in-wiki:checked'), 'has "are wiki" pre-populated');
// assert.ok(exists('.search-advanced-options .combobox .select2-choice .select2-chosen:contains("I\'ve bookmarked")'), 'has "I\'ve bookmarked" pre-populated');
// assert.ok(exists('.search-advanced-options .combobox .select2-choice .select2-chosen:contains("are open")'), 'has "are open" pre-populated');
// assert.ok(exists('.search-advanced-options .combobox .select2-choice .select2-chosen:contains("after")'), 'has "after" pre-populated');
// assert.equal(find('.search-advanced-options #search-post-date').val(), "2016-10-05", 'has "2016-10-05" pre-populated');
// assert.equal(find('.search-advanced-options #search-min-post-count').val(), "10", 'has "10" pre-populated');
// });
// });
andThen(() => {
assert.ok(exists('.search-advanced-options span:contains("admin")'), 'has "admin" pre-populated');
assert.ok(exists('.search-advanced-options .badge-category:contains("bug")'), 'has "bug" pre-populated');
//assert.ok(exists('.search-advanced-options span:contains("moderators")'), 'has "moderators" pre-populated');
//assert.ok(exists('.search-advanced-options span:contains("Reader")'), 'has "Reader" pre-populated');
assert.ok(exists('.search-advanced-options .tag-chooser .tag-monkey'), 'has "monkey" pre-populated');
assert.ok(exists('.search-advanced-options .in-likes:checked'), 'has "I liked" pre-populated');
assert.ok(exists('.search-advanced-options .in-private:checked'), 'has "are in my messages" pre-populated');
assert.ok(exists('.search-advanced-options .in-wiki:checked'), 'has "are wiki" pre-populated');
assert.ok(exists('.search-advanced-options .combobox .select2-choice .select2-chosen:contains("I\'ve bookmarked")'), 'has "I\'ve bookmarked" pre-populated');
assert.ok(exists('.search-advanced-options .combobox .select2-choice .select2-chosen:contains("are open")'), 'has "are open" pre-populated');
assert.ok(exists('.search-advanced-options .combobox .select2-choice .select2-chosen:contains("after")'), 'has "after" pre-populated');
assert.equal(find('.search-advanced-options #search-post-date').val(), "2016-10-05", 'has "2016-10-05" pre-populated');
assert.equal(find('.search-advanced-options #search-min-post-count').val(), "10", 'has "10" pre-populated');
});
});
test("escape search term", (assert) => {
visit("/search");

View File

@ -20,6 +20,6 @@ test("grantableBadges", function() {
});
not(badgeNames.includes(badgeDisabled), "excludes disabled badges");
not(badgeNames.contains(badgeDisabled), "excludes disabled badges");
deepEqual(badgeNames, sortedNames, "sorts badges by name");
});

View File

@ -5,10 +5,8 @@ import siteFixtures from 'fixtures/site-fixtures';
import HeaderComponent from 'discourse/components/site-header';
import { forceMobile, resetMobile } from 'discourse/lib/mobile';
import { resetPluginApi } from 'discourse/lib/plugin-api';
import { clearCache as clearOutletCache, resetExtraClasses } from 'discourse/lib/plugin-connectors';
import { clearCache as clearOutletCache } from 'discourse/helpers/plugin-outlet';
import { clearHTMLCache } from 'discourse/helpers/custom-html';
import { flushMap } from 'discourse/models/store';
function currentUser() {
return Discourse.User.create(sessionFixtures['/session/current.json'].current_user);
@ -46,7 +44,6 @@ function acceptance(name, options) {
// For now don't do scrolling stuff in Test Mode
HeaderComponent.reopen({examineDockHeader: Ember.K});
resetExtraClasses();
const siteJson = siteFixtures['site.json'].site;
if (options) {
if (options.setup) {
@ -80,11 +77,9 @@ function acceptance(name, options) {
if (options && options.teardown) {
options.teardown.call(this);
}
flushMap();
Discourse.User.resetCurrent();
Discourse.Site.resetCurrent(Discourse.Site.create(jQuery.extend(true, {}, fixtures['site.json'].site)));
resetExtraClasses();
clearOutletCache();
clearHTMLCache();
resetPluginApi();

View File

@ -170,7 +170,7 @@ test("toggleParticipant", function() {
equal(postStream.get('userFilters.length'), 0, "by default no participants are toggled");
postStream.toggleParticipant(participant.username);
ok(postStream.get('userFilters').includes('eviltrout'), 'eviltrout is in the filters');
ok(postStream.get('userFilters').contains('eviltrout'), 'eviltrout is in the filters');
postStream.toggleParticipant(participant.username);
blank(postStream.get('userFilters'), "toggling the participant again removes them");
@ -283,7 +283,7 @@ test("identity map", function() {
});
test("loadIntoIdentityMap with no data", () => {
return buildStream(1234).loadIntoIdentityMap([]).then(result => {
buildStream(1234).loadIntoIdentityMap([]).then(result => {
equal(result.length, 0, 'requesting no posts produces no posts');
});
});
@ -291,7 +291,7 @@ test("loadIntoIdentityMap with no data", () => {
test("loadIntoIdentityMap with post ids", function() {
const postStream = buildStream(1234);
return postStream.loadIntoIdentityMap([10]).then(function() {
postStream.loadIntoIdentityMap([10]).then(function() {
present(postStream.findLoadedPost(10), "it adds the returned post to the store");
});
});
@ -327,7 +327,7 @@ test("staging and undoing a new post", function() {
equal(stagedPost.get('topic'), topic, "it assigns the topic reference");
equal(stagedPost.get('post_number'), 2, "it is assigned the probable post_number");
present(stagedPost.get('created_at'), "it is assigned a created date");
ok(postStream.get('posts').includes(stagedPost), "the post is added to the stream");
ok(postStream.get('posts').contains(stagedPost), "the post is added to the stream");
equal(stagedPost.get('id'), -1, "the post has a magical -1 id");
// Undoing a created post (there was an error)
@ -337,7 +337,7 @@ test("staging and undoing a new post", function() {
equal(topic.get('highest_post_number'), 1, "it reverts the highest_post_number");
equal(topic.get('posts_count'), 1, "it reverts the post count");
equal(postStream.get('filteredPostsCount'), 1, "it retains the filteredPostsCount");
ok(!postStream.get('posts').includes(stagedPost), "the post is removed from the stream");
ok(!postStream.get('posts').contains(stagedPost), "the post is removed from the stream");
ok(postStream.get('lastAppended'), original, "it doesn't consider undid post lastAppended");
});
@ -367,7 +367,7 @@ test("staging and committing a post", function() {
ok(postStream.get('lastAppended'), original, "staging a post doesn't change the lastAppended");
postStream.commitPost(stagedPost);
ok(postStream.get('posts').includes(stagedPost), "the post is still in the stream");
ok(postStream.get('posts').contains(stagedPost), "the post is still in the stream");
ok(!postStream.get('loading'), "it is no longer loading");
equal(postStream.get('filteredPostsCount'), 2, "it increases the filteredPostsCount");

View File

@ -15,7 +15,7 @@ test('defaults', function() {
test('pagination support', function() {
const store = createStore();
return store.findAll('widget').then(function(rs) {
store.findAll('widget').then(function(rs) {
equal(rs.get('length'), 2);
equal(rs.get('totalRows'), 4);
ok(rs.get('loadMoreUrl'), 'has a url to load more');
@ -36,7 +36,7 @@ test('pagination support', function() {
test('refresh support', function() {
const store = createStore();
return store.findAll('widget').then(function(rs) {
store.findAll('widget').then(function(rs) {
equal(rs.get('refreshUrl'), '/widgets?refresh=true', 'it has the refresh url');
const promise = rs.refresh();

View File

@ -30,9 +30,9 @@
//= require sinon-1.7.1
//= require sinon-qunit-1.0.0
//= require helpers/qunit-helpers
//= require helpers/assertions
//= require helpers/qunit-helpers
//= require_tree ./fixtures
//= require_tree ./lib
//= require_tree .

View File

@ -23,7 +23,7 @@ widgetTest('listing actions', {
});
widgetTest('undo', {
template: '{{mount-widget widget="actions-summary" args=args undoPostAction=undoPostAction}}',
template: '{{mount-widget widget="actions-summary" args=args undoPostAction="undoPostAction"}}',
setup() {
this.set('args', {
actionsSummary: [
@ -31,7 +31,7 @@ widgetTest('undo', {
]
});
this.set('undoPostAction', () => this.undid = true);
this.on('undoPostAction', () => this.undid = true);
},
test(assert) {
assert.equal(this.$('.post-actions .post-action').length, 1);

File diff suppressed because it is too large Load Diff