Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
set advanced time format and tests
Browse files Browse the repository at this point in the history
Signed-off-by: Qxisylolo <[email protected]>
Qxisylolo committed Aug 14, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 4b26196 commit 9fc525c
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
import React from 'react';
import moment from 'moment';
import { BehaviorSubject, of } from 'rxjs';
import { render, fireEvent, screen, waitFor } from '@testing-library/react';
import { render, fireEvent, screen } from '@testing-library/react';
import { I18nProvider } from '@osd/i18n/react';
import { coreMock } from '../../../../../core/public/mocks';
import { navigateToWorkspaceDetail } from '../utils/workspace';
@@ -77,6 +77,14 @@ function getWrapWorkspaceListInContext(
workspaces: {
workspaceList$: of(workspaceList),
},
uiSettings: {
get: jest.fn().mockImplementation((key) => {
if (key === 'dateFormat') {
return 'MMM D, YYYY @ HH:mm:ss.SSS';
}
return null;
}),
},
};

return (
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ interface WorkspaceAttributeWithUseCaseID extends WorkspaceAttribute {

export const WorkspaceList = ({ registeredUseCases$ }: WorkspaceListProps) => {
const {
services: { workspaces, application, http },
services: { workspaces, application, http, uiSettings },
} = useOpenSearchDashboards();
const registeredUseCases = useObservable(registeredUseCases$);
const isDashboardAdmin = application?.capabilities?.dashboards?.isDashboardAdmin;
@@ -67,6 +67,8 @@ export const WorkspaceList = ({ registeredUseCases$ }: WorkspaceListProps) => {
const [deletedWorkspaces, setDeletedWorkspaces] = useState<WorkspaceAttribute[]>([]);
const [selection, setSelection] = useState<WorkspaceAttribute[]>([]);

const dateFormat = uiSettings?.get('dateFormat');

const extractUseCaseFromFeatures = useCallback(
(features: string[]) => {
if (!features || features.length === 0) {
@@ -277,7 +279,7 @@ export const WorkspaceList = ({ registeredUseCases$ }: WorkspaceListProps) => {
width: '25%',
truncateText: false,
render: (lastUpdatedTime: string) => {
return moment(lastUpdatedTime).format('MMM D, YYYY @ HH:mm:ss.SSS');
return moment(lastUpdatedTime).format(dateFormat);
},
},

0 comments on commit 9fc525c

Please sign in to comment.