Skip to content

Commit

Permalink
fix: fix event description example (#1611)
Browse files Browse the repository at this point in the history
Because

- fix event description example

This commit

- fix event description example
  • Loading branch information
EiffelFly authored Nov 20, 2024
1 parent 675ceb0 commit 1ef8ee8
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const FileAndStringUploadField = ({
field.onChange(e.target.value);
setFileName(e.target.value);
}}
placeholder="Enter a URL, paste a file, or drag a file over."
placeholder="Enter a URL, upload a file, or drag a file over."
className="w-full p-2 border rounded"
disabled={disabled}
/>
Expand Down
20 changes: 15 additions & 5 deletions packages/toolkit/src/view/recipe-editor/flow/nodes/StartNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import { CustomHandle } from "./CustomHandle";
const selector = (store: InstillStore) => ({
enabledQuery: store.enabledQuery,
accessToken: store.accessToken,
displayEventNodes: store.displayEventNodes,
updateDisplayEventNodes: store.updateDisplayEventNodes,
updateSelectedComponentId: store.updateSelectedComponentId,
});

export const StartNode = ({ id }: NodeProps) => {
Expand All @@ -31,7 +30,8 @@ export const StartNode = ({ id }: NodeProps) => {
);
}, [id, reactflowEdges]);

const { enabledQuery, accessToken } = useInstillStore(useShallow(selector));
const { enabledQuery, accessToken, updateSelectedComponentId } =
useInstillStore(useShallow(selector));

const pipeline = useNamespacePipeline({
namespaceId: routeInfo.data.namespaceId,
Expand Down Expand Up @@ -59,7 +59,12 @@ export const StartNode = ({ id }: NodeProps) => {
}, [pipeline.data, pipeline.isSuccess]);

return (
<div className="relative">
<div
onClick={() => {
updateSelectedComponentId(() => null);
}}
className="relative"
>
{eventCount > 0 ? (
<StartNodeOpenEventButton
hasEventErrorEdge={hasEventErrorEdge}
Expand All @@ -85,6 +90,11 @@ export const StartNode = ({ id }: NodeProps) => {
);
};

const buttonSelector = (store: InstillStore) => ({
displayEventNodes: store.displayEventNodes,
updateDisplayEventNodes: store.updateDisplayEventNodes,
});

const StartNodeOpenEventButton = ({
eventCount,
hasEventErrorEdge,
Expand All @@ -93,7 +103,7 @@ const StartNodeOpenEventButton = ({
hasEventErrorEdge: boolean;
}) => {
const { displayEventNodes, updateDisplayEventNodes } = useInstillStore(
useShallow(selector),
useShallow(buttonSelector),
);

if (hasEventErrorEdge) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class PipelineFlowFactory {
if (!hasVariableConnectToRunOnEvent) {
edges.push({
id: `run-on-event-${id}`,
source: `on-${id}`,
source: id,
target: "start",
type: "eventErrorEdge",
hidden: hideEventNodes,
Expand All @@ -134,7 +134,7 @@ export class PipelineFlowFactory {

edges.push({
id: `run-on-event-${id}`,
source: `on-${id}`,
source: id,
target: "start",
type: "eventEdge",
hidden: hideEventNodes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,18 @@ export function composeEdgesForReference({

const hasNoEdgeForThisReference =
currentEdges.find(
(edge) =>
edge.source === `on-${sourceId}` && edge.target === reference.id,
(edge) => edge.source === sourceId && edge.target === reference.id,
) === undefined;

if (referenceIsAvailable && hasNoEdgeForThisReference && reference.id) {
if (
sourceId &&
referenceIsAvailable &&
hasNoEdgeForThisReference &&
reference.id
) {
newEdges.push({
id: uuidv4(),
source: `on-${sourceId}`,
source: sourceId,
target: reference.id,
type: "generalEdge",
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function createNodesFromRunOnEvent(
}

nodes.push({
id: `on-${id}`,
id: id,
type: "runOnEventNode",
hidden: hideEventNodes,
data: e,
Expand Down

0 comments on commit 1ef8ee8

Please sign in to comment.