Revert "DEV: Upgrade to Ember 3.7.0 (#6977)" (#7165)

This reverts commit 3eebf8be733065996ff172adbcad85c254048274.
This commit is contained in:
Roman Rizzi
2019-03-13 15:49:47 -03:00
committed by GitHub
parent 4178578e09
commit 77931b70c3
33 changed files with 152 additions and 214 deletions

View File

@ -49,7 +49,7 @@ gem 'onebox', '1.8.82'
gem 'http_accept_language', '~>2.0.5', require: false gem 'http_accept_language', '~>2.0.5', require: false
gem 'ember-rails', '0.18.5' gem 'ember-rails', '0.18.5'
gem 'discourse-ember-source', '~> 3.7.0' gem 'discourse-ember-source', '~> 3.5.1'
gem 'ember-handlebars-template', '0.8.0' gem 'ember-handlebars-template', '0.8.0'
gem 'barber' gem 'barber'

View File

@ -108,7 +108,7 @@ GEM
terminal-table (~> 1) terminal-table (~> 1)
debug_inspector (0.0.3) debug_inspector (0.0.3)
diff-lcs (1.3) diff-lcs (1.3)
discourse-ember-source (3.7.0.2) discourse-ember-source (3.5.1.3)
discourse_image_optim (0.26.2) discourse_image_optim (0.26.2)
exifr (~> 1.2, >= 1.2.2) exifr (~> 1.2, >= 1.2.2)
fspath (~> 3.0) fspath (~> 3.0)
@ -466,7 +466,7 @@ DEPENDENCIES
colored2 colored2
cppjieba_rb cppjieba_rb
danger danger
discourse-ember-source (~> 3.7.0) discourse-ember-source (~> 3.5.1)
discourse_image_optim discourse_image_optim
email_reply_trimmer (~> 0.1) email_reply_trimmer (~> 0.1)
ember-handlebars-template (= 0.8.0) ember-handlebars-template (= 0.8.0)

View File

@ -100,7 +100,7 @@ export default Ember.Component.extend({
if (this.appEvents) { if (this.appEvents) {
// xxx: don't run during qunit tests // xxx: don't run during qunit tests
this.appEvents.on("ace:resize", this, "resize"); this.appEvents.on("ace:resize", () => this.resize());
} }
if (this.get("autofocus")) { if (this.get("autofocus")) {

View File

@ -10,13 +10,12 @@ export default Discourse.Route.extend({
const routeName = "adminUsersList.show"; const routeName = "adminUsersList.show";
if (transition.targetName === routeName) { if (transition.targetName === routeName) {
const params = transition.routeInfos.find(a => a.name === routeName) const params = transition.params[routeName];
.params;
const controller = this.controllerFor(routeName); const controller = this.controllerFor(routeName);
if (controller) { if (controller) {
controller.setProperties({ controller.setProperties({
order: transition.to.queryParams.order, order: transition.queryParams.order,
ascending: transition.to.queryParams.ascending, ascending: transition.queryParams.ascending,
query: params.filter, query: params.filter,
showEmails: false, showEmails: false,
refreshing: false refreshing: false

View File

@ -290,27 +290,25 @@ export default Ember.Component.extend({
}); });
if (this.get("composerEvents")) { if (this.get("composerEvents")) {
this.appEvents.on("composer:insert-block", this, "_insertBlock"); this.appEvents.on("composer:insert-block", text =>
this.appEvents.on("composer:insert-text", this, "_insertText"); this._addBlock(this._getSelected(), text)
this.appEvents.on("composer:replace-text", this, "_replaceText"); );
this.appEvents.on("composer:insert-text", (text, options) =>
this._addText(this._getSelected(), text, options)
);
this.appEvents.on("composer:replace-text", (oldVal, newVal, opts) =>
this._replaceText(oldVal, newVal, opts)
);
} }
this._mouseTrap = mouseTrap; this._mouseTrap = mouseTrap;
}, },
_insertBlock(text) {
this._addBlock(this._getSelected(), text);
},
_insertText(text, options) {
this._addText(this._getSelected(), text, options);
},
@on("willDestroyElement") @on("willDestroyElement")
_shutDown() { _shutDown() {
if (this.get("composerEvents")) { if (this.get("composerEvents")) {
this.appEvents.off("composer:insert-block", this, "_insertBlock"); this.appEvents.off("composer:insert-block");
this.appEvents.off("composer:insert-text", this, "_insertText"); this.appEvents.off("composer:insert-text");
this.appEvents.off("composer:replace-text", this, "_replaceText"); this.appEvents.off("composer:replace-text");
} }
const mouseTrap = this._mouseTrap; const mouseTrap = this._mouseTrap;

View File

@ -14,14 +14,14 @@ export default Ember.Component.extend({
} }
Ember.run.scheduleOnce("afterRender", this, this._afterFirstRender); Ember.run.scheduleOnce("afterRender", this, this._afterFirstRender);
this.appEvents.on("modal-body:flash", this, "_flash"); this.appEvents.on("modal-body:flash", msg => this._flash(msg));
this.appEvents.on("modal-body:clearFlash", this, "_clearFlash"); this.appEvents.on("modal-body:clearFlash", () => this._clearFlash());
}, },
willDestroyElement() { willDestroyElement() {
this._super(...arguments); this._super(...arguments);
this.appEvents.off("modal-body:flash", this, "_flash"); this.appEvents.off("modal-body:flash");
this.appEvents.off("modal-body:clearFlash", this, "_clearFlash"); this.appEvents.off("modal-body:clearFlash");
}, },
_afterFirstRender() { _afterFirstRender() {

View File

@ -77,7 +77,9 @@ export default Ember.Component.extend(AddArchetypeClass, Scrolling, {
} }
); );
this.appEvents.on("post:highlight", this, "_highlightPost"); this.appEvents.on("post:highlight", postNumber => {
Ember.run.scheduleOnce("afterRender", null, highlight, postNumber);
});
this.appEvents.on("header:update-topic", topic => { this.appEvents.on("header:update-topic", topic => {
if (topic === null) { if (topic === null) {
@ -97,29 +99,23 @@ export default Ember.Component.extend(AddArchetypeClass, Scrolling, {
}); });
// setup mobile scroll logo // setup mobile scroll logo
if (this.site.mobileView) { if (this.site.mobileView) {
this.appEvents.on("topic:scrolled", this, "mobileScrollGuard"); this.appEvents.on("topic:scrolled", offset =>
this.mobileScrollGaurd(offset)
);
// used to animate header contents on scroll // used to animate header contents on scroll
this.appEvents.on("header:show-topic", this, "_showTopic"); this.appEvents.on("header:show-topic", () => {
this.appEvents.on("header:hide-topic", this, "_hideTopic"); $("header.d-header")
.removeClass("scroll-up")
.addClass("scroll-down");
});
this.appEvents.on("header:hide-topic", () => {
$("header.d-header")
.removeClass("scroll-down")
.addClass("scroll-up");
});
} }
}, },
_showTopic() {
$("header.d-header")
.removeClass("scroll-up")
.addClass("scroll-down");
},
_hideTopic() {
$("header.d-header")
.removeClass("scroll-down")
.addClass("scroll-up");
},
_highlightPost(postNumber) {
Ember.run.scheduleOnce("afterRender", null, highlight, postNumber);
},
willDestroyElement() { willDestroyElement() {
this._super(...arguments); this._super(...arguments);
this.unbindScrolling("topic-view"); this.unbindScrolling("topic-view");
@ -132,10 +128,10 @@ export default Ember.Component.extend(AddArchetypeClass, Scrolling, {
// this happens after route exit, stuff could have trickled in // this happens after route exit, stuff could have trickled in
this.appEvents.trigger("header:hide-topic"); this.appEvents.trigger("header:hide-topic");
this.appEvents.off("post:highlight", this, "_highlightPost"); this.appEvents.off("post:highlight");
// mobile scroll logo clean up. // mobile scroll logo clean up.
if (this.site.mobileView) { if (this.site.mobileView) {
this.appEvents.off("topic:scrolled", this, "mobileScrollGuard"); this.appEvents.off("topic:scrolled");
$("header.d-header").removeClass("scroll-down scroll-up"); $("header.d-header").removeClass("scroll-down scroll-up");
} }
}, },
@ -203,7 +199,7 @@ export default Ember.Component.extend(AddArchetypeClass, Scrolling, {
// determines scroll direction, triggers header topic info on mobile // determines scroll direction, triggers header topic info on mobile
// and ensures that the switch happens only once per scroll direction change // and ensures that the switch happens only once per scroll direction change
mobileScrollGuard(offset) { mobileScrollGaurd(offset) {
// user hasn't scrolled past topic title. // user hasn't scrolled past topic title.
if (offset < this.dockAt) return; if (offset < this.dockAt) return;

View File

@ -77,11 +77,7 @@ export default Ember.Component.extend({
@on("willDestroyElement") @on("willDestroyElement")
_unbindGlobalEvents() { _unbindGlobalEvents() {
this.appEvents.off("emoji-picker:close", this, "_closeEmojiPicker"); this.appEvents.off("emoji-picker:close");
},
_closeEmojiPicker() {
this.set("active", false);
}, },
@on("didInsertElement") @on("didInsertElement")
@ -89,7 +85,7 @@ export default Ember.Component.extend({
this.$picker = this.$(".emoji-picker"); this.$picker = this.$(".emoji-picker");
this.$modal = this.$(".emoji-picker-modal"); this.$modal = this.$(".emoji-picker-modal");
this.appEvents.on("emoji-picker:close", this, "_closeEmojiPicker"); this.appEvents.on("emoji-picker:close", () => this.set("active", false));
if (!keyValueStore.getObject(EMOJI_USAGE)) { if (!keyValueStore.getObject(EMOJI_USAGE)) {
keyValueStore.setObject({ key: EMOJI_USAGE, value: [] }); keyValueStore.setObject({ key: EMOJI_USAGE, value: [] });

View File

@ -18,7 +18,7 @@ export default Ember.Component.extend({
"#login-account-password, #login-account-name, #login-second-factor" "#login-account-password, #login-account-name, #login-second-factor"
).keydown(e => { ).keydown(e => {
if (e.keyCode === 13) { if (e.keyCode === 13) {
this.action(); this.sendAction();
} }
}); });
}); });

View File

@ -7,7 +7,7 @@ export default Ember.Component.extend({
tagName: "li", tagName: "li",
classNameBindings: ["active"], classNameBindings: ["active"],
@computed @computed()
router() { router() {
return getOwner(this).lookup("router:main"); return getOwner(this).lookup("router:main");
}, },
@ -27,7 +27,7 @@ export default Ember.Component.extend({
router = this.get("router"); router = this.get("router");
return routeParam return routeParam
? router.currentRoute.params["filter"] === routeParam ? router.isActive(route, routeParam)
: router.isActive(route); : router.isActive(route);
} }
}); });

View File

@ -262,38 +262,6 @@ export default MountWidget.extend({
Ember.run.scheduleOnce("afterRender", this, this.scrolled); Ember.run.scheduleOnce("afterRender", this, this.scrolled);
}, },
_posted(staged) {
const disableJumpReply = this.currentUser.get("disable_jump_reply");
this.queueRerender(() => {
if (staged && !disableJumpReply) {
const postNumber = staged.get("post_number");
DiscourseURL.jumpToPost(postNumber, { skipIfOnScreen: true });
}
});
},
_refresh(args) {
if (args) {
if (args.id) {
this.dirtyKeys.keyDirty(`post-${args.id}`);
if (args.refreshLikes) {
this.dirtyKeys.keyDirty(`post-menu-${args.id}`, {
onRefresh: "refreshLikes"
});
}
} else if (args.force) {
this.dirtyKeys.forceAll();
}
}
this.queueRerender();
},
_debouncedScroll() {
Ember.run.debounce(this, this._scrollTriggered, 10);
},
didInsertElement() { didInsertElement() {
this._super(...arguments); this._super(...arguments);
const debouncedScroll = () => const debouncedScroll = () =>
@ -301,12 +269,21 @@ export default MountWidget.extend({
this._previouslyNearby = {}; this._previouslyNearby = {};
this.appEvents.on("post-stream:refresh", this, "_debouncedScroll"); this.appEvents.on("post-stream:refresh", debouncedScroll);
$(document).bind("touchmove.post-stream", debouncedScroll); $(document).bind("touchmove.post-stream", debouncedScroll);
$(window).bind("scroll.post-stream", debouncedScroll); $(window).bind("scroll.post-stream", debouncedScroll);
this._scrollTriggered(); this._scrollTriggered();
this.appEvents.on("post-stream:posted", this, "_posted"); this.appEvents.on("post-stream:posted", staged => {
const disableJumpReply = this.currentUser.get("disable_jump_reply");
this.queueRerender(() => {
if (staged && !disableJumpReply) {
const postNumber = staged.get("post_number");
DiscourseURL.jumpToPost(postNumber, { skipIfOnScreen: true });
}
});
});
this.$().on("mouseenter.post-stream", "button.widget-button", e => { this.$().on("mouseenter.post-stream", "button.widget-button", e => {
$("button.widget-button").removeClass("d-hover"); $("button.widget-button").removeClass("d-hover");
@ -317,18 +294,33 @@ export default MountWidget.extend({
$("button.widget-button").removeClass("d-hover"); $("button.widget-button").removeClass("d-hover");
}); });
this.appEvents.on("post-stream:refresh", this, "_refresh"); this.appEvents.on("post-stream:refresh", args => {
if (args) {
if (args.id) {
this.dirtyKeys.keyDirty(`post-${args.id}`);
if (args.refreshLikes) {
this.dirtyKeys.keyDirty(`post-menu-${args.id}`, {
onRefresh: "refreshLikes"
});
}
} else if (args.force) {
this.dirtyKeys.forceAll();
}
}
this.queueRerender();
});
}, },
willDestroyElement() { willDestroyElement() {
this._super(...arguments); this._super(...arguments);
$(document).unbind("touchmove.post-stream"); $(document).unbind("touchmove.post-stream");
$(window).unbind("scroll.post-stream"); $(window).unbind("scroll.post-stream");
this.appEvents.off("post-stream:refresh", this, "_debouncedScroll"); this.appEvents.off("post-stream:refresh");
this.$().off("mouseenter.post-stream"); this.$().off("mouseenter.post-stream");
this.$().off("mouseleave.post-stream"); this.$().off("mouseleave.post-stream");
this.appEvents.off("post-stream:refresh", this, "_refresh"); this.appEvents.off("post-stream:refresh");
this.appEvents.off("post-stream:posted", this, "_posted"); this.appEvents.off("post-stream:posted");
}, },
showModerationHistory(post) { showModerationHistory(post) {

View File

@ -231,14 +231,19 @@ const SiteHeaderComponent = MountWidget.extend(Docking, PanEvents, {
const { isAndroid } = this.capabilities; const { isAndroid } = this.capabilities;
$(window).on("resize.discourse-menu-panel", () => this.afterRender()); $(window).on("resize.discourse-menu-panel", () => this.afterRender());
this.appEvents.on("header:show-topic", this, "setTopic"); this.appEvents.on("header:show-topic", topic => this.setTopic(topic));
this.appEvents.on("header:hide-topic", this, "setTopic"); this.appEvents.on("header:hide-topic", () => this.setTopic(null));
this.dispatch("notifications:changed", "user-notifications"); this.dispatch("notifications:changed", "user-notifications");
this.dispatch("header:keyboard-trigger", "header"); this.dispatch("header:keyboard-trigger", "header");
this.dispatch("search-autocomplete:after-complete", "search-term"); this.dispatch("search-autocomplete:after-complete", "search-term");
this.appEvents.on("dom:clean", this, "_cleanDom"); this.appEvents.on("dom:clean", () => {
// For performance, only trigger a re-render if any menu panels are visible
if (this.$(".menu-panel").length) {
this.eventDispatched("dom:clean", "header");
}
});
// Only add listeners for opening menus by swiping them in on Android devices // Only add listeners for opening menus by swiping them in on Android devices
// iOS will respond to these events, but also does swiping for back/forward // iOS will respond to these events, but also does swiping for back/forward
@ -247,22 +252,15 @@ const SiteHeaderComponent = MountWidget.extend(Docking, PanEvents, {
} }
}, },
_cleanDom() {
// For performance, only trigger a re-render if any menu panels are visible
if (this.$(".menu-panel").length) {
this.eventDispatched("dom:clean", "header");
}
},
willDestroyElement() { willDestroyElement() {
this._super(...arguments); this._super(...arguments);
const { isAndroid } = this.capabilities; const { isAndroid } = this.capabilities;
$("body").off("keydown.header"); $("body").off("keydown.header");
$(window).off("resize.discourse-menu-panel"); $(window).off("resize.discourse-menu-panel");
this.appEvents.off("header:show-topic", this, "setTopic"); this.appEvents.off("header:show-topic");
this.appEvents.off("header:hide-topic", this, "setTopic"); this.appEvents.off("header:hide-topic");
this.appEvents.off("dom:clean", this, "_cleanDom"); this.appEvents.off("dom:clean");
if (isAndroid) { if (isAndroid) {
this.removeTouchListeners($("body")); this.removeTouchListeners($("body"));

View File

@ -53,7 +53,7 @@ export default Ember.Component.extend(CleansUp, {
didInsertElement() { didInsertElement() {
this._super(...arguments); this._super(...arguments);
this.appEvents.on("topic-entrance:show", this, "_show"); this.appEvents.on("topic-entrance:show", data => this._show(data));
}, },
_setCSS() { _setCSS() {
@ -100,7 +100,7 @@ export default Ember.Component.extend(CleansUp, {
}, },
willDestroyElement() { willDestroyElement() {
this.appEvents.off("topic-entrance:show", this, "_show"); this.appEvents.off("topic-entrance:show");
}, },
_jumpTo(destination) { _jumpTo(destination) {

View File

@ -13,7 +13,7 @@ export default Ember.Component.extend({
$(window).on("load.faq resize.faq scroll.faq", () => { $(window).on("load.faq resize.faq scroll.faq", () => {
const faqUnread = !currentUser.get("read_faq"); const faqUnread = !currentUser.get("read_faq");
if (faqUnread && isElementInViewport($(".contents p").last())) { if (faqUnread && isElementInViewport($(".contents p").last())) {
this.action(); this.sendAction();
} }
}); });
} }

View File

@ -9,14 +9,15 @@ const {
runInDebug runInDebug
} = Ember; } = Ember;
function getCurrentRouteInfos(router) { function getCurrentHandlerInfos(router) {
let routerLib = router._routerMicrolib || router.router; let routerLib = router._routerMicrolib || router.router;
return routerLib.currentRouteInfos;
return routerLib.currentHandlerInfos;
} }
function getRoutes(router) { function getRoutes(router) {
return emberArray(getCurrentRouteInfos(router)) return emberArray(getCurrentHandlerInfos(router))
.mapBy("_route") .mapBy("handler")
.reverse(); .reverse();
} }

View File

@ -12,12 +12,10 @@ export default {
initialize(container) { initialize(container) {
// Tell our AJAX system to track a page transition // Tell our AJAX system to track a page transition
const router = container.lookup("router:main"); const router = container.lookup("router:main");
router.on("willTransition", viewTrackingRequired);
router.on("routeWillChange", viewTrackingRequired); router.on("didTransition", cleanDOM);
router.on("routeDidChange", cleanDOM);
let appEvents = container.lookup("app-events:main"); let appEvents = container.lookup("app-events:main");
startPageTracking(router, appEvents); startPageTracking(router, appEvents);
// Out of the box, Discourse tries to track google analytics // Out of the box, Discourse tries to track google analytics

View File

@ -7,7 +7,7 @@ export default {
// only take care of hiding the footer here // only take care of hiding the footer here
// controllers MUST take care of displaying it // controllers MUST take care of displaying it
router.on("routeWillChange", () => { router.on("willTransition", () => {
application.set("showFooter", false); application.set("showFooter", false);
return true; return true;
}); });

View File

@ -1,48 +1 @@
import deprecated from "discourse-common/lib/deprecated"; export default Ember.Object.extend(Ember.Evented);
export default Ember.Object.extend(Ember.Evented, {
_events: {},
on() {
if (arguments.length === 2) {
let [name, fn] = arguments;
let target = {};
this._events[name] = this._events[name] || [];
this._events[name].push({ target, fn });
this._super(name, target, fn);
} else if (arguments.length === 3) {
let [name, target, fn] = arguments;
this._events[name] = this._events[name] || [];
this._events[name].push({ target, fn });
this._super(...arguments);
}
return this;
},
off() {
let name = arguments[0];
let fn = arguments[2];
if (this._events[name]) {
if (arguments.length === 1) {
deprecated(
"Removing all event listeners at once is deprecated, please remove each listener individually."
);
this._events[name].forEach(ref => {
this._super(name, ref.target, ref.fn);
});
delete this._events[name];
} else if (arguments.length === 3) {
this._super(...arguments);
this._events[name] = this._events[name].filter(e => e.fn !== fn);
if (this._events[name].length === 0) delete this._events[name];
}
}
return this;
}
});

View File

@ -15,9 +15,10 @@ export function startPageTracking(router, appEvents) {
if (_started) { if (_started) {
return; return;
} }
router.on("routeDidChange", () => {
router.send("refreshTitle"); router.on("didTransition", function() {
const url = Discourse.getURL(router.get("url")); this.send("refreshTitle");
const url = Discourse.getURL(this.get("url"));
// Refreshing the title is debounced, so we need to trigger this in the // Refreshing the title is debounced, so we need to trigger this in the
// next runloop to have the correct title. // next runloop to have the correct title.
@ -38,7 +39,6 @@ export function startPageTracking(router, appEvents) {
} }
}); });
}); });
_started = true; _started = true;
} }

View File

@ -122,7 +122,10 @@ export default Ember.Mixin.create({
return this._show($target.text().replace(/^@/, ""), $target); return this._show($target.text().replace(/^@/, ""), $target);
}); });
this.appEvents.on(previewClickEvent, this, "_previewClick"); this.appEvents.on(previewClickEvent, $target => {
this.set("isFixed", true);
return this._show($target.text().replace(/^@/, ""), $target);
});
this.appEvents.on(`topic-header:trigger-${id}`, (username, $target) => { this.appEvents.on(`topic-header:trigger-${id}`, (username, $target) => {
this.setProperties({ isFixed: true, isDocked: true }); this.setProperties({ isFixed: true, isDocked: true });
@ -130,11 +133,6 @@ export default Ember.Mixin.create({
}); });
}, },
_previewClick($target) {
this.set("isFixed", true);
return this._show($target.text().replace(/^@/, ""), $target);
},
_positionCard(target) { _positionCard(target) {
const rtl = $("html").css("direction") === "rtl"; const rtl = $("html").css("direction") === "rtl";
if (!target) { if (!target) {
@ -241,7 +239,7 @@ export default Ember.Mixin.create({
$("#main") $("#main")
.off(clickDataExpand) .off(clickDataExpand)
.off(clickMention); .off(clickMention);
this.appEvents.off(previewClickEvent, this, "_previewClick"); this.appEvents.off(previewClickEvent);
}, },
keyUp(e) { keyUp(e) {

View File

@ -7,12 +7,12 @@ export default {
didInsertElement() { didInsertElement() {
this._super(...arguments); this._super(...arguments);
this.appEvents.on("url:refresh", this, "refresh"); this.appEvents.on("url:refresh", this.refresh);
}, },
willDestroyElement() { willDestroyElement() {
this._super(...arguments); this._super(...arguments);
this.appEvents.off("url:refresh", this, "refresh"); this.appEvents.off("url:refresh");
} }
}; };

View File

@ -30,8 +30,7 @@ export default Discourse.Route.extend({
}, },
afterModel(model, transition) { afterModel(model, transition) {
const username = const username = transition.queryParams && transition.queryParams.username;
transition.to.queryParams && transition.to.queryParams.username;
const userBadgesGrant = UserBadge.findByBadgeId(model.get("id"), { const userBadgesGrant = UserBadge.findByBadgeId(model.get("id"), {
username username

View File

@ -93,7 +93,7 @@ export default (filterArg, params) => {
const listFilter = `c/${Discourse.Category.slugFor( const listFilter = `c/${Discourse.Category.slugFor(
category category
)}/l/${this.filter(category)}`, )}/l/${this.filter(category)}`,
findOpts = filterQueryParams(transition.to.queryParams, params), findOpts = filterQueryParams(transition.queryParams, params),
extras = { cached: this.isPoppedState(transition) }; extras = { cached: this.isPoppedState(transition) };
return findTopicList( return findTopicList(

View File

@ -7,7 +7,7 @@ export function buildGroupPage(type) {
}, },
model(params, transition) { model(params, transition) {
let categoryId = Ember.get(transition.to, "queryParams.category_id"); let categoryId = Ember.get(transition, "queryParams.category_id");
return this.modelFor("group").findPosts({ type, categoryId }); return this.modelFor("group").findPosts({ type, categoryId });
}, },

View File

@ -3,8 +3,7 @@ import Group from "discourse/models/group";
export default Discourse.Route.extend({ export default Discourse.Route.extend({
beforeModel(transition) { beforeModel(transition) {
const params = transition.to.queryParams; const params = transition.queryParams;
const groupName = params.groupname || params.group_name; const groupName = params.groupname || params.group_name;
if (this.currentUser) { if (this.currentUser) {

View File

@ -6,11 +6,11 @@ export default Discourse.Route.extend({
if (Discourse.User.current()) { if (Discourse.User.current()) {
let category, category_id; let category, category_id;
if (transition.to.queryParams.category_id) { if (transition.queryParams.category_id) {
category_id = transition.to.queryParams.category_id; category_id = transition.queryParams.category_id;
category = Category.findById(category_id); category = Category.findById(category_id);
} else if (transition.to.queryParams.category) { } else if (transition.queryParams.category) {
const splitCategory = transition.to.queryParams.category.split("/"); const splitCategory = transition.queryParams.category.split("/");
category = this._getCategory( category = this._getCategory(
splitCategory[0], splitCategory[0],
splitCategory[1], splitCategory[1],
@ -46,10 +46,10 @@ export default Discourse.Route.extend({
Ember.run.next(function() { Ember.run.next(function() {
e.send( e.send(
"createNewTopicViaParams", "createNewTopicViaParams",
transition.to.queryParams.title, transition.queryParams.title,
transition.to.queryParams.body, transition.queryParams.body,
category_id, category_id,
transition.to.queryParams.tags transition.queryParams.tags
); );
}); });
} }
@ -60,10 +60,10 @@ export default Discourse.Route.extend({
Ember.run.next(function() { Ember.run.next(function() {
e.send( e.send(
"createNewTopicViaParams", "createNewTopicViaParams",
transition.to.queryParams.title, transition.queryParams.title,
transition.to.queryParams.body, transition.queryParams.body,
null, null,
transition.to.queryParams.tags transition.queryParams.tags
); );
}); });
} }

View File

@ -70,8 +70,8 @@ export default Discourse.Route.extend({
controller.set("loading", true); controller.set("loading", true);
const params = controller.getProperties("order", "ascending"); const params = controller.getProperties("order", "ascending");
params.order = transition.to.queryParams.order || params.order; params.order = transition.queryParams.order || params.order;
params.ascending = transition.to.queryParams.ascending || params.ascending; params.ascending = transition.queryParams.ascending || params.ascending;
const categorySlug = this.get("categorySlug"); const categorySlug = this.get("categorySlug");
const parentCategorySlug = this.get("parentCategorySlug"); const parentCategorySlug = this.get("parentCategorySlug");

View File

@ -231,7 +231,7 @@ const TopicRoute = Discourse.Route.extend({
}); });
} }
const queryParams = transition.to.queryParams; const queryParams = transition.queryParams;
let topic = this.modelFor("topic"); let topic = this.modelFor("topic");
if (topic && topic.get("id") === parseInt(params.id, 10)) { if (topic && topic.get("id") === parseInt(params.id, 10)) {

View File

@ -14,7 +14,7 @@ export default Discourse.Route.extend(ViewingActionType, {
filter: this.get("userActionType"), filter: this.get("userActionType"),
noContentHelpKey: noContentHelpKey:
this.get("noContentHelpKey") || "user_activity.no_default", this.get("noContentHelpKey") || "user_activity.no_default",
actingUsername: transition.to.queryParams.acting_username actingUsername: transition.queryParams.acting_username
}); });
}, },

View File

@ -1,4 +1,5 @@
import ComboBoxComponent from "select-kit/components/combo-box"; import ComboBoxComponent from "select-kit/components/combo-box";
import { on } from "ember-addons/ember-computed-decorators";
import computed from "ember-addons/ember-computed-decorators"; import computed from "ember-addons/ember-computed-decorators";
import PermissionType from "discourse/models/permission-type"; import PermissionType from "discourse/models/permission-type";
import Category from "discourse/models/category"; import Category from "discourse/models/category";
@ -99,6 +100,16 @@ export default ComboBoxComponent.extend({
return content; return content;
}, },
@on("didRender")
_bindComposerResizing() {
this.appEvents.on("composer:resized", this, this.applyDirection);
},
@on("willDestroyElement")
_unbindComposerResizing() {
this.appEvents.off("composer:resized");
},
didSelect(computedContentItem) { didSelect(computedContentItem) {
if (this.attrs.onChooseCategory) { if (this.attrs.onChooseCategory) {
this.attrs.onChooseCategory(computedContentItem.originalContent); this.attrs.onChooseCategory(computedContentItem.originalContent);

View File

@ -28,6 +28,6 @@ export default DropdownSelectBoxComponent.extend({
}, },
mutateValue(value) { mutateValue(value) {
this.get(value)(); this.sendAction(value);
} }
}); });

View File

@ -134,10 +134,10 @@ export default Ember.Component.extend(
this.removeObserver( this.removeObserver(
`content.@each.${this.get("nameProperty")}`, `content.@each.${this.get("nameProperty")}`,
this, this,
"_compute" this._compute
); );
this.removeObserver(`content.[]`, this, "_compute"); this.removeObserver(`content.[]`, this, this._compute);
this.removeObserver(`asyncContent.[]`, this, "_compute"); this.removeObserver(`asyncContent.[]`, this, this._compute);
}, },
willComputeAttributes() {}, willComputeAttributes() {},

View File

@ -17,20 +17,20 @@ export default NotificationOptionsComponent.extend({
return archetype === "private_message" ? "_pm" : ""; return archetype === "private_message" ? "_pm" : "";
}, },
_changed(msg) {
if (this.get("computedValue") !== msg.id) {
this.get("topic.details").updateNotifications(msg.id);
}
},
@on("didInsertElement") @on("didInsertElement")
_bindGlobalLevelChanged() { _bindGlobalLevelChanged() {
this.appEvents.on("topic-notifications-button:changed", this, "_changed"); this.appEvents.on("topic-notifications-button:changed", msg => {
if (msg.type === "notification") {
if (this.get("computedValue") !== msg.id) {
this.get("topic.details").updateNotifications(msg.id);
}
}
});
}, },
@on("willDestroyElement") @on("willDestroyElement")
_unbindGlobalLevelChanged() { _unbindGlobalLevelChanged() {
this.appEvents.off("topic-notifications-button:changed", this, "_changed"); this.appEvents.off("topic-notifications-button:changed");
}, },
mutateValue(value) { mutateValue(value) {