Skip to content

Commit

Permalink
Reapply Ember 2.10 for good this time!
Browse files Browse the repository at this point in the history
This reverts commit ddd299f.
  • Loading branch information
eviltrout committed Dec 19, 2016
1 parent 5058911 commit e03d5e2
Show file tree
Hide file tree
Showing 101 changed files with 1,832 additions and 1,239 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ gem 'onebox'
gem 'http_accept_language', '~>2.0.5', require: false

gem 'ember-rails', '0.18.5'
gem 'ember-source', '2.4.6'
gem 'ember-source', '2.10.0'
gem 'ember-handlebars-template', '0.7.5'
gem 'barber'
gem 'babel-transpiler'

Expand Down
13 changes: 7 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ GEM
babel-transpiler (0.7.0)
babel-source (>= 4.0, < 6)
execjs (~> 2.0)
barber (0.11.1)
barber (0.11.2)
ember-source (>= 1.0, < 3)
execjs (>= 1.2, < 3)
better_errors (2.1.1)
Expand Down Expand Up @@ -82,7 +82,7 @@ GEM
email_reply_trimmer (0.1.6)
ember-data-source (2.2.1)
ember-source (>= 1.8, < 3.0)
ember-handlebars-template (0.7.4)
ember-handlebars-template (0.7.5)
barber (>= 0.11.0)
sprockets (>= 3.3, < 4)
ember-rails (0.18.5)
Expand All @@ -92,7 +92,7 @@ GEM
ember-source (>= 1.1.0)
jquery-rails (>= 1.0.17)
railties (>= 3.1)
ember-source (2.4.6)
ember-source (2.10.0)
erubis (2.7.0)
eventmachine (1.2.0.1)
excon (0.53.0)
Expand Down Expand Up @@ -231,7 +231,7 @@ GEM
pry (>= 0.9.10)
puma (3.6.0)
r2 (0.2.6)
rack (1.6.4)
rack (1.6.5)
rack-mini-profiler (0.10.1)
rack (>= 1.2.0)
rack-openid (1.3.1)
Expand Down Expand Up @@ -355,7 +355,7 @@ GEM
spork-rails (4.0.0)
rails (>= 3.0.0, < 5)
spork (>= 1.0rc0)
sprockets (3.6.3)
sprockets (3.7.0)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.1.1)
Expand Down Expand Up @@ -401,8 +401,9 @@ DEPENDENCIES
discourse-qunit-rails
discourse_fastimage (= 2.0.3)
email_reply_trimmer (= 0.1.6)
ember-handlebars-template (= 0.7.5)
ember-rails (= 0.18.5)
ember-source (= 2.4.6)
ember-source (= 2.10.0)
excon
execjs
fabrication (= 2.9.8)
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/admin/components/ace-editor.js.es6
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default Ember.Component.extend({

loadScript("/javascripts/ace/ace.js", { scriptTag: true }).then(() => {
window.ace.require(['ace/ace'], loadedAce => {
if (!this.element || this.isDestroying || this.isDestroyed) { return; }
const editor = loadedAce.edit(this.$('.ace')[0]);

editor.setTheme("ace/theme/chrome");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.contains(model)) {
if (!adminBadges.includes(model)) {
adminBadges.pushObject(model);
}
this.transitionToRoute('adminBadges.show', model.get('id'));
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/admin/templates/admin.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{{nav-item route='admin.backups' label='admin.backups.title'}}
{{/if}}
{{nav-item route='adminPlugins' label='admin.plugins.title'}}
{{plugin-outlet "admin-menu" tagName="li"}}
{{plugin-outlet name="admin-menu" connectorTagName="li"}}
</ul>

<div class='boxed white admin-content'>
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/admin/templates/dashboard.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{plugin-outlet "admin-dashboard-top"}}
{{plugin-outlet name="admin-dashboard-top"}}

{{#conditional-loading-spinner condition=loading}}
<div class="dashboard-left">
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/admin/templates/group.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,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 "group-email-in"}}
{{plugin-outlet name="group-email-in" args=(hash model=model)}}
{{/if}}
{{/unless}}

Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/admin/templates/version-checks.hbs
Original file line number Diff line number Diff line change
@@ -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 'upgrade-header'}}
{{custom-html name="upgrade-header"}}
<tr>
<th>&nbsp;</th>
<th>{{i18n 'admin.dashboard.installed_version'}}</th>
Expand Down
1 change: 0 additions & 1 deletion app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
//= 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
Expand Down
33 changes: 23 additions & 10 deletions app/assets/javascripts/discourse-common/resolver.js.es6
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,23 @@ export function setResolverOption(name, value) {
_options[name] = value;
}

export function getResolverOption(name) {
return _options[name];
}

function parseName(fullName) {
const nameParts = fullName.split(":"),
type = nameParts[0], fullNameWithoutType = nameParts[1],
name = fullNameWithoutType,
namespace = get(this, 'namespace'),
root = namespace;
const nameParts = fullName.split(":");
const type = nameParts[0];
let fullNameWithoutType = nameParts[1];
const namespace = get(this, 'namespace');
const root = namespace;

return {
fullName: fullName,
type: type,
fullNameWithoutType: fullNameWithoutType,
name: name,
root: root,
fullName,
type,
fullNameWithoutType,
name: fullNameWithoutType,
root,
resolveMethodName: "resolve" + classify(type)
};
}
Expand Down Expand Up @@ -125,12 +129,21 @@ 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;
},

Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/discourse.js.es6
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const _pluginCallbacks = [];
const Discourse = Ember.Application.extend({
rootElement: '#main',
_docTitle: document.title,
__TAGS_INCLUDED__: true,
RAW_TEMPLATES: {},

getURL(url) {
if (!url) return url;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { on, observes, default as computed } from 'ember-addons/ember-computed-decorators';
import { getOwner } from 'discourse-common/lib/get-owner';
import { findRawTemplate } from 'discourse/lib/raw-templates';

export default Ember.Component.extend({
@computed('placeholderKey')
Expand All @@ -18,7 +18,6 @@ export default Ember.Component.extend({
var self = this;
var selectedBadges;

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')],
Expand All @@ -43,7 +42,7 @@ export default Ember.Component.extend({
});
});
},
template: template
template: findRawTemplate('badge-selector-autocomplete')
});
}
});
Original file line number Diff line number Diff line change
@@ -1,7 +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';
import { findRawTemplate } from 'discourse/lib/raw-templates';

export default Ember.Component.extend({
@observes('categories')
Expand All @@ -13,7 +13,6 @@ export default Ember.Component.extend({
@on('didInsertElement')
_initializeAutocomplete(opts) {
const self = this,
template = getOwner(this).lookup('template:category-selector-autocomplete.raw'),
regexp = new RegExp(`href=['\"]${Discourse.getURL('/c/')}([^'\"]+)`);

this.$('input').autocomplete({
Expand Down Expand Up @@ -41,7 +40,7 @@ export default Ember.Component.extend({
self.set('categories', categories);
});
},
template,
template: findRawTemplate('category-selector-autocomplete'),
transformComplete(category) {
return categoryBadgeHTML(category, {allowUncategorized: true});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +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 { findRawTemplate } from 'discourse/lib/raw-templates';
import { tinyAvatar,
displayErrorForUpload,
getUploadMarkdown,
Expand Down Expand Up @@ -62,10 +62,9 @@ export default Ember.Component.extend({
@on('didInsertElement')
_composerEditorInit() {
const topicId = this.get('topic.id');
const template = getOwner(this).lookup('template:user-selector-autocomplete.raw');
const $input = this.$('.d-editor-input');
$input.autocomplete({
template,
template: findRawTemplate('user-selector-autocomplete'),
dataSource: term => userSearch({ term, topicId, includeGroups: true }),
key: "@",
transformComplete: v => v.username || v.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ 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.

Expand Down
20 changes: 20 additions & 0 deletions app/assets/javascripts/discourse/components/custom-html.js.es6
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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);
}
}
}
});
7 changes: 3 additions & 4 deletions app/assets/javascripts/discourse/components/d-editor.js.es6
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { translations } from 'pretty-text/emoji/data';
import { emojiSearch } from 'pretty-text/emoji';
import { emojiUrlFor } from 'discourse/lib/text';
import { getRegister } from 'discourse-common/lib/get-owner';
import { findRawTemplate } from 'discourse/lib/raw-templates';
import deprecated from 'discourse-common/lib/deprecated';

// Our head can be a static string or a function that returns a string
Expand Down Expand Up @@ -297,11 +298,10 @@ export default Ember.Component.extend({
},

_applyCategoryHashtagAutocomplete() {
const template = this.register.lookup('template:category-tag-autocomplete.raw');
const siteSettings = this.siteSettings;

this.$('.d-editor-input').autocomplete({
template: template,
template: findRawTemplate('category-tag-autocomplete'),
key: '#',
transformComplete(obj) {
if (obj.model) {
Expand All @@ -323,11 +323,10 @@ export default Ember.Component.extend({
if (!this.siteSettings.enable_emoji) { return; }

const register = this.register;
const template = this.register.lookup('template:emoji-selector-autocomplete.raw');
const self = this;

$editorInput.autocomplete({
template: template,
template: findRawTemplate('emoji-selector-autocomplete'),
key: ":",
afterComplete(text) {
self.set('value', text);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { on, observes, default as computed } from 'ember-addons/ember-computed-decorators';
import { getOwner } from 'discourse-common/lib/get-owner';
import { findRawTemplate } from 'discourse/lib/raw-templates';

export default Ember.Component.extend({
@computed('placeholderKey')
Expand All @@ -19,7 +19,6 @@ export default Ember.Component.extend({
var selectedGroups;
var groupNames = this.get('groupNames');

var template = getOwner(this).lookup('template:group-selector-autocomplete.raw');
self.$('input').autocomplete({
allowAny: false,
items: _.isArray(groupNames) ? groupNames : (Ember.isEmpty(groupNames)) ? [] : [groupNames],
Expand All @@ -44,7 +43,7 @@ export default Ember.Component.extend({
});
});
},
template: template
template: findRawTemplate('group-selector-autocomplete')
});
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ 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}`);
Expand All @@ -33,7 +31,6 @@ export default Ember.Component.extend({
console.error(`Error: Could not find widget: ${name}`);
}


this._childEvents = [];
this._connected = [];
this._dispatched = [];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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);
}

});
Loading

0 comments on commit e03d5e2

Please sign in to comment.