Tie Huginn node articles to viewport layout
This commit is contained in:
parent
8dc87fa2c4
commit
5adf52e221
3 changed files with 35 additions and 41 deletions
|
|
@ -10,6 +10,8 @@ type Selection = {
|
||||||
record: number;
|
record: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type NodeArticle = NonNullable<Parameters<typeof EpiphanyGraphViewer>[0]["nodeArticle"]>;
|
||||||
|
|
||||||
type RawSelection =
|
type RawSelection =
|
||||||
| { kind: "record"; index: number }
|
| { kind: "record"; index: number }
|
||||||
| { kind: "value"; recordIndex: number; path: string; value: unknown };
|
| { kind: "value"; recordIndex: number; path: string; value: unknown };
|
||||||
|
|
@ -273,41 +275,6 @@ function InspectionView({
|
||||||
setSelection: (selection: Selection) => void;
|
setSelection: (selection: Selection) => void;
|
||||||
onInspectFile: (file: File) => Promise<void>;
|
onInspectFile: (file: File) => Promise<void>;
|
||||||
}) {
|
}) {
|
||||||
const expandedRawSelection = graphSelection?.kind === "node"
|
|
||||||
? graphProjection.nodeSelections.get(graphSelection.nodeId)
|
|
||||||
: graphSelection?.kind === "edge"
|
|
||||||
? graphProjection.edgeSelections.get(graphSelection.edgeId)
|
|
||||||
: undefined;
|
|
||||||
const expandedRecord = expandedRawSelection?.kind === "record"
|
|
||||||
? inspection.records[expandedRawSelection.index]
|
|
||||||
: expandedRawSelection?.kind === "value"
|
|
||||||
? inspection.records[expandedRawSelection.recordIndex]
|
|
||||||
: undefined;
|
|
||||||
const expandedValue = expandedRawSelection?.kind === "value"
|
|
||||||
? {
|
|
||||||
path: expandedRawSelection.path,
|
|
||||||
value: expandedRawSelection.value,
|
|
||||||
}
|
|
||||||
: undefined;
|
|
||||||
const expandedCatalogEntry = expandedRecord
|
|
||||||
? inspection.catalog.find((entry) => entry.schemaId === expandedRecord.schemaId)
|
|
||||||
: undefined;
|
|
||||||
const expandedNode = graphSelection?.kind === "node"
|
|
||||||
? {
|
|
||||||
graphKey: graphSelection.graphKey,
|
|
||||||
nodeId: graphSelection.nodeId,
|
|
||||||
className: "huginn-expanded-node",
|
|
||||||
ariaLabel: "Selected CultCache node",
|
|
||||||
content: (
|
|
||||||
<ExpandedNodePanel
|
|
||||||
catalogEntry={expandedCatalogEntry}
|
|
||||||
expandedValue={expandedValue}
|
|
||||||
inspection={inspection}
|
|
||||||
record={expandedRecord}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
}
|
|
||||||
: undefined;
|
|
||||||
const selectRaw = (next: Extract<RawSelection, { kind: "record" }>) => {
|
const selectRaw = (next: Extract<RawSelection, { kind: "record" }>) => {
|
||||||
setSelection({ record: next.index });
|
setSelection({ record: next.index });
|
||||||
setGraphSelection({
|
setGraphSelection({
|
||||||
|
|
@ -338,6 +305,35 @@ function InspectionView({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const nodeArticle: NodeArticle = {
|
||||||
|
className: "huginn-expanded-node",
|
||||||
|
ariaLabel: (node) => `${node.title} CultCache detail`,
|
||||||
|
content: (node) => {
|
||||||
|
const rawSelection = graphProjection.nodeSelections.get(node.id);
|
||||||
|
const record = rawSelection?.kind === "record"
|
||||||
|
? inspection.records[rawSelection.index]
|
||||||
|
: rawSelection?.kind === "value"
|
||||||
|
? inspection.records[rawSelection.recordIndex]
|
||||||
|
: undefined;
|
||||||
|
const expandedValue = rawSelection?.kind === "value"
|
||||||
|
? {
|
||||||
|
path: rawSelection.path,
|
||||||
|
value: rawSelection.value,
|
||||||
|
}
|
||||||
|
: undefined;
|
||||||
|
const catalogEntry = record
|
||||||
|
? inspection.catalog.find((entry) => entry.schemaId === record.schemaId)
|
||||||
|
: undefined;
|
||||||
|
return (
|
||||||
|
<ExpandedNodePanel
|
||||||
|
catalogEntry={catalogEntry}
|
||||||
|
expandedValue={expandedValue}
|
||||||
|
inspection={inspection}
|
||||||
|
record={record}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="inspector-stage">
|
<div className="inspector-stage">
|
||||||
|
|
@ -363,9 +359,7 @@ function InspectionView({
|
||||||
}}
|
}}
|
||||||
overlayPanels
|
overlayPanels
|
||||||
showSidebar={false}
|
showSidebar={false}
|
||||||
focusSelection
|
nodeArticle={nodeArticle}
|
||||||
selectionFocusMode="article"
|
|
||||||
expandedNode={expandedNode}
|
|
||||||
graphLabels={{ architecture: "File", dataflow: "Payload Cloud" }}
|
graphLabels={{ architecture: "File", dataflow: "Payload Cloud" }}
|
||||||
style={{ minHeight: "100vh" }}
|
style={{ minHeight: "100vh" }}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "cultcache-ts",
|
"name": "cultcache-ts",
|
||||||
"version": "0.13.3",
|
"version": "0.13.4",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "cultcache-ts",
|
"name": "cultcache-ts",
|
||||||
"version": "0.13.3",
|
"version": "0.13.4",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@msgpack/msgpack": "^3.1.3",
|
"@msgpack/msgpack": "^3.1.3",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "cultcache-ts",
|
"name": "cultcache-ts",
|
||||||
"version": "0.13.3",
|
"version": "0.13.4",
|
||||||
"description": "CultCache-style typed persistence for TypeScript with schema-backed polymorphic MessagePack storage.",
|
"description": "CultCache-style typed persistence for TypeScript with schema-backed polymorphic MessagePack storage.",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue