UX: improve the list of options on the slow mode modal (#16561)

This commit is contained in:
Andrei Prigorshnev 2022-04-28 17:05:32 +04:00 committed by GitHub
parent 1928bb6ac6
commit badde13894
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 11 deletions

View File

@ -112,17 +112,18 @@ export default Controller.extend(ModalFunctionality, {
timeShortcuts() { timeShortcuts() {
const timezone = this.currentUser.resolvedTimezone(this.currentUser); const timezone = this.currentUser.resolvedTimezone(this.currentUser);
const shortcuts = timeShortcuts(timezone); const shortcuts = timeShortcuts(timezone);
const nextWeek = shortcuts.monday();
nextWeek.label = "time_shortcut.next_week";
return [ return [
shortcuts.laterToday(), shortcuts.laterToday(),
shortcuts.tomorrow(), shortcuts.tomorrow(),
shortcuts.laterThisWeek(), shortcuts.twoDays(),
shortcuts.monday(), nextWeek,
shortcuts.twoWeeks(), shortcuts.twoWeeks(),
shortcuts.nextMonth(), shortcuts.nextMonth(),
shortcuts.twoMonths(), shortcuts.twoMonths(),
shortcuts.threeMonths(),
shortcuts.fourMonths(),
shortcuts.sixMonths(),
]; ];
}, },

View File

@ -17,6 +17,7 @@ import {
thousandYears, thousandYears,
threeMonths, threeMonths,
tomorrow, tomorrow,
twoDays,
twoMonths, twoMonths,
twoWeeks, twoWeeks,
} from "discourse/lib/time-utils"; } from "discourse/lib/time-utils";
@ -94,6 +95,15 @@ export function timeShortcuts(timezone) {
timeFormatKey: "dates.time_short_day", timeFormatKey: "dates.time_short_day",
}; };
}, },
twoDays() {
return {
id: "two_days",
icon: "angle-right",
label: "time_shortcut.two_days",
time: twoDays(timezone),
timeFormatKey: "dates.time_short_day",
};
},
laterThisWeek() { laterThisWeek() {
return { return {
id: TIME_SHORTCUT_TYPES.LATER_THIS_WEEK, id: TIME_SHORTCUT_TYPES.LATER_THIS_WEEK,

View File

@ -37,10 +37,14 @@ export function laterToday(timezone) {
: later.add(30, "minutes").startOf("hour"); : later.add(30, "minutes").startOf("hour");
} }
export function laterThisWeek(timezone) { export function twoDays(timezone) {
return startOfDay(now(timezone).add(2, "days")); return startOfDay(now(timezone).add(2, "days"));
} }
export function laterThisWeek(timezone) {
return twoDays(timezone);
}
export function nextMonth(timezone) { export function nextMonth(timezone) {
return startOfDay(now(timezone).add(1, "month").startOf("month")); return startOfDay(now(timezone).add(1, "month").startOf("month"));
} }

View File

@ -54,14 +54,11 @@ acceptance("Topic - Set Slow Mode", function (needs) {
const expected = [ const expected = [
I18n.t("time_shortcut.later_today"), I18n.t("time_shortcut.later_today"),
I18n.t("time_shortcut.tomorrow"), I18n.t("time_shortcut.tomorrow"),
I18n.t("time_shortcut.later_this_week"), I18n.t("time_shortcut.two_days"),
I18n.t("time_shortcut.start_of_next_business_week_alt"), I18n.t("time_shortcut.next_week"),
I18n.t("time_shortcut.two_weeks"), I18n.t("time_shortcut.two_weeks"),
I18n.t("time_shortcut.next_month"), I18n.t("time_shortcut.next_month"),
I18n.t("time_shortcut.two_months"), I18n.t("time_shortcut.two_months"),
I18n.t("time_shortcut.three_months"),
I18n.t("time_shortcut.four_months"),
I18n.t("time_shortcut.six_months"),
I18n.t("time_shortcut.custom"), I18n.t("time_shortcut.custom"),
]; ];

View File

@ -642,6 +642,7 @@ en:
time_shortcut: time_shortcut:
later_today: "Later today" later_today: "Later today"
two_days: "Two days"
next_business_day: "Next business day" next_business_day: "Next business day"
tomorrow: "Tomorrow" tomorrow: "Tomorrow"
post_local_date: "Date in post" post_local_date: "Date in post"
@ -649,6 +650,7 @@ en:
this_weekend: "This weekend" this_weekend: "This weekend"
start_of_next_business_week: "Monday" start_of_next_business_week: "Monday"
start_of_next_business_week_alt: "Next Monday" start_of_next_business_week_alt: "Next Monday"
next_week: "Next week"
two_weeks: "Two weeks" two_weeks: "Two weeks"
next_month: "Next month" next_month: "Next month"
two_months: "Two months" two_months: "Two months"