forked from KaotoIO/kaoto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(viz): Introduce visualization-node class
relates to: KaotoIO#34
- Loading branch information
Showing
23 changed files
with
460 additions
and
596 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
56 changes: 3 additions & 53 deletions
56
packages/ui/src/components/Visualization/Visualization.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,10 @@ | ||
import { Button, Modal } from '@patternfly/react-core'; | ||
import { FunctionComponent, PropsWithChildren, useCallback, useState } from 'react'; | ||
import { CamelRoute, Step } from '../../camel-entities'; | ||
import { getCamelRandomId } from '../../camel-utils/camel-random-id'; | ||
import { Catalog, ITile } from '../Catalog'; | ||
import { VisualizationCanvas } from './VisualizationCanvas'; | ||
import './VisualizationCanvas.scss'; | ||
import { FunctionComponent, PropsWithChildren } from 'react'; | ||
import './Visualization.scss'; | ||
|
||
interface CanvasProps { | ||
className?: string; | ||
tiles: Record<string, ITile[]>; | ||
} | ||
|
||
export const Visualization: FunctionComponent<PropsWithChildren<CanvasProps>> = (props) => { | ||
const [entities, setEntities] = useState<CamelRoute[]>([]); | ||
const [isModalOpen, setIsModalOpen] = useState(false); | ||
const [selectedCamelEntity, setSelectedCamelEntity] = useState<CamelRoute | undefined>(undefined); | ||
|
||
const onTileClick = useCallback( | ||
(tile: ITile) => { | ||
if (selectedCamelEntity === undefined) { | ||
return; | ||
} | ||
|
||
setIsModalOpen(false); | ||
const firstStep = new Step({ name: tile.name }); | ||
selectedCamelEntity._addStep(firstStep); | ||
setEntities([...entities, selectedCamelEntity]); | ||
}, | ||
[entities, selectedCamelEntity], | ||
); | ||
|
||
const handleModalToggle = useCallback(() => { | ||
setIsModalOpen(!isModalOpen); | ||
}, [isModalOpen]); | ||
|
||
return ( | ||
<div className={`canvasSurface ${props.className ?? ''}`}> | ||
<VisualizationCanvas | ||
contextToolbar={ | ||
<Button | ||
onClick={() => { | ||
setIsModalOpen(true); | ||
const newEntity = new CamelRoute(); | ||
newEntity.id = getCamelRandomId('route'); | ||
setSelectedCamelEntity(newEntity); | ||
}} | ||
> | ||
New Camel route | ||
</Button> | ||
} | ||
entities={entities} | ||
/> | ||
|
||
<Modal title="Catalog browser" isOpen={isModalOpen} onClose={handleModalToggle} ouiaId="BasicModal"> | ||
<Catalog tiles={props.tiles} onTileClick={onTileClick} /> | ||
</Modal> | ||
</div> | ||
); | ||
return <div className={`canvasSurface ${props.className ?? ''}`}>Visualization</div>; | ||
}; |
95 changes: 0 additions & 95 deletions
95
packages/ui/src/components/Visualization/VisualizationCanvas.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.