Skip to content

Commit

Permalink
Provide a getItemId function
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Feb 6, 2025
1 parent 70c4948 commit 99ff7c1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions client/sites/tools/logs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { sprintf } from '@wordpress/i18n';
import { download } from '@wordpress/icons';
import { useI18n } from '@wordpress/react-i18n';
import { translate } from 'i18n-calypso';
import { useCallback, useEffect, useState } from 'react';
import { useCallback, useEffect, useState, useMemo } from 'react';
import { v4 as uuid } from 'uuid';
import QuerySiteSettings from 'calypso/components/data/query-site-settings';
import InlineSupportLink from 'calypso/components/inline-support-link';
import { useLocalizedMoment } from 'calypso/components/localized-moment';
Expand Down Expand Up @@ -263,14 +264,16 @@ export const SiteLogsDataViews = ( { logType }: { logType: LogType } ) => {
// - translate for field labels https://github.com/Automattic/wp-calypso/blob/update/logs-to-dataviews/client/sites/tools/logs/components/site-logs-toolbar/index.tsx#L82

const { __ } = useI18n();

const moment = useLocalizedMoment();
const getLatestDateRange = useCallback( () => {
const startTime = moment().subtract( 7, 'd' );
const endTime = moment();
return { startTime, endTime };
}, [ moment ] );

// Can we actually derive an unique ID from the data?
const getItemId = useMemo( () => () => uuid(), [] );

const [ dateRange, setDateRange ] = useState( () => {
const latest = getLatestDateRange();
const dateRangeQuery = getDateRangeQueryParam( moment );
Expand Down Expand Up @@ -426,6 +429,7 @@ export const SiteLogsDataViews = ( { logType }: { logType: LogType } ) => {
view={ view }
onChangeView={ onChangeView }
search={ false }
getItemId={ getItemId }
defaultLayouts={ { table: {} } }
header={
<Button
Expand Down

0 comments on commit 99ff7c1

Please sign in to comment.