MCPcopy Create free account
hub / github.com/ShipSecAI/studio / loadResources

Function loadResources

frontend/src/pages/WebhookEditorPage.tsx:141–181  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

139 // Load Initial Data
140 useEffect(() => {
141 const loadResources = async () => {
142 try {
143 if (!isNew) setIsLoading(true);
144
145 const workflowsList = await api.workflows.list();
146 setWorkflows(workflowsList.map((w) => ({ id: w.id, name: w.name })));
147
148 if (isNew) {
149 const defaultState = {
150 workflowId: '',
151 name: 'New Webhook',
152 description: '',
153 parsingScript: DEFAULT_PARSING_SCRIPT,
154 expectedInputs: [],
155 };
156 setForm(defaultState);
157 setInitialForm(defaultState);
158 } else if (id) {
159 const loadedWebhook = (await api.webhooks.get(id)) as unknown as WebhookConfiguration;
160 setWebhook(loadedWebhook);
161 const loadedForm = {
162 workflowId: loadedWebhook.workflowId,
163 name: loadedWebhook.name,
164 description: loadedWebhook.description || '',
165 parsingScript: loadedWebhook.parsingScript,
166 expectedInputs: loadedWebhook.expectedInputs,
167 };
168 setForm(loadedForm);
169 setInitialForm(loadedForm);
170 }
171 } catch (error) {
172 toast({
173 title: 'Error loading data',
174 description: String(error),
175 variant: 'destructive',
176 });
177 if (!isNew) navigate('/webhooks');
178 } finally {
179 setIsLoading(false);
180 }
181 };
182 loadResources();
183 }, [id, isNew, navigate, toast]);
184

Callers 1

WebhookEditorPageFunction · 0.85

Calls 2

listMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected