FIX: Broken computing of userHasTimezone in bookmark modal and missing tap-tile templates for regular users (#9229)

Based on reports here https://meta.discourse.org/t/improved-bookmarks-with-reminders/144542

* Because the `userHasTimezone` property was computed and we were checking on an (essentially) global object, ember was not aware that the user timezone had changed because it changed in a different place. instead set the timezone as internal state for the modal on show and base the computed property off of that so it mutates correctly
* The tap-tile components were in the admin folder completely unnecessarily, move them out into the main discourse folder otherwise noone else can use the new bookmarks (icon + text is missing)
This commit is contained in:
Martin Brennan
2020-03-18 11:12:23 +10:00
committed by GitHub
parent 45ce9876cc
commit e2ce12d414
4 changed files with 23 additions and 12 deletions

View File

@@ -3,7 +3,8 @@ let BookmarkController;
moduleFor("controller:bookmark", {
beforeEach() {
BookmarkController = this.subject({ currentUser: currentUser() });
Discourse.currentUser = currentUser();
BookmarkController = this.subject({ currentUser: Discourse.currentUser });
},
afterEach() {
@@ -12,7 +13,7 @@ moduleFor("controller:bookmark", {
});
function mockMomentTz(dateString) {
let now = moment.tz(dateString, BookmarkController.currentUser.timezone);
let now = moment.tz(dateString, BookmarkController.userTimezone);
sandbox.useFakeTimers(now.valueOf());
}
@@ -179,3 +180,15 @@ QUnit.test(
assert.equal(BookmarkController.lastCustomReminderTime, null);
}
);
QUnit.test(
"userHasTimezoneSet updates true/false based on whether the current user timezone is set globally",
function(assert) {
Discourse.currentUser.timezone = null;
BookmarkController.onShow();
assert.equal(BookmarkController.userHasTimezoneSet, false);
Discourse.currentUser.timezone = "Australia/Brisbane";
BookmarkController.onShow();
assert.equal(BookmarkController.userHasTimezoneSet, true);
}
);