Skip to content

Commit

Permalink
chore(ui): format files
Browse files Browse the repository at this point in the history
  • Loading branch information
a-asaad committed Jul 9, 2024
1 parent 3023de1 commit bf1c98a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 24 deletions.
14 changes: 3 additions & 11 deletions ui/src/components/assistant/llmClient.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { Ollama } from "@langchain/community/llms/ollama"
import { Edge } from "reactflow"
import { EipFlowNode} from "../../api/flow"
import {
getEdgesView,
getNodesView,
getLayout
} from "../../singletons/store"
import { EipFlowNode } from "../../api/flow"
import { getEdgesView, getNodesView, getLayout } from "../../singletons/store"
import { fuzzyMatchNodeEipIds } from "./fuzzyEipIdMatch"
import { newFlowLayout } from "../layout/layouting"
import { flowCreatePrompt, flowUpdatePrompt } from "./prompt"
Expand Down Expand Up @@ -129,11 +125,7 @@ class LlmClient {
fuzzyMatchNodeEipIds(response.nodes)

const layout = getLayout()
response.nodes = newFlowLayout(
response.nodes,
response.edges,
layout
)
response.nodes = newFlowLayout(response.nodes, response.edges, layout)

return JSON.stringify(response)
}
Expand Down
19 changes: 14 additions & 5 deletions ui/src/components/canvas/EipNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { Button, Stack, Tile } from "@carbon/react"
import { Handle, NodeProps, Position } from "reactflow"
import { ServiceId } from "@carbon/react/icons"
import { FlowType, Role } from "../../api/eipSchema"
import { EipNodeData, Layout} from "../../api/flow"
import { EipNodeData, Layout } from "../../api/flow"
import { ChildNodeId, EipId } from "../../api/id"
import { lookupEipComponent } from "../../singletons/eipDefinitions"
import getIconUrl from "../../singletons/eipIconCatalog"
import {
useAppActions,
useGetChildren,
useIsChildSelected,
useGetLayout
useGetLayout,
} from "../../singletons/store"
import { toTitleCase } from "../../utils/titleTransform"
import "./nodes.scss"
Expand All @@ -24,7 +24,10 @@ interface ChildrenIconsProps {
const defaultNamespace = "integration"

// TODO: Limit handles to the appropriate number of connections
const renderHandles = (flowType: FlowType, layoutType: Layout["orientation"]) => {
const renderHandles = (
flowType: FlowType,
layoutType: Layout["orientation"]
) => {
if (layoutType === "horizontal") {
switch (flowType) {
case "source":
Expand Down Expand Up @@ -120,7 +123,10 @@ export const EipNode = (props: NodeProps<EipNodeData>) => {
const { data } = props
const componentDefinition = lookupEipComponent(data.eipId)!
const layout = useGetLayout()
const handles = renderHandles(componentDefinition.flowType, layout.orientation)
const handles = renderHandles(
componentDefinition.flowType,
layout.orientation
)

return (
<Tile
Expand All @@ -129,7 +135,10 @@ export const EipNode = (props: NodeProps<EipNodeData>) => {
>
<div>{getNamespacedTitle(data.eipId)}</div>
<img className="eip-node-image" src={getIconUrl(data.eipId)} />
<div className="eip-node-label" style={hasChildren ? { marginBottom: "0.5rem" } : {}}>
<div
className="eip-node-label"
style={hasChildren ? { marginBottom: "0.5rem" } : {}}
>
<strong>{data.label}</strong>
</div>
{hasChildren && (
Expand Down
6 changes: 5 additions & 1 deletion ui/src/components/canvas/FlowCanvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import ReactFlow, {
useReactFlow,
} from "reactflow"

import { useAppActions, useFlowStore, useGetLayout } from "../../singletons/store"
import {
useAppActions,
useFlowStore,
useGetLayout,
} from "../../singletons/store"
import "reactflow/dist/base.css"
import {
TrashCan,
Expand Down
1 change: 0 additions & 1 deletion ui/src/components/layout/layouting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import dagre from "@dagrejs/dagre"
import { Edge, Position } from "reactflow"
import { EipFlowNode, Layout } from "../../api/flow"


const DEFAULT_NODE_WIDTH = 128
const DEFAULT_NODE_HEIGHT = 128

Expand Down
12 changes: 6 additions & 6 deletions ui/src/singletons/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ import { create } from "zustand"
import { createJSONStorage, persist } from "zustand/middleware"
import { useShallow } from "zustand/react/shallow"
import { AttributeTypes } from "../api/eipSchema"
import { EIP_NODE_KEY, EipFlowNode, Layout} from "../api/flow"
import { EIP_NODE_KEY, EipFlowNode, Layout } from "../api/flow"
import { ChildNodeId, EipId, areChildIdsEqual } from "../api/id"
import { newFlowLayout } from "../components/layout/layouting"


export const ROOT_PARENT = "root"

const NO_PERSIST = new Set(["appActions", "reactFlowActions"])
Expand Down Expand Up @@ -215,21 +214,22 @@ const useStore = create<AppStore>()(
const nodes = newFlowLayout(state.nodes, state.edges, newLayout)
return {
nodes: nodes,
layout: newLayout
layout: newLayout,
}
}),

updateLayoutDensity: () =>
set((state) => {
const newDensity = state.layout.density === "compact" ? "comfortable" : "compact"
const newDensity =
state.layout.density === "compact" ? "comfortable" : "compact"
const newLayout: Layout = {
...state.layout,
density: newDensity,
}
const nodes = newFlowLayout(state.nodes, state.edges, newLayout)
return {
nodes: nodes,
layout: newLayout
layout: newLayout,
}
}),
},
Expand Down Expand Up @@ -359,4 +359,4 @@ export const getNodesView: () => Readonly<EipFlowNode[]> = () =>
export const getEdgesView: () => Readonly<Edge[]> = () =>
useStore.getState().edges
export const getLayout: () => Readonly<Layout> = () =>
useStore.getState().layout
useStore.getState().layout

0 comments on commit bf1c98a

Please sign in to comment.