Skip to content

Commit 0428701

Browse files
Merge pull request #201 from alanconway/time-text
COO-1622: fix: The time text are wrong in Timepicker
2 parents 25c2015 + 632086c commit 0428701

3 files changed

Lines changed: 6 additions & 15 deletions

File tree

web/locales/en/plugin__troubleshooting-panel-console-plugin.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
"Include data from this time range": "Include data from this time range",
2121
"Korrel8r Error": "Korrel8r Error",
2222
"Last": "Last",
23-
"Last {{count}} {{unit}}_one": "Last {{count}} {{unit}}_one",
24-
"Last {{count}} {{unit}}_other": "Last {{count}} {{unit}}_other",
2523
"Logging Plugin Disabled": "Logging Plugin Disabled",
2624
"Neighbours": "Neighbours",
2725
"Neighbours or Goal search": "Neighbours or Goal search",

web/src/components/Korrel8rPanel.tsx

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,7 @@ import { usePluginAvailable } from '../hooks/usePluginAvailable';
3030
import { getGoalsGraph, getNeighborsGraph } from '../korrel8r-client';
3131
import * as api from '../korrel8r/client';
3232
import * as korrel8r from '../korrel8r/types';
33-
import {
34-
defaultSearch,
35-
Result,
36-
Search,
37-
SearchType,
38-
setResult as setResultAction,
39-
setSearch as setSearchAction,
40-
} from '../redux-actions';
33+
import { defaultSearch, Result, Search, SearchType, setResult, setSearch } from '../redux-actions';
4134
import { State } from '../redux-reducers';
4235
import * as time from '../time';
4336
import { AdvancedSearchForm } from './AdvancedSearchForm';
@@ -74,7 +67,7 @@ export default function Korrel8rPanel() {
7467
if (initialized.current) return; // Run once on mount
7568
initialized.current = true;
7669
if (!search?.queryStr && locationQuery) {
77-
dispatch(setSearchAction({ ...defaultSearch, queryStr: locationQuery.toString() }));
70+
dispatch(setSearch({ ...defaultSearch, queryStr: locationQuery.toString() }));
7871
}
7972
}, [search?.queryStr, locationQuery, dispatch]);
8073

@@ -90,7 +83,7 @@ export default function Korrel8rPanel() {
9083
};
9184
let cancelled = false;
9285
const onResult = (newResult: Result) => {
93-
if (!cancelled) dispatch(setResultAction(newResult));
86+
if (!cancelled) dispatch(setResult(newResult));
9487
};
9588
const fetch =
9689
search.searchType === SearchType.Goal
@@ -115,7 +108,7 @@ export default function Korrel8rPanel() {
115108

116109
// Dispatch a new search.
117110
// The SetSearch reducer clears result, triggering the fetch effect.
118-
const doSearch = React.useCallback((s: Search) => dispatch(setSearchAction(s)), [dispatch]);
111+
const doSearch = React.useCallback((s: Search) => dispatch(setSearch(s)), [dispatch]);
119112

120113
return (
121114
<>

web/src/components/TimeRangeDropdown.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const formatDate = (d: Date): string =>
4848

4949
const labelFromPeriod = (period: time.Period, t: TFunction): string => {
5050
if (period instanceof time.Duration) {
51-
return t('Last {{count}} {{unit}}', { count: period.count, unit: period.unit.name });
51+
return `${t('Last')} ${period.count} ${t(period.unit.name)}`;
5252
}
5353
if (period instanceof time.Range) {
5454
return `${formatDate(period.start)}${formatDate(period.end)}`;
@@ -221,7 +221,7 @@ export const TimeRangeDropdown: React.FC<TimeRangeDropdownProps> = ({
221221
isSelected={key === selectedKey}
222222
onClick={() => onChange(optPeriod)}
223223
>
224-
{t('Last {{count}} {{unit}}', { count: optPeriod.count, unit: optPeriod.unit.name })}
224+
{labelFromPeriod(optPeriod, t)}
225225
</DropdownItem>
226226
))}
227227
<Divider />

0 commit comments

Comments
 (0)