import * as React from 'react'; export interface IJarDiffItem { displayDiff: string; } export interface IJarDiff { [key: string]: IJarDiffItem[]; added: IJarDiffItem[]; downgraded: IJarDiffItem[]; duplicates: IJarDiffItem[]; removed: IJarDiffItem[]; unchanged: IJarDiffItem[]; unknown: IJarDiffItem[]; upgraded: IJarDiffItem[]; } export interface IJarDiffsProps { jarDiffs: IJarDiff; } export interface IJarDiffTableProps { heading: string; jars: IJarDiffItem[]; } export const JarDiffTable = ({ heading, jars }: IJarDiffTableProps) => ( {jars.map((jar) => ( ))}
{heading}
{jar.displayDiff}
); export const JarDiffs = ({ jarDiffs }: IJarDiffsProps) => { const hasJarDiffs = Object.keys(jarDiffs).some((key: string) => jarDiffs[key].length > 0); if (!hasJarDiffs) { return null; } return (
{Boolean(jarDiffs.added?.length) && } {Boolean(jarDiffs.removed?.length) && } {Boolean(jarDiffs.upgraded?.length) && } {Boolean(jarDiffs.downgraded?.length) && } {Boolean(jarDiffs.duplicates?.length) && } {Boolean(jarDiffs.unknown?.length) && }
); };