Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(1094): Keep current visibility when adding a new entity to the ca… #1615

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import { EntityType } from '../../../../models/camel/entities';
import { EntitiesContext } from '../../../../providers/entities.provider';
import { VisibleFlowsContext } from '../../../../providers/visible-flows.provider';
import { SELECTION_EVENT, useVisualizationController } from '@patternfly/react-topology';
import { getVisualizationNodesFromGraph } from '../../../../utils';

export const NewEntity: FunctionComponent = () => {
const { camelResource, updateEntitiesFromCamelResource } = useContext(EntitiesContext)!;
Expand All @@ -13,6 +15,7 @@
const menuRef = useRef<HTMLDivElement>(null);
const toggleRef = useRef<HTMLButtonElement>(null);
const groupedEntities = useRef<BaseVisualCamelEntityDefinition>(camelResource.getCanvasEntityList());
const controller = useVisualizationController();

const onSelect = useCallback(
(_event: unknown, entityType: string | number | undefined) => {
Expand All @@ -26,7 +29,14 @@
* supported
*/
const newId = camelResource.addNewEntity(entityType as EntityType);
visibleFlowsContext.visualFlowsApi.hideAllFlows();
setTimeout(() => {
const result = getVisualizationNodesFromGraph(

Check warning on line 33 in packages/ui/src/components/Visualization/ContextToolbar/NewEntity/NewEntity.tsx

View check run for this annotation

Codecov / codecov/patch

packages/ui/src/components/Visualization/ContextToolbar/NewEntity/NewEntity.tsx#L33

Added line #L33 was not covered by tests
controller.getGraph(),
(vizNode) => vizNode.data.entity?.id === newId,

Check warning on line 35 in packages/ui/src/components/Visualization/ContextToolbar/NewEntity/NewEntity.tsx

View check run for this annotation

Codecov / codecov/patch

packages/ui/src/components/Visualization/ContextToolbar/NewEntity/NewEntity.tsx#L35

Added line #L35 was not covered by tests
);
controller.fireEvent(SELECTION_EVENT, [result[0]?.id]);

Check warning on line 37 in packages/ui/src/components/Visualization/ContextToolbar/NewEntity/NewEntity.tsx

View check run for this annotation

Codecov / codecov/patch

packages/ui/src/components/Visualization/ContextToolbar/NewEntity/NewEntity.tsx#L37

Added line #L37 was not covered by tests
}, 300);

visibleFlowsContext.visualFlowsApi.toggleFlowVisible(newId);
updateEntitiesFromCamelResource();
setIsOpen(false);
Expand Down
Loading