feat(snippets): add snippets entity, crud, and auto-browser-per-run
- add Snippet entity with name, description, code; full CRUD backend - add snippets pages (list, create, edit, detail) and nav entry - add runSnippet helper in code-executor using new Function with args array - add result param to execute() so validateCode can access exec output - remove sessionName from steps; each run now spawns its own fresh browser - fix waitForURL race by polling localStorage for token instead
This commit is contained in:
1 parent
1efbbb38a3
commit
1164289173
26 files changed
+876
-89
No files matched your search
@@ -18,7 +18,6 @@ export function CreateStepPage() {
|
||||
const [order, setOrder] = useState('0');
|
||||
const [title, setTitle] = useState('');
|
||||
const [type, setType] = useState<StepType>('exec');
|
||||
const [sessionName, setSessionName] = useState('');
|
||||
const [execCode, setExecCode] = useState('');
|
||||
const [validateCode, setValidateCode] = useState('');
|
||||
const [errors, setErrors] = useState<Partial<Record<keyof CreateStepPayload, string>>>({});
|
||||
@@ -32,7 +31,6 @@ export function CreateStepPage() {
|
||||
|
||||
const validate = (): boolean => {
|
||||
const next: typeof errors = {};
|
||||
if (!sessionName.trim()) next.sessionName = t('steps.form_session_required');
|
||||
if (isNaN(Number(order)) || Number(order) < 0) next.order = t('steps.form_order_invalid');
|
||||
setErrors(next);
|
||||
return Object.keys(next).length === 0;
|
||||
@@ -48,7 +46,6 @@ export function CreateStepPage() {
|
||||
order: Number(order),
|
||||
title: title.trim() || undefined,
|
||||
type,
|
||||
sessionName: sessionName.trim(),
|
||||
execCode: execCode.trim() || undefined,
|
||||
validateCode: validateCode.trim() || undefined,
|
||||
});
|
||||
@@ -100,17 +97,6 @@ export function CreateStepPage() {
|
||||
onChange={(e) => setType(e.target.value as StepType)}
|
||||
options={STEP_TYPES.map((v) => ({ value: v, label: v }))}
|
||||
/>
|
||||
<Input
|
||||
label={t('steps.form_session')}
|
||||
placeholder={t('steps.form_session_placeholder')}
|
||||
value={sessionName}
|
||||
onChange={(e) => {
|
||||
setSessionName(e.target.value);
|
||||
setErrors((prev) => ({ ...prev, sessionName: undefined }));
|
||||
}}
|
||||
error={errors.sessionName}
|
||||
required
|
||||
/>
|
||||
<div className={styles.formField}>
|
||||
<label className={styles.fieldLabel}>{t('steps.form_exec_code')}</label>
|
||||
<textarea
|
||||
|
||||
Reference in new issue
Block a user