MCPcopy
hub / github.com/AndrewWalsh/openapi-devtools / ControlDynamic

Function ControlDynamic

src/ui/ControlDynamic.tsx:23–104  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21};
22
23const ControlDynamic = () => {
24 const { endpoints, parameterise } = useContext(Context);
25 const [search, setSearch] = useState("");
26 const filteredEndpoints: Endpoint[] = useMemo(() => {
27 if (!search) return endpoints;
28 const fuseOptions = {
29 keys: ["pathname"],
30 };
31 const fuse = new Fuse(endpoints, fuseOptions);
32 const result = fuse.search(search).map((r) => r.item);
33 return result;
34 }, [search, endpoints]);
35 return (
36 <>
37 <Input
38 placeholder="Search for endpoint..."
39 value={search}
40 onChange={(e) => setSearch(e.target.value)}
41 className={classes.search}
42 />
43 <div className={classes.wrapper}>
44 <AutoSizer className={classes.autosizer}>
45 {({ height, width }) => (
46 <List
47 className={classes.autosizerchild}
48 height={height}
49 itemCount={filteredEndpoints.length}
50 itemSize={height / 8}
51 width={width}
52 itemData={filteredEndpoints}
53 itemKey={(index) => filteredEndpoints[index].pathname}
54 >
55 {({ index, data, style }) => {
56 const endpoint = data[index];
57 const backgroundColor = index % 2 === 0 ? WHITE : undefined;
58 const outerKey = endpoint.host + endpoint.pathname;
59 return (
60 <div style={style} className={classes.autosizerchild}>
61 <Wrap
62 className={classes.listchild}
63 backgroundColor={backgroundColor}
64 key={outerKey}
65 spacing={0}
66 >
67 {endpoint.parts.map(({ part, type }, parameterIsIdx) => {
68 const onClick =
69 type === PartType.Dynamic
70 ? () => {}
71 : () => {
72 parameterise(
73 parameterIsIdx,
74 endpoint.pathname,
75 endpoint.host
76 );
77 };
78 const color = type === PartType.Dynamic ? TEAL : BLUE;
79 const key = parameterIsIdx + part;
80 return (

Callers

nothing calls this directly

Calls 2

parameteriseFunction · 0.85
getClassnameFromPartTypeFunction · 0.85

Tested by

no test coverage detected