import React, {useContext} from 'react'; import {ReactApplicationContext} from "../../dom/ReactApplicationContext"; import {useStream} from "ui/effects"; import {Dialog} from "ui/components/Dialog"; import {matchAvailableSubjects, MatchIndex, matchSelection} from "../../../sketcher/selectionMatcher"; import {AssemblyConstraintSchema} from "../assemblyConstraint"; import {AssemblyConstraintsSchemas} from "../assemblySchemas"; export function ModellerContextualActions() { const ctx = useContext(ReactApplicationContext); const selection: string[] = useStream(ctx => ctx.streams.selection.all); if (!selection || selection.length === 0) { return null; } const entities = selection.map(ctx.cadRegistry.find).filter(x => !!x); const allConstraints = Object.values(AssemblyConstraintsSchemas) as AssemblyConstraintSchema[]; const availableConstraints = matchAvailableSubjects(entities, allConstraints) as AssemblyConstraintSchema[]; if (availableConstraints.length === 0) { return null; } return {}}> {availableConstraints.map( schema => ) } ; }