Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

feat: usage information in selection view #942

Merged
merged 4 commits into from
Jul 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ export const ParameterView: React.FC<ParameterViewProps> = function ({ pythonPar
</Stack>
)}

{parameterUsages && (
<Stack spacing={4}>
<Heading as="h4" size="md">
Usages
</Heading>
<UsageSum parameterUsages={parameterUsages} />
</Stack>
)}

{parameterUsages && (
<Stack spacing={4}>
<Heading as="h4" size="md">
Expand Down Expand Up @@ -141,3 +150,13 @@ const isStringifiedLiteral = function (value: string): boolean {
}
return !Number.isNaN(Number.parseFloat(value));
};

const UsageSum: React.FC<CustomBarChartProps> = function ({ parameterUsages }) {
let usage = 0;

parameterUsages.forEach((value) => {
usage += value;
});

return <ChakraText paddingLeft={4}>{usage}</ChakraText>;
};