function internalConsumerClick()

in karavan-app/src/main/webui/src/editor/DesignerEditor.tsx [123:165]


    function internalConsumerClick(uri?: string, name?: string, routeId?: string, fileName?: string) {
        let done = false;
        const integrations = files.filter(f => f.name.endsWith(".camel.yaml"))
            .map(f => CamelDefinitionYaml.yamlToIntegration(f.name, f.code));
        if (fileName) {
            const uniqueUri = uri + ':name=' + name;
            const outgoingNodes = TopologyUtils.findTopologyRouteOutgoingNodes(integrations);
            let step = outgoingNodes.filter(node => node.uniqueUri === uniqueUri).at(0)?.step;
            if (step === undefined) {
                const restUri = uri + ':' + name;
                const restNodes = TopologyUtils.findTopologyRestNodes(integrations);
                restNodes.filter(restNode => restNode.uris.includes(restUri)).forEach(restNode => {
                    step = restNode.rest.get?.filter(m => m.to === restUri).at(0)
                        || restNode.rest.post?.filter(m => m.to === restUri).at(0)
                        || restNode.rest.put?.filter(m => m.to === restUri).at(0)
                        || restNode.rest.delete?.filter(m => m.to === restUri).at(0)
                        || restNode.rest.patch?.filter(m => m.to === restUri).at(0)
                        || restNode.rest.head?.filter(m => m.to === restUri).at(0);
                })
            }
            switchToFile(fileName);
            setSelectedStep(step)
            done = true;
        } else if (uri && name) {
            const routes = TopologyUtils.findTopologyRouteNodes(integrations);
            for (const route of routes) {
                if (route?.from?.uri === uri && (route?.from?.parameters?.name === name || route?.from?.parameters?.address === name)) {
                    switchToFile(route.fileName);
                    setSelectedStep(route?.from);
                    done = true;
                }
            }
        } else {
            const nodes = TopologyUtils.findTopologyRouteOutgoingNodes(integrations).filter(t => t.routeId === routeId);
            for (const node of nodes) {
                switchToFile(node.fileName);
                done = true;
            }
        }
        if (!done) {
            EventBus.sendAlert('Warning', 'Route not found. Possibly not created.', 'warning');
        }
    }