Skip to content

Commit ae0019a

Browse files
authored
Render keybinding hints in the range picker (#3325)
* Render keybinding hints in the range picker There was a regression in #3321 - some keybinding hints stopped appearing due to exact string matching. * Switch casing
1 parent 29d0f82 commit ae0019a

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

assets/js/dashboard/datepicker.js

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -292,17 +292,6 @@ function DatePicker({ query, site, history }) {
292292

293293
opts.date = opts.date ? formatISO(opts.date) : false;
294294

295-
const keybinds = {
296-
'Today': 'D',
297-
'Realtime': 'R',
298-
'Last 7 days': 'W',
299-
'Month to Date': 'M',
300-
'Year to Date': 'Y',
301-
'Last 12 months': 'L',
302-
'Last 30 days': 'T',
303-
'All time': 'A',
304-
};
305-
306295
return (
307296
<QueryLink
308297
to={{ from: false, to: false, period, ...opts }}
@@ -312,7 +301,8 @@ function DatePicker({ query, site, history }) {
312301
dark:hover:bg-gray-900 dark:hover:text-gray-100 flex items-center justify-between`}
313302
>
314303
{text}
315-
<span className='font-normal'>{keybinds[text]}</span>
304+
305+
{opts.keybindHint ? (<span className='font-normal'>{opts.keybindHint}</span>) : null}
316306
</QueryLink>
317307
);
318308
}
@@ -329,23 +319,23 @@ function DatePicker({ query, site, history }) {
329319
font-medium text-gray-800 dark:text-gray-200 date-options"
330320
>
331321
<div className="py-1 border-b border-gray-200 dark:border-gray-500 date-option-group">
332-
{renderLink("day", "Today")}
333-
{renderLink("realtime", "Realtime")}
322+
{renderLink("day", "Today", { keybindHint: 'D' })}
323+
{renderLink("realtime", "Realtime", { keybindHint: 'R' })}
334324
</div>
335325
<div className="py-1 border-b border-gray-200 dark:border-gray-500 date-option-group">
336-
{renderLink("7d", "Last 7 Days")}
337-
{renderLink("30d", "Last 30 Days")}
326+
{renderLink("7d", "Last 7 Days", { keybindHint: 'W' })}
327+
{renderLink("30d", "Last 30 Days", { keybindHint: 'T' })}
338328
</div>
339329
<div className="py-1 border-b border-gray-200 dark:border-gray-500 date-option-group">
340-
{renderLink('month', 'Month to Date')}
330+
{renderLink('month', 'Month to Date', { keybindHint: 'M' })}
341331
{renderLink('month', 'Last Month', { date: lastMonth(site) })}
342332
</div>
343333
<div className="py-1 border-b border-gray-200 dark:border-gray-500 date-option-group">
344-
{renderLink("year", "Year to Date")}
345-
{renderLink("12mo", "Last 12 months")}
334+
{renderLink("year", "Year to Date", { keybindHint: 'Y' })}
335+
{renderLink("12mo", "Last 12 months", { keybindHint: 'L' })}
346336
</div>
347337
<div className="py-1 date-option-group">
348-
{renderLink("all", "All time")}
338+
{renderLink("all", "All time", { keybindHint: 'A' })}
349339
<span
350340
onClick={() => setMode('calendar')}
351341
onKeyPress={() => setMode('calendar')}

0 commit comments

Comments
 (0)