Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[@azure-tools/cadl-ranch-dashboard] Add Number of Scenarios under each heading #765

Merged
merged 4 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
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 { 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,21 @@ const GotoSourceButton: FunctionComponent<ShowSourceButtonProps> = ({ scenario }
function getGithubLineNumber(value: number): `L${number}` {
return `L${value + 1}`;
}

function getLabelForRow(row: TreeTableRow): string {
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);
sarangan12 marked this conversation as resolved.
Show resolved Hide resolved
return `${name} (${totalLeafChildren} scenarios)`;
}
Loading