ui/components/DataFormatter/README.md
The BodySectionRenderer is responsible for formatting and rendering raw text strings into React components. During this process, it parses the string to replace external links with <Link> components and checks if the link matches predefined sites to render the link accordingly.
The ArrayRenderer is responsible for rendering an array of items in a recursive manner, presenting them as a bulletized list using the StructuredDataFormatter.
Object properties with string values are considered key-value pairs and are rendered as such.
You can start using the StructuredDataFormatter for your structured data by using the FormatStructuredData component , the component takes two props the data to be formatted and optional propertyFormatter object , which the formatter uses to format the specific properties of the structured data using the propertyFormatter .
export const FormattedMetadata = ({ event, classes }) => {
const PropertyFormatters = {
Doc: (value, _metadata) => LinkFormatters.DOC.formatter(value),
error: (value) => <ErrorMetadataFormatter metadata={value} event={event} classes={classes} />,
dryRunResponse: (value) => <DryRunResponse response={value} />,
};
if (!event || !event.metadata || isEmptyAtAllDepths(event.metadata)) {
return <EmptyState event={event} />;
}
return <FormatStructuredData propertyFormatters={PropertyFormatters} data={event.metadata} />;
};