Skip to content

Commit

Permalink
Preview example of new Designer #1012
Browse files Browse the repository at this point in the history
  • Loading branch information
mgubaidullin committed Dec 6, 2023
1 parent b660dd4 commit 75c03d8
Show file tree
Hide file tree
Showing 34 changed files with 1,799 additions and 1,439 deletions.
2 changes: 1 addition & 1 deletion karavan-designer/src/designer/route/element/DslElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ export function DslElement(props: Props) {
key={step.uuid + "-child-" + index}>
{children.map((element, index) => {
let prevStep = children.at(index - 1);
let nextStep = undefined;
let nextStep: CamelElement | undefined = undefined;
if (['TryDefinition', 'ChoiceDefinition'].includes(step.dslName)) {
nextStep = props.nextStep;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

import "./DslElement.css"
import React from 'react'

export function DeleteElementIcon() {
return (
Expand Down
30 changes: 29 additions & 1 deletion karavan-space/src/designer/DesignerStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

import {CamelElement, Integration} from "karavan-core/lib/model/IntegrationDefinition";
import {DslPosition, EventBus} from "./utils/EventBus";
import {ButtonPosition, DslPosition, EventBus} from "./utils/EventBus";
import {createWithEqualityFn} from "zustand/traditional";
import {shallow} from "zustand/shallow";

Expand Down Expand Up @@ -120,6 +120,10 @@ interface ConnectionsState {
deleteStep: (uuid: string) => void;
clearSteps: () => void;
setSteps: (steps: Map<string, DslPosition>) => void;
buttons: ButtonPosition[];
addButton: (button: ButtonPosition) => void;
deleteButton: (button: ButtonPosition) => void;
clearButtons: () => void;
}

export const useConnectionsStore = createWithEqualityFn<ConnectionsState>((set) => ({
Expand Down Expand Up @@ -148,6 +152,30 @@ export const useConnectionsStore = createWithEqualityFn<ConnectionsState>((set)
setSteps: (steps: Map<string, DslPosition>) => {
set({steps: steps})
},
buttons: [],
addButton: (button: ButtonPosition) => {
set((state: ConnectionsState) => {
const index = state.buttons.findIndex(b => b.uuid === button.uuid);
if (index !== -1) {
state.buttons.splice(index, 1);
}
state.buttons.push(button);
return state;
})
},
clearButtons: () => {
set((state: ConnectionsState) => {
state.buttons.length = 0;
return state;
})
},
deleteButton: (button: ButtonPosition) => {
set((state: ConnectionsState) => {
const index = state.buttons.findIndex(b => b.uuid === button.uuid);
state.buttons.splice(index, 1);
return state;
})
},
}), shallow)

type DesignerState = {
Expand Down
Loading

0 comments on commit 75c03d8

Please sign in to comment.