A platform for community discussion. Free, open, simple.
FEATURE: show the this weekend option on the bookmark modal (#15755)
Andrei Prigorshnevcd2e7d5436f9
diff --git a/app/assets/javascripts/discourse/app/components/edit-topic-timer-form.js b/app/assets/javascripts/discourse/app/components/edit-topic-timer-form.jsindex aa98c28bb82..f7a726d8484 100644--- a/app/assets/javascripts/discourse/app/components/edit-topic-timer-form.js+++ b/app/assets/javascripts/discourse/app/components/edit-topic-timer-form.js@@ -14,12 +14,7 @@ import I18n from "I18n";import { action } from "@ember/object";import Component from "@ember/component";import { isEmpty } from "@ember/utils";-import {- MOMENT_MONDAY,- now,- startOfDay,- thisWeekend,-} from "discourse/lib/time-utils";+import { MOMENT_MONDAY, now, startOfDay } from "discourse/lib/time-utils";import KeyboardShortcuts from "discourse/lib/keyboard-shortcuts";import { TIME_SHORTCUT_TYPES } from "discourse/lib/time-shortcut";import ItsATrap from "@discourse/itsatrap";@@ -88,13 +83,6 @@ export default Component.extend({@discourseComputed()customTimeShortcutOptions() {return [- {- icon: "bed",- id: "this_weekend",- label: "time_shortcut.this_weekend",- time: thisWeekend(),- timeFormatKey: "dates.time_short_day",- },{icon: "far-clock",id: "two_weeks",diff --git a/app/assets/javascripts/discourse/app/components/time-shortcut-picker.js b/app/assets/javascripts/discourse/app/components/time-shortcut-picker.jsindex caee171d91b..10219e71fc7 100644--- a/app/assets/javascripts/discourse/app/components/time-shortcut-picker.js+++ b/app/assets/javascripts/discourse/app/components/time-shortcut-picker.js@@ -1,5 +1,6 @@import {LATER_TODAY_CUTOFF_HOUR,+ MOMENT_FRIDAY,MOMENT_THURSDAY,START_OF_DAY_HOUR,laterToday,@@ -283,6 +284,10 @@ export default Component.extend({if (now(this.userTimezone).day() >= MOMENT_THURSDAY) {this._hideOption(options, TIME_SHORTCUT_TYPES.LATER_THIS_WEEK);}++ if (now(this.userTimezone).day() >= MOMENT_FRIDAY) {+ this._hideOption(options, TIME_SHORTCUT_TYPES.THIS_WEEKEND);+ }},_hideOption(options, optionId) {diff --git a/app/assets/javascripts/discourse/app/lib/time-shortcut.js b/app/assets/javascripts/discourse/app/lib/time-shortcut.jsindex 5d6349afef1..7ee30b041c0 100644--- a/app/assets/javascripts/discourse/app/lib/time-shortcut.js+++ b/app/assets/javascripts/discourse/app/lib/time-shortcut.js@@ -6,6 +6,7 @@ import {nextBusinessWeekStart,nextMonth,now,+ thisWeekend,tomorrow,} from "discourse/lib/time-utils";import I18n from "I18n";@@ -13,6 +14,7 @@ import I18n from "I18n";export const TIME_SHORTCUT_TYPES = {LATER_TODAY: "later_today",TOMORROW: "tomorrow",+ THIS_WEEKEND: "this_weekend",NEXT_MONTH: "next_month",CUSTOM: "custom",RELATIVE: "relative",@@ -48,6 +50,15 @@ export function defaultShortcutOptions(timezone) {I18n.t("dates.time_short_day")),},+ {+ icon: "bed",+ id: TIME_SHORTCUT_TYPES.THIS_WEEKEND,+ label: "time_shortcut.this_weekend",+ time: thisWeekend(timezone),+ timeFormatted: thisWeekend(timezone).format(+ I18n.t("dates.time_short_day")+ ),+ },{icon: "briefcase",id: TIME_SHORTCUT_TYPES.START_OF_NEXT_BUSINESS_WEEK,diff --git a/app/assets/javascripts/discourse/app/lib/time-utils.js b/app/assets/javascripts/discourse/app/lib/time-utils.jsindex 114b151af48..5266362e5b4 100644--- a/app/assets/javascripts/discourse/app/lib/time-utils.js+++ b/app/assets/javascripts/discourse/app/lib/time-utils.js@@ -6,6 +6,7 @@ export const LATER_TODAY_MAX_HOUR = 18;export const MOMENT_SUNDAY = 0;export const MOMENT_MONDAY = 1;export const MOMENT_THURSDAY = 4;+export const MOMENT_FRIDAY = 5;export const MOMENT_SATURDAY = 6;export function now(timezone) {diff --git a/app/assets/javascripts/discourse/tests/integration/components/time-shortcut-picker-test.js b/app/assets/javascripts/discourse/tests/integration/components/time-shortcut-picker-test.jsindex 66c4101ad59..443e8866694 100644--- a/app/assets/javascripts/discourse/tests/integration/components/time-shortcut-picker-test.js+++ b/app/assets/javascripts/discourse/tests/integration/components/time-shortcut-picker-test.js@@ -47,6 +47,7 @@ discourseModule(I18n.t("time_shortcut.later_today"),I18n.t("time_shortcut.tomorrow"),I18n.t("time_shortcut.later_this_week"),+ I18n.t("time_shortcut.this_weekend"),I18n.t("time_shortcut.start_of_next_business_week"),I18n.t("time_shortcut.next_month"),I18n.t("time_shortcut.custom"),