-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Canvas): Rename steps context menu items
- Loading branch information
Showing
12 changed files
with
318 additions
and
244 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
58 changes: 0 additions & 58 deletions
58
packages/ui/src/components/Visualization/Custom/ItemAddNode.tsx
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
packages/ui/src/components/Visualization/Custom/ItemAddStep.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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { ContextMenuItem } from '@patternfly/react-topology'; | ||
import { FunctionComponent, PropsWithChildren, useCallback, useContext } from 'react'; | ||
import { IDataTestID } from '../../../models'; | ||
import { AddStepMode, IVisualizationNode } from '../../../models/visualization/base-visual-entity'; | ||
import { CatalogModalContext } from '../../../providers/catalog-modal.provider'; | ||
import { EntitiesContext } from '../../../providers/entities.provider'; | ||
|
||
interface ItemAddStepProps extends PropsWithChildren<IDataTestID> { | ||
mode: AddStepMode.PrependStep | AddStepMode.AppendStep; | ||
vizNode: IVisualizationNode; | ||
} | ||
|
||
export const ItemAddStep: FunctionComponent<ItemAddStepProps> = (props) => { | ||
const entitiesContext = useContext(EntitiesContext); | ||
const catalogModalContext = useContext(CatalogModalContext); | ||
|
||
const onAddNode = useCallback(async () => { | ||
if (!props.vizNode || !entitiesContext) return; | ||
|
||
/** Get compatible nodes and the location where can be introduced */ | ||
const compatibleNodes = entitiesContext.camelResource.getCompatibleComponents(props.mode, props.vizNode.data); | ||
|
||
/** Open Catalog modal, filtering the compatible nodes */ | ||
const definedComponent = await catalogModalContext?.getNewComponent(compatibleNodes); | ||
if (!definedComponent) return; | ||
|
||
/** Add new node to the entities */ | ||
props.vizNode.addBaseEntityStep(definedComponent, props.mode); | ||
|
||
/** Update entity */ | ||
entitiesContext.updateEntitiesFromCamelResource(); | ||
}, [catalogModalContext, entitiesContext, props.mode, props.vizNode]); | ||
|
||
return ( | ||
<ContextMenuItem onClick={onAddNode} data-testid={props['data-testid']}> | ||
{props.children} | ||
</ContextMenuItem> | ||
); | ||
}; |
26 changes: 26 additions & 0 deletions
26
packages/ui/src/components/Visualization/Custom/ItemDeleteGroup.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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { TrashIcon } from '@patternfly/react-icons'; | ||
import { ContextMenuItem } from '@patternfly/react-topology'; | ||
import { FunctionComponent, PropsWithChildren, useCallback, useContext } from 'react'; | ||
import { IDataTestID } from '../../../models'; | ||
import { IVisualizationNode } from '../../../models/visualization/base-visual-entity'; | ||
import { EntitiesContext } from '../../../providers/entities.provider'; | ||
|
||
interface ItemDeleteGroupProps extends PropsWithChildren<IDataTestID> { | ||
vizNode: IVisualizationNode; | ||
} | ||
|
||
export const ItemDeleteGroup: FunctionComponent<ItemDeleteGroupProps> = (props) => { | ||
const entitiesContext = useContext(EntitiesContext); | ||
const flowId = props.vizNode?.getBaseEntity()?.getId(); | ||
|
||
const onRemoveGroup = useCallback(() => { | ||
entitiesContext?.camelResource.removeEntity(flowId); | ||
entitiesContext?.updateEntitiesFromCamelResource(); | ||
}, [entitiesContext, flowId]); | ||
|
||
return ( | ||
<ContextMenuItem onClick={onRemoveGroup} data-testid={props['data-testid']}> | ||
<TrashIcon /> Delete | ||
</ContextMenuItem> | ||
); | ||
}; |
25 changes: 25 additions & 0 deletions
25
packages/ui/src/components/Visualization/Custom/ItemDeleteStep.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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { TrashIcon } from '@patternfly/react-icons'; | ||
import { ContextMenuItem } from '@patternfly/react-topology'; | ||
import { FunctionComponent, PropsWithChildren, useCallback, useContext } from 'react'; | ||
import { IDataTestID } from '../../../models'; | ||
import { IVisualizationNode } from '../../../models/visualization/base-visual-entity'; | ||
import { EntitiesContext } from '../../../providers/entities.provider'; | ||
|
||
interface ItemDeleteStepProps extends PropsWithChildren<IDataTestID> { | ||
vizNode: IVisualizationNode; | ||
} | ||
|
||
export const ItemDeleteStep: FunctionComponent<ItemDeleteStepProps> = (props) => { | ||
const entitiesContext = useContext(EntitiesContext); | ||
|
||
const onRemoveNode = useCallback(() => { | ||
props.vizNode?.removeChild(); | ||
entitiesContext?.updateEntitiesFromCamelResource(); | ||
}, [entitiesContext, props.vizNode]); | ||
|
||
return ( | ||
<ContextMenuItem onClick={onRemoveNode} data-testid={props['data-testid']}> | ||
<TrashIcon /> Delete | ||
</ContextMenuItem> | ||
); | ||
}; |
Oops, something went wrong.