MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / ConnectDialog

Function ConnectDialog

packages/react/src/pages/integrations.tsx:191–348  ·  view source on GitHub ↗
(props: { open: boolean; onOpenChange: (open: boolean) => void })

Source from the content-addressed store, hash-verified

189};
190
191function ConnectDialog(props: { open: boolean; onOpenChange: (open: boolean) => void }) {
192 const integrationPlugins = useIntegrationPlugins();
193 const doDetect = useAtomSet(detectIntegration, { mode: "promiseExit" });
194 const navigate = useNavigate();
195
196 const [query, setQuery] = useState("");
197 const [detecting, setDetecting] = useState(false);
198 const [error, setError] = useState<string | null>(null);
199
200 const isUrl = looksLikeUrl(query);
201 const presetSearch = isUrl ? "" : query;
202
203 const closeAndReset = useCallback(() => {
204 setQuery("");
205 setError(null);
206 setDetecting(false);
207 props.onOpenChange(false);
208 }, [props]);
209
210 const handleDetect = useCallback(async () => {
211 const trimmed = query.trim();
212 if (!trimmed) return;
213 setDetecting(true);
214 setError(null);
215 const gitRepository = detectGitRepository(trimmed);
216 if (gitRepository && integrationPlugins.some((p) => p.key === "apps")) {
217 trackEvent("integration_detect_submitted", {
218 success: true,
219 detected_kind: "apps",
220 confidence: "high",
221 });
222 trackEvent("integration_add_started", { plugin_key: "apps", via: "detect" });
223 closeAndReset();
224 void navigate({
225 to: "/{-$orgSlug}/integrations/add/$pluginKey",
226 params: { pluginKey: "apps" },
227 search: { url: gitRepository.endpoint, namespace: gitRepository.slug },
228 });
229 return;
230 }
231 // Detection is read-only — it inspects a URL and returns candidates without
232 // mutating the catalog, so it invalidates nothing.
233 const exit = await doDetect({
234 payload: { url: trimmed },
235 reactivityKeys: [],
236 });
237 if (Exit.isFailure(exit)) {
238 trackEvent("integration_detect_submitted", { success: false });
239 setError("Detection failed. Try adding an integration manually.");
240 setDetecting(false);
241 return;
242 }
243 const results = exit.value;
244 if (results.length === 0) {
245 trackEvent("integration_detect_submitted", { success: false });
246 setError("Could not detect an integration type from this URL. Try adding manually.");
247 setDetecting(false);
248 return;

Callers

nothing calls this directly

Calls 5

useIntegrationPluginsFunction · 0.90
trackEventFunction · 0.90
looksLikeUrlFunction · 0.85
detectGitRepositoryFunction · 0.85
bestDetectionFunction · 0.85

Tested by

no test coverage detected