Skip to content

Commit 2fa121e

Browse files
committed
add i18n and address comments
Signed-off-by: abbyhu2000 <[email protected]>
1 parent 00d9de4 commit 2fa121e

File tree

6 files changed

+32
-18
lines changed

6 files changed

+32
-18
lines changed

src/core/public/chrome/recently_accessed/recently_accessed_service.ts

+15-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export interface ChromeRecentlyAccessedHistoryItem {
4040
label: string;
4141
id: string;
4242
type?: string;
43-
updatedAt?: string;
43+
updatedAt?: number;
4444
}
4545

4646
interface StartDeps {
@@ -58,7 +58,14 @@ export class RecentlyAccessedService {
5858

5959
return {
6060
/** Adds a new item to the history. */
61-
add: (link: string, label: string, id: string, type?: string, updatedAt?: string) => {
61+
add: (
62+
link: string,
63+
label: string,
64+
id: string,
65+
extraProps: { type?: string; updatedAt?: number }
66+
) => {
67+
const type = extraProps.type;
68+
const updatedAt = extraProps.updatedAt;
6269
history.add({
6370
link,
6471
label,
@@ -96,7 +103,12 @@ export interface ChromeRecentlyAccessed {
96103
* @param type the item type
97104
* @param updatedAt the time that the item is last updated at
98105
*/
99-
add(link: string, label: string, id: string, type?: string, updatedAt?: string): void;
106+
add(
107+
link: string,
108+
label: string,
109+
id: string,
110+
extraProps: { type?: string; updatedAt?: number }
111+
): void;
100112

101113
/**
102114
* Gets an Array of the current recently accessed history.

src/plugins/dashboard/public/application/utils/use/use_saved_dashboard_instance.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import { i18n } from '@osd/i18n';
77
import { EventEmitter } from 'events';
88
import { useEffect, useRef, useState } from 'react';
9-
import moment from 'moment';
109
import {
1110
redirectWhenMissing,
1211
SavedObjectNotFound,
@@ -131,8 +130,7 @@ export const useSavedDashboardInstance = ({
131130
savedDashboard.getFullPath(),
132131
savedDashboard.title,
133132
dashboardIdFromUrl,
134-
savedDashboard.getOpenSearchType(),
135-
moment(Date.now()).format('MM/DD/YYYY HH:mm')
133+
{ type: savedDashboard.getOpenSearchType(), updatedAt: Date.now() }
136134
);
137135
setSavedDashboardInstance(dashboardInstance);
138136
} catch (error: any) {

src/plugins/discover/public/application/view_components/utils/use_search.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { i18n } from '@osd/i18n';
1010
import { useEffect } from 'react';
1111
import { cloneDeep } from 'lodash';
1212
import { useLocation } from 'react-router-dom';
13-
import moment from 'moment';
1413
import { RequestAdapter } from '../../../../../inspector/public';
1514
import { DiscoverViewServices } from '../../../build_services';
1615
import { search } from '../../../../../data/public';
@@ -311,8 +310,10 @@ export const useSearch = (services: DiscoverViewServices) => {
311310
savedSearchInstance.getFullPath(),
312311
savedSearchInstance.title,
313312
savedSearchInstance.id,
314-
savedSearchInstance.getOpenSearchType(),
315-
moment(Date.now()).format('MM/DD/YYYY HH:mm')
313+
{
314+
type: savedSearchInstance.getOpenSearchType(),
315+
updatedAt: Date.now(),
316+
}
316317
);
317318
}
318319
})();

src/plugins/home/public/application/components/homepage/sections/recent_work.tsx

+10-3
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ const render = renderFn(() => {
6262
<EuiFlexItem>
6363
<EuiCard
6464
layout="horizontal"
65-
title={recentAccessItem.label}
65+
title={i18n.translate('homepage.recentWorkSection.title', {
66+
defaultMessage: recentAccessItem.label,
67+
})}
6668
titleSize="xs"
6769
description={
6870
<>
@@ -71,9 +73,14 @@ const render = renderFn(() => {
7173
className="recent-work-title-icon"
7274
type={recentWorkItem[0].icon}
7375
/>
74-
{recentWorkItem[0].name}
76+
{i18n.translate('homepage.recentWorkSection.name', {
77+
defaultMessage: recentWorkItem[0].name,
78+
})}
7579
<br />
76-
{'Last updated ' + moment(recentAccessItem?.updatedAt).fromNow()}
80+
{i18n.translate('homepage.recentWorkSection.updatedAt', {
81+
defaultMessage:
82+
'Last updated ' + moment(recentAccessItem?.updatedAt).fromNow(),
83+
})}
7784
</>
7885
}
7986
onClick={() => navigateToUrl(services.addBasePath(recentAccessItem.link))}

src/plugins/vis_builder/public/application/utils/use/use_saved_vis_builder_vis.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import { i18n } from '@osd/i18n';
77
import { useEffect, useState } from 'react';
8-
import moment from 'moment';
98
import { SavedObject } from '../../../../../saved_objects/public';
109
import {
1110
InvalidJSONProperty,
@@ -79,8 +78,7 @@ export const useSavedVisBuilderVis = (visualizationIdFromUrl: string | undefined
7978
savedVisBuilderVis.getFullPath(),
8079
title,
8180
savedVisBuilderVis.id,
82-
savedVisBuilderVis.getOpenSearchType(),
83-
moment(Date.now()).format('MM/DD/YYYY HH:mm')
81+
{ type: savedVisBuilderVis.getOpenSearchType(), updatedAt: Date.now() }
8482
);
8583

8684
dispatch(setUIStateState(state.ui));

src/plugins/visualize/public/application/utils/use/use_saved_vis_instance.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import { useEffect, useRef, useState } from 'react';
3232
import { EventEmitter } from 'events';
3333
import { parse } from 'query-string';
3434
import { i18n } from '@osd/i18n';
35-
import moment from 'moment';
3635

3736
import { redirectWhenMissing } from '../../../../../opensearch_dashboards_utils/public';
3837
import { DefaultEditorController } from '../../../../../vis_default_editor/public';
@@ -106,8 +105,7 @@ export const useSavedVisInstance = (
106105
savedVisInstance.savedVis.getFullPath(),
107106
savedVisInstance.savedVis.title,
108107
visualizationIdFromUrl,
109-
savedVisInstance.savedVis.getOpenSearchType(),
110-
moment(Date.now()).format('MM/DD/YYYY HH:mm')
108+
{ type: savedVisInstance.savedVis.getOpenSearchType(), updatedAt: Date.now() }
111109
);
112110
}
113111
}

0 commit comments

Comments
 (0)