Skip to content

Commit fb96ccd

Browse files
committed
null safety working properly
1 parent 5680645 commit fb96ccd

File tree

4 files changed

+24
-18
lines changed

4 files changed

+24
-18
lines changed

src/frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,5 @@
5656
"last 1 safari version"
5757
]
5858
},
59-
"proxy": "http://localhost:7860"
59+
"proxy": "http://backend:7860"
6060
}

src/frontend/src/CustomNodes/GenericNode/index.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,19 @@ export default function GenericNode({
1919
selected: boolean;
2020
}) {
2121
const { setErrorData } = useContext(alertContext);
22-
const showError = useRef(true)
22+
const showError = useRef(true);
2323
const { types, deleteNode } = useContext(typesContext);
2424
const Icon = nodeIcons[types[data.type]];
2525
if (!Icon) {
2626
console.log(data);
27-
if(showError.current){
28-
setErrorData({
29-
title: data.type?`The ${data.type} node could not be rendered, please review your json file`:
30-
"There was a node that can't be rendered, please review your json file",
31-
});
32-
showError.current=false
33-
}
27+
if (showError.current) {
28+
setErrorData({
29+
title: data.type
30+
? `The ${data.type} node could not be rendered, please review your json file`
31+
: "There was a node that can't be rendered, please review your json file",
32+
});
33+
showError.current = false;
34+
}
3435
return;
3536
}
3637

@@ -45,7 +46,9 @@ export default function GenericNode({
4546
<div className="w-full flex items-center truncate gap-4 text-lg">
4647
<Icon
4748
className="w-10 h-10 p-1 rounded"
48-
style={{ color: nodeColors[types[data.type]] }}
49+
style={{
50+
color: nodeColors[types[data.type]] ?? nodeColors.unknown,
51+
}}
4952
/>
5053
<div className="truncate">{data.type}</div>
5154
</div>
@@ -80,8 +83,7 @@ export default function GenericNode({
8083
data={data}
8184
color={
8285
nodeColors[types[data.node.template[t].type]] ??
83-
nodeColors[types[data.node.template[t].type]] ??
84-
"black"
86+
nodeColors.unknown
8587
}
8688
title={snakeToNormalCase(t)}
8789
name={t}
@@ -105,7 +107,7 @@ export default function GenericNode({
105107
</div>
106108
<ParameterComponent
107109
data={data}
108-
color={nodeColors[types[data.type]]}
110+
color={nodeColors[types[data.type]] ?? nodeColors.unknown}
109111
title={data.type}
110112
tooltipTitle={`Type: ${data.node.base_classes.join(" | ")}`}
111113
id={[data.type, data.id, ...data.node.base_classes].join("|")}

src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ export default function ExtraSidebar() {
5555
{Object.keys(data).map((d:keyof APIObjectType, i) => (
5656
<DisclosureComponent
5757
key={i}
58-
button={{ title: nodeNames[d], Icon: nodeIcons[d] }}
58+
button={{ title: nodeNames[d]??nodeNames.unknown, Icon: nodeIcons[d]??nodeIcons.unknown }}
5959
>
6060
<div className="p-2 flex flex-col gap-2">
6161
{Object.keys(data[d]).map((t: string, k) => (
6262
<div key={k}>
6363
<div
6464
draggable
6565
className={" cursor-grab border-l-8 rounded-l-md"}
66-
style={{ borderLeftColor: nodeColors[d] }}
66+
style={{ borderLeftColor: nodeColors[d]??nodeColors.unknown }}
6767
onDragStart={(event) =>
6868
onDragStart(event, {
6969
type: t,

src/frontend/src/utils.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
ComputerDesktopIcon,
99
Bars3CenterLeftIcon,
1010
PaperClipIcon,
11+
QuestionMarkCircleIcon,
1112
} from "@heroicons/react/24/outline";
1213
import { Connection, Edge, Node, ReactFlowInstance } from "reactflow";
1314
import { FlowType } from "./types/flow";
@@ -73,7 +74,8 @@ export const nodeColors: {[char: string]: string} = {
7374
advanced: "#000000",
7475
chat: "#454173",
7576
thought:"#272541",
76-
docloaders:"#10B981"
77+
docloaders:"#FF9135",
78+
unknown:"#9CA3AF"
7779
};
7880

7981
export const nodeNames:{[char: string]: string} = {
@@ -85,7 +87,8 @@ export const nodeNames:{[char: string]: string} = {
8587
memories: "Memories",
8688
advanced: "Advanced",
8789
chat: "Chat",
88-
docloaders:"Document Loader"
90+
docloaders:"Document Loader",
91+
unknown:"Unknown"
8992
};
9093

9194
export const nodeIcons:{[char: string]: React.ForwardRefExoticComponent<React.SVGProps<SVGSVGElement>>} = {
@@ -97,7 +100,8 @@ export const nodeIcons:{[char: string]: React.ForwardRefExoticComponent<React.SV
97100
tools: WrenchScrewdriverIcon,
98101
advanced: ComputerDesktopIcon,
99102
chat: Bars3CenterLeftIcon,
100-
docloaders:PaperClipIcon
103+
docloaders:Bars3CenterLeftIcon,
104+
unknown:QuestionMarkCircleIcon
101105
};
102106

103107
export const bgColors = {

0 commit comments

Comments
 (0)