chore: apply code formatting and linting
- format long import statements with consistent line wrapping - apply consistent indentation across client and server modules - remove generated tsconfig.tsbuildinfo file
This commit is contained in:
@@ -1,10 +1,31 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useEffect, useState, SubmitEvent } from 'react';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Play, Pencil, Plus, History, Trash2, Upload, GripVertical, ClipboardList } from 'lucide-react';
|
||||
import {
|
||||
Play,
|
||||
Pencil,
|
||||
Plus,
|
||||
History,
|
||||
Trash2,
|
||||
Upload,
|
||||
GripVertical,
|
||||
ClipboardList,
|
||||
} from 'lucide-react';
|
||||
import { stringify as yamlStringify } from 'yaml';
|
||||
import { environments, scenarios, steps, scenarioCredentials, credentials as credentialsApi } from '../../api';
|
||||
import type { Scenario, ScenarioStep, ScenarioCredential, Credential, Environment } from '../../api';
|
||||
import {
|
||||
environments,
|
||||
scenarios,
|
||||
steps,
|
||||
scenarioCredentials,
|
||||
credentials as credentialsApi,
|
||||
} from '../../api';
|
||||
import type {
|
||||
Scenario,
|
||||
ScenarioStep,
|
||||
ScenarioCredential,
|
||||
Credential,
|
||||
Environment,
|
||||
} from '../../api';
|
||||
import {
|
||||
Breadcrumbs,
|
||||
Button,
|
||||
@@ -28,7 +49,6 @@ export function ScenarioDetailPage() {
|
||||
const toast = useToast();
|
||||
const [scenario, setScenario] = useState<(Scenario & { steps: ScenarioStep[] }) | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
// Credentials state
|
||||
const [scenarioCreds, setScenarioCreds] = useState<ScenarioCredential[]>([]);
|
||||
@@ -60,7 +80,6 @@ export function ScenarioDetailPage() {
|
||||
setScenario(s);
|
||||
setScenarioCreds(s.scenarioCredentials ?? []);
|
||||
})
|
||||
.catch((err: Error) => setError(err.message))
|
||||
.finally(() => setLoading(false));
|
||||
credentialsApi
|
||||
.list(1, 200)
|
||||
@@ -91,7 +110,7 @@ export function ScenarioDetailPage() {
|
||||
setRunning(true);
|
||||
try {
|
||||
const run = await scenarios.run(scenario.id, selectedEnvId, saveSessionFlag);
|
||||
toast.success('Scenario run started');
|
||||
toast.success(t('scenarios.run_started'));
|
||||
navigate(`/scenarios/${id}/runs/${run.id}`);
|
||||
setRunModalOpen(false);
|
||||
setSaveSessionFlag(false);
|
||||
@@ -140,7 +159,7 @@ export function ScenarioDetailPage() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleAddCredential = async (e: React.FormEvent) => {
|
||||
const handleAddCredential = async (e: SubmitEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
let valid = true;
|
||||
if (!addCredId) {
|
||||
@@ -321,7 +340,11 @@ export function ScenarioDetailPage() {
|
||||
<div className={styles.pageToolbar}>
|
||||
<Breadcrumbs
|
||||
items={[
|
||||
{ label: t('scenarios.title'), icon: <ClipboardList size={14} />, onClick: () => navigate('/scenarios') },
|
||||
{
|
||||
label: t('scenarios.title'),
|
||||
icon: <ClipboardList size={14} />,
|
||||
onClick: () => navigate('/scenarios'),
|
||||
},
|
||||
{ label: scenario?.name ?? `#${id}` },
|
||||
]}
|
||||
/>
|
||||
@@ -343,7 +366,11 @@ export function ScenarioDetailPage() {
|
||||
<Pencil size={14} />
|
||||
{t('scenarios.action_edit')}
|
||||
</Button>
|
||||
<Button variant="danger" size="sm" onClick={() => setPendingDelete({ type: 'scenario' })}>
|
||||
<Button
|
||||
variant="danger"
|
||||
size="sm"
|
||||
onClick={() => setPendingDelete({ type: 'scenario' })}
|
||||
>
|
||||
<Trash2 size={14} />
|
||||
{t('scenarios.action_delete')}
|
||||
</Button>
|
||||
@@ -513,36 +540,36 @@ export function ScenarioDetailPage() {
|
||||
: t('scenarios.action_delete')
|
||||
}
|
||||
onClose={() => !deleting && setPendingDelete(null)}
|
||||
footer={(
|
||||
footer={
|
||||
<>
|
||||
<Button variant="secondary" onClick={() => setPendingDelete(null)} disabled={deleting}>
|
||||
Cancel
|
||||
{t('common.button_cancel')}
|
||||
</Button>
|
||||
<Button variant="danger" onClick={confirmDelete} disabled={deleting}>
|
||||
Confirm
|
||||
{t('common.button_confirm')}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
}
|
||||
>
|
||||
{pendingDelete?.type === 'step' && 'Are you sure you want to delete this step?'}
|
||||
{pendingDelete?.type === 'credential' && 'Are you sure you want to remove this credential from scenario?'}
|
||||
{pendingDelete?.type === 'scenario' && 'Are you sure you want to delete this scenario?'}
|
||||
{pendingDelete?.type === 'step' && t('common.confirm_delete_step')}
|
||||
{pendingDelete?.type === 'credential' && t('common.confirm_remove_credential')}
|
||||
{pendingDelete?.type === 'scenario' && t('common.confirm_delete_scenario')}
|
||||
</Modal>
|
||||
|
||||
<Modal
|
||||
open={runModalOpen}
|
||||
title={t('scenarios.run_modal_title')}
|
||||
onClose={() => !running && setRunModalOpen(false)}
|
||||
footer={(
|
||||
footer={
|
||||
<>
|
||||
<Button variant="secondary" onClick={() => setRunModalOpen(false)} disabled={running}>
|
||||
Cancel
|
||||
{t('common.button_cancel')}
|
||||
</Button>
|
||||
<Button variant="primary" onClick={handleRun} disabled={running || !selectedEnvId}>
|
||||
{t('scenarios.action_run')}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
}
|
||||
>
|
||||
{envs.length === 0 ? (
|
||||
<p>{t('scenarios.run_modal_no_env')}</p>
|
||||
@@ -554,13 +581,15 @@ export function ScenarioDetailPage() {
|
||||
onChange={(e) => setSelectedEnvId(e.target.value)}
|
||||
options={envs.map((env) => ({ value: env.id, label: env.name }))}
|
||||
/>
|
||||
<label style={{ display: 'flex', alignItems: 'center', marginTop: '1rem', gap: '0.5rem' }}>
|
||||
<label
|
||||
style={{ display: 'flex', alignItems: 'center', marginTop: '1rem', gap: '0.5rem' }}
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={saveSessionFlag}
|
||||
onChange={(e) => setSaveSessionFlag(e.target.checked)}
|
||||
/>
|
||||
<span>Save session</span>
|
||||
<span>{t('common.save_session')}</span>
|
||||
</label>
|
||||
</>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user