Skip to content
This repository was archived by the owner on Jan 21, 2025. It is now read-only.

Commit

Permalink
Merge branch 'main' into checkupdate
Browse files Browse the repository at this point in the history
  • Loading branch information
mcgallan authored Oct 31, 2024
2 parents 333bcc2 + 9d65984 commit 2d72382
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/quick-coins-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@azure-tools/cadl-ranch-dashboard": minor
---

Added number of scenarios under each row
2 changes: 1 addition & 1 deletion packages/cadl-ranch-dashboard/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@azure-tools/cadl-ranch-dashboard",
"private": true,
"version": "0.9.0",
"version": "0.10.0",
"description": "Cadl Ranch Dashboard website",
"main": "dist/index.js",
"type": "module",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FunctionComponent } from "react";
import { TreeTableRow } from "./types.js";
import { FunctionComponent, useMemo } from "react";
import { ManifestTreeNode, TreeTableRow } from "./types.js";
import { Button, Popover, PopoverSurface, PopoverTrigger, Title3, Tooltip } from "@fluentui/react-components";
import ReactMarkdown from "react-markdown";
import { ScenarioData } from "@azure-tools/cadl-ranch-coverage-sdk";
Expand All @@ -17,6 +17,7 @@ const INDENT_SIZE = 14;
export const RowLabelCell: FunctionComponent<RowLabelCellProps> = ({ row }) => {
const caret = row.hasChildren ? row.expanded ? <ChevronDown20Filled /> : <ChevronRight20Filled /> : null;
const marginLeft = row.depth * INDENT_SIZE;
const rowLabel = getLabelForRow(row);
return (
<td
css={[
Expand All @@ -42,7 +43,7 @@ export const RowLabelCell: FunctionComponent<RowLabelCellProps> = ({ row }) => {
flex: 1,
}}
>
{row.item.name}
{rowLabel}
</div>
<div css={{}}>
{row.item.scenario && <ScenarioInfoButton scenario={row.item.scenario} />}
Expand Down Expand Up @@ -98,3 +99,24 @@ const GotoSourceButton: FunctionComponent<ShowSourceButtonProps> = ({ scenario }
function getGithubLineNumber(value: number): `L${number}` {
return `L${value + 1}`;
}

function getLabelForRow(row: TreeTableRow): string {
return useMemo(() => {
const countLeafChildren = (node: ManifestTreeNode): number => {
if (Object.keys(node.children).length === 0) {
return 1;
}

return Object.values(node.children).reduce((acc, child) => acc + countLeafChildren(child), 0);
};

const { name } = row.item;

if (!row.hasChildren) {
return name;
}

const totalLeafChildren = countLeafChildren(row.item);
return `${name} (${totalLeafChildren} scenarios)`;
}, [row.item, row.hasChildren]);
}

0 comments on commit 2d72382

Please sign in to comment.