mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
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:
parent
45ce9876cc
commit
e2ce12d414
|
@ -32,6 +32,7 @@ export default Controller.extend(ModalFunctionality, {
|
||||||
customReminderTime: null,
|
customReminderTime: null,
|
||||||
lastCustomReminderDate: null,
|
lastCustomReminderDate: null,
|
||||||
lastCustomReminderTime: null,
|
lastCustomReminderTime: null,
|
||||||
|
userTimezone: null,
|
||||||
|
|
||||||
onShow() {
|
onShow() {
|
||||||
this.setProperties({
|
this.setProperties({
|
||||||
|
@ -43,7 +44,8 @@ export default Controller.extend(ModalFunctionality, {
|
||||||
customReminderDate: null,
|
customReminderDate: null,
|
||||||
customReminderTime: null,
|
customReminderTime: null,
|
||||||
lastCustomReminderDate: null,
|
lastCustomReminderDate: null,
|
||||||
lastCustomReminderTime: null
|
lastCustomReminderTime: null,
|
||||||
|
userTimezone: this.currentUser.timezone
|
||||||
});
|
});
|
||||||
|
|
||||||
this.loadLastUsedCustomReminderDatetime();
|
this.loadLastUsedCustomReminderDatetime();
|
||||||
|
@ -174,9 +176,9 @@ export default Controller.extend(ModalFunctionality, {
|
||||||
return Discourse.BaseUri;
|
return Discourse.BaseUri;
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed()
|
@discourseComputed("userTimezone")
|
||||||
userHasTimezoneSet() {
|
userHasTimezoneSet(userTimezone) {
|
||||||
return !_.isEmpty(this.userTimezone());
|
return !_.isEmpty(userTimezone);
|
||||||
},
|
},
|
||||||
|
|
||||||
saveBookmark() {
|
saveBookmark() {
|
||||||
|
@ -216,7 +218,7 @@ export default Controller.extend(ModalFunctionality, {
|
||||||
},
|
},
|
||||||
|
|
||||||
parseCustomDateTime(date, time) {
|
parseCustomDateTime(date, time) {
|
||||||
return moment.tz(date + " " + time, this.userTimezone());
|
return moment.tz(date + " " + time, this.userTimezone);
|
||||||
},
|
},
|
||||||
|
|
||||||
reminderAt() {
|
reminderAt() {
|
||||||
|
@ -288,12 +290,8 @@ export default Controller.extend(ModalFunctionality, {
|
||||||
return momentDate.hour(START_OF_DAY_HOUR).startOf("hour");
|
return momentDate.hour(START_OF_DAY_HOUR).startOf("hour");
|
||||||
},
|
},
|
||||||
|
|
||||||
userTimezone() {
|
|
||||||
return this.currentUser.timezone;
|
|
||||||
},
|
|
||||||
|
|
||||||
now() {
|
now() {
|
||||||
return moment.tz(this.userTimezone());
|
return moment.tz(this.userTimezone);
|
||||||
},
|
},
|
||||||
|
|
||||||
laterToday() {
|
laterToday() {
|
||||||
|
|
|
@ -3,7 +3,8 @@ let BookmarkController;
|
||||||
|
|
||||||
moduleFor("controller:bookmark", {
|
moduleFor("controller:bookmark", {
|
||||||
beforeEach() {
|
beforeEach() {
|
||||||
BookmarkController = this.subject({ currentUser: currentUser() });
|
Discourse.currentUser = currentUser();
|
||||||
|
BookmarkController = this.subject({ currentUser: Discourse.currentUser });
|
||||||
},
|
},
|
||||||
|
|
||||||
afterEach() {
|
afterEach() {
|
||||||
|
@ -12,7 +13,7 @@ moduleFor("controller:bookmark", {
|
||||||
});
|
});
|
||||||
|
|
||||||
function mockMomentTz(dateString) {
|
function mockMomentTz(dateString) {
|
||||||
let now = moment.tz(dateString, BookmarkController.currentUser.timezone);
|
let now = moment.tz(dateString, BookmarkController.userTimezone);
|
||||||
sandbox.useFakeTimers(now.valueOf());
|
sandbox.useFakeTimers(now.valueOf());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,3 +180,15 @@ QUnit.test(
|
||||||
assert.equal(BookmarkController.lastCustomReminderTime, null);
|
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);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user