feat(ui): add toasts for create edit and run flows

- add global ToastProvider and useToast hook mounted at app root

- show success/error toasts for environment, credential, snippet, and scenario create/edit actions

- show run-started/error toasts on scenario run actions with 100ms exit animation
This commit is contained in:
ars9 committed 2026-04-10 21:44:04 +03:00
1 parent d511c85891
commit 7444082b65
18 files changed
+285 -31

No files matched your search

@@ -3,12 +3,13 @@ import { useNavigate } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { X, Globe, Save } from 'lucide-react';
import { environments } from '../../api';
import { Breadcrumbs, Button, Card, Input, CodeEditor } from '../../ui';
import { Breadcrumbs, Button, Card, Input, CodeEditor, useToast } from '../../ui';
import styles from '../Page.module.css';
export function CreateEnvironmentPage() {
const { t } = useTranslation();
const navigate = useNavigate();
const toast = useToast();
const [name, setName] = useState('');
const [dataJson, setDataJson] = useState('{\n "id": "https://id.example.com"\n}');
@@ -44,9 +45,12 @@ export function CreateEnvironmentPage() {
setError(null);
try {
const env = await environments.create(name.trim(), parsedData);
toast.success('Environment created');
navigate(`/environments/${env.id}`);
} catch (err) {
setError((err as Error).message);
const message = (err as Error).message;
setError(message);
toast.error(message);
} finally {
setSaving(false);
}
@@ -4,13 +4,14 @@ import { useTranslation } from 'react-i18next';
import { X, Globe, Save } from 'lucide-react';
import { environments } from '../../api';
import type { Environment } from '../../api';
import { Breadcrumbs, Button, Card, Input, CodeEditor } from '../../ui';
import { Breadcrumbs, Button, Card, Input, CodeEditor, useToast } from '../../ui';
import styles from '../Page.module.css';
export function EditEnvironmentPage() {
const { t } = useTranslation();
const { id } = useParams<{ id: string }>();
const navigate = useNavigate();
const toast = useToast();
const [env, setEnv] = useState<Environment | null>(null);
const [name, setName] = useState('');
@@ -64,9 +65,12 @@ export function EditEnvironmentPage() {
name: name.trim(),
data: parsedData,
});
toast.success('Environment updated');
navigate(`/environments/${id}`);
} catch (err) {
setError((err as Error).message);
const message = (err as Error).message;
setError(message);
toast.error(message);
} finally {
setSaving(false);
}