Skip to content

Commit 74414ff

Browse files
kubeclaude
andcommitted
Add group action buttons and renderGroupAction to tree items
Add renderGroupAction to FilterableListItem so group rows can show an action button (hover-to-reveal). Export header action components from types-list, differential-equations-list, and parameters-list, then import them in the entities tree as group actions. Nodes has no action. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f8e021f commit 74414ff

5 files changed

Lines changed: 22 additions & 3 deletions

File tree

libs/@hashintel/petrinaut/src/views/Editor/panels/LeftSideBar/subviews/differential-equations-list.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
/**
1919
* DifferentialEquationsSectionHeaderAction renders the add button for the section header.
2020
*/
21-
const DifferentialEquationsSectionHeaderAction: React.FC = () => {
21+
export const DifferentialEquationsSectionHeaderAction: React.FC = () => {
2222
const {
2323
petriNetDefinition: { types, differentialEquations },
2424
addDifferentialEquation,

libs/@hashintel/petrinaut/src/views/Editor/panels/LeftSideBar/subviews/entities-tree.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ import { EditorContext } from "../../../../../state/editor-context";
1515
import { SDCPNContext } from "../../../../../state/sdcpn-context";
1616
import type { SelectionItem } from "../../../../../state/selection";
1717
import { useIsReadOnly } from "../../../../../state/use-is-read-only";
18+
import { DifferentialEquationsSectionHeaderAction } from "./differential-equations-list";
1819
import {
1920
RowMenu,
2021
createFilterableListSubView,
2122
} from "./filterable-list-sub-view";
23+
import { ParametersHeaderAction } from "./parameters-list";
24+
import { TypesSectionHeaderAction } from "./types-list";
2225

2326
const parameterVarNameStyle = css({
2427
margin: "0",
@@ -33,6 +36,7 @@ interface EntityTreeItem {
3336
iconColor?: string;
3437
children?: EntityTreeItem[];
3538
emptyGroupMessage?: string;
39+
renderGroupAction?: ComponentType;
3640
selectionItem?: SelectionItem;
3741
variableName?: string;
3842
}
@@ -121,6 +125,7 @@ function useEntityTreeItems(): EntityTreeItem[] {
121125
id: "group-types",
122126
name: "Token Types",
123127
emptyGroupMessage: "No token types",
128+
renderGroupAction: TypesSectionHeaderAction,
124129
children: types.map((t) => ({
125130
id: t.id,
126131
name: t.name,
@@ -133,6 +138,7 @@ function useEntityTreeItems(): EntityTreeItem[] {
133138
id: "group-equations",
134139
name: "Differential Equations",
135140
emptyGroupMessage: "No differential equations",
141+
renderGroupAction: DifferentialEquationsSectionHeaderAction,
136142
children: differentialEquations.map((eq) => ({
137143
id: eq.id,
138144
name: eq.name,
@@ -147,6 +153,7 @@ function useEntityTreeItems(): EntityTreeItem[] {
147153
id: "group-parameters",
148154
name: "Parameters",
149155
emptyGroupMessage: "No parameters",
156+
renderGroupAction: ParametersHeaderAction,
150157
children: parameters.map((p) => ({
151158
id: p.id,
152159
name: p.name,

libs/@hashintel/petrinaut/src/views/Editor/panels/LeftSideBar/subviews/filterable-list-sub-view.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ interface FilterableListItem {
168168
children?: FilterableListItem[];
169169
/** Message shown when this group is expanded but has no children. */
170170
emptyGroupMessage?: string;
171+
/** Optional action component shown on the right side of a group row (e.g. an add button). */
172+
renderGroupAction?: ComponentType;
171173
}
172174

173175
interface FilterableListSubViewConfig<T extends FilterableListItem> {
@@ -567,6 +569,16 @@ const FilterableListContent = <T extends FilterableListItem>({
567569
{renderItem(item, isSelected)}
568570
</div>
569571
</div>
572+
{isGroup && item.renderGroupAction && (
573+
<span
574+
role="presentation"
575+
data-row-action
576+
onClick={(event) => event.stopPropagation()}
577+
onKeyDown={(event) => event.stopPropagation()}
578+
>
579+
<item.renderGroupAction />
580+
</span>
581+
)}
570582
{!isGroup && RenderRowMenu && <RenderRowMenu item={item} />}
571583
</div>
572584
);

libs/@hashintel/petrinaut/src/views/Editor/panels/LeftSideBar/subviews/parameters-list.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const parameterVarNameStyle = css({
2525
* Header action component for adding parameters.
2626
* Shown in the panel header when not in simulation mode.
2727
*/
28-
const ParametersHeaderAction: React.FC = () => {
28+
export const ParametersHeaderAction: React.FC = () => {
2929
const {
3030
petriNetDefinition: { parameters },
3131
addParameter,

libs/@hashintel/petrinaut/src/views/Editor/panels/LeftSideBar/subviews/types-list.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function getNextTypeNumber(existingNames: string[]): number {
6060
/**
6161
* TypesSectionHeaderAction renders the add button for the types section header.
6262
*/
63-
const TypesSectionHeaderAction: React.FC = () => {
63+
export const TypesSectionHeaderAction: React.FC = () => {
6464
const {
6565
petriNetDefinition: { types },
6666
addType,

0 commit comments

Comments
 (0)