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

Function handleEditSubmit

frontend/src/pages/SecretsManager.tsx:229–285  ·  view source on GitHub ↗
(event: React.FormEvent)

Source from the content-addressed store, hash-verified

227 };
228
229 const handleEditSubmit = async (event: React.FormEvent) => {
230 event.preventDefault();
231 if (!editingSecret) {
232 return;
233 }
234
235 if (!canManageSecrets) {
236 setEditError('Only workspace administrators can modify secrets.');
237 return;
238 }
239
240 setEditError(null);
241 setListSuccess(null);
242 setIsEditing(true);
243
244 const trimmedName = editFormState.name.trim();
245 const normalizedDescription = normalizeDescriptionInput(editFormState.description);
246 const existingDescription = normalizeDescriptionInput(editingSecret.description ?? '');
247 const normalizedTags = normalizeTagsForUpdate(editFormState.tags);
248 const newSecretValue = editFormState.value.trim();
249
250 const metadataChanged =
251 trimmedName !== editingSecret.name ||
252 normalizedDescription !== existingDescription ||
253 !areTagsEqual(editingSecret.tags, normalizedTags);
254 const shouldRotate = newSecretValue.length > 0;
255
256 try {
257 let latest = editingSecret;
258
259 if (metadataChanged) {
260 latest = await updateSecretMetadata(editingSecret.id, {
261 name: trimmedName,
262 description: normalizedDescription,
263 tags: normalizedTags,
264 });
265 }
266
267 if (shouldRotate) {
268 latest = await rotateSecretValue(editingSecret.id, { value: newSecretValue });
269 }
270
271 const actions: string[] = [];
272 if (metadataChanged) actions.push('updated');
273 if (shouldRotate) actions.push('rotated');
274 const actionSummary =
275 actions.length === 0 ? 'unchanged' : `${actions.join(' and ')} successfully`;
276
277 setListSuccess(`Secret "${latest.name}" ${actionSummary}.`);
278 handleEditDialogChange(false);
279 } catch (err) {
280 const message = err instanceof Error ? err.message : 'Failed to update secret';
281 setEditError(message);
282 } finally {
283 setIsEditing(false);
284 }
285 };
286

Callers

nothing calls this directly

Calls 5

normalizeTagsForUpdateFunction · 0.85
areTagsEqualFunction · 0.85
handleEditDialogChangeFunction · 0.85
pushMethod · 0.65

Tested by

no test coverage detected