This is an automated email from the ASF dual-hosted git repository. marat pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-karavan.git
commit 83230331614ddf03ad1ffb5e2899d31afb1406d9 Author: Marat Gubaidullin <ma...@talismancloud.io> AuthorDate: Thu Feb 1 16:57:19 2024 -0500 Designer #1094 --- karavan-designer/src/DesignerPage.tsx | 3 +-- karavan-designer/src/designer/DesignerStore.ts | 15 +++++++++++++-- karavan-designer/src/designer/KaravanDesigner.tsx | 7 +++++-- .../designer/property/property/ComponentPropertyField.tsx | 6 ++---- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/karavan-designer/src/DesignerPage.tsx b/karavan-designer/src/DesignerPage.tsx index 16e4efd8..3173548c 100644 --- a/karavan-designer/src/DesignerPage.tsx +++ b/karavan-designer/src/DesignerPage.tsx @@ -19,13 +19,12 @@ import { Toolbar, ToolbarContent, ToolbarItem, - PageSection, TextContent, Text, Flex, FlexItem, Button, Tooltip, ToggleGroup, ToggleGroupItem, Page + PageSection, TextContent, Text, Flex, FlexItem, Button, Tooltip } from '@patternfly/react-core'; import './designer/karavan.css'; import DownloadIcon from "@patternfly/react-icons/dist/esm/icons/download-icon"; import DownloadImageIcon from "@patternfly/react-icons/dist/esm/icons/image-icon"; import {KaravanDesigner} from "./designer/KaravanDesigner"; -import Editor from "@monaco-editor/react"; import {EventBus} from "./designer/utils/EventBus"; interface Props { diff --git a/karavan-designer/src/designer/DesignerStore.ts b/karavan-designer/src/designer/DesignerStore.ts index fe198a7f..8a836e5f 100644 --- a/karavan-designer/src/designer/DesignerStore.ts +++ b/karavan-designer/src/designer/DesignerStore.ts @@ -19,6 +19,7 @@ import {CamelElement, Integration} from "karavan-core/lib/model/IntegrationDefin import {DslPosition, EventBus} from "./utils/EventBus"; import {createWithEqualityFn} from "zustand/traditional"; import {shallow} from "zustand/shallow"; +import {RegistryBeanDefinition} from "karavan-core/src/core/model/CamelDefinition"; interface IntegrationState { integration: Integration; @@ -169,7 +170,8 @@ type DesignerState = { top: number, left: number, moveElements: [string | undefined, string | undefined], - propertyPlaceholders: string[]; + propertyPlaceholders: string[], + beans: RegistryBeanDefinition[] } const designerState: DesignerState = { @@ -188,7 +190,8 @@ const designerState: DesignerState = { top: 0, left: 0, moveElements: [undefined, undefined], - propertyPlaceholders: [] + propertyPlaceholders: [], + beans: [] }; type DesignerAction = { @@ -206,6 +209,7 @@ type DesignerAction = { setNotification: (notificationBadge: boolean, notificationMessage: [string, string]) => void; setMoveElements: (moveElements: [string | undefined, string | undefined]) => void; setPropertyPlaceholders: (propertyPlaceholders: string[]) => void; + setBeans: (beans: RegistryBeanDefinition[]) => void; } export const useDesignerStore = createWithEqualityFn<DesignerState & DesignerAction>((set) => ({ @@ -268,4 +272,11 @@ export const useDesignerStore = createWithEqualityFn<DesignerState & DesignerAct return state; }) }, + setBeans: (beans: RegistryBeanDefinition[]) => { + set((state: DesignerState) => { + state.beans.length = 0; + state.beans.push(...beans); + return state; + }) + }, }), shallow) \ No newline at end of file diff --git a/karavan-designer/src/designer/KaravanDesigner.tsx b/karavan-designer/src/designer/KaravanDesigner.tsx index 7f201e4c..11bf8b6c 100644 --- a/karavan-designer/src/designer/KaravanDesigner.tsx +++ b/karavan-designer/src/designer/KaravanDesigner.tsx @@ -41,6 +41,7 @@ import {BeansDesigner} from "./beans/BeansDesigner"; import {CodeEditor} from "./editor/CodeEditor"; import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon'; import {KameletDesigner} from "./kamelet/KameletDesigner"; +import {RegistryBeanDefinition} from "karavan-core/lib/model/CamelDefinition"; interface Props { onSave: (filename: string, yaml: string, propertyOnly: boolean) => void @@ -54,14 +55,15 @@ interface Props { showCodeTab: boolean tab?: "routes" | "rest" | "beans" propertyPlaceholders: string[] + beans: RegistryBeanDefinition[] } export function KaravanDesigner(props: Props) { const [tab, setTab] = useState<string>('routes'); - const [setDark, hideLogDSL, setHideLogDSL, setSelectedStep, reset, badge, message, setPropertyPlaceholders] = + const [setDark, hideLogDSL, setHideLogDSL, setSelectedStep, reset, badge, message, setPropertyPlaceholders, setBeans] = useDesignerStore((s) => - [s.setDark, s.hideLogDSL, s.setHideLogDSL, s.setSelectedStep, s.reset, s.notificationBadge, s.notificationMessage, s.setPropertyPlaceholders], shallow) + [s.setDark, s.hideLogDSL, s.setHideLogDSL, s.setSelectedStep, s.reset, s.notificationBadge, s.notificationMessage, s.setPropertyPlaceholders, s.setBeans], shallow) const [integration, setIntegration] = useIntegrationStore((s) => [s.integration, s.setIntegration], shallow) @@ -87,6 +89,7 @@ export function KaravanDesigner(props: Props) { reset(); setDark(props.dark); setPropertyPlaceholders(props.propertyPlaceholders) + setBeans(props.beans) setHideLogDSL(props.hideLogDSL === true); return () => { sub?.unsubscribe(); diff --git a/karavan-designer/src/designer/property/property/ComponentPropertyField.tsx b/karavan-designer/src/designer/property/property/ComponentPropertyField.tsx index 402aaf8b..1287c18a 100644 --- a/karavan-designer/src/designer/property/property/ComponentPropertyField.tsx +++ b/karavan-designer/src/designer/property/property/ComponentPropertyField.tsx @@ -71,8 +71,8 @@ export function ComponentPropertyField(props: Props) { const {onParametersChange, getInternalComponentName} = usePropertiesHook(); const [integration] = useIntegrationStore((state) => [state.integration], shallow) - const [dark, setSelectedStep, propertyPlaceholders] = useDesignerStore((s) => - [s.dark, s.setSelectedStep, s.propertyPlaceholders], shallow) + const [dark, setSelectedStep, beans] = useDesignerStore((s) => + [s.dark, s.setSelectedStep, s.beans], shallow) const [selectStatus, setSelectStatus] = useState<Map<string, boolean>>(new Map<string, boolean>()); const [showEditor, setShowEditor] = useState<boolean>(false); @@ -82,7 +82,6 @@ export function ComponentPropertyField(props: Props) { const [id, setId] = useState<string>(prefix + "-" + props.property.name); const ref = useRef<any>(null); - const [isOpenPlaceholdersDropdown, setOpenPlaceholdersDropdown] = useState<boolean>(false); function parametersChanged(parameter: string, value: string | number | boolean | any, pathParameter?: boolean, newRoute?: RouteToCreate) { @@ -100,7 +99,6 @@ export function ComponentPropertyField(props: Props) { function getSelectBean(property: ComponentProperty, value: any) { const selectOptions: JSX.Element[] = []; - const beans = CamelUi.getBeans(integration); if (beans) { selectOptions.push(<SelectOption key={0} value={"Select..."} isPlaceholder/>); selectOptions.push(...beans.map((bean) => <SelectOption key={bean.name} value={beanPrefix + bean.name}