show subtree variable
This commit is contained in:
1 parent
8199a0d24e
commit
35ca8285d0
2 files changed
+59
-12
No files matched your search
@@ -1,4 +1,10 @@
|
|||||||
import { AimOutlined, EditOutlined, MinusCircleOutlined, PlusOutlined } from "@ant-design/icons";
|
import {
|
||||||
|
AimOutlined,
|
||||||
|
EditOutlined,
|
||||||
|
FormOutlined,
|
||||||
|
MinusCircleOutlined,
|
||||||
|
PlusOutlined,
|
||||||
|
} from "@ant-design/icons";
|
||||||
import {
|
import {
|
||||||
AutoComplete,
|
AutoComplete,
|
||||||
Button,
|
Button,
|
||||||
@@ -144,6 +150,8 @@ const TreeInspector: FC = () => {
|
|||||||
groupDefs: state.groupDefs,
|
groupDefs: state.groupDefs,
|
||||||
nodeDefs: state.nodeDefs,
|
nodeDefs: state.nodeDefs,
|
||||||
relative: state.relative,
|
relative: state.relative,
|
||||||
|
open: state.open,
|
||||||
|
workdir: state.workdir,
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -241,10 +249,12 @@ const TreeInspector: FC = () => {
|
|||||||
);
|
);
|
||||||
form.setFieldValue(
|
form.setFieldValue(
|
||||||
"subtree",
|
"subtree",
|
||||||
workspace.editingTree.subtree.map((v) => ({
|
workspace.editingTree.subtree.map((entry) => ({
|
||||||
|
path: entry.path,
|
||||||
|
vars: entry.vars.map((v) => ({
|
||||||
name: v.name,
|
name: v.name,
|
||||||
desc: v.desc,
|
|
||||||
count: usingCount[v.name] ?? 0,
|
count: usingCount[v.name] ?? 0,
|
||||||
|
})),
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
}, [workspace.editingTree, groupDefs, usingCount]);
|
}, [workspace.editingTree, groupDefs, usingCount]);
|
||||||
@@ -402,12 +412,51 @@ const TreeInspector: FC = () => {
|
|||||||
<h4>{t("tree.vars.subtree")}</h4>
|
<h4>{t("tree.vars.subtree")}</h4>
|
||||||
</Divider>
|
</Divider>
|
||||||
<Form.List name="subtree">
|
<Form.List name="subtree">
|
||||||
{(fields) => (
|
{(items) => (
|
||||||
<div style={{ display: "flex", flexDirection: "column", rowGap: 0 }}>
|
<div style={{ display: "flex", flexDirection: "column", rowGap: 4 }}>
|
||||||
{fields.map((item) => (
|
{items.map((item) => (
|
||||||
<Form.Item key={item.key} name={item.name} style={{ marginBottom: 2 }}>
|
<Space.Compact
|
||||||
<VarDefItem name={item.name} disabled={true} />
|
key={item.key}
|
||||||
|
className="b3-inspector-import-item"
|
||||||
|
direction="vertical"
|
||||||
|
style={{ marginBottom: 5 }}
|
||||||
|
>
|
||||||
|
<Flex gap={4} style={{ width: "100%" }}>
|
||||||
|
<Form.Item
|
||||||
|
name={[item.name, "path"]}
|
||||||
|
style={{ width: "100%", marginBottom: 2 }}
|
||||||
|
>
|
||||||
|
<Select
|
||||||
|
disabled={true}
|
||||||
|
showSearch
|
||||||
|
options={subtreeOptions}
|
||||||
|
onBlur={form.submit}
|
||||||
|
onInputKeyDown={(e) => e.code === Hotkey.Escape && e.preventDefault()}
|
||||||
|
filterOption={(value, option) => {
|
||||||
|
const label = option!.label as string;
|
||||||
|
return label.toUpperCase().includes(value.toUpperCase());
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
<FormOutlined
|
||||||
|
onClick={() => {
|
||||||
|
const path = workspace.editingTree.subtree[item.name].path;
|
||||||
|
workspace.open(`${workspace.workdir}/${path}`);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Flex>
|
||||||
|
<Form.List name={[item.name, "vars"]}>
|
||||||
|
{(vars) => (
|
||||||
|
<div style={{ display: "flex", flexDirection: "column", rowGap: 0 }}>
|
||||||
|
{vars.map((v) => (
|
||||||
|
<Form.Item key={v.key} name={v.name} style={{ marginBottom: 2 }}>
|
||||||
|
<VarDefItem name={v.name} disabled={true} />
|
||||||
|
</Form.Item>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Form.List>
|
||||||
|
</Space.Compact>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ export type EditTree = {
|
|||||||
group: string[];
|
group: string[];
|
||||||
import: ImportDef[];
|
import: ImportDef[];
|
||||||
declvar: VarDef[];
|
declvar: VarDef[];
|
||||||
subtree: VarDef[];
|
subtree: ImportDef[];
|
||||||
root: TreeGraphData;
|
root: TreeGraphData;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -699,9 +699,7 @@ export const useWorkspace = create<WorkspaceStore>((set, get) => ({
|
|||||||
root: editor.root,
|
root: editor.root,
|
||||||
import: editor.declare.import,
|
import: editor.declare.import,
|
||||||
declvar: editor.declare.declvar,
|
declvar: editor.declare.declvar,
|
||||||
subtree: editor.declare.subtree
|
subtree: editor.declare.subtree,
|
||||||
.map((def) => def.vars)
|
|
||||||
.reduce((acc, v) => [...acc, ...v], []),
|
|
||||||
},
|
},
|
||||||
editingNodeDef: null,
|
editingNodeDef: null,
|
||||||
editingNode: null,
|
editingNode: null,
|
||||||
|
|||||||
Reference in new issue
Block a user