Upgrade to Ember 2.9
This commit is contained in:
parent
239d06b218
commit
765e5e9186
2
Gemfile
2
Gemfile
|
@ -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.4.6'
|
||||
gem 'ember-source', '2.9.1.1'
|
||||
gem 'barber'
|
||||
gem 'babel-transpiler'
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ GEM
|
|||
ember-source (>= 1.1.0)
|
||||
jquery-rails (>= 1.0.17)
|
||||
railties (>= 3.1)
|
||||
ember-source (2.4.6)
|
||||
ember-source (2.9.1.1)
|
||||
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.4.6)
|
||||
ember-source (= 2.9.1.1)
|
||||
excon
|
||||
execjs
|
||||
fabrication (= 2.9.8)
|
||||
|
|
|
@ -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'));
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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}`);
|
||||
|
@ -33,7 +31,6 @@ export default Ember.Component.extend({
|
|||
console.error(`Error: Could not find widget: ${name}`);
|
||||
}
|
||||
|
||||
|
||||
this._childEvents = [];
|
||||
this._connected = [];
|
||||
this._dispatched = [];
|
||||
|
|
|
@ -1,17 +1,11 @@
|
|||
import computed from 'ember-addons/ember-computed-decorators';
|
||||
import DelegatedActions from 'discourse/mixins/delegated-actions';
|
||||
|
||||
export default Ember.Component.extend(DelegatedActions, {
|
||||
export default Ember.Component.extend({
|
||||
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;
|
||||
|
|
|
@ -3,17 +3,11 @@ 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;
|
||||
|
|
|
@ -15,4 +15,10 @@ export default Ember.Controller.extend({
|
|||
loginRequired() {
|
||||
return Discourse.SiteSettings.login_required && !Discourse.User.current();
|
||||
},
|
||||
|
||||
actions: {
|
||||
appRouteAction(name) {
|
||||
return this.send(name);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -114,7 +114,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
|||
|
||||
email = this.get("accountEmail");
|
||||
|
||||
if (this.get('rejectedEmails').contains(email)) {
|
||||
if (this.get('rejectedEmails').includes(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').contains(password)) {
|
||||
if (this.get('rejectedPasswords').includes(password)) {
|
||||
return InputValidation.create({
|
||||
failed: true,
|
||||
reason: I18n.t('user.password.common')
|
||||
|
|
|
@ -16,7 +16,7 @@ if (customNavItemHref) {
|
|||
if (navItem.get('tagId')) {
|
||||
var name = navItem.get('name');
|
||||
|
||||
if ( !Discourse.Site.currentProp('filters').contains(name) ) {
|
||||
if ( !Discourse.Site.currentProp('filters').includes(name) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,30 +32,6 @@ 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'));
|
||||
|
@ -175,6 +151,22 @@ 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 });
|
||||
},
|
||||
|
@ -818,7 +810,7 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
|
|||
|
||||
postSelected(post) {
|
||||
if (this.get('allPostsSelected')) { return true; }
|
||||
if (this.get('selectedPosts').contains(post)) { return true; }
|
||||
if (this.get('selectedPosts').includes(post)) { return true; }
|
||||
if (this.get('selectedReplies').findBy('post_number', post.get('reply_to_post_number'))) { return true; }
|
||||
|
||||
return false;
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
export default Ember.Mixin.create({
|
||||
init() {
|
||||
this._super();
|
||||
(this.get('delegated') || []).forEach(m => this.set(m, m));
|
||||
},
|
||||
});
|
|
@ -1,12 +0,0 @@
|
|||
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);
|
||||
});
|
||||
}
|
||||
});
|
|
@ -86,9 +86,9 @@ NavItem.reopenClass({
|
|||
testName = name.split("/")[0],
|
||||
anonymous = !Discourse.User.current();
|
||||
|
||||
if (anonymous && !Discourse.Site.currentProp('anonymous_top_menu_items').contains(testName)) return null;
|
||||
if (anonymous && !Discourse.Site.currentProp('anonymous_top_menu_items').includes(testName)) return null;
|
||||
if (!Discourse.Category.list() && testName === "categories") return null;
|
||||
if (!Discourse.Site.currentProp('top_menu_items').contains(testName)) return null;
|
||||
if (!Discourse.Site.currentProp('top_menu_items').includes(testName)) return null;
|
||||
|
||||
var args = { name: name, hasIcon: name === "unread" }, extra = null, self = this;
|
||||
if (opts.category) { args.category = opts.category; }
|
||||
|
|
|
@ -168,7 +168,7 @@ export default RestModel.extend({
|
|||
this.set('summary', false);
|
||||
|
||||
let jump = false;
|
||||
if (userFilters.contains(username)) {
|
||||
if (userFilters.includes(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.contains(stored)) {
|
||||
if (!currentPosts.includes(stored)) {
|
||||
currentPosts.insertAt(postIdx++, stored);
|
||||
}
|
||||
});
|
||||
|
@ -410,7 +410,7 @@ export default RestModel.extend({
|
|||
if (stored) {
|
||||
const posts = this.get('posts');
|
||||
|
||||
if (!posts.contains(stored)) {
|
||||
if (!posts.includes(stored)) {
|
||||
if (!this.get('loadingBelow')) {
|
||||
this.get('postsWithPlaceholders').appendPost(() => posts.pushObject(stored));
|
||||
} else {
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
{{!-- THIS IS AN EMPTY TEMPLATE THAT NEEDS TO BE OVERWRITTEN --}}
|
|
@ -1,11 +1,11 @@
|
|||
{{plugin-outlet "above-site-header"}}
|
||||
{{site-header canSignUp=canSignUp
|
||||
showCreateAccount="showCreateAccount"
|
||||
showLogin="showLogin"
|
||||
showKeyboard="showKeyboardShortcutsHelp"
|
||||
toggleMobileView="toggleMobileView"
|
||||
toggleAnonymous="toggleAnonymous"
|
||||
logout="logout"}}
|
||||
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 "below-site-header"}}
|
||||
|
||||
<div id="main-outlet" class="wrap">
|
||||
|
|
|
@ -1,5 +1,18 @@
|
|||
{{#if showAdminButton}}
|
||||
{{topic-admin-menu-button topic=topic delegated=topicDelegated openUpwards="true"}}
|
||||
{{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}}
|
||||
{{/if}}
|
||||
|
||||
{{#unless topic.isPrivateMessage}}
|
||||
|
@ -10,7 +23,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"}}
|
||||
|
@ -22,7 +35,7 @@
|
|||
title="topic.flag_topic.help"
|
||||
label="topic.flag_topic.title"
|
||||
icon="flag"
|
||||
action="showFlagTopic"}}
|
||||
action=showFlagTopic}}
|
||||
{{/if}}
|
||||
|
||||
{{/if}}
|
||||
|
@ -33,7 +46,7 @@
|
|||
title="topic.invite_reply.help"
|
||||
label="topic.invite_reply.title"
|
||||
icon="users"
|
||||
action="showInvite"
|
||||
action=showInvite
|
||||
disabled=inviteDisabled}}
|
||||
{{/if}}
|
||||
|
||||
|
@ -42,19 +55,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 "after-topic-footer-main-buttons" tagName="span"}}
|
||||
|
||||
{{pinned-button topic=topic topicDelegated=topicDelegated}}
|
||||
{{topic-notifications-button topic=topic topicDelegated=topicDelegated}}
|
||||
{{pinned-button topic=topic}}
|
||||
{{topic-notifications-button topic=topic}}
|
||||
{{plugin-outlet "after-topic-footer-buttons" tagName="span"}}
|
||||
|
|
|
@ -4,5 +4,4 @@
|
|||
<span>/</span>
|
||||
<h4>{{postStream.filteredPostsCount}}</h4></span>
|
||||
</div>
|
||||
<i class="fa {{unless expanded 'fa-sort'}}"></i>
|
||||
</nav>
|
||||
|
|
|
@ -78,7 +78,6 @@
|
|||
{{#if model.archetype.hasOptions}}
|
||||
<button class='btn' {{action "showOptions"}}>{{i18n 'topic.options'}}</button>
|
||||
{{/if}}
|
||||
{{render "additional-composer-buttons" model}}
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
|
|
@ -70,24 +70,53 @@
|
|||
</div>
|
||||
|
||||
{{#topic-navigation jumpToIndex="jumpToIndex" as |info|}}
|
||||
|
||||
{{#if info.renderAdminMenuButton}}
|
||||
{{topic-admin-menu-button topic=model fixed="true" delegated=topicDelegated}}
|
||||
{{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")}}
|
||||
{{/if}}
|
||||
|
||||
{{#if info.renderTimeline}}
|
||||
{{topic-timeline topic=model
|
||||
prevEvent=info.prevEvent
|
||||
fullscreen=info.topicProgressExpanded
|
||||
enteredIndex=enteredIndex
|
||||
loading=model.postStream.loading
|
||||
delegated=topicDelegated}}
|
||||
|
||||
{{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")}}
|
||||
{{else}}
|
||||
{{topic-progress prevEvent=info.prevEvent topic=model delegated=topicDelegated expanded=info.topicProgressExpanded}}
|
||||
{{topic-progress
|
||||
prevEvent=info.prevEvent
|
||||
topic=model
|
||||
expanded=info.topicProgressExpanded}}
|
||||
{{/if}}
|
||||
|
||||
|
||||
{{/topic-navigation}}
|
||||
|
||||
<div class="row">
|
||||
|
@ -106,35 +135,34 @@
|
|||
selectedPostsCount=selectedPostsCount
|
||||
selectedQuery=selectedQuery
|
||||
gaps=model.postStream.gaps
|
||||
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"}}
|
||||
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")}}
|
||||
{{/unless}}
|
||||
|
||||
{{conditional-loading-spinner condition=model.postStream.loadingBelow}}
|
||||
|
@ -150,7 +178,25 @@
|
|||
{{signup-cta}}
|
||||
{{else}}
|
||||
{{#if currentUser}}
|
||||
{{topic-footer-buttons topic=model topicDelegated=topicDelegated}}
|
||||
{{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")
|
||||
}}
|
||||
{{else}}
|
||||
{{d-button icon="reply" class="btn-primary" action="showLogin" label="topic.reply.title"}}
|
||||
{{/if}}
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
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();
|
||||
}
|
||||
});
|
|
@ -11,7 +11,7 @@ function renderParticipants(userFilters, participants) {
|
|||
|
||||
userFilters = userFilters || [];
|
||||
return participants.map(p => {
|
||||
return this.attach('topic-participant', p, { state: { toggled: userFilters.contains(p.username) } });
|
||||
return this.attach('topic-participant', p, { state: { toggled: userFilters.includes(p.username) } });
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -256,31 +256,24 @@ export default class Widget {
|
|||
}
|
||||
|
||||
_sendComponentAction(name, param) {
|
||||
const view = this._findAncestorWithProperty('_emberView');
|
||||
|
||||
let promise;
|
||||
if (view) {
|
||||
// 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`);
|
||||
const view = this._findView();
|
||||
if (view) {
|
||||
const method = view.attrs[name];
|
||||
if (!method) {
|
||||
console.warn(`${name} not found`);
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
if (typeof name === "string") {
|
||||
view.sendAction(name, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
window.ENV = { };
|
||||
window.EmberENV = window.EmberENV || {};
|
||||
window.EmberENV.FORCE_JQUERY = true;
|
||||
window.EmberENV._ENABLE_LEGACY_VIEW_SUPPORT = true;
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -20,6 +20,6 @@ test("grantableBadges", function() {
|
|||
});
|
||||
|
||||
|
||||
not(badgeNames.contains(badgeDisabled), "excludes disabled badges");
|
||||
not(badgeNames.includes(badgeDisabled), "excludes disabled badges");
|
||||
deepEqual(badgeNames, sortedNames, "sorts badges by name");
|
||||
});
|
||||
|
|
|
@ -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').contains('eviltrout'), 'eviltrout is in the filters');
|
||||
ok(postStream.get('userFilters').includes('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", () => {
|
||||
buildStream(1234).loadIntoIdentityMap([]).then(result => {
|
||||
return 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);
|
||||
|
||||
postStream.loadIntoIdentityMap([10]).then(function() {
|
||||
return 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').contains(stagedPost), "the post is added to the stream");
|
||||
ok(postStream.get('posts').includes(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').contains(stagedPost), "the post is removed from the stream");
|
||||
ok(!postStream.get('posts').includes(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').contains(stagedPost), "the post is still in the stream");
|
||||
ok(postStream.get('posts').includes(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");
|
||||
|
|
|
@ -15,7 +15,7 @@ test('defaults', function() {
|
|||
|
||||
test('pagination support', function() {
|
||||
const store = createStore();
|
||||
store.findAll('widget').then(function(rs) {
|
||||
return 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();
|
||||
store.findAll('widget').then(function(rs) {
|
||||
return store.findAll('widget').then(function(rs) {
|
||||
equal(rs.get('refreshUrl'), '/widgets?refresh=true', 'it has the refresh url');
|
||||
|
||||
const promise = rs.refresh();
|
||||
|
|
|
@ -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.on('undoPostAction', () => this.undid = true);
|
||||
this.set('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
Loading…
Reference in New Issue