Skip to content

Commit

Permalink
Merge pull request hyperledger#140 from kaleido-io/event-enriching
Browse files Browse the repository at this point in the history
Event enriching
  • Loading branch information
dechdev authored Mar 24, 2022
2 parents 3fc40f7 + 65622ed commit 946b117
Show file tree
Hide file tree
Showing 19 changed files with 584 additions and 343 deletions.
118 changes: 79 additions & 39 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"@mui/material": "^5.4.1",
"@mui/styles": "^5.4.1",
"@nivo/bar": "^0.79.1",
"@nivo/circle-packing": "^0.79.1",
"@nivo/core": "^0.79.0",
"@nivo/legends": "^0.79.1",
"@nivo/network": "^0.79.1",
"@nivo/pie": "^0.79.1",
"clsx": "^1.1.1",
"dayjs": "^1.10.7",
Expand Down
8 changes: 6 additions & 2 deletions src/components/Accordions/ApiAccordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,13 @@ export const ApiAccordion: React.FC<Props> = ({ api, isOpen = false }) => {
))}
</Grid>
{/* OpenAPI */}
<FFAccordionLink header={t('openApi')} link={api.urls.openapi} />
{api.urls.openapi && (
<FFAccordionLink header={t('openApi')} link={api.urls.openapi} />
)}
{/* Swagger */}
<FFAccordionLink header={t('swagger')} link={api.urls.ui} />
{api.urls.ui && (
<FFAccordionLink header={t('swagger')} link={api.urls.ui} />
)}
</AccordionDetails>
</Accordion>
);
Expand Down
4 changes: 2 additions & 2 deletions src/components/Accordions/FFAccordionHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export const FFAccordionHeader: React.FC<Props> = ({
}) => {
return (
<Grid container direction="row" alignItems="center">
<Grid xs={6} item container justifyContent="flex-start">
<Grid xs={8} item container justifyContent="flex-start">
{leftContent}
</Grid>
<Grid xs={6} item container justifyContent="flex-end" alignItems="center">
<Grid xs={4} item container justifyContent="flex-end" alignItems="center">
{rightContent}
</Grid>
</Grid>
Expand Down
1 change: 1 addition & 0 deletions src/components/Accordions/FFAccordionText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const FFAccordionText: React.FC<Props> = ({
}}
color={color}
variant="body2"
noWrap
>
{text}
</Typography>
Expand Down
24 changes: 18 additions & 6 deletions src/components/Cards/EventCards/BaseCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const BaseCard: React.FC<Props> = ({
>
<Grid container item alignItems="center" direction="row">
<Grid
xs={6}
xs={8}
container
item
direction="row"
Expand All @@ -94,7 +94,7 @@ export const BaseCard: React.FC<Props> = ({
</Typography>
</Grid>
<Grid
xs={6}
xs={4}
container
item
direction="row"
Expand Down Expand Up @@ -127,13 +127,25 @@ export const BaseCard: React.FC<Props> = ({
item
alignItems="center"
>
<Grid item>
<Typography color="text.secondary" fontSize={12}>
<Grid
xs={8}
container
item
direction="row"
justifyContent="flex-start"
>
<Typography noWrap color="text.secondary" fontSize={12}>
{description}
</Typography>
</Grid>
<Grid item>
<Typography color="text.secondary" fontSize={12}>
<Grid
xs={4}
container
item
direction="row"
justifyContent="flex-end"
>
<Typography noWrap color="text.secondary" fontSize={12}>
{timestamp}
</Typography>
</Grid>
Expand Down
14 changes: 11 additions & 3 deletions src/components/Cards/EventCards/EventCardWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ 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 @@ -34,12 +42,12 @@ export const EventCardWrapper = ({
? () => onHandleViewTx(event.transaction)
: () => onHandleViewEvent(event)
}
title={t(FF_EVENTS_CATEGORY_MAP[event.type]?.nicename)}
description={
title={
event.transaction
? t(FF_TX_CATEGORY_MAP[event.transaction?.type]?.nicename)
: t('event')
: t(t(FF_EVENTS_CATEGORY_MAP[event.type]?.nicename))
}
description={getEnrichedText(event)}
timestamp={getFFTime(event.created)}
status={<HashPopover address={event.id} shortHash paper />}
color={FF_EVENTS_CATEGORY_MAP[event.type]?.color}
Expand Down
13 changes: 10 additions & 3 deletions src/components/Lists/PoolList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,20 @@ export const PoolList: React.FC<Props> = ({ pool, showPoolLink = true }) => {
},
{
label: t('transactionID'),
value: <FFListText color="primary" text={pool.tx.id} />,
button: (
value: pool.tx.id ? (
<FFListText color="primary" text={pool.tx.id} />
) : (
<FFListText
color="secondary"
text={t('transactionIDUnavailable')}
/>
),
button: pool.tx.id ? (
<>
<TxButton ns={selectedNamespace} txID={pool.tx.id} />
<FFCopyButton value={pool.tx.id} />
</>
),
) : undefined,
},
{
label: t('messageID'),
Expand Down
15 changes: 11 additions & 4 deletions src/components/Lists/TransferList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const TransferList: React.FC<Props> = ({
const [dataList, setDataList] = useState<IDataListItem[]>(FFSkeletonList);

useEffect(() => {
if (transfer && txStatus) {
if (transfer) {
setDataList([
{
label: t('localID'),
Expand All @@ -40,15 +40,22 @@ export const TransferList: React.FC<Props> = ({
},
{
label: t('transactionID'),
value: <FFListText color="primary" text={transfer.tx.id} />,
button: (
value: transfer.tx.id ? (
<FFListText color="primary" text={transfer.tx.id} />
) : (
<FFListText
color="secondary"
text={t('transactionIDUnavailable')}
/>
),
button: transfer.tx.id ? (
<>
{showTxLink && (
<TxButton ns={selectedNamespace} txID={transfer.tx.id} />
)}
<FFCopyButton value={transfer.tx.id} />
</>
),
) : undefined,
},
{
label: t('author'),
Expand Down
Loading

0 comments on commit 946b117

Please sign in to comment.