Skip to content

Commit

Permalink
Merge pull request #142 from kaleido-io/fetchreferences
Browse files Browse the repository at this point in the history
[fetchreferences] fetchreferences for event table and tx details
  • Loading branch information
dechdev authored Mar 25, 2022
2 parents bcb5517 + c435f76 commit 2ccb2bb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
11 changes: 2 additions & 9 deletions src/components/Cards/EventCards/EventCardWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useTranslation } from 'react-i18next';
import {
FF_EVENTS_CATEGORY_MAP,
FF_TX_CATEGORY_MAP,
getEnrichedEventText,
IEvent,
} from '../../../interfaces';
import { getFFTime } from '../../../utils';
Expand All @@ -26,14 +27,6 @@ export const EventCardWrapper = ({
}: Props) => {
const { t } = useTranslation();

const getEnrichedText = (event: IEvent) => {
const eventObject = FF_EVENTS_CATEGORY_MAP[event.type];
if (eventObject) {
return eventObject.enrichedEventString(event);
}
return t('event');
};

return (
<>
<BaseCard
Expand All @@ -47,7 +40,7 @@ export const EventCardWrapper = ({
? t(FF_TX_CATEGORY_MAP[event.transaction?.type]?.nicename)
: t(t(FF_EVENTS_CATEGORY_MAP[event.type]?.nicename))
}
description={getEnrichedText(event)}
description={getEnrichedEventText(event)}
timestamp={getFFTime(event.created)}
status={<HashPopover address={event.id} shortHash paper />}
color={FF_EVENTS_CATEGORY_MAP[event.type]?.color}
Expand Down
8 changes: 8 additions & 0 deletions src/interfaces/enums/eventTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ interface IEventCategory {
nicename: string;
}

export const getEnrichedEventText = (event: IEvent) => {
const eventObject = FF_EVENTS_CATEGORY_MAP[event.type];
if (eventObject) {
return eventObject.enrichedEventString(event);
}
return t('event');
};

export const FF_EVENTS_CATEGORY_MAP: {
[key in FF_EVENTS]: IEventCategory;
} = {
Expand Down
15 changes: 12 additions & 3 deletions src/pages/Activity/views/Events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
EventFilters,
FF_EVENTS_CATEGORY_MAP,
FF_Paths,
getEnrichedEventText,
ICreatedFilter,
IDataTableRecord,
IEvent,
Expand Down Expand Up @@ -137,9 +138,11 @@ export const ActivityEvents: () => JSX.Element = () => {
fetchCatcher(
`${FF_Paths.nsPrefix}/${selectedNamespace}${
FF_Paths.events
}?limit=${rowsPerPage}&count&skip=${rowsPerPage * currentPage}${
createdFilterObject.filterString
}${filterString !== undefined ? filterString : ''}`
}?limit=${rowsPerPage}&fetchreferences&count&skip=${
rowsPerPage * currentPage
}${createdFilterObject.filterString}${
filterString !== undefined ? filterString : ''
}`
)
.then((eventRes: IPagedEventResponse) => {
if (isMounted) {
Expand Down Expand Up @@ -186,6 +189,7 @@ export const ActivityEvents: () => JSX.Element = () => {

const eventsColumnHeaders = [
t('type'),
t('details'),
t('id'),
t('reference'),
t('transactionID'),
Expand All @@ -204,6 +208,11 @@ export const ActivityEvents: () => JSX.Element = () => {
/>
),
},
{
value: (
<FFTableText color="secondary" text={getEnrichedEventText(event)} />
),
},
{
value: (
<HashPopover shortHash={true} address={event.id}></HashPopover>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Activity/views/TransactionDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export const TransactionDetails: () => JSX.Element = () => {
});
// Transaction events
fetchCatcher(
`${FF_Paths.nsPrefix}/${selectedNamespace}${FF_Paths.events}?tx=${txID}`
`${FF_Paths.nsPrefix}/${selectedNamespace}${FF_Paths.events}?tx=${txID}&fetchreferences`
)
.then((events: IEvent[]) => {
isMounted && setTxEvents(events);
Expand Down

0 comments on commit 2ccb2bb

Please sign in to comment.