Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
502a3e4f2c | ||
|
|
b57b55f3e1 | ||
|
|
06c662042b | ||
|
|
461669b3fb | ||
|
|
9580a7b2df | ||
|
|
86f9ac5603 | ||
|
|
6a91ce30e3 | ||
|
|
aa3bae9020 | ||
|
|
ba46789226 | ||
|
|
4e494ce4fd | ||
|
|
8c6158e8e3 | ||
|
|
b4cfe050fa | ||
|
|
a199700878 | ||
|
|
2a46b355db | ||
|
|
a50dce2755 | ||
|
|
8dbd319bba | ||
|
|
67e230a647 | ||
|
|
ad155e269c | ||
|
|
f268d0e3eb | ||
|
|
a779ab4667 | ||
|
|
e6aacc899d | ||
|
|
4dab218b75 | ||
|
|
622924ed53 | ||
|
|
6c43b53590 | ||
|
|
e66e53c817 | ||
|
|
a71be39076 | ||
|
|
5ec9fd0bc3 | ||
|
|
80d9af42b5 | ||
|
|
dcb002304b | ||
|
|
196bf4c2e8 | ||
|
|
0e47623a6b | ||
|
|
90be5a5490 | ||
|
|
1a2e786ca8 | ||
|
|
d34ea9e943 | ||
|
|
310997c3ae | ||
|
|
7acd1bc5a1 | ||
|
|
5ba327b745 | ||
|
|
238c52610a | ||
|
|
29e91b0078 | ||
|
|
56d23f913d | ||
|
|
d8ea2d0126 | ||
|
|
7223371fae | ||
|
|
11db983ea6 | ||
|
|
ccce3381c1 | ||
|
|
7444082b65 | ||
|
|
d511c85891 | ||
|
|
fd515ee459 | ||
|
|
b45f95d8cf | ||
|
|
1627733701 | ||
|
|
0e4a2e1819 | ||
|
|
99da7ac891 | ||
|
|
de0cbeef7c | ||
|
|
259dac806e | ||
|
|
673aa0f458 | ||
|
|
1c13e068ad | ||
|
|
2046e64428 | ||
|
|
fd655c3253 | ||
|
|
607abcafc5 | ||
|
|
b26eb10b3d | ||
|
|
32be7c0a59 | ||
|
|
1164289173 | ||
|
|
1efbbb38a3 | ||
|
|
1f3a604940 | ||
|
|
ebcb8b8ff4 | ||
|
|
6b1307c58a | ||
|
|
a2afe97cd3 | ||
|
|
a5f87b904e | ||
|
|
d342637eb6 | ||
|
|
097c747993 | ||
|
|
18177cac52 | ||
|
|
89016b01d2 | ||
|
|
35997f8bcb | ||
|
|
077cd6ad5f | ||
|
|
b4d576c6e9 | ||
|
|
f83141b484 | ||
|
|
32beec2229 | ||
|
|
50b942801f | ||
|
|
876b1518da | ||
|
|
aefa1db2bd | ||
|
|
9916ef5aaf | ||
|
|
5cc16725fb | ||
|
|
afc4627353 | ||
|
|
73cfe99cb7 | ||
|
|
9e79cad237 |
No files matched your search
+6
-4
@@ -1,7 +1,9 @@
|
||||
.git
|
||||
.gitignore
|
||||
node_modules
|
||||
dist
|
||||
**/node_modules
|
||||
**/dist
|
||||
**/.DS_Store
|
||||
**/*.log
|
||||
data
|
||||
keys
|
||||
.env
|
||||
.git
|
||||
*.log
|
||||
+10
-1
@@ -5,4 +5,13 @@ PORT=3000
|
||||
KEYS_DIR=keys
|
||||
|
||||
# SQLite database path
|
||||
DB_PATH=data/sessions.db
|
||||
DB_PATH=data/sessions.db
|
||||
|
||||
# Playwright executable (set in Docker; leave empty to use system default)
|
||||
# PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=/usr/bin/chromium
|
||||
|
||||
# Session lifecycle
|
||||
# Close open sessions that have been idle for longer than this many minutes
|
||||
SESSION_IDLE_TIMEOUT_MINUTES=30
|
||||
# Delete closed sessions whose updatedAt is older than this many days
|
||||
SESSION_DELETE_CLOSED_DAYS=7
|
||||
+21
-4
@@ -1,6 +1,23 @@
|
||||
/keys
|
||||
/node_modules
|
||||
/dist
|
||||
# runtime
|
||||
/data
|
||||
.env
|
||||
/*.log
|
||||
*.log
|
||||
|
||||
# dependencies
|
||||
node_modules/
|
||||
|
||||
# build outputs
|
||||
/dist
|
||||
server/dist
|
||||
client/dist
|
||||
*storybook.log
|
||||
storybook-static
|
||||
tsconfig.tsbuildinfo
|
||||
|
||||
# organization
|
||||
TODO.md
|
||||
|
||||
# IDE/editor
|
||||
.vscode/
|
||||
.idea/
|
||||
.github/
|
||||
@@ -0,0 +1,36 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## 1.7.1 - 2026-04-21
|
||||
|
||||
Changes since 1.7.0:
|
||||
|
||||
### Added
|
||||
|
||||
- Added MCP tools to upload, list, and fetch scenario files using base64 content payloads.
|
||||
- Added MCP tools to list run artifacts and fetch run artifact content with metadata.
|
||||
|
||||
### Changed
|
||||
|
||||
- Documented MCP binary content handling for scenario files and run artifacts.
|
||||
|
||||
## 1.7.0 - 2026-04-21
|
||||
|
||||
Changes since 1.6.1:
|
||||
|
||||
### Added
|
||||
|
||||
- Added scenario file storage and run artifact support on the backend.
|
||||
- Added file management UI for scenarios and run details, including artifact lists.
|
||||
- Added snippet CRUD tools to the MCP server.
|
||||
|
||||
### Changed
|
||||
|
||||
- Added dynamic page titles based on the active client content.
|
||||
- Extended the scenarios list to show the latest run status and timestamp.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Exposed file expiry metadata in scenario and run file responses.
|
||||
- Disabled expired download actions in the UI while keeping the action visible.
|
||||
@@ -0,0 +1,8 @@
|
||||
node_modules
|
||||
client/node_modules
|
||||
client/dist
|
||||
server
|
||||
data
|
||||
keys
|
||||
.env
|
||||
*.log
|
||||
@@ -0,0 +1,3 @@
|
||||
# Frontend API base URL.
|
||||
# Example for local Docker server: backend container is exposed on localhost:13000.
|
||||
VITE_API_URL=http://localhost:13000/api/v1
|
||||
@@ -0,0 +1,5 @@
|
||||
dist/
|
||||
storybook-static/
|
||||
node_modules/
|
||||
*.css
|
||||
*.json
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all",
|
||||
"printWidth": 100,
|
||||
"tabWidth": 2,
|
||||
"arrowParens": "always"
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import type { StorybookConfig } from '@storybook/react-vite';
|
||||
|
||||
import { dirname } from 'path';
|
||||
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
/**
|
||||
* This function is used to resolve the absolute path of a package.
|
||||
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
|
||||
*/
|
||||
function getAbsolutePath(value: string) {
|
||||
return dirname(fileURLToPath(import.meta.resolve(`${value}/package.json`)));
|
||||
}
|
||||
const config: StorybookConfig = {
|
||||
stories: ['./stories/**/*.mdx', './stories/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
|
||||
addons: [
|
||||
getAbsolutePath('@storybook/addon-vitest'),
|
||||
getAbsolutePath('@storybook/addon-a11y'),
|
||||
getAbsolutePath('@storybook/addon-docs'),
|
||||
],
|
||||
framework: getAbsolutePath('@storybook/react-vite'),
|
||||
};
|
||||
export default config;
|
||||
@@ -0,0 +1,45 @@
|
||||
import React from 'react';
|
||||
import type { Preview } from '@storybook/react-vite';
|
||||
import '../src/ui/tokens.css';
|
||||
|
||||
const preview: Preview = {
|
||||
globalTypes: {
|
||||
theme: {
|
||||
name: 'Theme',
|
||||
description: 'Color theme',
|
||||
defaultValue: 'light',
|
||||
toolbar: {
|
||||
icon: 'circlehollow',
|
||||
items: [
|
||||
{ value: 'light', icon: 'sun', title: 'Light' },
|
||||
{ value: 'dark', icon: 'moon', title: 'Dark' },
|
||||
],
|
||||
dynamicTitle: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
decorators: [
|
||||
(Story, context) => {
|
||||
const theme = (context.globals['theme'] as string) ?? 'light';
|
||||
document.documentElement.setAttribute('data-theme', theme);
|
||||
return (
|
||||
<div style={{ background: 'var(--color-bg)', minHeight: '100vh', padding: 0 }}>
|
||||
<Story />
|
||||
</div>
|
||||
);
|
||||
},
|
||||
],
|
||||
parameters: {
|
||||
controls: {
|
||||
matchers: {
|
||||
color: /(background|color)$/i,
|
||||
date: /Date$/i,
|
||||
},
|
||||
},
|
||||
a11y: {
|
||||
test: 'todo',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default preview;
|
||||
@@ -0,0 +1,25 @@
|
||||
import type { Meta, StoryObj } from '@storybook/react-vite';
|
||||
import { Badge } from '../../src/ui/Badge/Badge';
|
||||
|
||||
const meta: Meta<typeof Badge> = {
|
||||
title: 'UI/Badge',
|
||||
component: Badge,
|
||||
parameters: { layout: 'centered' },
|
||||
tags: ['autodocs'],
|
||||
argTypes: {
|
||||
variant: {
|
||||
control: 'select',
|
||||
options: ['success', 'error', 'warning', 'info', 'neutral', 'running'],
|
||||
},
|
||||
dot: { control: 'boolean' },
|
||||
},
|
||||
};
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof Badge>;
|
||||
|
||||
export const Success: Story = { args: { children: 'Passed', variant: 'success', dot: true } };
|
||||
export const Error: Story = { args: { children: 'Failed', variant: 'error', dot: true } };
|
||||
export const Warning: Story = { args: { children: 'Warning', variant: 'warning' } };
|
||||
export const Info: Story = { args: { children: 'Info', variant: 'info' } };
|
||||
export const Neutral: Story = { args: { children: 'Pending', variant: 'neutral' } };
|
||||
export const Running: Story = { args: { children: 'Running', variant: 'running', dot: true } };
|
||||
@@ -0,0 +1,45 @@
|
||||
import type { Meta, StoryObj } from '@storybook/react-vite';
|
||||
import { Breadcrumbs } from '../../src/ui/Breadcrumbs/Breadcrumbs';
|
||||
|
||||
const meta: Meta<typeof Breadcrumbs> = {
|
||||
title: 'UI/Breadcrumbs',
|
||||
component: Breadcrumbs,
|
||||
parameters: { layout: 'centered' },
|
||||
tags: ['autodocs'],
|
||||
};
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof Breadcrumbs>;
|
||||
|
||||
export const Default: Story = {
|
||||
args: {
|
||||
items: [{ label: 'Scenarios', href: '#' }, { label: 'Login flow' }],
|
||||
},
|
||||
};
|
||||
|
||||
export const Deep: Story = {
|
||||
args: {
|
||||
items: [
|
||||
{ label: 'Home', href: '#' },
|
||||
{ label: 'Scenarios', href: '#' },
|
||||
{ label: 'Login flow', href: '#' },
|
||||
{ label: 'Step 3' },
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
export const SingleItem: Story = {
|
||||
args: {
|
||||
items: [{ label: 'Dashboard' }],
|
||||
},
|
||||
};
|
||||
|
||||
export const CustomSeparator: Story = {
|
||||
args: {
|
||||
separator: '/',
|
||||
items: [
|
||||
{ label: 'Environments', href: '#' },
|
||||
{ label: 'Staging', href: '#' },
|
||||
{ label: 'Config' },
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
import type { Meta, StoryObj } from '@storybook/react-vite';
|
||||
import { Button } from '../../src/ui/Button/Button';
|
||||
|
||||
const meta: Meta<typeof Button> = {
|
||||
title: 'UI/Button',
|
||||
component: Button,
|
||||
parameters: { layout: 'centered' },
|
||||
tags: ['autodocs'],
|
||||
argTypes: {
|
||||
variant: { control: 'select', options: ['primary', 'secondary', 'ghost', 'danger'] },
|
||||
size: { control: 'select', options: ['sm', 'md', 'lg'] },
|
||||
loading: { control: 'boolean' },
|
||||
disabled: { control: 'boolean' },
|
||||
},
|
||||
};
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof Button>;
|
||||
|
||||
export const Primary: Story = { args: { children: 'Button', variant: 'primary' } };
|
||||
export const Secondary: Story = { args: { children: 'Button', variant: 'secondary' } };
|
||||
export const Ghost: Story = { args: { children: 'Button', variant: 'ghost' } };
|
||||
export const Danger: Story = { args: { children: 'Delete', variant: 'danger' } };
|
||||
export const Small: Story = { args: { children: 'Small', size: 'sm' } };
|
||||
export const Large: Story = { args: { children: 'Large', size: 'lg' } };
|
||||
export const Loading: Story = { args: { children: 'Saving…', loading: true } };
|
||||
export const Disabled: Story = { args: { children: 'Button', disabled: true } };
|
||||
@@ -0,0 +1,85 @@
|
||||
import React from 'react';
|
||||
import type { Meta, StoryObj } from '@storybook/react-vite';
|
||||
import { Card } from '../../src/ui/Card/Card';
|
||||
import { Badge } from '../../src/ui/Badge/Badge';
|
||||
import { Button } from '../../src/ui/Button/Button';
|
||||
|
||||
const meta: Meta<typeof Card> = {
|
||||
title: 'UI/Card',
|
||||
component: Card,
|
||||
parameters: { layout: 'centered' },
|
||||
tags: ['autodocs'],
|
||||
decorators: [
|
||||
(Story) => (
|
||||
<div style={{ width: 360 }}>
|
||||
<Story />
|
||||
</div>
|
||||
),
|
||||
],
|
||||
argTypes: {
|
||||
padding: { control: 'select', options: ['sm', 'md', 'lg'] },
|
||||
headerVariant: { control: 'select', options: ['primary', 'secondary'] },
|
||||
},
|
||||
};
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof Card>;
|
||||
|
||||
export const Default: Story = {
|
||||
args: { children: 'Card content goes here.', padding: 'md' },
|
||||
};
|
||||
|
||||
export const WithPrimaryHeader: Story = {
|
||||
args: {
|
||||
header: 'Section Title',
|
||||
headerVariant: 'primary',
|
||||
children: 'Card content with a primary header.',
|
||||
},
|
||||
};
|
||||
|
||||
export const WithSecondaryHeader: Story = {
|
||||
args: {
|
||||
header: 'Section Title',
|
||||
headerVariant: 'secondary',
|
||||
children: 'Card content with a secondary header.',
|
||||
},
|
||||
};
|
||||
|
||||
export const WithFooter: Story = {
|
||||
args: {
|
||||
header: 'My Card',
|
||||
headerVariant: 'primary',
|
||||
children: 'Card body content.',
|
||||
footer: 'Last updated 2 minutes ago',
|
||||
},
|
||||
};
|
||||
|
||||
export const ScenarioCard: Story = {
|
||||
render: () => (
|
||||
<Card>
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'flex-start',
|
||||
marginBottom: 8,
|
||||
}}
|
||||
>
|
||||
<span style={{ fontWeight: 600, fontSize: 14 }}>Login flow</span>
|
||||
<Badge variant="success" dot>
|
||||
Passed
|
||||
</Badge>
|
||||
</div>
|
||||
<p style={{ margin: '0 0 16px', fontSize: 13, color: 'var(--color-text-muted)' }}>
|
||||
Last run 2 minutes ago · 4 steps
|
||||
</p>
|
||||
<div style={{ display: 'flex', gap: 8 }}>
|
||||
<Button size="sm" variant="primary">
|
||||
Run
|
||||
</Button>
|
||||
<Button size="sm" variant="ghost">
|
||||
Edit
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
),
|
||||
};
|
||||
@@ -0,0 +1,142 @@
|
||||
import React from 'react';
|
||||
import type { Meta, StoryObj } from '@storybook/react-vite';
|
||||
|
||||
const palette = [
|
||||
{ name: 'Atlantis', token: '--color-primary', hex: '#9DD341', role: 'Primary / Action' },
|
||||
{ name: 'Outer Space', token: '--color-text', hex: '#2D3339', role: 'Text / Surface' },
|
||||
{ name: 'Kimberly', token: '--color-text-muted', hex: '#6650C0', role: 'Muted text / Info' },
|
||||
{ name: 'Powder Ash', token: '--color-border', hex: '#AFBFB9', role: 'Border / Neutral' },
|
||||
];
|
||||
|
||||
const semanticColors = [
|
||||
{ name: 'Success bg', token: '--color-success-bg', hex: '#EEF8D6' },
|
||||
{ name: 'Success fg', token: '--color-success-fg', hex: '#3E6010' },
|
||||
{ name: 'Error bg', token: '--color-error-bg', hex: '#FAEAEA' },
|
||||
{ name: 'Error fg', token: '--color-error-fg', hex: '#8B2020' },
|
||||
{ name: 'Warning bg', token: '--color-warning-bg', hex: '#FEF5E0' },
|
||||
{ name: 'Warning fg', token: '--color-warning-fg', hex: '#7A4E00' },
|
||||
{ name: 'Info bg', token: '--color-info-bg', hex: '#EEEDF6' },
|
||||
{ name: 'Info fg', token: '--color-info-fg', hex: '#4A4270' },
|
||||
{ name: 'Neutral bg', token: '--color-neutral-bg', hex: '#EDF1EF' },
|
||||
{ name: 'Neutral fg', token: '--color-neutral-fg', hex: '#4D6059' },
|
||||
{ name: 'Running bg', token: '--color-running-bg', hex: '#FEF9C3' },
|
||||
{ name: 'Running fg', token: '--color-running-fg', hex: '#6B4A00' },
|
||||
];
|
||||
|
||||
const surfaceColors = [
|
||||
{ name: 'Background', token: '--color-bg', hex: '#E6EDEA' },
|
||||
{ name: 'Background subtle', token: '--color-bg-subtle', hex: '#D8E2DE' },
|
||||
{ name: 'Secondary', token: '--color-secondary', hex: '#EDF1EF' },
|
||||
{ name: 'Secondary hover', token: '--color-secondary-hover', hex: '#DFE6E3' },
|
||||
{ name: 'Danger', token: '--color-danger', hex: '#D94F4F' },
|
||||
{ name: 'Primary fg', token: '--color-primary-fg', hex: '#2D3339' },
|
||||
];
|
||||
|
||||
function Swatch({
|
||||
name,
|
||||
token,
|
||||
hex,
|
||||
role,
|
||||
}: {
|
||||
name: string;
|
||||
token: string;
|
||||
hex: string;
|
||||
role?: string;
|
||||
}) {
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
overflow: 'hidden',
|
||||
borderRadius: 8,
|
||||
border: 'var(--border-width) solid var(--color-border)',
|
||||
minWidth: 160,
|
||||
flex: '1 1 160px',
|
||||
maxWidth: 220,
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
background: `var(${token}, ${hex})`,
|
||||
height: 80,
|
||||
}}
|
||||
/>
|
||||
<div style={{ padding: '10px 12px', background: 'var(--color-bg)' }}>
|
||||
<div style={{ fontWeight: 600, fontSize: 13, color: 'var(--color-text)', marginBottom: 2 }}>
|
||||
{name}
|
||||
</div>
|
||||
{role && (
|
||||
<div style={{ fontSize: 11, color: 'var(--color-text-muted)', marginBottom: 4 }}>
|
||||
{role}
|
||||
</div>
|
||||
)}
|
||||
<div style={{ fontSize: 11, fontFamily: 'monospace', color: 'var(--color-text-muted)' }}>
|
||||
{hex}
|
||||
</div>
|
||||
<div style={{ fontSize: 11, fontFamily: 'monospace', color: 'var(--color-text-muted)' }}>
|
||||
{token}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Section({ title, children }: { title: string; children: React.ReactNode }) {
|
||||
return (
|
||||
<div style={{ marginBottom: 40 }}>
|
||||
<h2
|
||||
style={{
|
||||
fontFamily: 'var(--font-family)',
|
||||
color: 'var(--color-text)',
|
||||
fontSize: 14,
|
||||
fontWeight: 600,
|
||||
marginBottom: 16,
|
||||
textTransform: 'uppercase',
|
||||
letterSpacing: '0.08em',
|
||||
}}
|
||||
>
|
||||
{title}
|
||||
</h2>
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 12 }}>{children}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ColorPalette() {
|
||||
return (
|
||||
<div style={{ padding: 32, fontFamily: 'var(--font-family)' }}>
|
||||
<h1 style={{ color: 'var(--color-text)', fontSize: 22, fontWeight: 700, marginBottom: 8 }}>
|
||||
Color Palette
|
||||
</h1>
|
||||
<p style={{ color: 'var(--color-text-muted)', fontSize: 14, marginBottom: 40 }}>
|
||||
All colors are exposed as CSS custom properties on <code>:root</code> via{' '}
|
||||
<code>tokens.css</code>.
|
||||
</p>
|
||||
<Section title="Brand">
|
||||
{palette.map((c) => (
|
||||
<Swatch key={c.token} {...c} />
|
||||
))}
|
||||
</Section>
|
||||
<Section title="Semantic">
|
||||
{semanticColors.map((c) => (
|
||||
<Swatch key={c.token} {...c} />
|
||||
))}
|
||||
</Section>
|
||||
<Section title="Surface & Action">
|
||||
{surfaceColors.map((c) => (
|
||||
<Swatch key={c.token} {...c} />
|
||||
))}
|
||||
</Section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const meta: Meta = {
|
||||
title: 'Design Tokens/Colors',
|
||||
parameters: { layout: 'fullscreen' },
|
||||
};
|
||||
export default meta;
|
||||
|
||||
type Story = StoryObj;
|
||||
export const All: Story = { render: () => <ColorPalette /> };
|
||||
@@ -0,0 +1,52 @@
|
||||
import type { Meta, StoryObj } from '@storybook/react-vite';
|
||||
import { Settings, Trash2, ExternalLink } from 'lucide-react';
|
||||
import { Button } from '../../src/ui/Button/Button';
|
||||
import { ContextMenu } from '../../src/ui/ContextMenu/ContextMenu';
|
||||
|
||||
const meta: Meta<typeof ContextMenu> = {
|
||||
title: 'UI/ContextMenu',
|
||||
component: ContextMenu,
|
||||
parameters: { layout: 'centered' },
|
||||
tags: ['autodocs'],
|
||||
};
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof ContextMenu>;
|
||||
|
||||
const trigger = (
|
||||
<Button variant="ghost" size="sm">
|
||||
<Settings size={16} />
|
||||
</Button>
|
||||
);
|
||||
|
||||
export const Default: Story = {
|
||||
args: {
|
||||
trigger,
|
||||
items: [
|
||||
{ label: 'View details', icon: <ExternalLink size={14} />, onClick: () => {} },
|
||||
{ label: 'Delete', icon: <Trash2 size={14} />, variant: 'danger', onClick: () => {} },
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
export const AlignLeft: Story = {
|
||||
args: {
|
||||
trigger,
|
||||
align: 'left',
|
||||
items: [
|
||||
{ label: 'View details', icon: <ExternalLink size={14} />, onClick: () => {} },
|
||||
{ label: 'Delete', icon: <Trash2 size={14} />, variant: 'danger', onClick: () => {} },
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
export const ManyItems: Story = {
|
||||
args: {
|
||||
trigger,
|
||||
items: [
|
||||
{ label: 'View details', icon: <ExternalLink size={14} />, onClick: () => {} },
|
||||
{ label: 'Edit', icon: <Settings size={14} />, onClick: () => {} },
|
||||
{ label: 'Duplicate', onClick: () => {} },
|
||||
{ label: 'Delete', icon: <Trash2 size={14} />, variant: 'danger', onClick: () => {} },
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
import React from 'react';
|
||||
import type { Meta, StoryObj } from '@storybook/react-vite';
|
||||
import { DescriptionList } from '../../src/ui/DescriptionList/DescriptionList';
|
||||
|
||||
const meta: Meta<typeof DescriptionList> = {
|
||||
title: 'UI/DescriptionList',
|
||||
component: DescriptionList,
|
||||
parameters: { layout: 'centered' },
|
||||
tags: ['autodocs'],
|
||||
decorators: [
|
||||
(Story) => (
|
||||
<div style={{ width: 360 }}>
|
||||
<Story />
|
||||
</div>
|
||||
),
|
||||
],
|
||||
argTypes: {
|
||||
layout: { control: 'select', options: ['inline', 'compact'] },
|
||||
},
|
||||
};
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof DescriptionList>;
|
||||
|
||||
const urlItems = [
|
||||
{ term: 'ID_URL', detail: 'https://id.example.com/' },
|
||||
{ term: 'CABINET_URL', detail: 'https://cabinet.example.com/messages' },
|
||||
{ term: 'ADMIN_URL', detail: 'https://admin.example.com/' },
|
||||
];
|
||||
|
||||
export const Inline: Story = {
|
||||
args: { items: urlItems, layout: 'inline' },
|
||||
};
|
||||
|
||||
export const Compact: Story = {
|
||||
args: { items: urlItems, layout: 'compact' },
|
||||
};
|
||||
|
||||
export const WithLinks: Story = {
|
||||
args: {
|
||||
layout: 'inline',
|
||||
items: urlItems.map(({ term, detail }) => ({
|
||||
term,
|
||||
detail: (
|
||||
<a href={detail as string} target="_blank" rel="noopener noreferrer">
|
||||
{detail}
|
||||
</a>
|
||||
),
|
||||
})),
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
import type { Meta, StoryObj } from '@storybook/react-vite';
|
||||
import { Input } from '../../src/ui/Input/Input';
|
||||
|
||||
const meta: Meta<typeof Input> = {
|
||||
title: 'UI/Input',
|
||||
component: Input,
|
||||
parameters: { layout: 'centered' },
|
||||
tags: ['autodocs'],
|
||||
decorators: [
|
||||
(Story) => (
|
||||
<div style={{ width: 320 }}>
|
||||
<Story />
|
||||
</div>
|
||||
),
|
||||
],
|
||||
};
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof Input>;
|
||||
|
||||
export const Default: Story = {
|
||||
args: { label: 'Label', placeholder: 'Placeholder' },
|
||||
};
|
||||
export const WithHint: Story = {
|
||||
args: {
|
||||
label: 'Environment name',
|
||||
placeholder: 'e.g. staging',
|
||||
hint: 'Used to identify this environment in scenarios.',
|
||||
},
|
||||
};
|
||||
export const WithError: Story = {
|
||||
args: {
|
||||
label: 'URL',
|
||||
placeholder: 'https://...',
|
||||
defaultValue: 'not a url',
|
||||
error: 'Must be a valid URL.',
|
||||
},
|
||||
};
|
||||
export const Disabled: Story = {
|
||||
args: { label: 'Label', value: 'Some value', disabled: true, readOnly: true },
|
||||
};
|
||||
@@ -0,0 +1,56 @@
|
||||
import type { Meta, StoryObj } from '@storybook/react-vite';
|
||||
import { useState } from 'react';
|
||||
import { Pagination } from '../../src/ui/Pagination/Pagination';
|
||||
|
||||
const meta: Meta<typeof Pagination> = {
|
||||
title: 'UI/Pagination',
|
||||
component: Pagination,
|
||||
parameters: { layout: 'padded' },
|
||||
tags: ['autodocs'],
|
||||
};
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof Pagination>;
|
||||
|
||||
function Controlled(args: React.ComponentProps<typeof Pagination>) {
|
||||
const [page, setPage] = useState(args.page);
|
||||
const [pageSize, setPageSize] = useState(args.pageSize);
|
||||
return (
|
||||
<Pagination
|
||||
{...args}
|
||||
page={page}
|
||||
pageSize={pageSize}
|
||||
onPageChange={setPage}
|
||||
onPageSizeChange={args.onPageSizeChange ? setPageSize : undefined}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export const FewPages: Story = {
|
||||
render: (args) => <Controlled {...args} />,
|
||||
args: { page: 1, pageSize: 10, total: 30 },
|
||||
};
|
||||
|
||||
export const ManyPages: Story = {
|
||||
render: (args) => <Controlled {...args} />,
|
||||
args: { page: 5, pageSize: 10, total: 200 },
|
||||
};
|
||||
|
||||
export const LastPage: Story = {
|
||||
render: (args) => <Controlled {...args} />,
|
||||
args: { page: 20, pageSize: 10, total: 200 },
|
||||
};
|
||||
|
||||
export const SinglePage: Story = {
|
||||
render: (args) => <Controlled {...args} />,
|
||||
args: { page: 1, pageSize: 10, total: 7 },
|
||||
};
|
||||
|
||||
export const WithPageSizeSelector: Story = {
|
||||
render: (args) => <Controlled {...args} />,
|
||||
args: {
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
total: 150,
|
||||
onPageSizeChange: () => {},
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,75 @@
|
||||
import type { Meta, StoryObj } from '@storybook/react-vite';
|
||||
import { Select } from '../../src/ui/Select/Select';
|
||||
|
||||
const ENVIRONMENTS = [
|
||||
{ value: 'dev', label: 'Development' },
|
||||
{ value: 'staging', label: 'Staging' },
|
||||
{ value: 'prod', label: 'Production' },
|
||||
];
|
||||
|
||||
const SCENARIO_TYPES = [
|
||||
{ value: 'smoke', label: 'Smoke test' },
|
||||
{ value: 'regression', label: 'Regression' },
|
||||
{ value: 'e2e', label: 'End-to-end' },
|
||||
{ value: 'perf', label: 'Performance', disabled: true },
|
||||
];
|
||||
|
||||
const meta: Meta<typeof Select> = {
|
||||
title: 'UI/Select',
|
||||
component: Select,
|
||||
parameters: { layout: 'centered' },
|
||||
tags: ['autodocs'],
|
||||
decorators: [
|
||||
(Story) => (
|
||||
<div style={{ width: 320 }}>
|
||||
<Story />
|
||||
</div>
|
||||
),
|
||||
],
|
||||
};
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof Select>;
|
||||
|
||||
export const Default: Story = {
|
||||
args: {
|
||||
label: 'Environment',
|
||||
options: ENVIRONMENTS,
|
||||
placeholder: 'Select an environment…',
|
||||
},
|
||||
};
|
||||
|
||||
export const WithValue: Story = {
|
||||
args: {
|
||||
label: 'Environment',
|
||||
options: ENVIRONMENTS,
|
||||
defaultValue: 'staging',
|
||||
},
|
||||
};
|
||||
|
||||
export const WithHint: Story = {
|
||||
args: {
|
||||
label: 'Test type',
|
||||
options: SCENARIO_TYPES,
|
||||
placeholder: 'Choose a type…',
|
||||
hint: 'Performance tests require a dedicated runner.',
|
||||
},
|
||||
};
|
||||
|
||||
export const WithError: Story = {
|
||||
args: {
|
||||
label: 'Environment',
|
||||
options: ENVIRONMENTS,
|
||||
defaultValue: '',
|
||||
placeholder: 'Select an environment…',
|
||||
error: 'Please select an environment.',
|
||||
},
|
||||
};
|
||||
|
||||
export const Disabled: Story = {
|
||||
args: {
|
||||
label: 'Environment',
|
||||
options: ENVIRONMENTS,
|
||||
defaultValue: 'prod',
|
||||
disabled: true,
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,75 @@
|
||||
import type { Meta, StoryObj } from '@storybook/react-vite';
|
||||
import { SidePanel } from '../../src/ui/SidePanel/SidePanel';
|
||||
|
||||
const NAV_ITEMS = ['Dashboard', 'Scenarios', 'Environments', 'Reports', 'Settings'];
|
||||
|
||||
function NavList() {
|
||||
return (
|
||||
<ul
|
||||
style={{
|
||||
listStyle: 'none',
|
||||
margin: 0,
|
||||
padding: 0,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: 2,
|
||||
}}
|
||||
>
|
||||
{NAV_ITEMS.map((item) => (
|
||||
<li key={item}>
|
||||
<button
|
||||
style={{
|
||||
width: '100%',
|
||||
textAlign: 'left',
|
||||
background: 'none',
|
||||
border: 'none',
|
||||
borderRadius: 'var(--radius-md)',
|
||||
padding: 'var(--space-2) var(--space-3)',
|
||||
fontSize: 'var(--font-size-sm)',
|
||||
color: 'var(--color-text)',
|
||||
cursor: 'pointer',
|
||||
fontFamily: 'var(--font-family)',
|
||||
}}
|
||||
onMouseEnter={(e) => (e.currentTarget.style.background = 'var(--color-secondary)')}
|
||||
onMouseLeave={(e) => (e.currentTarget.style.background = 'none')}
|
||||
>
|
||||
{item}
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
|
||||
const meta: Meta<typeof SidePanel> = {
|
||||
title: 'UI/SidePanel',
|
||||
component: SidePanel,
|
||||
parameters: { layout: 'fullscreen' },
|
||||
tags: ['autodocs'],
|
||||
decorators: [
|
||||
(Story) => (
|
||||
<div style={{ display: 'flex', height: 420, background: 'var(--color-bg)' }}>
|
||||
<Story />
|
||||
<div
|
||||
style={{
|
||||
flex: 1,
|
||||
padding: 'var(--space-6)',
|
||||
color: 'var(--color-text-muted)',
|
||||
fontSize: 'var(--font-size-sm)',
|
||||
}}
|
||||
>
|
||||
Main content area
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
],
|
||||
};
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof SidePanel>;
|
||||
|
||||
export const Default: Story = {
|
||||
args: {
|
||||
header: 'Navigation',
|
||||
children: <NavList />,
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,107 @@
|
||||
import type { Meta, StoryObj } from '@storybook/react-vite';
|
||||
import { Table } from '../../src/ui/Table/Table';
|
||||
import { Badge } from '../../src/ui/Badge/Badge';
|
||||
import { Timestamp } from '../../src/ui/Timestamp/Timestamp';
|
||||
|
||||
const meta: Meta<typeof Table> = {
|
||||
title: 'UI/Table',
|
||||
component: Table,
|
||||
tags: ['autodocs'],
|
||||
parameters: { layout: 'padded' },
|
||||
};
|
||||
export default meta;
|
||||
|
||||
interface User {
|
||||
id: number;
|
||||
name: string;
|
||||
email: string;
|
||||
status: 'active' | 'inactive';
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
const daysAgo = (n: number) => new Date(Date.now() - n * 86_400_000).toISOString();
|
||||
|
||||
const users: User[] = [
|
||||
{
|
||||
id: 1,
|
||||
name: 'Alice Müller',
|
||||
email: 'alice@example.com',
|
||||
status: 'active',
|
||||
updatedAt: daysAgo(1),
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'Bob Nguyen',
|
||||
email: 'bob@example.com',
|
||||
status: 'inactive',
|
||||
updatedAt: daysAgo(5),
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: 'Carol Santos',
|
||||
email: 'carol@example.com',
|
||||
status: 'active',
|
||||
updatedAt: daysAgo(30),
|
||||
},
|
||||
];
|
||||
|
||||
const manyUsers: User[] = Array.from({ length: 47 }, (_, i) => ({
|
||||
id: i + 1,
|
||||
name: `User ${i + 1}`,
|
||||
email: `user${i + 1}@example.com`,
|
||||
status: i % 3 === 0 ? 'inactive' : 'active',
|
||||
updatedAt: daysAgo(i),
|
||||
}));
|
||||
|
||||
const columns: StoryObj<typeof Table<User>>['args'] = {
|
||||
rowKey: (u: User) => u.id,
|
||||
emptyMessage: 'No users found.',
|
||||
columns: [
|
||||
{ key: 'id', header: 'ID', render: (u: User) => u.id, width: 60 },
|
||||
{ key: 'name', header: 'Name', render: (u: User) => u.name },
|
||||
{ key: 'email', header: 'Email', render: (u: User) => u.email },
|
||||
{
|
||||
key: 'status',
|
||||
header: 'Status',
|
||||
width: 110,
|
||||
render: (u: User) => (
|
||||
<Badge variant={u.status === 'active' ? 'success' : 'neutral'}>{u.status}</Badge>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'updated',
|
||||
header: 'Updated',
|
||||
width: 140,
|
||||
render: (u: User) => <Timestamp value={u.updatedAt} />,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const Default: StoryObj<typeof Table<User>> = {
|
||||
args: { ...columns, data: users },
|
||||
};
|
||||
|
||||
export const Loading: StoryObj<typeof Table<User>> = {
|
||||
args: { ...columns, data: users, loading: true },
|
||||
};
|
||||
|
||||
export const Empty: StoryObj<typeof Table<User>> = {
|
||||
args: { ...columns, data: [] },
|
||||
};
|
||||
|
||||
export const SingleRow: StoryObj<typeof Table<User>> = {
|
||||
args: { ...columns, data: [users[0]] },
|
||||
};
|
||||
|
||||
export const WithPagination: StoryObj<typeof Table<User>> = {
|
||||
args: { ...columns, data: manyUsers, pageSize: 10 },
|
||||
};
|
||||
|
||||
export const WithPaginationAndSizeSelector: StoryObj<typeof Table<User>> = {
|
||||
args: {
|
||||
...columns,
|
||||
data: manyUsers,
|
||||
pageSize: 10,
|
||||
pageSizeOptions: [10, 25, 50],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
import type { Meta, StoryObj } from '@storybook/react-vite';
|
||||
import { ThemeSwitcher } from '../../src/ui/ThemeSwitcher/ThemeSwitcher';
|
||||
|
||||
const meta: Meta<typeof ThemeSwitcher> = {
|
||||
title: 'UI/ThemeSwitcher',
|
||||
component: ThemeSwitcher,
|
||||
parameters: { layout: 'centered' },
|
||||
tags: ['autodocs'],
|
||||
};
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof ThemeSwitcher>;
|
||||
|
||||
export const Default: Story = {};
|
||||
@@ -0,0 +1,21 @@
|
||||
import type { Meta, StoryObj } from '@storybook/react-vite';
|
||||
import { Timestamp } from '../../src/ui/Timestamp/Timestamp';
|
||||
|
||||
const meta: Meta<typeof Timestamp> = {
|
||||
title: 'UI/Timestamp',
|
||||
component: Timestamp,
|
||||
parameters: { layout: 'centered' },
|
||||
tags: ['autodocs'],
|
||||
};
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof Timestamp>;
|
||||
|
||||
const minutesAgo = (n: number) => new Date(Date.now() - n * 60_000).toISOString();
|
||||
const hoursAgo = (n: number) => new Date(Date.now() - n * 3_600_000).toISOString();
|
||||
const daysAgo = (n: number) => new Date(Date.now() - n * 86_400_000).toISOString();
|
||||
|
||||
export const JustNow: Story = { args: { value: minutesAgo(1) } };
|
||||
export const MinutesAgo: Story = { args: { value: minutesAgo(15) } };
|
||||
export const HoursAgo: Story = { args: { value: hoursAgo(3) } };
|
||||
export const DaysAgo: Story = { args: { value: daysAgo(5) } };
|
||||
export const MonthsAgo: Story = { args: { value: daysAgo(90) } };
|
||||
@@ -0,0 +1,20 @@
|
||||
# ── Build stage ───────────────────────────────────────────────────────────────
|
||||
FROM node:22-slim AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy root lockfile + workspace manifests so npm ci can resolve the full graph
|
||||
COPY package*.json ./
|
||||
COPY client/package.json ./client/
|
||||
RUN npm ci -w client
|
||||
|
||||
COPY client ./client
|
||||
RUN npm run -w client build
|
||||
|
||||
# ── Runtime stage ─────────────────────────────────────────────────────────────
|
||||
FROM nginx:alpine AS runtime
|
||||
|
||||
COPY --from=builder /app/client/dist /usr/share/nginx/html
|
||||
COPY client/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
EXPOSE 80
|
||||
@@ -0,0 +1,34 @@
|
||||
import js from '@eslint/js';
|
||||
import tseslint from 'typescript-eslint';
|
||||
import reactHooks from 'eslint-plugin-react-hooks';
|
||||
import reactRefresh from 'eslint-plugin-react-refresh';
|
||||
import prettier from 'eslint-plugin-prettier';
|
||||
import prettierConfig from 'eslint-config-prettier';
|
||||
|
||||
export default tseslint.config(
|
||||
{ ignores: ['dist', 'storybook-static'] },
|
||||
|
||||
// Base JS rules
|
||||
js.configs.recommended,
|
||||
|
||||
// TypeScript rules
|
||||
...tseslint.configs.recommended,
|
||||
|
||||
// React rules
|
||||
{
|
||||
plugins: {
|
||||
'react-hooks': reactHooks,
|
||||
'react-refresh': reactRefresh,
|
||||
prettier,
|
||||
},
|
||||
rules: {
|
||||
...reactHooks.configs.recommended.rules,
|
||||
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
|
||||
'prettier/prettier': 'warn',
|
||||
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
|
||||
},
|
||||
},
|
||||
|
||||
// Disable ESLint formatting rules that conflict with Prettier
|
||||
prettierConfig,
|
||||
);
|
||||
@@ -0,0 +1,22 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Liqa</title>
|
||||
<script>
|
||||
(function () {
|
||||
var stored = localStorage.getItem('qa-bot-theme');
|
||||
var theme = stored === 'light' || stored === 'dark'
|
||||
? stored
|
||||
: window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
||||
document.documentElement.setAttribute('data-theme', theme);
|
||||
})();
|
||||
</script>
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,17 @@
|
||||
server {
|
||||
listen 80;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://server:3000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
{
|
||||
"name": "liqa-client",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"dev:compose-api": "VITE_API_URL=http://localhost:13000/api/v1 vite",
|
||||
"build": "tsc -b && vite build",
|
||||
"preview": "vite preview",
|
||||
"storybook": "storybook dev -p 6006",
|
||||
"build-storybook": "storybook build",
|
||||
"test:compile": "tsc --noEmit",
|
||||
"test:storybook": "vitest run --project storybook",
|
||||
"lint": "eslint src .storybook",
|
||||
"lint:fix": "eslint src .storybook --fix",
|
||||
"format": "prettier --write \"src/**/*.{ts,tsx}\" \".storybook/**/*.{ts,tsx}\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@monaco-editor/react": "^4.7.0",
|
||||
"@tanstack/react-query": "^5.99.0",
|
||||
"highlight.js": "^11.11.1",
|
||||
"i18next": "^26.0.4",
|
||||
"lucide-react": "^1.7.0",
|
||||
"moment": "^2.30.1",
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0",
|
||||
"react-i18next": "^17.0.2",
|
||||
"react-markdown": "^10.1.0",
|
||||
"react-router-dom": "^7.14.0",
|
||||
"remark-gfm": "^4.0.1",
|
||||
"yaml": "^2.8.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.39.4",
|
||||
"@storybook/addon-a11y": "^10.3.5",
|
||||
"@storybook/addon-docs": "^10.3.5",
|
||||
"@storybook/addon-vitest": "^10.3.5",
|
||||
"@storybook/react-vite": "^10.3.5",
|
||||
"@types/react": "^19.1.2",
|
||||
"@types/react-dom": "^19.1.2",
|
||||
"@vitejs/plugin-react": "^4.4.1",
|
||||
"@vitest/browser-playwright": "^4.1.3",
|
||||
"@vitest/coverage-v8": "^4.1.3",
|
||||
"eslint": "^10.2.0",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-prettier": "^5.5.5",
|
||||
"eslint-plugin-react-hooks": "^7.0.1",
|
||||
"eslint-plugin-react-refresh": "^0.5.2",
|
||||
"playwright": "^1.59.1",
|
||||
"prettier": "^3.8.1",
|
||||
"storybook": "^10.3.5",
|
||||
"typescript": "~5.8.3",
|
||||
"typescript-eslint": "^8.58.1",
|
||||
"vite": "^6.3.1",
|
||||
"vitest": "^4.1.3"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
version="1.1"
|
||||
id="svg92"
|
||||
width="421.86172"
|
||||
height="421.86172"
|
||||
viewBox="0 0 421.86173 421.86172"
|
||||
sodipodi:docname="liqa-mini.svg"
|
||||
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<defs
|
||||
id="defs96" />
|
||||
<sodipodi:namedview
|
||||
id="namedview94"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="false"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
showgrid="false"
|
||||
showborder="false"
|
||||
borderlayer="false"
|
||||
shape-rendering="auto"
|
||||
inkscape:zoom="0.60813025"
|
||||
inkscape:cx="-51.798114"
|
||||
inkscape:cy="-76.463882"
|
||||
inkscape:window-width="2544"
|
||||
inkscape:window-height="1355"
|
||||
inkscape:window-x="20"
|
||||
inkscape:window-y="20"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="g98" />
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
inkscape:label="Image"
|
||||
id="g98"
|
||||
transform="translate(-270.03557,-210.1151)">
|
||||
<circle
|
||||
style="fill:#e6edea;fill-opacity:1;stroke-width:0.926933"
|
||||
id="path331"
|
||||
cx="480.96643"
|
||||
cy="421.04596"
|
||||
r="210.93086" />
|
||||
<path
|
||||
style="fill:#39196b"
|
||||
d="m 453.91034,593.79867 c -34.08673,-5.09427 -70.45402,-12.61452 -97.32495,-35.64384 -9.91285,-8.49217 -10.39503,-22.11427 -9.93686,-34.15838 -29.11758,-32.44273 -47.40043,-75.91137 -44.17964,-119.94221 -0.1082,-69.39624 50.26509,-133.2096 115.02861,-155.43859 65.94576,-23.97068 145.13988,-7.25178 194.05946,43.53493 33.75034,34.13894 52.73157,82.84814 48.59098,130.92571 -2.05053,36.83319 -19.00255,72.10194 -42.95534,99.74833 0.59009,14.27144 -0.67496,30.5898 -14.31879,38.78996 -29.95318,20.71235 -66.75963,30.54233 -102.80366,32.85732 -15.37106,0.58367 -30.83524,0.86962 -46.15981,-0.67323 z m 60,-25.40946 c 63.80512,-11.608 115.95832,-65.21248 129.69191,-127.96784 13.52875,-65.57348 -19.88327,-136.69388 -77.86044,-169.61945 -62.09585,-37.00081 -148.54942,-29.25016 -200.28124,22.40983 -39.98962,37.54618 -58.68926,96.3072 -45.60991,149.85388 15.1241,64.40785 71.02087,118.19945 137.36624,126.41525 18.58372,2.99672 38.14468,1.6814 56.69344,-1.09167 z m -47.5,-2.22871 c -38.4767,-4.43103 -77.04078,-22.16808 -101.12198,-53.12116 -3.19125,-10.71063 13.54949,-17.36711 -0.27511,-27.21578 -8.26021,-16.11409 -8.83665,-33.71408 -14.27833,-50.67086 -0.2541,-18.10794 20.10105,-26.35624 25.6663,-43.23729 6.35587,-8.46898 -3.9027,-20.33944 -0.39344,-30.42399 2.15786,-25.3474 4.36566,-52.60471 18.52953,-74.47265 14.78936,-16.29232 35.47458,0.7495 45.63689,13.63324 11.08594,12.42904 21.91316,33.6459 41.91941,25.85866 15.44797,-0.25083 30.76053,2.11785 38.30644,-15.26956 12.94844,-12.26049 29.58114,-33.49814 49.51863,-25.31725 15.14143,14.78032 23.40098,35.53589 30.24631,55.23997 4.55565,15.36852 4.6391,31.94493 3.28453,47.62379 9.36324,3.04253 19.5843,3.12362 29.33081,4.80945 4.13961,36.35364 -6.87221,74.41869 -29.06057,103.34533 6.1277,-6.57686 -11.08201,-8.1108 -10.42592,-13.41902 -3.13078,8.77758 6.94663,20.41165 8.2868,16.46805 -0.56187,16.28936 -17.32423,27.53773 -29.07955,37.58785 -29.98728,22.19243 -69.09541,32.24465 -106.09075,28.58122 z m 45.894,-11.81034 c 33.41589,-6.42529 64.06763,-23.96926 87.606,-48.31107 -8.2548,8.75218 -16.68941,10.99135 -19.0901,-3.25812 -6.74621,-5.75317 4.24595,-28.93739 -7.93245,-14.80685 -12.56916,8.84191 6.92924,-12.74278 9.10243,-19.35578 10.01143,-17.42491 0.0574,-37.62462 -13.95795,-49.29114 -14.6216,-12.15862 17.42439,7.41163 7.0361,-3.83503 -3.38412,-4.97478 -17.07811,-12.87071 -3.49938,-12.93686 13.39611,-15.67737 9.03047,-38.51699 7.49334,-57.46672 -2.84393,-16.45555 -4.77538,-34.52556 -15.35747,-48.05543 -16.01154,-1.14314 -26.08547,16.38647 -36.61497,26.39715 -5.70545,5.13719 -20.49899,28.37559 -21.75329,21.0369 3.13269,-11.75191 -28.76493,7.02326 -18.04711,-7.35592 -10.84777,9.86053 -22.17174,2.09875 -33.04263,1.86322 -2.31736,12.36385 -11.29846,-13.13312 -16.5778,-17.49645 -8.72025,-8.90768 -19.97374,-34.20851 -33.96144,-25.78405 -11.69397,23.33334 -16.11056,50.56447 -13.69042,76.47881 -0.0602,5.91781 4.34322,13.08008 8.02259,9.96256 -4.67811,10.89105 -12.41488,20.03503 -20.60515,28.45263 22.15351,-6.46272 -6.75848,11.20914 -11.32612,18.11668 -5.55558,6.00011 11.23537,1.21603 0.92918,8.09759 -9.85267,8.82172 0.90225,10.96263 8.1364,5.52234 -4.41896,7.2779 -9.93121,27.69907 -1.30508,20.25982 0.44192,16.24753 13.24689,28.89821 26.07394,36.28908 -10.01689,-1.25504 -15.28697,-1.68273 -5.9142,7.18994 3.70419,9.09923 23.65171,23.14135 23.12198,22.88781 -12.68887,4.52612 -29.20638,-24.63453 -27.10977,-1.62665 -9.20938,-6.00136 -15.0215,-10.95439 -3.62102,-1.07286 31.42731,22.76742 71.23535,34.48211 110.0246,30.09948 5.31264,-0.40711 10.63645,-0.91452 15.85979,-2.00108 z m -79.394,-56.9057 c -18.73446,-5.59419 -23.41478,-28.49195 -31.70439,-43.75488 0.73828,-22.35343 4.08716,18.31153 19.32861,13.3197 10.72041,3.69956 18.56946,-8.44963 4.11462,-10.47485 -18.38015,-9.06725 -5.72431,-34.51184 13.30082,-25.76665 19.67,-4.41443 29.38373,22.02008 8.34506,27.51407 -25.0255,1.82433 5.10704,22.06779 16.86359,15.14318 12.34376,1.24347 30.75969,-17.67713 36.73091,-14.00618 -13.61842,14.55795 -29.70193,27.50096 -47.61646,36.34545 -6.2007,1.87716 -12.93269,2.79172 -19.36276,1.68016 z m 18.05419,-9.22941 c 21.08959,-9.895 -13.07749,-8.33914 -20.416,-11.59804 -26.4844,-5.24126 10.83882,26.8471 20.416,11.59804 z m 36.94581,-67.39043 c -25.50005,-11.63653 30.4889,-32.64656 20.12991,-2.60629 -4.12977,6.69198 -14.22499,6.53985 -20.12991,2.60629 z m 6.91801,-10.3468 c -0.82071,-13.3392 -12.1627,7.55602 0,0 z m -83.17504,3.76276 c -13.79522,-8.61428 4.31712,-27.04557 15.39702,-18.85616 13.6067,12.03589 -1.44836,24.55833 -15.39702,18.85616 z m 7.75703,-12.30697 c -5.2255,-11.64565 -10.19028,9.41998 0,0 z m -42.5,116.01345 c -6.02723,-7.2088 -1.92276,0.67135 0,0 z m 249.36364,-91.2588 c 13.806,-15.02329 -17.50241,-28.77029 -15.20919,-6.0755 0.688,7.20314 9.8789,12.01227 15.20919,6.0755 z"
|
||||
id="path262"
|
||||
sodipodi:nodetypes="ssscsssssssssscscsssssssscssssssssssscssssssssssscsssssssssssssssscssssssssssssssssssssssssssss" />
|
||||
<path
|
||||
style="fill:#98b322"
|
||||
d="m 509.53513,538.91636 c -11.96373,-4.91645 8.89339,-3.88826 12.76305,-6.86225 9.28643,-1.97818 -6.4996,-8.86225 -5.56764,-12.40041 5.30229,-0.44489 21.32889,0.97664 9.25743,-4.06036 -4.4293,-2.38922 -8.90334,-4.6942 -13.35565,-7.04008 14.22958,-1.11906 29.14185,-5.34748 39.25328,-15.90169 2.68838,-4.49776 -4.08229,-15.62608 5.03556,-9.22194 7.93306,-6.96815 2.94935,-21.58829 -1.33828,-30.24933 4.40924,-0.25594 16.57977,4.55985 7.33655,-4.04687 -11.00538,-12.31768 -23.14999,-27.52514 -40.87556,-28.89523 -12.38683,-0.11681 -24.80253,7.9637 -36.90946,1.50561 -13.66459,6.45135 -15.89413,-15.41822 -16.10693,-25.52605 0.11257,-17.90444 10.83888,-33.45475 20.92523,-47.40792 -3.05408,-0.24055 -14.13675,6.43308 -7.58956,-2.00266 5.14711,-6.58606 16.1968,-5.55188 24.24745,-6.48256 -0.64652,2.77294 -5.38496,13.38337 1.49882,5.24279 15.35654,-16.366 27.78739,-36.47005 47.56874,-47.96687 13.25414,-5.46069 15.39695,14.72588 18.71219,23.21422 4.97338,21.83679 8.88088,44.88811 4.653,67.17671 -0.42681,8.2555 -8.28775,16.55282 -13.7633,17.08103 3.79273,4.42442 20.53747,19.65551 5.40245,12.0655 -5.32651,-2.18699 -9.60486,-3.59981 -3.31377,1.55124 10.07734,9.32175 19.68413,21.27699 18.4153,35.87995 -0.32668,14.70676 -12.03558,25.33807 -18.87369,37.35808 5.58909,-1.69527 15.58549,-15.93947 11.4519,-2.55177 -3.60074,10.062 11.10418,20.4953 5.86292,28.05887 -22.26582,9.35137 -44.64925,20.52878 -69.03559,22.50306 -1.92036,-0.05 -3.84901,-0.34274 -5.65444,-1.02107 z m 65.78575,-29.48994 c 5.78966,-7.75443 -13.2439,10.9428 -2.23057,2.0827 l 1.25202,-1.10346 z m -68.81054,-89.5018 c 10.3928,-9.60021 -7.59416,-23.65065 -17.40017,-16.92149 -6.0022,5.20108 -14.16395,16.91183 -1.19983,17.82149 5.04579,3.34277 14.31037,4.11548 18.6,-0.9 z m 11.8433,-13.82251 c 4.8073,-13.20848 -17.62579,-19.46625 -25.78482,-10.4034 -8.24468,7.90366 12.43507,0.51199 15.14174,8.29731 2.90454,2.60721 7.25729,6.87958 10.64308,2.10609 z m 40.39101,-19.31318 c 5.78684,-9.84304 14.87824,-18.85981 14.28152,-31.17347 0.29281,-17.2393 -3.29381,-34.47275 -8.87177,-50.70971 -8.2269,-11.71842 -18.48254,9.20895 -24.65918,14.58319 -8.27896,11.14993 -15.97671,24.13537 -16.43162,38.33565 5.81105,9.59348 20.2801,2.52537 22.63335,-7.59849 1.91751,-11.39629 10.56353,-19.72811 14.71934,-30.52016 1.40753,-4.75338 2.7467,-8.65513 3.19367,-1.43954 3.03818,19.50172 2.73205,40.2994 -6.23148,58.32147 -1.42557,1.68784 -2.84962,18.49044 1.36617,10.20106 z m -132.57252,30.28569 c 8.9312,-6.02734 7.48296,-23.09684 -5.07505,-23.64993 -7.30021,-0.58972 -13.70802,6.3178 -14.80605,12.7258 1.80508,5.41863 11.08041,12.34728 0.43734,7.07322 -8.78538,-4.63851 -18.9703,-5.08549 -28.34587,-2.82766 -0.78195,-1.20615 5.95898,-6.38547 7.64726,-9.1958 3.17899,-4.75979 14.14408,-17.04143 10.66391,-19.05896 -8.21587,0.49898 -7.15269,-16.45349 -7.61833,-23.35234 0.38694,-1.92842 0.568,-15.11456 1.50148,-11.0615 2.18799,9.93834 4.54838,20.74835 11.16901,28.59085 7.73714,-10.57308 -5.25092,-24.23902 -0.95866,-36.88296 1.19051,-8.36811 0.86918,-24.11671 5.29194,-27.6918 3.79977,11.14223 8.72133,21.86587 12.7256,32.92008 1.469,13.02823 21.40974,10.49286 17.83409,-2.39696 -3.32571,-15.92393 -12.20464,-30.4869 -22.81624,-42.64305 -1.61447,-5.5579 -16.04555,-2.78383 -6.17414,-7.11693 11.4822,2.4981 18.13579,14.1012 25.27589,22.56913 6.89239,9.91602 14.82304,19.48443 19.27939,30.80078 2.47751,-2.96246 1.89049,-12.09704 8.49383,-6.61144 6.65112,0.58151 16.26357,5.55912 6.89945,11.05947 0.73719,-14.80175 -8.75677,15.1836 -10.62746,8.56225 -0.72867,-12.69039 -5.40734,8.91481 -6.08907,12.65018 -2.18787,18.03406 -8.95803,36.69358 -24.11683,47.78757 l -0.516,-0.66094 z m -14.20337,-23.32605 c 5.77671,-2.92338 22.69464,0.31989 10.56863,-7.78429 -7.14341,-6.64682 -23.87398,-0.74632 -20.72199,9.89207 3.22405,1.98101 7.17289,-0.8495 10.15336,-2.10778 z m 3.70324,21.86879 c 8.31993,-0.40006 2.55621,1.04523 0,0 z"
|
||||
id="path264"
|
||||
sodipodi:nodetypes="ssssscssscsssssssssssssscsssssssssssssssssscsssssssssssssssssssssssssssscssssssss" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 10 KiB |
@@ -0,0 +1,108 @@
|
||||
.shell {
|
||||
display: flex;
|
||||
height: 100vh;
|
||||
background: var(--color-bg);
|
||||
color: var(--color-text);
|
||||
font-family: var(--font-family);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.brand {
|
||||
height: 28px;
|
||||
width: auto;
|
||||
display: block;
|
||||
background: #E6EDEA;
|
||||
border-radius: 6px;
|
||||
padding: 3px 6px;
|
||||
}
|
||||
|
||||
.nav {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
padding: var(--space-2) 0;
|
||||
}
|
||||
|
||||
.sideContent {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
.sideFooter {
|
||||
margin-top: auto;
|
||||
padding: var(--space-3) var(--space-2) var(--space-2);
|
||||
border-top: var(--border-width) solid var(--color-border);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
|
||||
.version {
|
||||
color: var(--color-text-muted);
|
||||
font-size: var(--font-size-xs);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.navItem {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
width: 100%;
|
||||
padding: var(--space-2) var(--space-3);
|
||||
background: none;
|
||||
border: none;
|
||||
border-radius: var(--radius-md);
|
||||
color: var(--color-text);
|
||||
font-size: var(--font-size-sm);
|
||||
font-family: var(--font-family);
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
transition: background 120ms ease, color 120ms ease;
|
||||
}
|
||||
|
||||
.navIcon {
|
||||
flex-shrink: 0;
|
||||
opacity: 0.65;
|
||||
transition: opacity 120ms ease;
|
||||
}
|
||||
|
||||
.navItem:hover .navIcon,
|
||||
.navItemActive .navIcon {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.navItem:hover {
|
||||
background: var(--color-bg-subtle);
|
||||
}
|
||||
|
||||
.navItemActive {
|
||||
background: var(--color-secondary);
|
||||
color: var(--color-secondary-fg);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.navItemActive:hover {
|
||||
background: var(--color-secondary-hover);
|
||||
}
|
||||
|
||||
.navSeparator {
|
||||
height: var(--border-width);
|
||||
background: var(--color-border);
|
||||
margin: var(--space-2) var(--space-2);
|
||||
}
|
||||
|
||||
.main {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: var(--space-6);
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
import { lazy, Suspense } from 'react';
|
||||
import { NavLink, Navigate, Route, Routes } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Globe, Monitor, ClipboardList, Activity, KeyRound, Braces } from 'lucide-react';
|
||||
import type { LucideIcon } from 'lucide-react';
|
||||
import styles from './App.module.css';
|
||||
import { SidePanel, ThemeSwitcher } from './ui';
|
||||
import liqaLogo from './assets/liqa.svg';
|
||||
|
||||
const EnvironmentsPage = lazy(() =>
|
||||
import('./pages/environment/EnvironmentsPage').then((m) => ({ default: m.EnvironmentsPage })),
|
||||
);
|
||||
const EnvironmentDetailPage = lazy(() =>
|
||||
import('./pages/environment/EnvironmentDetailPage').then((m) => ({
|
||||
default: m.EnvironmentDetailPage,
|
||||
})),
|
||||
);
|
||||
const CreateEnvironmentPage = lazy(() =>
|
||||
import('./pages/environment/CreateEnvironmentPage').then((m) => ({
|
||||
default: m.CreateEnvironmentPage,
|
||||
})),
|
||||
);
|
||||
const EditEnvironmentPage = lazy(() =>
|
||||
import('./pages/environment/EditEnvironmentPage').then((m) => ({
|
||||
default: m.EditEnvironmentPage,
|
||||
})),
|
||||
);
|
||||
|
||||
const SessionsPage = lazy(() =>
|
||||
import('./pages/session/SessionsPage').then((m) => ({ default: m.SessionsPage })),
|
||||
);
|
||||
const SessionDetailPage = lazy(() =>
|
||||
import('./pages/session/SessionDetailPage').then((m) => ({ default: m.SessionDetailPage })),
|
||||
);
|
||||
|
||||
const ScenariosPage = lazy(() =>
|
||||
import('./pages/scenario/ScenariosPage').then((m) => ({ default: m.ScenariosPage })),
|
||||
);
|
||||
const ScenarioDetailPage = lazy(() =>
|
||||
import('./pages/scenario/ScenarioDetailPage').then((m) => ({ default: m.ScenarioDetailPage })),
|
||||
);
|
||||
const CreateScenarioPage = lazy(() =>
|
||||
import('./pages/scenario/CreateScenarioPage').then((m) => ({ default: m.CreateScenarioPage })),
|
||||
);
|
||||
const EditScenarioPage = lazy(() =>
|
||||
import('./pages/scenario/EditScenarioPage').then((m) => ({ default: m.EditScenarioPage })),
|
||||
);
|
||||
const CreateStepPage = lazy(() =>
|
||||
import('./pages/scenario/CreateStepPage').then((m) => ({ default: m.CreateStepPage })),
|
||||
);
|
||||
const EditStepPage = lazy(() =>
|
||||
import('./pages/scenario/EditStepPage').then((m) => ({ default: m.EditStepPage })),
|
||||
);
|
||||
|
||||
const RunsPage = lazy(() => import('./pages/run/RunsPage').then((m) => ({ default: m.RunsPage })));
|
||||
const RunDetailPage = lazy(() =>
|
||||
import('./pages/run/RunDetailPage').then((m) => ({ default: m.RunDetailPage })),
|
||||
);
|
||||
const AllRunsPage = lazy(() =>
|
||||
import('./pages/run/AllRunsPage').then((m) => ({ default: m.AllRunsPage })),
|
||||
);
|
||||
|
||||
const CredentialsPage = lazy(() =>
|
||||
import('./pages/credential/CredentialsPage').then((m) => ({ default: m.CredentialsPage })),
|
||||
);
|
||||
const CreateCredentialPage = lazy(() =>
|
||||
import('./pages/credential/CreateCredentialPage').then((m) => ({
|
||||
default: m.CreateCredentialPage,
|
||||
})),
|
||||
);
|
||||
const EditCredentialPage = lazy(() =>
|
||||
import('./pages/credential/EditCredentialPage').then((m) => ({ default: m.EditCredentialPage })),
|
||||
);
|
||||
const CredentialDetailPage = lazy(() =>
|
||||
import('./pages/credential/CredentialDetailPage').then((m) => ({
|
||||
default: m.CredentialDetailPage,
|
||||
})),
|
||||
);
|
||||
|
||||
const SnippetsPage = lazy(() =>
|
||||
import('./pages/snippet/SnippetsPage').then((m) => ({ default: m.SnippetsPage })),
|
||||
);
|
||||
const CreateSnippetPage = lazy(() =>
|
||||
import('./pages/snippet/CreateSnippetPage').then((m) => ({ default: m.CreateSnippetPage })),
|
||||
);
|
||||
const EditSnippetPage = lazy(() =>
|
||||
import('./pages/snippet/EditSnippetPage').then((m) => ({ default: m.EditSnippetPage })),
|
||||
);
|
||||
const SnippetDetailPage = lazy(() =>
|
||||
import('./pages/snippet/SnippetDetailPage').then((m) => ({ default: m.SnippetDetailPage })),
|
||||
);
|
||||
|
||||
const NAV: ({ path: string; labelKey: string; Icon: LucideIcon } | { separator: true })[] = [
|
||||
{ path: '/runs', labelKey: 'nav.runs', Icon: Activity },
|
||||
{ path: '/sessions', labelKey: 'nav.sessions', Icon: Monitor },
|
||||
{ separator: true },
|
||||
{ path: '/scenarios', labelKey: 'nav.scenarios', Icon: ClipboardList },
|
||||
{ path: '/snippets', labelKey: 'nav.snippets', Icon: Braces },
|
||||
{ path: '/credentials', labelKey: 'nav.credentials', Icon: KeyRound },
|
||||
{ path: '/environments', labelKey: 'nav.environments', Icon: Globe },
|
||||
];
|
||||
|
||||
export default function App() {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<div className={styles.shell}>
|
||||
<SidePanel
|
||||
header={
|
||||
<div className={styles.header}>
|
||||
<img src={liqaLogo} alt="Liqa" className={styles.brand} />
|
||||
</div>
|
||||
}
|
||||
width={220}
|
||||
>
|
||||
<div className={styles.sideContent}>
|
||||
<nav className={styles.nav}>
|
||||
{NAV.map((item, index) =>
|
||||
'separator' in item ? (
|
||||
<div key={`separator-${index}`} className={styles.navSeparator} />
|
||||
) : (
|
||||
<NavLink
|
||||
key={item.path}
|
||||
to={item.path}
|
||||
className={({ isActive }) =>
|
||||
[styles.navItem, isActive ? styles.navItemActive : ''].filter(Boolean).join(' ')
|
||||
}
|
||||
>
|
||||
<item.Icon size={16} className={styles.navIcon} aria-hidden="true" />
|
||||
{t(item.labelKey)}
|
||||
</NavLink>
|
||||
),
|
||||
)}
|
||||
</nav>
|
||||
|
||||
<div className={styles.sideFooter}>
|
||||
<ThemeSwitcher />
|
||||
<div className={styles.version}>v{__APP_VERSION__}</div>
|
||||
</div>
|
||||
</div>
|
||||
</SidePanel>
|
||||
|
||||
<main className={styles.main}>
|
||||
<Suspense fallback={<p>Loading…</p>}>
|
||||
<Routes>
|
||||
<Route index element={<Navigate to="/scenarios" replace />} />
|
||||
<Route path="/environments" element={<EnvironmentsPage />} />
|
||||
<Route path="/environments/new" element={<CreateEnvironmentPage />} />
|
||||
<Route path="/environments/:id/edit" element={<EditEnvironmentPage />} />
|
||||
<Route path="/environments/:id" element={<EnvironmentDetailPage />} />
|
||||
<Route path="/sessions" element={<SessionsPage />} />
|
||||
<Route path="/sessions/:id" element={<SessionDetailPage />} />
|
||||
<Route path="/scenarios" element={<ScenariosPage />} />
|
||||
<Route path="/scenarios/new" element={<CreateScenarioPage />} />
|
||||
<Route path="/scenarios/:id/edit" element={<EditScenarioPage />} />
|
||||
<Route path="/scenarios/:id/steps/new" element={<CreateStepPage />} />
|
||||
<Route path="/scenarios/:id/steps/:stepId/edit" element={<EditStepPage />} />
|
||||
<Route path="/scenarios/:id/runs" element={<RunsPage />} />
|
||||
<Route path="/scenarios/:id/runs/:runId" element={<RunDetailPage />} />
|
||||
<Route path="/scenarios/:id" element={<ScenarioDetailPage />} />
|
||||
<Route path="/credentials" element={<CredentialsPage />} />
|
||||
<Route path="/credentials/new" element={<CreateCredentialPage />} />
|
||||
<Route path="/credentials/:id/edit" element={<EditCredentialPage />} />
|
||||
<Route path="/credentials/:id" element={<CredentialDetailPage />} />
|
||||
<Route path="/snippets" element={<SnippetsPage />} />
|
||||
<Route path="/snippets/new" element={<CreateSnippetPage />} />
|
||||
<Route path="/snippets/:id/edit" element={<EditSnippetPage />} />
|
||||
<Route path="/snippets/:id" element={<SnippetDetailPage />} />
|
||||
<Route path="/runs" element={<AllRunsPage />} />
|
||||
<Route path="*" element={<Navigate to="/scenarios" replace />} />
|
||||
</Routes>
|
||||
</Suspense>
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,382 @@
|
||||
import type {
|
||||
PaginatedResponse,
|
||||
Credential,
|
||||
Environment,
|
||||
FileMetadata,
|
||||
FileListResponse,
|
||||
ScenarioCredential,
|
||||
Session,
|
||||
Scenario,
|
||||
ScenarioRun,
|
||||
ScenarioRunDetail,
|
||||
ScenarioRunStep,
|
||||
ScenarioStep,
|
||||
Snippet,
|
||||
} from './types';
|
||||
import { emitApiErrorToast } from '../lib/toast-events';
|
||||
|
||||
// API calls are versioned under /api/v1 by default.
|
||||
// Set VITE_API_URL (for example, http://localhost:13000/api/v1) to use a different origin.
|
||||
const BASE_URL = ((import.meta.env.VITE_API_URL as string | undefined) ?? '/api/v1').replace(
|
||||
/\/$/,
|
||||
'',
|
||||
);
|
||||
|
||||
async function request<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
let res: Response;
|
||||
try {
|
||||
const headers = new Headers(init?.headers);
|
||||
if (!(init?.body instanceof FormData) && !headers.has('Content-Type')) {
|
||||
headers.set('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
res = await fetch(`${BASE_URL}${path}`, {
|
||||
...init,
|
||||
headers,
|
||||
});
|
||||
} catch (err) {
|
||||
const message = (err as Error).message || 'Network request failed';
|
||||
emitApiErrorToast(message);
|
||||
throw new Error(message);
|
||||
}
|
||||
if (!res.ok) {
|
||||
const text = await res.text().catch(() => res.statusText);
|
||||
const message = `${res.status} ${text}`;
|
||||
emitApiErrorToast(message);
|
||||
throw new Error(message);
|
||||
}
|
||||
const contentLength = res.headers.get('content-length');
|
||||
if (res.status === 204 || contentLength === '0') return undefined as T;
|
||||
const contentType = res.headers.get('content-type')?.toLowerCase() ?? '';
|
||||
const text = await res.text();
|
||||
if (!text) return undefined as T;
|
||||
if (contentType.includes('application/json')) {
|
||||
return JSON.parse(text) as T;
|
||||
}
|
||||
return text as T;
|
||||
}
|
||||
|
||||
// ── Credentials ───────────────────────────────────────────────────────────────
|
||||
|
||||
export const credentials = {
|
||||
list(page = 1, limit = 50): Promise<PaginatedResponse<Credential>> {
|
||||
return request(`/credentials?page=${page}&limit=${limit}`);
|
||||
},
|
||||
get(id: string): Promise<Credential> {
|
||||
return request(`/credentials/${id}`);
|
||||
},
|
||||
create(name: string, data?: string): Promise<Credential> {
|
||||
return request('/credentials', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ name, data }),
|
||||
});
|
||||
},
|
||||
update(id: string, patch: Partial<Pick<Credential, 'name' | 'data'>>): Promise<Credential> {
|
||||
return request(`/credentials/${id}`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(patch),
|
||||
});
|
||||
},
|
||||
remove(id: string): Promise<void> {
|
||||
return request(`/credentials/${id}`, { method: 'DELETE' });
|
||||
},
|
||||
exportCredential(id: string): Promise<unknown> {
|
||||
return request(`/credentials/${id}/export`);
|
||||
},
|
||||
importCredential(payload: unknown): Promise<Credential> {
|
||||
return request('/credentials/import', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
// ── Snippets ──────────────────────────────────────────────────────────────────
|
||||
|
||||
export const snippets = {
|
||||
list(page = 1, limit = 50): Promise<PaginatedResponse<Snippet>> {
|
||||
return request(`/snippets?page=${page}&limit=${limit}`);
|
||||
},
|
||||
get(id: string): Promise<Snippet> {
|
||||
return request(`/snippets/${id}`);
|
||||
},
|
||||
create(
|
||||
payload: Pick<Snippet, 'alias' | 'title' | 'code'> & { description?: string },
|
||||
): Promise<Snippet> {
|
||||
return request('/snippets', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
},
|
||||
update(
|
||||
id: string,
|
||||
patch: Partial<Pick<Snippet, 'alias' | 'title' | 'description' | 'code'>>,
|
||||
): Promise<Snippet> {
|
||||
return request(`/snippets/${id}`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(patch),
|
||||
});
|
||||
},
|
||||
remove(id: string): Promise<void> {
|
||||
return request(`/snippets/${id}`, { method: 'DELETE' });
|
||||
},
|
||||
exportSnippet(id: string): Promise<unknown> {
|
||||
return request(`/snippets/${id}/export`);
|
||||
},
|
||||
importSnippet(payload: unknown): Promise<Snippet> {
|
||||
return request('/snippets/import', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
// ── Environments ──────────────────────────────────────────────────────────────
|
||||
|
||||
export const environments = {
|
||||
list(page = 1, limit = 50): Promise<PaginatedResponse<Environment>> {
|
||||
return request(`/environments?page=${page}&limit=${limit}`);
|
||||
},
|
||||
get(id: string): Promise<Environment> {
|
||||
return request(`/environments/${id}`);
|
||||
},
|
||||
create(name: string, data: Environment['data'], description?: string): Promise<Environment> {
|
||||
return request('/environments', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ name, description, data }),
|
||||
});
|
||||
},
|
||||
update(
|
||||
id: string,
|
||||
patch: Partial<Pick<Environment, 'name' | 'description' | 'data'>>,
|
||||
): Promise<Environment> {
|
||||
return request(`/environments/${id}`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(patch),
|
||||
});
|
||||
},
|
||||
remove(id: string): Promise<void> {
|
||||
return request(`/environments/${id}`, { method: 'DELETE' });
|
||||
},
|
||||
exportEnvironment(id: string): Promise<unknown> {
|
||||
return request(`/environments/${id}/export`);
|
||||
},
|
||||
importEnvironment(payload: unknown): Promise<Environment> {
|
||||
return request('/environments/import', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
// ── Sessions ──────────────────────────────────────────────────────────────────
|
||||
|
||||
export const sessions = {
|
||||
list(
|
||||
page = 1,
|
||||
limit = 50,
|
||||
orderBy = 'id',
|
||||
orderDir: 'ASC' | 'DESC' = 'DESC',
|
||||
): Promise<PaginatedResponse<Session>> {
|
||||
return request(`/sessions?page=${page}&limit=${limit}&orderBy=${orderBy}&orderDir=${orderDir}`);
|
||||
},
|
||||
get(id: string): Promise<Session> {
|
||||
return request(`/sessions/${id}`);
|
||||
},
|
||||
remove(id: string): Promise<void> {
|
||||
return request(`/sessions/${id}`, { method: 'DELETE' });
|
||||
},
|
||||
};
|
||||
|
||||
// ── Scenarios ─────────────────────────────────────────────────────────────────
|
||||
|
||||
export const scenarios = {
|
||||
list(
|
||||
page = 1,
|
||||
limit = 50,
|
||||
orderBy = 'updatedAt',
|
||||
orderDir: 'ASC' | 'DESC' = 'DESC',
|
||||
): Promise<PaginatedResponse<Scenario>> {
|
||||
return request(
|
||||
`/scenarios?page=${page}&limit=${limit}&orderBy=${orderBy}&orderDir=${orderDir}`,
|
||||
);
|
||||
},
|
||||
get(id: string): Promise<Scenario & { steps: ScenarioStep[] }> {
|
||||
return request(`/scenarios/${id}`);
|
||||
},
|
||||
create(name: string, description?: string, environmentId?: string): Promise<Scenario> {
|
||||
return request('/scenarios', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ name, description, environmentId }),
|
||||
});
|
||||
},
|
||||
update(
|
||||
id: string,
|
||||
patch: Partial<Pick<Scenario, 'name' | 'description' | 'environmentId' | 'timeoutSeconds'>>,
|
||||
): Promise<Scenario> {
|
||||
return request(`/scenarios/${id}`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(patch),
|
||||
});
|
||||
},
|
||||
remove(id: string): Promise<void> {
|
||||
return request(`/scenarios/${id}`, { method: 'DELETE' });
|
||||
},
|
||||
run(id: string, environmentId: string, saveSession?: boolean): Promise<ScenarioRun> {
|
||||
return request(`/scenarios/${id}/run`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ environmentId, saveSession }),
|
||||
});
|
||||
},
|
||||
getRun(scenarioId: string, runId: string): Promise<ScenarioRunDetail> {
|
||||
return request(`/scenarios/${scenarioId}/run/${runId}`);
|
||||
},
|
||||
waitForRun(scenarioId: string, runId: string): Promise<ScenarioRunDetail> {
|
||||
return request(`/scenarios/${scenarioId}/run/${runId}/wait`, { method: 'POST' });
|
||||
},
|
||||
listRuns(
|
||||
scenarioId: string,
|
||||
page = 1,
|
||||
limit = 20,
|
||||
): Promise<PaginatedResponse<ScenarioRun & { stepRuns: ScenarioRunStep[] }>> {
|
||||
return request(`/scenarios/${scenarioId}/runs?page=${page}&limit=${limit}`);
|
||||
},
|
||||
exportScenario(
|
||||
id: string,
|
||||
options: { includeEnvironment: boolean; credentialIds: string[] } = {
|
||||
includeEnvironment: false,
|
||||
credentialIds: [],
|
||||
},
|
||||
): Promise<string> {
|
||||
const params = new URLSearchParams();
|
||||
params.set('includeEnvironment', String(options.includeEnvironment));
|
||||
for (const cid of options.credentialIds) {
|
||||
params.append('credentialIds', cid);
|
||||
}
|
||||
return request(`/scenarios/${id}/export?${params.toString()}`);
|
||||
},
|
||||
importScenario(payload: unknown): Promise<Scenario> {
|
||||
return request('/scenarios/import', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
// ── Runs ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
export const runs = {
|
||||
listAll(
|
||||
page = 1,
|
||||
limit = 20,
|
||||
status?: string,
|
||||
orderBy = 'createdAt',
|
||||
orderDir: 'ASC' | 'DESC' = 'DESC',
|
||||
): Promise<PaginatedResponse<ScenarioRun & { scenario: { id: string; name: string } }>> {
|
||||
const q = new URLSearchParams({ page: String(page), limit: String(limit), orderBy, orderDir });
|
||||
if (status) q.set('status', status);
|
||||
return request(`/scenarios/runs?${q}`);
|
||||
},
|
||||
list(
|
||||
scenarioId: string,
|
||||
page = 1,
|
||||
limit = 20,
|
||||
orderBy = 'createdAt',
|
||||
orderDir: 'ASC' | 'DESC' = 'DESC',
|
||||
): Promise<PaginatedResponse<ScenarioRun & { stepRuns: ScenarioRunStep[] }>> {
|
||||
return request(
|
||||
`/scenarios/${scenarioId}/runs?page=${page}&limit=${limit}&orderBy=${orderBy}&orderDir=${orderDir}`,
|
||||
);
|
||||
},
|
||||
get(scenarioId: string, runId: string, q?: string): Promise<ScenarioRunDetail> {
|
||||
const qs = q?.trim() ? `?q=${encodeURIComponent(q.trim())}` : '';
|
||||
return request(`/scenarios/${scenarioId}/run/${runId}${qs}`);
|
||||
},
|
||||
};
|
||||
|
||||
// ── Scenario Credentials ──────────────────────────────────────────────────────
|
||||
|
||||
export const scenarioCredentials = {
|
||||
list(scenarioId: string): Promise<ScenarioCredential[]> {
|
||||
return request(`/scenarios/${scenarioId}/credentials`);
|
||||
},
|
||||
add(scenarioId: string, credentialId: string, alias: string): Promise<ScenarioCredential> {
|
||||
return request(`/scenarios/${scenarioId}/credentials`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ credentialId, alias }),
|
||||
});
|
||||
},
|
||||
remove(scenarioId: string, scCredId: string): Promise<void> {
|
||||
return request(`/scenarios/${scenarioId}/credentials/${scCredId}`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
// ── Scenario Steps ────────────────────────────────────────────────────────────
|
||||
export interface CreateStepPayload {
|
||||
title?: string;
|
||||
execCode?: string;
|
||||
timeoutSeconds?: number | null;
|
||||
}
|
||||
|
||||
export interface UpdateStepPayload {
|
||||
title?: string;
|
||||
order?: number;
|
||||
execCode?: string;
|
||||
timeoutSeconds?: number | null;
|
||||
}
|
||||
|
||||
export const steps = {
|
||||
get(scenarioId: string, stepId: string): Promise<ScenarioStep> {
|
||||
return request(`/scenarios/${scenarioId}/steps/${stepId}`);
|
||||
},
|
||||
create(scenarioId: string, payload: CreateStepPayload): Promise<ScenarioStep> {
|
||||
return request(`/scenarios/${scenarioId}/steps`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
},
|
||||
update(scenarioId: string, stepId: string, payload: UpdateStepPayload): Promise<ScenarioStep> {
|
||||
return request(`/scenarios/${scenarioId}/steps/${stepId}`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
},
|
||||
remove(scenarioId: string, stepId: string): Promise<void> {
|
||||
return request(`/scenarios/${scenarioId}/steps/${stepId}`, { method: 'DELETE' });
|
||||
},
|
||||
};
|
||||
|
||||
// ── Scenario Files ────────────────────────────────────────────────────────
|
||||
|
||||
export const scenarioFiles = {
|
||||
upload(scenarioId: string, file: File, expiresAt?: Date): Promise<FileMetadata> {
|
||||
const form = new FormData();
|
||||
form.append('file', file);
|
||||
if (expiresAt) form.append('expiresAt', expiresAt.toISOString());
|
||||
return request(`/scenarios/${scenarioId}/files`, {
|
||||
method: 'POST',
|
||||
body: form,
|
||||
});
|
||||
},
|
||||
list(scenarioId: string, limit = 20, offset = 0): Promise<FileListResponse> {
|
||||
return request(`/scenarios/${scenarioId}/files?limit=${limit}&offset=${offset}`);
|
||||
},
|
||||
/** Returns a URL that can be used as an <a href> for direct download. */
|
||||
contentUrl(scenarioId: string, fileId: string): string {
|
||||
return `${BASE_URL}/scenarios/${scenarioId}/files/${fileId}/content`;
|
||||
},
|
||||
};
|
||||
|
||||
// ── Run Files ─────────────────────────────────────────────────────────────
|
||||
|
||||
export const runFiles = {
|
||||
list(scenarioId: string, runId: string, limit = 20, offset = 0): Promise<FileListResponse> {
|
||||
return request(`/scenarios/${scenarioId}/runs/${runId}/files?limit=${limit}&offset=${offset}`);
|
||||
},
|
||||
/** Returns a URL that can be used as an <a href> for direct download. */
|
||||
contentUrl(scenarioId: string, runId: string, fileId: string): string {
|
||||
return `${BASE_URL}/scenarios/${scenarioId}/runs/${runId}/files/${fileId}/content`;
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './client';
|
||||
export * from './types';
|
||||
@@ -0,0 +1,162 @@
|
||||
// ── Shared ────────────────────────────────────────────────────────────────────
|
||||
|
||||
export interface PaginatedResponse<T> {
|
||||
data: T[];
|
||||
total: number;
|
||||
page: number;
|
||||
limit: number;
|
||||
}
|
||||
|
||||
// ── Environments ──────────────────────────────────────────────────────────────
|
||||
|
||||
export interface EnvironmentData {
|
||||
[key: string]: string | undefined;
|
||||
}
|
||||
|
||||
export interface Environment {
|
||||
id: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
data: EnvironmentData;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
// ── Credentials ───────────────────────────────────────────────────────────────
|
||||
|
||||
export interface Credential {
|
||||
id: string;
|
||||
name: string;
|
||||
data: string | null;
|
||||
lastUsedAt: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
// ── Snippets ──────────────────────────────────────────────────────────────────
|
||||
|
||||
export interface Snippet {
|
||||
id: string;
|
||||
alias: string;
|
||||
title: string;
|
||||
description: string | null;
|
||||
code: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
// ── Sessions ──────────────────────────────────────────────────────────────────
|
||||
|
||||
export type SessionStatus = 'open' | 'closed';
|
||||
|
||||
export interface Session {
|
||||
id: string;
|
||||
sessionName: string;
|
||||
token: string;
|
||||
status: SessionStatus;
|
||||
lastUsedAt: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
// ── Scenarios ─────────────────────────────────────────────────────────────────
|
||||
|
||||
export interface ScenarioStep {
|
||||
id: string;
|
||||
scenarioId: string;
|
||||
order: number;
|
||||
title: string | null;
|
||||
execCode: string | null;
|
||||
timeoutSeconds: number | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface ScenarioCredential {
|
||||
id: string;
|
||||
scenarioId: string;
|
||||
credentialId: string;
|
||||
alias: string;
|
||||
credential: Credential;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface Scenario {
|
||||
id: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
environmentId?: string | null;
|
||||
timeoutSeconds?: number | null;
|
||||
environment?: Pick<Environment, 'id' | 'name'>;
|
||||
steps?: ScenarioStep[];
|
||||
scenarioCredentials?: ScenarioCredential[];
|
||||
lastRunStatus?: ScenarioRunStatus | null;
|
||||
lastRunAt?: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export type ScenarioRunStatus = 'pending' | 'in_progress' | 'pass' | 'fail';
|
||||
|
||||
export type RunStepStatus = 'waiting' | 'pending' | 'in_progress' | 'pass' | 'fail' | 'cancelled';
|
||||
|
||||
export type LogLevel = 'log' | 'warn' | 'error';
|
||||
|
||||
export interface ScenarioRun {
|
||||
id: string;
|
||||
scenarioId: string;
|
||||
environmentId: string;
|
||||
sessionId?: string | null;
|
||||
saveSession: boolean;
|
||||
scenario?: Pick<Scenario, 'id' | 'name'>;
|
||||
environment?: Pick<Environment, 'id' | 'name'>;
|
||||
session?: { id: string; sessionName: string };
|
||||
status: ScenarioRunStatus;
|
||||
stepRuns?: ScenarioRunStep[];
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface ScenarioRunStep {
|
||||
id: string;
|
||||
runId: string;
|
||||
scenarioStepId: string;
|
||||
scenarioStep: ScenarioStep;
|
||||
status: RunStepStatus;
|
||||
order: number;
|
||||
description: string | null;
|
||||
output: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface ScenarioRunLog {
|
||||
id: string;
|
||||
runId: string;
|
||||
stepRunId: string | null;
|
||||
level: LogLevel;
|
||||
message: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface ScenarioRunDetail extends ScenarioRun {
|
||||
stepRuns: ScenarioRunStep[];
|
||||
logs: ScenarioRunLog[];
|
||||
}
|
||||
|
||||
// ── Files ─────────────────────────────────────────────────────────────────
|
||||
|
||||
export interface FileMetadata {
|
||||
id: string;
|
||||
name: string;
|
||||
mimeType: string;
|
||||
size: number;
|
||||
sha256: string;
|
||||
expiresAt: string | null;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface FileListResponse {
|
||||
items: FileMetadata[];
|
||||
total: number;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
version="1.1"
|
||||
id="svg92"
|
||||
width="421.86172"
|
||||
height="421.86172"
|
||||
viewBox="0 0 421.86173 421.86172"
|
||||
sodipodi:docname="liqa-mini.svg"
|
||||
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<defs
|
||||
id="defs96" />
|
||||
<sodipodi:namedview
|
||||
id="namedview94"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="false"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
showgrid="false"
|
||||
showborder="false"
|
||||
borderlayer="false"
|
||||
shape-rendering="auto"
|
||||
inkscape:zoom="0.60813025"
|
||||
inkscape:cx="-51.798114"
|
||||
inkscape:cy="-76.463882"
|
||||
inkscape:window-width="2544"
|
||||
inkscape:window-height="1355"
|
||||
inkscape:window-x="20"
|
||||
inkscape:window-y="20"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="g98" />
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
inkscape:label="Image"
|
||||
id="g98"
|
||||
transform="translate(-270.03557,-210.1151)">
|
||||
<circle
|
||||
style="fill:#e6edea;fill-opacity:1;stroke-width:0.926933"
|
||||
id="path331"
|
||||
cx="480.96643"
|
||||
cy="421.04596"
|
||||
r="210.93086" />
|
||||
<path
|
||||
style="fill:#39196b"
|
||||
d="m 453.91034,593.79867 c -34.08673,-5.09427 -70.45402,-12.61452 -97.32495,-35.64384 -9.91285,-8.49217 -10.39503,-22.11427 -9.93686,-34.15838 -29.11758,-32.44273 -47.40043,-75.91137 -44.17964,-119.94221 -0.1082,-69.39624 50.26509,-133.2096 115.02861,-155.43859 65.94576,-23.97068 145.13988,-7.25178 194.05946,43.53493 33.75034,34.13894 52.73157,82.84814 48.59098,130.92571 -2.05053,36.83319 -19.00255,72.10194 -42.95534,99.74833 0.59009,14.27144 -0.67496,30.5898 -14.31879,38.78996 -29.95318,20.71235 -66.75963,30.54233 -102.80366,32.85732 -15.37106,0.58367 -30.83524,0.86962 -46.15981,-0.67323 z m 60,-25.40946 c 63.80512,-11.608 115.95832,-65.21248 129.69191,-127.96784 13.52875,-65.57348 -19.88327,-136.69388 -77.86044,-169.61945 -62.09585,-37.00081 -148.54942,-29.25016 -200.28124,22.40983 -39.98962,37.54618 -58.68926,96.3072 -45.60991,149.85388 15.1241,64.40785 71.02087,118.19945 137.36624,126.41525 18.58372,2.99672 38.14468,1.6814 56.69344,-1.09167 z m -47.5,-2.22871 c -38.4767,-4.43103 -77.04078,-22.16808 -101.12198,-53.12116 -3.19125,-10.71063 13.54949,-17.36711 -0.27511,-27.21578 -8.26021,-16.11409 -8.83665,-33.71408 -14.27833,-50.67086 -0.2541,-18.10794 20.10105,-26.35624 25.6663,-43.23729 6.35587,-8.46898 -3.9027,-20.33944 -0.39344,-30.42399 2.15786,-25.3474 4.36566,-52.60471 18.52953,-74.47265 14.78936,-16.29232 35.47458,0.7495 45.63689,13.63324 11.08594,12.42904 21.91316,33.6459 41.91941,25.85866 15.44797,-0.25083 30.76053,2.11785 38.30644,-15.26956 12.94844,-12.26049 29.58114,-33.49814 49.51863,-25.31725 15.14143,14.78032 23.40098,35.53589 30.24631,55.23997 4.55565,15.36852 4.6391,31.94493 3.28453,47.62379 9.36324,3.04253 19.5843,3.12362 29.33081,4.80945 4.13961,36.35364 -6.87221,74.41869 -29.06057,103.34533 6.1277,-6.57686 -11.08201,-8.1108 -10.42592,-13.41902 -3.13078,8.77758 6.94663,20.41165 8.2868,16.46805 -0.56187,16.28936 -17.32423,27.53773 -29.07955,37.58785 -29.98728,22.19243 -69.09541,32.24465 -106.09075,28.58122 z m 45.894,-11.81034 c 33.41589,-6.42529 64.06763,-23.96926 87.606,-48.31107 -8.2548,8.75218 -16.68941,10.99135 -19.0901,-3.25812 -6.74621,-5.75317 4.24595,-28.93739 -7.93245,-14.80685 -12.56916,8.84191 6.92924,-12.74278 9.10243,-19.35578 10.01143,-17.42491 0.0574,-37.62462 -13.95795,-49.29114 -14.6216,-12.15862 17.42439,7.41163 7.0361,-3.83503 -3.38412,-4.97478 -17.07811,-12.87071 -3.49938,-12.93686 13.39611,-15.67737 9.03047,-38.51699 7.49334,-57.46672 -2.84393,-16.45555 -4.77538,-34.52556 -15.35747,-48.05543 -16.01154,-1.14314 -26.08547,16.38647 -36.61497,26.39715 -5.70545,5.13719 -20.49899,28.37559 -21.75329,21.0369 3.13269,-11.75191 -28.76493,7.02326 -18.04711,-7.35592 -10.84777,9.86053 -22.17174,2.09875 -33.04263,1.86322 -2.31736,12.36385 -11.29846,-13.13312 -16.5778,-17.49645 -8.72025,-8.90768 -19.97374,-34.20851 -33.96144,-25.78405 -11.69397,23.33334 -16.11056,50.56447 -13.69042,76.47881 -0.0602,5.91781 4.34322,13.08008 8.02259,9.96256 -4.67811,10.89105 -12.41488,20.03503 -20.60515,28.45263 22.15351,-6.46272 -6.75848,11.20914 -11.32612,18.11668 -5.55558,6.00011 11.23537,1.21603 0.92918,8.09759 -9.85267,8.82172 0.90225,10.96263 8.1364,5.52234 -4.41896,7.2779 -9.93121,27.69907 -1.30508,20.25982 0.44192,16.24753 13.24689,28.89821 26.07394,36.28908 -10.01689,-1.25504 -15.28697,-1.68273 -5.9142,7.18994 3.70419,9.09923 23.65171,23.14135 23.12198,22.88781 -12.68887,4.52612 -29.20638,-24.63453 -27.10977,-1.62665 -9.20938,-6.00136 -15.0215,-10.95439 -3.62102,-1.07286 31.42731,22.76742 71.23535,34.48211 110.0246,30.09948 5.31264,-0.40711 10.63645,-0.91452 15.85979,-2.00108 z m -79.394,-56.9057 c -18.73446,-5.59419 -23.41478,-28.49195 -31.70439,-43.75488 0.73828,-22.35343 4.08716,18.31153 19.32861,13.3197 10.72041,3.69956 18.56946,-8.44963 4.11462,-10.47485 -18.38015,-9.06725 -5.72431,-34.51184 13.30082,-25.76665 19.67,-4.41443 29.38373,22.02008 8.34506,27.51407 -25.0255,1.82433 5.10704,22.06779 16.86359,15.14318 12.34376,1.24347 30.75969,-17.67713 36.73091,-14.00618 -13.61842,14.55795 -29.70193,27.50096 -47.61646,36.34545 -6.2007,1.87716 -12.93269,2.79172 -19.36276,1.68016 z m 18.05419,-9.22941 c 21.08959,-9.895 -13.07749,-8.33914 -20.416,-11.59804 -26.4844,-5.24126 10.83882,26.8471 20.416,11.59804 z m 36.94581,-67.39043 c -25.50005,-11.63653 30.4889,-32.64656 20.12991,-2.60629 -4.12977,6.69198 -14.22499,6.53985 -20.12991,2.60629 z m 6.91801,-10.3468 c -0.82071,-13.3392 -12.1627,7.55602 0,0 z m -83.17504,3.76276 c -13.79522,-8.61428 4.31712,-27.04557 15.39702,-18.85616 13.6067,12.03589 -1.44836,24.55833 -15.39702,18.85616 z m 7.75703,-12.30697 c -5.2255,-11.64565 -10.19028,9.41998 0,0 z m -42.5,116.01345 c -6.02723,-7.2088 -1.92276,0.67135 0,0 z m 249.36364,-91.2588 c 13.806,-15.02329 -17.50241,-28.77029 -15.20919,-6.0755 0.688,7.20314 9.8789,12.01227 15.20919,6.0755 z"
|
||||
id="path262"
|
||||
sodipodi:nodetypes="ssscsssssssssscscsssssssscssssssssssscssssssssssscsssssssssssssssscssssssssssssssssssssssssssss" />
|
||||
<path
|
||||
style="fill:#98b322"
|
||||
d="m 509.53513,538.91636 c -11.96373,-4.91645 8.89339,-3.88826 12.76305,-6.86225 9.28643,-1.97818 -6.4996,-8.86225 -5.56764,-12.40041 5.30229,-0.44489 21.32889,0.97664 9.25743,-4.06036 -4.4293,-2.38922 -8.90334,-4.6942 -13.35565,-7.04008 14.22958,-1.11906 29.14185,-5.34748 39.25328,-15.90169 2.68838,-4.49776 -4.08229,-15.62608 5.03556,-9.22194 7.93306,-6.96815 2.94935,-21.58829 -1.33828,-30.24933 4.40924,-0.25594 16.57977,4.55985 7.33655,-4.04687 -11.00538,-12.31768 -23.14999,-27.52514 -40.87556,-28.89523 -12.38683,-0.11681 -24.80253,7.9637 -36.90946,1.50561 -13.66459,6.45135 -15.89413,-15.41822 -16.10693,-25.52605 0.11257,-17.90444 10.83888,-33.45475 20.92523,-47.40792 -3.05408,-0.24055 -14.13675,6.43308 -7.58956,-2.00266 5.14711,-6.58606 16.1968,-5.55188 24.24745,-6.48256 -0.64652,2.77294 -5.38496,13.38337 1.49882,5.24279 15.35654,-16.366 27.78739,-36.47005 47.56874,-47.96687 13.25414,-5.46069 15.39695,14.72588 18.71219,23.21422 4.97338,21.83679 8.88088,44.88811 4.653,67.17671 -0.42681,8.2555 -8.28775,16.55282 -13.7633,17.08103 3.79273,4.42442 20.53747,19.65551 5.40245,12.0655 -5.32651,-2.18699 -9.60486,-3.59981 -3.31377,1.55124 10.07734,9.32175 19.68413,21.27699 18.4153,35.87995 -0.32668,14.70676 -12.03558,25.33807 -18.87369,37.35808 5.58909,-1.69527 15.58549,-15.93947 11.4519,-2.55177 -3.60074,10.062 11.10418,20.4953 5.86292,28.05887 -22.26582,9.35137 -44.64925,20.52878 -69.03559,22.50306 -1.92036,-0.05 -3.84901,-0.34274 -5.65444,-1.02107 z m 65.78575,-29.48994 c 5.78966,-7.75443 -13.2439,10.9428 -2.23057,2.0827 l 1.25202,-1.10346 z m -68.81054,-89.5018 c 10.3928,-9.60021 -7.59416,-23.65065 -17.40017,-16.92149 -6.0022,5.20108 -14.16395,16.91183 -1.19983,17.82149 5.04579,3.34277 14.31037,4.11548 18.6,-0.9 z m 11.8433,-13.82251 c 4.8073,-13.20848 -17.62579,-19.46625 -25.78482,-10.4034 -8.24468,7.90366 12.43507,0.51199 15.14174,8.29731 2.90454,2.60721 7.25729,6.87958 10.64308,2.10609 z m 40.39101,-19.31318 c 5.78684,-9.84304 14.87824,-18.85981 14.28152,-31.17347 0.29281,-17.2393 -3.29381,-34.47275 -8.87177,-50.70971 -8.2269,-11.71842 -18.48254,9.20895 -24.65918,14.58319 -8.27896,11.14993 -15.97671,24.13537 -16.43162,38.33565 5.81105,9.59348 20.2801,2.52537 22.63335,-7.59849 1.91751,-11.39629 10.56353,-19.72811 14.71934,-30.52016 1.40753,-4.75338 2.7467,-8.65513 3.19367,-1.43954 3.03818,19.50172 2.73205,40.2994 -6.23148,58.32147 -1.42557,1.68784 -2.84962,18.49044 1.36617,10.20106 z m -132.57252,30.28569 c 8.9312,-6.02734 7.48296,-23.09684 -5.07505,-23.64993 -7.30021,-0.58972 -13.70802,6.3178 -14.80605,12.7258 1.80508,5.41863 11.08041,12.34728 0.43734,7.07322 -8.78538,-4.63851 -18.9703,-5.08549 -28.34587,-2.82766 -0.78195,-1.20615 5.95898,-6.38547 7.64726,-9.1958 3.17899,-4.75979 14.14408,-17.04143 10.66391,-19.05896 -8.21587,0.49898 -7.15269,-16.45349 -7.61833,-23.35234 0.38694,-1.92842 0.568,-15.11456 1.50148,-11.0615 2.18799,9.93834 4.54838,20.74835 11.16901,28.59085 7.73714,-10.57308 -5.25092,-24.23902 -0.95866,-36.88296 1.19051,-8.36811 0.86918,-24.11671 5.29194,-27.6918 3.79977,11.14223 8.72133,21.86587 12.7256,32.92008 1.469,13.02823 21.40974,10.49286 17.83409,-2.39696 -3.32571,-15.92393 -12.20464,-30.4869 -22.81624,-42.64305 -1.61447,-5.5579 -16.04555,-2.78383 -6.17414,-7.11693 11.4822,2.4981 18.13579,14.1012 25.27589,22.56913 6.89239,9.91602 14.82304,19.48443 19.27939,30.80078 2.47751,-2.96246 1.89049,-12.09704 8.49383,-6.61144 6.65112,0.58151 16.26357,5.55912 6.89945,11.05947 0.73719,-14.80175 -8.75677,15.1836 -10.62746,8.56225 -0.72867,-12.69039 -5.40734,8.91481 -6.08907,12.65018 -2.18787,18.03406 -8.95803,36.69358 -24.11683,47.78757 l -0.516,-0.66094 z m -14.20337,-23.32605 c 5.77671,-2.92338 22.69464,0.31989 10.56863,-7.78429 -7.14341,-6.64682 -23.87398,-0.74632 -20.72199,9.89207 3.22405,1.98101 7.17289,-0.8495 10.15336,-2.10778 z m 3.70324,21.86879 c 8.31993,-0.40006 2.55621,1.04523 0,0 z"
|
||||
id="path264"
|
||||
sodipodi:nodetypes="ssssscssscsssssssssssssscsssssssssssssssssscsssssssssssssssssssssssssssscssssssss" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 10 KiB |
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
version="1.1"
|
||||
id="svg92"
|
||||
width="982.44299"
|
||||
height="421.86172"
|
||||
viewBox="0 0 982.443 421.86172"
|
||||
sodipodi:docname="liqa.svg"
|
||||
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<defs
|
||||
id="defs96" />
|
||||
<sodipodi:namedview
|
||||
id="namedview94"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="false"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
showgrid="false"
|
||||
showborder="false"
|
||||
borderlayer="false"
|
||||
shape-rendering="auto"
|
||||
inkscape:zoom="0.60813025"
|
||||
inkscape:cx="-51.798114"
|
||||
inkscape:cy="-76.463882"
|
||||
inkscape:window-width="2544"
|
||||
inkscape:window-height="1355"
|
||||
inkscape:window-x="20"
|
||||
inkscape:window-y="20"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="g98" />
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
inkscape:label="Image"
|
||||
id="g98"
|
||||
transform="translate(-270.03557,-210.1151)">
|
||||
<circle
|
||||
style="fill:#e6edea;fill-opacity:1;stroke-width:0.926933"
|
||||
id="path331"
|
||||
cx="480.96643"
|
||||
cy="421.04596"
|
||||
r="210.93086" />
|
||||
<path
|
||||
style="fill:#39196b"
|
||||
d="m 453.91034,593.79867 c -34.08673,-5.09427 -70.45402,-12.61452 -97.32495,-35.64384 -9.91285,-8.49217 -10.39503,-22.11427 -9.93686,-34.15838 -29.11758,-32.44273 -47.40043,-75.91137 -44.17964,-119.94221 -0.1082,-69.39624 50.26509,-133.2096 115.02861,-155.43859 65.94576,-23.97068 145.13988,-7.25178 194.05946,43.53493 33.75034,34.13894 52.73157,82.84814 48.59098,130.92571 -2.05053,36.83319 -19.00255,72.10194 -42.95534,99.74833 0.59009,14.27144 -0.67496,30.5898 -14.31879,38.78996 -29.95318,20.71235 -66.75963,30.54233 -102.80366,32.85732 -15.37106,0.58367 -30.83524,0.86962 -46.15981,-0.67323 z m 60,-25.40946 c 63.80512,-11.608 115.95832,-65.21248 129.69191,-127.96784 13.52875,-65.57348 -19.88327,-136.69388 -77.86044,-169.61945 -62.09585,-37.00081 -148.54942,-29.25016 -200.28124,22.40983 -39.98962,37.54618 -58.68926,96.3072 -45.60991,149.85388 15.1241,64.40785 71.02087,118.19945 137.36624,126.41525 18.58372,2.99672 38.14468,1.6814 56.69344,-1.09167 z m -47.5,-2.22871 c -38.4767,-4.43103 -77.04078,-22.16808 -101.12198,-53.12116 -3.19125,-10.71063 13.54949,-17.36711 -0.27511,-27.21578 -8.26021,-16.11409 -8.83665,-33.71408 -14.27833,-50.67086 -0.2541,-18.10794 20.10105,-26.35624 25.6663,-43.23729 6.35587,-8.46898 -3.9027,-20.33944 -0.39344,-30.42399 2.15786,-25.3474 4.36566,-52.60471 18.52953,-74.47265 14.78936,-16.29232 35.47458,0.7495 45.63689,13.63324 11.08594,12.42904 21.91316,33.6459 41.91941,25.85866 15.44797,-0.25083 30.76053,2.11785 38.30644,-15.26956 12.94844,-12.26049 29.58114,-33.49814 49.51863,-25.31725 15.14143,14.78032 23.40098,35.53589 30.24631,55.23997 4.55565,15.36852 4.6391,31.94493 3.28453,47.62379 9.36324,3.04253 19.5843,3.12362 29.33081,4.80945 4.13961,36.35364 -6.87221,74.41869 -29.06057,103.34533 6.1277,-6.57686 -11.08201,-8.1108 -10.42592,-13.41902 -3.13078,8.77758 6.94663,20.41165 8.2868,16.46805 -0.56187,16.28936 -17.32423,27.53773 -29.07955,37.58785 -29.98728,22.19243 -69.09541,32.24465 -106.09075,28.58122 z m 45.894,-11.81034 c 33.41589,-6.42529 64.06763,-23.96926 87.606,-48.31107 -8.2548,8.75218 -16.68941,10.99135 -19.0901,-3.25812 -6.74621,-5.75317 4.24595,-28.93739 -7.93245,-14.80685 -12.56916,8.84191 6.92924,-12.74278 9.10243,-19.35578 10.01143,-17.42491 0.0574,-37.62462 -13.95795,-49.29114 -14.6216,-12.15862 17.42439,7.41163 7.0361,-3.83503 -3.38412,-4.97478 -17.07811,-12.87071 -3.49938,-12.93686 13.39611,-15.67737 9.03047,-38.51699 7.49334,-57.46672 -2.84393,-16.45555 -4.77538,-34.52556 -15.35747,-48.05543 -16.01154,-1.14314 -26.08547,16.38647 -36.61497,26.39715 -5.70545,5.13719 -20.49899,28.37559 -21.75329,21.0369 3.13269,-11.75191 -28.76493,7.02326 -18.04711,-7.35592 -10.84777,9.86053 -22.17174,2.09875 -33.04263,1.86322 -2.31736,12.36385 -11.29846,-13.13312 -16.5778,-17.49645 -8.72025,-8.90768 -19.97374,-34.20851 -33.96144,-25.78405 -11.69397,23.33334 -16.11056,50.56447 -13.69042,76.47881 -0.0602,5.91781 4.34322,13.08008 8.02259,9.96256 -4.67811,10.89105 -12.41488,20.03503 -20.60515,28.45263 22.15351,-6.46272 -6.75848,11.20914 -11.32612,18.11668 -5.55558,6.00011 11.23537,1.21603 0.92918,8.09759 -9.85267,8.82172 0.90225,10.96263 8.1364,5.52234 -4.41896,7.2779 -9.93121,27.69907 -1.30508,20.25982 0.44192,16.24753 13.24689,28.89821 26.07394,36.28908 -10.01689,-1.25504 -15.28697,-1.68273 -5.9142,7.18994 3.70419,9.09923 23.65171,23.14135 23.12198,22.88781 -12.68887,4.52612 -29.20638,-24.63453 -27.10977,-1.62665 -9.20938,-6.00136 -15.0215,-10.95439 -3.62102,-1.07286 31.42731,22.76742 71.23535,34.48211 110.0246,30.09948 5.31264,-0.40711 10.63645,-0.91452 15.85979,-2.00108 z m -79.394,-56.9057 c -18.73446,-5.59419 -23.41478,-28.49195 -31.70439,-43.75488 0.73828,-22.35343 4.08716,18.31153 19.32861,13.3197 10.72041,3.69956 18.56946,-8.44963 4.11462,-10.47485 -18.38015,-9.06725 -5.72431,-34.51184 13.30082,-25.76665 19.67,-4.41443 29.38373,22.02008 8.34506,27.51407 -25.0255,1.82433 5.10704,22.06779 16.86359,15.14318 12.34376,1.24347 30.75969,-17.67713 36.73091,-14.00618 -13.61842,14.55795 -29.70193,27.50096 -47.61646,36.34545 -6.2007,1.87716 -12.93269,2.79172 -19.36276,1.68016 z m 18.05419,-9.22941 c 21.08959,-9.895 -13.07749,-8.33914 -20.416,-11.59804 -26.4844,-5.24126 10.83882,26.8471 20.416,11.59804 z m 36.94581,-67.39043 c -25.50005,-11.63653 30.4889,-32.64656 20.12991,-2.60629 -4.12977,6.69198 -14.22499,6.53985 -20.12991,2.60629 z m 6.91801,-10.3468 c -0.82071,-13.3392 -12.1627,7.55602 0,0 z m -83.17504,3.76276 c -13.79522,-8.61428 4.31712,-27.04557 15.39702,-18.85616 13.6067,12.03589 -1.44836,24.55833 -15.39702,18.85616 z m 7.75703,-12.30697 c -5.2255,-11.64565 -10.19028,9.41998 0,0 z m -42.5,116.01345 c -6.02723,-7.2088 -1.92276,0.67135 0,0 z m 249.36364,-91.2588 c 13.806,-15.02329 -17.50241,-28.77029 -15.20919,-6.0755 0.688,7.20314 9.8789,12.01227 15.20919,6.0755 z"
|
||||
id="path262"
|
||||
sodipodi:nodetypes="ssscsssssssssscscsssssssscssssssssssscssssssssssscsssssssssssssssscssssssssssssssssssssssssssss" />
|
||||
<path
|
||||
style="fill:#98b322"
|
||||
d="m 509.53513,538.91636 c -11.96373,-4.91645 8.89339,-3.88826 12.76305,-6.86225 9.28643,-1.97818 -6.4996,-8.86225 -5.56764,-12.40041 5.30229,-0.44489 21.32889,0.97664 9.25743,-4.06036 -4.4293,-2.38922 -8.90334,-4.6942 -13.35565,-7.04008 14.22958,-1.11906 29.14185,-5.34748 39.25328,-15.90169 2.68838,-4.49776 -4.08229,-15.62608 5.03556,-9.22194 7.93306,-6.96815 2.94935,-21.58829 -1.33828,-30.24933 4.40924,-0.25594 16.57977,4.55985 7.33655,-4.04687 -11.00538,-12.31768 -23.14999,-27.52514 -40.87556,-28.89523 -12.38683,-0.11681 -24.80253,7.9637 -36.90946,1.50561 -13.66459,6.45135 -15.89413,-15.41822 -16.10693,-25.52605 0.11257,-17.90444 10.83888,-33.45475 20.92523,-47.40792 -3.05408,-0.24055 -14.13675,6.43308 -7.58956,-2.00266 5.14711,-6.58606 16.1968,-5.55188 24.24745,-6.48256 -0.64652,2.77294 -5.38496,13.38337 1.49882,5.24279 15.35654,-16.366 27.78739,-36.47005 47.56874,-47.96687 13.25414,-5.46069 15.39695,14.72588 18.71219,23.21422 4.97338,21.83679 8.88088,44.88811 4.653,67.17671 -0.42681,8.2555 -8.28775,16.55282 -13.7633,17.08103 3.79273,4.42442 20.53747,19.65551 5.40245,12.0655 -5.32651,-2.18699 -9.60486,-3.59981 -3.31377,1.55124 10.07734,9.32175 19.68413,21.27699 18.4153,35.87995 -0.32668,14.70676 -12.03558,25.33807 -18.87369,37.35808 5.58909,-1.69527 15.58549,-15.93947 11.4519,-2.55177 -3.60074,10.062 11.10418,20.4953 5.86292,28.05887 -22.26582,9.35137 -44.64925,20.52878 -69.03559,22.50306 -1.92036,-0.05 -3.84901,-0.34274 -5.65444,-1.02107 z m 65.78575,-29.48994 c 5.78966,-7.75443 -13.2439,10.9428 -2.23057,2.0827 l 1.25202,-1.10346 z m -68.81054,-89.5018 c 10.3928,-9.60021 -7.59416,-23.65065 -17.40017,-16.92149 -6.0022,5.20108 -14.16395,16.91183 -1.19983,17.82149 5.04579,3.34277 14.31037,4.11548 18.6,-0.9 z m 11.8433,-13.82251 c 4.8073,-13.20848 -17.62579,-19.46625 -25.78482,-10.4034 -8.24468,7.90366 12.43507,0.51199 15.14174,8.29731 2.90454,2.60721 7.25729,6.87958 10.64308,2.10609 z m 40.39101,-19.31318 c 5.78684,-9.84304 14.87824,-18.85981 14.28152,-31.17347 0.29281,-17.2393 -3.29381,-34.47275 -8.87177,-50.70971 -8.2269,-11.71842 -18.48254,9.20895 -24.65918,14.58319 -8.27896,11.14993 -15.97671,24.13537 -16.43162,38.33565 5.81105,9.59348 20.2801,2.52537 22.63335,-7.59849 1.91751,-11.39629 10.56353,-19.72811 14.71934,-30.52016 1.40753,-4.75338 2.7467,-8.65513 3.19367,-1.43954 3.03818,19.50172 2.73205,40.2994 -6.23148,58.32147 -1.42557,1.68784 -2.84962,18.49044 1.36617,10.20106 z m -132.57252,30.28569 c 8.9312,-6.02734 7.48296,-23.09684 -5.07505,-23.64993 -7.30021,-0.58972 -13.70802,6.3178 -14.80605,12.7258 1.80508,5.41863 11.08041,12.34728 0.43734,7.07322 -8.78538,-4.63851 -18.9703,-5.08549 -28.34587,-2.82766 -0.78195,-1.20615 5.95898,-6.38547 7.64726,-9.1958 3.17899,-4.75979 14.14408,-17.04143 10.66391,-19.05896 -8.21587,0.49898 -7.15269,-16.45349 -7.61833,-23.35234 0.38694,-1.92842 0.568,-15.11456 1.50148,-11.0615 2.18799,9.93834 4.54838,20.74835 11.16901,28.59085 7.73714,-10.57308 -5.25092,-24.23902 -0.95866,-36.88296 1.19051,-8.36811 0.86918,-24.11671 5.29194,-27.6918 3.79977,11.14223 8.72133,21.86587 12.7256,32.92008 1.469,13.02823 21.40974,10.49286 17.83409,-2.39696 -3.32571,-15.92393 -12.20464,-30.4869 -22.81624,-42.64305 -1.61447,-5.5579 -16.04555,-2.78383 -6.17414,-7.11693 11.4822,2.4981 18.13579,14.1012 25.27589,22.56913 6.89239,9.91602 14.82304,19.48443 19.27939,30.80078 2.47751,-2.96246 1.89049,-12.09704 8.49383,-6.61144 6.65112,0.58151 16.26357,5.55912 6.89945,11.05947 0.73719,-14.80175 -8.75677,15.1836 -10.62746,8.56225 -0.72867,-12.69039 -5.40734,8.91481 -6.08907,12.65018 -2.18787,18.03406 -8.95803,36.69358 -24.11683,47.78757 l -0.516,-0.66094 z m -14.20337,-23.32605 c 5.77671,-2.92338 22.69464,0.31989 10.56863,-7.78429 -7.14341,-6.64682 -23.87398,-0.74632 -20.72199,9.89207 3.22405,1.98101 7.17289,-0.8495 10.15336,-2.10778 z m 3.70324,21.86879 c 8.31993,-0.40006 2.55621,1.04523 0,0 z"
|
||||
id="path264"
|
||||
sodipodi:nodetypes="ssssscssscsssssssssssssscsssssssssssssssssscsssssssssssssssssssssssssssscssssssss" />
|
||||
<path
|
||||
d="m 1024.2783,547.21642 c -9.6474,-14.6212 -6.632,-40.42073 -4.8502,-53.76535 2.6928,-16.90372 -3.3202,-12.12461 -13.6577,-4.45447 -25.01447,12.27949 -59.18425,4.28457 -72.04163,-21.68733 -10.2406,-17.71164 -8.40772,-39.31392 -6.28209,-58.79606 6.45645,-29.86765 33.30762,-52.02721 63.40527,-54.57572 23.99335,-2.09972 48.62905,-0.44983 71.62095,7.06815 0.091,62.23891 0.5942,124.48041 0.1981,186.71765 -12.6287,0.43508 -26.0071,2.19718 -38.3927,-0.50687 z m -19.2972,-85.14028 c 8.9811,-3.69403 17.2196,-10.77319 14.5221,-21.15186 -0.2965,-18.90657 0.8377,-37.93383 -1.0647,-56.74097 -17.6803,-4.80898 -39.46324,1.42399 -45.83356,20.20953 -5.84919,19.35871 -7.2627,47.76691 14.0742,58.19247 5.98319,1.52206 12.40867,1.30531 18.30196,-0.50917 z m 114.7494,31.20018 c -34.0059,-8.04356 -45.9919,-48.32423 -39.5447,-79.17262 4.3945,-28.8021 27.3959,-53.05095 56.1731,-58.26248 25.86,-6.01589 53.0851,-1.80688 77.8616,6.72508 0.5883,33.54678 -0.8778,67.22968 1.7215,100.66471 4.7565,10.75749 21.7529,2.5844 16.5612,17.85564 3.817,12.07463 -6.9999,13.24912 -16.9182,13.03401 -16.0647,3.64109 -33.3851,-6.02131 -41.0468,-16.02871 -13.8775,14.34702 -35.5941,19.64241 -54.8077,15.18437 z m 40.5023,-32.20953 c 9.4402,-3.42968 11.2078,-10.92943 11.2078,-21.12672 l -0.4374,-55.71678 c -18.9818,-5.02361 -42.4004,3.77993 -46.5039,24.80962 -8.42,21.69593 1.1213,62.6043 31.4405,53.73703 1.4729,-0.46468 2.8792,-1.08873 4.293,-1.70315 z m -422.72957,31.72665 c -18.80084,-7.53055 -6.7665,-35.95425 -10.3367,-52.35268 0.099,-46.1716 0.30201,-92.34293 0.45214,-138.5144 14.30782,-1.61194 31.93718,-5.49591 44.37628,3.17584 3.51117,5.47623 0.51565,13.38784 1.50829,19.80673 v 134.81436 h 76 v 32.70051 c -37.24011,2.12636 -74.73098,1.27931 -112.00001,0.36964 z m 132.75001,0.19481 c -8.92902,1.39282 -3.09221,-10.86174 -4.75,-16.18938 V 357.88248 c 13.82936,-0.68735 31.04568,-5.74109 42.2204,4.10116 2.66309,43.37133 1.18106,86.97172 1.8489,130.44397 -13.04795,1.46659 -26.22936,1.3221 -39.3193,0.56064 z m 10.0451,-150.25092 c -20.83065,-2.20719 -27.42012,-33.88436 -8.55042,-43.73165 18.44309,-10.35465 48.41166,4.6393 39.315,28.01944 -4.07387,12.71854 -18.43094,18.32981 -30.76458,15.71221 z"
|
||||
style="fill:#98b322"
|
||||
id="path529"
|
||||
sodipodi:nodetypes="ccccccccccccccccccccccccccccccccccccccccccccccccc" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 13 KiB |
@@ -0,0 +1,45 @@
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { X, Trash2 } from 'lucide-react';
|
||||
import { Modal, Button } from '../../ui';
|
||||
|
||||
export interface DeleteConfirmationModalProps {
|
||||
open: boolean;
|
||||
title: string;
|
||||
message: string;
|
||||
onClose: () => void;
|
||||
onConfirm: () => void;
|
||||
isDeleting: boolean;
|
||||
}
|
||||
|
||||
export function DeleteConfirmationModal({
|
||||
open,
|
||||
title,
|
||||
message,
|
||||
onClose,
|
||||
onConfirm,
|
||||
isDeleting,
|
||||
}: DeleteConfirmationModalProps) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<Modal
|
||||
open={open}
|
||||
title={title}
|
||||
onClose={() => !isDeleting && onClose()}
|
||||
footer={
|
||||
<>
|
||||
<Button variant="secondary" onClick={onClose} disabled={isDeleting}>
|
||||
<X size={14} />
|
||||
{t('common.button_cancel')}
|
||||
</Button>
|
||||
<Button variant="danger" onClick={onConfirm} disabled={isDeleting}>
|
||||
<Trash2 size={14} />
|
||||
{t('common.button_delete')}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
{message}
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
.exportModal {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.25rem;
|
||||
}
|
||||
|
||||
.scenarioMeta {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
padding: 0.75rem 1rem;
|
||||
background: var(--color-primary);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.metaRow {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.metaLabel {
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
color: var(--color-primary-fg);
|
||||
opacity: 0.7;
|
||||
min-width: 4rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
|
||||
.metaValue {
|
||||
font-size: 0.875rem;
|
||||
color: var(--color-primary-fg);
|
||||
}
|
||||
|
||||
.section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.sectionTitle {
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 600;
|
||||
color: var(--text-muted, #888);
|
||||
margin: 0;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
|
||||
.checkboxRow {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
font-size: 0.875rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.checkboxRow input[type='checkbox'] {
|
||||
cursor: pointer;
|
||||
accent-color: var(--color-primary);
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { X, Upload } from 'lucide-react';
|
||||
import { Modal, Button, UuidBadge } from '../../ui';
|
||||
import type { Scenario, ScenarioCredential } from '../../api';
|
||||
import styles from './ExportScenarioModal.module.css';
|
||||
|
||||
export interface ExportScenarioModalProps {
|
||||
open: boolean;
|
||||
scenario: Scenario | null;
|
||||
scenarioCredentials: ScenarioCredential[];
|
||||
environment: Pick<{ id: string; name: string }, 'id' | 'name'> | null;
|
||||
includeEnvironment: boolean;
|
||||
onIncludeEnvironmentChange: (v: boolean) => void;
|
||||
includedCredentialIds: Set<string>;
|
||||
onCredentialToggle: (id: string, checked: boolean) => void;
|
||||
onClose: () => void;
|
||||
onExport: () => void;
|
||||
isExporting: boolean;
|
||||
}
|
||||
|
||||
export function ExportScenarioModal({
|
||||
open,
|
||||
scenario,
|
||||
scenarioCredentials,
|
||||
environment,
|
||||
includeEnvironment,
|
||||
onIncludeEnvironmentChange,
|
||||
includedCredentialIds,
|
||||
onCredentialToggle,
|
||||
onClose,
|
||||
onExport,
|
||||
isExporting,
|
||||
}: ExportScenarioModalProps) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<Modal
|
||||
open={open}
|
||||
title={t('scenarios.export_modal_title')}
|
||||
onClose={() => !isExporting && onClose()}
|
||||
footer={
|
||||
<>
|
||||
<Button variant="secondary" onClick={onClose} disabled={isExporting}>
|
||||
<X size={14} />
|
||||
{t('common.button_cancel')}
|
||||
</Button>
|
||||
<Button variant="primary" onClick={onExport} disabled={isExporting}>
|
||||
<Upload size={14} />
|
||||
{t('scenarios.action_export')}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
{scenario && (
|
||||
<div className={styles.exportModal}>
|
||||
<div className={styles.scenarioMeta}>
|
||||
<div className={styles.metaRow}>
|
||||
<span className={styles.metaLabel}>{t('scenarios.field_name')}</span>
|
||||
<span className={styles.metaValue}>{scenario.name}</span>
|
||||
</div>
|
||||
<div className={styles.metaRow}>
|
||||
<span className={styles.metaLabel}>{t('scenarios.field_id')}</span>
|
||||
<span className={styles.metaValue}>
|
||||
<UuidBadge id={scenario.id} />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{environment && (
|
||||
<div className={styles.section}>
|
||||
<h4 className={styles.sectionTitle}>{t('scenarios.export_include_environment')}</h4>
|
||||
<label className={styles.checkboxRow}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={includeEnvironment}
|
||||
onChange={(e) => onIncludeEnvironmentChange(e.target.checked)}
|
||||
/>
|
||||
<span>{environment.name}</span>
|
||||
</label>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{scenarioCredentials.length > 0 && (
|
||||
<div className={styles.section}>
|
||||
<h4 className={styles.sectionTitle}>{t('scenarios.export_include_credentials')}</h4>
|
||||
{scenarioCredentials.map((sc) => (
|
||||
<label key={sc.credentialId} className={styles.checkboxRow}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={includedCredentialIds.has(sc.credentialId)}
|
||||
onChange={(e) => onCredentialToggle(sc.credentialId, e.target.checked)}
|
||||
/>
|
||||
<span>{sc.credential?.name ?? sc.alias}</span>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { X, Play } from 'lucide-react';
|
||||
import { Modal, Button, Select } from '../../ui';
|
||||
import type { Environment } from '../../api';
|
||||
|
||||
export interface RunScenarioModalProps {
|
||||
open: boolean;
|
||||
environments: Environment[];
|
||||
selectedEnvId: string;
|
||||
onEnvSelect: (envId: string) => void;
|
||||
saveSessionFlag: boolean;
|
||||
onSaveSessionChange: (flag: boolean) => void;
|
||||
onClose: () => void;
|
||||
onRun: () => void;
|
||||
isRunning: boolean;
|
||||
actionLabel?: string;
|
||||
}
|
||||
|
||||
export function RunScenarioModal({
|
||||
open,
|
||||
environments,
|
||||
selectedEnvId,
|
||||
onEnvSelect,
|
||||
saveSessionFlag,
|
||||
onSaveSessionChange,
|
||||
onClose,
|
||||
onRun,
|
||||
isRunning,
|
||||
actionLabel,
|
||||
}: RunScenarioModalProps) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<Modal
|
||||
open={open}
|
||||
title={t('scenarios.run_modal_title')}
|
||||
onClose={() => !isRunning && onClose()}
|
||||
footer={
|
||||
<>
|
||||
<Button variant="secondary" onClick={onClose} disabled={isRunning}>
|
||||
<X size={14} />
|
||||
{t('common.button_cancel')}
|
||||
</Button>
|
||||
<Button variant="primary" onClick={onRun} disabled={isRunning || !selectedEnvId}>
|
||||
<Play size={14} />
|
||||
{actionLabel || t('scenarios.action_run')}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
{environments.length === 0 ? (
|
||||
<p>{t('scenarios.run_modal_no_env')}</p>
|
||||
) : (
|
||||
<>
|
||||
<Select
|
||||
label={t('scenarios.run_modal_env_label')}
|
||||
value={selectedEnvId}
|
||||
onChange={(e) => onEnvSelect(e.target.value)}
|
||||
options={environments.map((env) => ({ value: env.id, label: env.name }))}
|
||||
/>
|
||||
<label
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
marginTop: '1rem',
|
||||
gap: '0.5rem',
|
||||
}}
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={saveSessionFlag}
|
||||
onChange={(e) => onSaveSessionChange(e.target.checked)}
|
||||
/>
|
||||
<span>{t('common.save_session')}</span>
|
||||
</label>
|
||||
</>
|
||||
)}
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
export { DeleteConfirmationModal } from './DeleteConfirmationModal';
|
||||
export type { DeleteConfirmationModalProps } from './DeleteConfirmationModal';
|
||||
export { ExportScenarioModal } from './ExportScenarioModal';
|
||||
export type { ExportScenarioModalProps } from './ExportScenarioModal';
|
||||
export { RunScenarioModal } from './RunScenarioModal';
|
||||
export type { RunScenarioModalProps } from './RunScenarioModal';
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
declare module '*.css' {
|
||||
const styles: Record<string, string>;
|
||||
export default styles;
|
||||
}
|
||||
|
||||
interface ImportMetaEnv {
|
||||
readonly VITE_API_URL?: string;
|
||||
}
|
||||
|
||||
declare const __APP_VERSION__: string;
|
||||
@@ -0,0 +1,17 @@
|
||||
import { useEffect } from 'react';
|
||||
|
||||
const APP_NAME = 'Liqa';
|
||||
|
||||
/**
|
||||
* Sets document.title to "<title> | Liqa" for the current page.
|
||||
* Pass undefined or empty string to fall back to just "Liqa".
|
||||
*/
|
||||
export function usePageTitle(title: string | null | undefined): void {
|
||||
useEffect(() => {
|
||||
const prev = document.title;
|
||||
document.title = title ? `${title} | ${APP_NAME}` : APP_NAME;
|
||||
return () => {
|
||||
document.title = prev;
|
||||
};
|
||||
}, [title]);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
|
||||
type Theme = 'light' | 'dark';
|
||||
|
||||
const STORAGE_KEY = 'qa-bot-theme';
|
||||
|
||||
function getInitialTheme(): Theme {
|
||||
const stored = localStorage.getItem(STORAGE_KEY);
|
||||
if (stored === 'light' || stored === 'dark') return stored;
|
||||
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
||||
}
|
||||
|
||||
export function useTheme() {
|
||||
const [theme, setTheme] = useState<Theme>(getInitialTheme);
|
||||
|
||||
useEffect(() => {
|
||||
document.documentElement.setAttribute('data-theme', theme);
|
||||
localStorage.setItem(STORAGE_KEY, theme);
|
||||
}, [theme]);
|
||||
|
||||
function toggleTheme() {
|
||||
setTheme((t) => (t === 'light' ? 'dark' : 'light'));
|
||||
}
|
||||
|
||||
return { theme, toggleTheme } as const;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import i18n from 'i18next';
|
||||
import { initReactI18next } from 'react-i18next';
|
||||
import en from './locales/en.json';
|
||||
|
||||
i18n.use(initReactI18next).init({
|
||||
resources: { en: { translation: en } },
|
||||
lng: 'en',
|
||||
fallbackLng: 'en',
|
||||
interpolation: { escapeValue: false },
|
||||
});
|
||||
|
||||
export default i18n;
|
||||
@@ -0,0 +1,316 @@
|
||||
{
|
||||
"common": {
|
||||
"button_cancel": "Cancel",
|
||||
"button_confirm": "Confirm",
|
||||
"button_delete": "Delete",
|
||||
"confirm_delete_credential": "Are you sure you want to delete this credential?",
|
||||
"confirm_delete_environment": "Are you sure you want to delete this environment?",
|
||||
"confirm_delete_scenario": "Are you sure you want to delete this scenario?",
|
||||
"confirm_delete_step": "Are you sure you want to delete this step?",
|
||||
"confirm_delete_session": "Are you sure you want to delete this session?",
|
||||
"confirm_delete_snippet": "Are you sure you want to delete this snippet?",
|
||||
"confirm_remove_credential": "Are you sure you want to remove this credential from scenario?",
|
||||
"save_session": "Save session"
|
||||
},
|
||||
"errors": {
|
||||
"not_found": "Not found",
|
||||
"not_found_session": "Session {{id}} does not exist or has been deleted.",
|
||||
"not_found_environment": "Environment {{id}} does not exist or has been deleted.",
|
||||
"not_found_credential": "Credential {{id}} does not exist or has been deleted.",
|
||||
"not_found_scenario": "Scenario {{id}} does not exist or has been deleted.",
|
||||
"not_found_snippet": "Snippet {{id}} does not exist or has been deleted.",
|
||||
"generic": "Something went wrong. Please try again."
|
||||
},
|
||||
"nav": {
|
||||
"environments": "Environments",
|
||||
"credentials": "Credentials",
|
||||
"snippets": "Snippets",
|
||||
"keys": "Keys",
|
||||
"sessions": "Sessions",
|
||||
"scenarios": "Scenarios",
|
||||
"runs": "Runs"
|
||||
},
|
||||
"environments": {
|
||||
"title": "Environments",
|
||||
"created": "Environment created",
|
||||
"updated": "Environment updated",
|
||||
"col_id": "ID",
|
||||
"col_name": "Name",
|
||||
"col_description": "Description",
|
||||
"col_data": "Data",
|
||||
"col_updated": "Updated",
|
||||
"empty": "No environments yet.",
|
||||
"loading": "Loading…",
|
||||
"no_data": "No data configured.",
|
||||
"menu_label": "Environment options",
|
||||
"action_view": "View details",
|
||||
"action_delete": "Delete",
|
||||
"action_add": "Add environment",
|
||||
"action_edit": "Edit",
|
||||
"action_export": "Export",
|
||||
"action_import": "Import",
|
||||
"action_save": "Create",
|
||||
"action_update": "Save",
|
||||
"action_cancel": "Cancel",
|
||||
"create_title": "New Environment",
|
||||
"edit_title": "Edit Environment",
|
||||
"form_name": "Name",
|
||||
"form_name_placeholder": "e.g. staging, production",
|
||||
"form_name_required": "Name is required",
|
||||
"form_description": "Description",
|
||||
"form_description_placeholder": "Describe this environment",
|
||||
"form_data": "Data (JSON)",
|
||||
"form_data_invalid_json": "Must be a valid JSON object",
|
||||
"back": "Environments",
|
||||
"field_id": "ID",
|
||||
"field_description": "Description",
|
||||
"field_created": "Created",
|
||||
"field_updated": "Updated",
|
||||
"section_data": "Data"
|
||||
},
|
||||
"credentials": {
|
||||
"title": "Credentials",
|
||||
"created": "Credential created",
|
||||
"updated": "Credential updated",
|
||||
"empty": "No credentials yet.",
|
||||
"loading": "Loading…",
|
||||
"menu_label": "Credential options",
|
||||
"action_edit": "Edit",
|
||||
"action_delete": "Delete",
|
||||
"action_add": "Add credential",
|
||||
"action_save": "Create",
|
||||
"action_update": "Save",
|
||||
"action_cancel": "Cancel",
|
||||
"create_title": "New Credential",
|
||||
"edit_title": "Edit Credential",
|
||||
"form_name": "Name",
|
||||
"form_name_placeholder": "e.g. staging-api-key",
|
||||
"form_name_required": "Name is required",
|
||||
"form_data": "Data (JSON)",
|
||||
"form_data_placeholder": "{\"token\": \"…\"}",
|
||||
"form_data_invalid_json": "Must be valid JSON",
|
||||
"field_id": "ID",
|
||||
"field_last_used": "Last Used",
|
||||
"field_created": "Created",
|
||||
"field_updated": "Updated",
|
||||
"section_data": "Data",
|
||||
"action_export": "Export",
|
||||
"action_import": "Import",
|
||||
"import_error": "Failed to import credential"
|
||||
},
|
||||
"keys": {
|
||||
"col_name": "Key name",
|
||||
"empty": "No key files found."
|
||||
},
|
||||
"sessions": {
|
||||
"title": "Sessions",
|
||||
"col_id": "ID",
|
||||
"col_name": "Name",
|
||||
"col_status": "Status",
|
||||
"col_lastUsed": "Last Used",
|
||||
"empty": "No sessions yet.",
|
||||
"loading": "Loading…",
|
||||
"action_delete": "Delete",
|
||||
"field_id": "ID",
|
||||
"field_name": "Name",
|
||||
"field_token": "Token",
|
||||
"field_status": "Status",
|
||||
"field_created": "Created",
|
||||
"field_updated": "Updated",
|
||||
"field_lastUsed": "Last Used"
|
||||
},
|
||||
"scenarios": {
|
||||
"title": "Scenarios",
|
||||
"created": "Scenario created",
|
||||
"updated": "Scenario updated",
|
||||
"run_started": "Scenario run started",
|
||||
"col_id": "ID",
|
||||
"col_name": "Name",
|
||||
"col_description": "Description",
|
||||
"col_last_run": "Last Run",
|
||||
"col_updated": "Updated",
|
||||
"empty": "No scenarios yet.",
|
||||
"loading": "Loading…",
|
||||
"action_run": "Run",
|
||||
"action_delete": "Delete",
|
||||
"field_id": "ID",
|
||||
"field_name": "Name",
|
||||
"field_description": "Description",
|
||||
"field_steps": "Steps",
|
||||
"field_created": "Created",
|
||||
"field_updated": "Updated",
|
||||
"steps_heading": "Steps",
|
||||
"step_order": "#",
|
||||
"step_title": "Title",
|
||||
"step_type": "Type",
|
||||
"step_session": "Session",
|
||||
"step_updated": "Updated",
|
||||
"action_add": "New scenario",
|
||||
"action_edit": "Edit",
|
||||
"action_runs": "Runs",
|
||||
"action_export": "Export",
|
||||
"action_import": "Import",
|
||||
"import_error": "Failed to import scenario",
|
||||
"action_save": "Create",
|
||||
"action_update": "Save",
|
||||
"action_cancel": "Cancel",
|
||||
"create_title": "New Scenario",
|
||||
"edit_title": "Edit Scenario",
|
||||
"form_description": "Description",
|
||||
"form_description_placeholder": "Describe this scenario",
|
||||
"form_environment": "Default Environment",
|
||||
"form_environment_none": "None (no default environment)",
|
||||
"field_environment": "Default Environment",
|
||||
"form_name": "Name",
|
||||
"form_name_placeholder": "e.g. Login flow",
|
||||
"form_name_required": "Name is required",
|
||||
"credentials_heading": "Credentials",
|
||||
"cred_empty": "No credentials assigned.",
|
||||
"cred_col_alias": "Alias",
|
||||
"cred_col_name": "Credential",
|
||||
"cred_col_added": "Added",
|
||||
"cred_action_add": "Add credential",
|
||||
"cred_action_remove": "Remove",
|
||||
"cred_action_save": "Add",
|
||||
"cred_action_cancel": "Cancel",
|
||||
"cred_form_cred": "Credential",
|
||||
"cred_form_cred_placeholder": "Select credential…",
|
||||
"cred_form_cred_required": "Select a credential",
|
||||
"cred_form_alias": "Alias",
|
||||
"cred_form_alias_placeholder": "e.g. api_key",
|
||||
"cred_form_alias_required": "Alias is required",
|
||||
"run_modal_title": "Select environment",
|
||||
"run_modal_env_label": "Environment",
|
||||
"run_modal_no_env": "No environments found. Create an environment before running a scenario.",
|
||||
"run_modal_env_required": "Please select an environment",
|
||||
"export_modal_title": "Export Scenario",
|
||||
"export_include_environment": "Include Environment",
|
||||
"export_include_credentials": "Include Credentials",
|
||||
"form_timeout": "Scenario Timeout (seconds)",
|
||||
"form_timeout_placeholder": "Default: 600",
|
||||
"form_timeout_hint": "Max seconds for the entire scenario run (default: 600)",
|
||||
"field_name": "Name",
|
||||
"field_id": "ID"
|
||||
},
|
||||
"theme": {
|
||||
"switch_to_light": "Switch to light theme",
|
||||
"switch_to_dark": "Switch to dark theme",
|
||||
"light_mode": "Light mode",
|
||||
"dark_mode": "Dark mode"
|
||||
},
|
||||
"pagination": {
|
||||
"prev": "Previous page",
|
||||
"next": "Next page",
|
||||
"range": "{{from}}–{{to}} of {{total}}",
|
||||
"per_page": "{{count}} per page",
|
||||
"page_size": "Items per page"
|
||||
},
|
||||
"steps": {
|
||||
"created": "Step created",
|
||||
"updated": "Step updated",
|
||||
"create_title": "Add Step",
|
||||
"edit_title": "Edit Step #{{order}}",
|
||||
"loading": "Loading…",
|
||||
"action_add": "Add step",
|
||||
"action_edit": "Edit",
|
||||
"action_delete": "Delete",
|
||||
"action_save": "Add step",
|
||||
"action_update": "Save",
|
||||
"action_cancel": "Cancel",
|
||||
"form_order": "Order",
|
||||
"form_order_invalid": "Order must be a non-negative integer",
|
||||
"form_title": "Title",
|
||||
"form_title_placeholder": "e.g. Check login page",
|
||||
"form_type": "Type",
|
||||
"form_session": "Session name",
|
||||
"form_session_placeholder": "e.g. my-session",
|
||||
"form_session_required": "Session name is required",
|
||||
"form_exec_code": "Exec code",
|
||||
"form_exec_code_placeholder": "return await page.title();",
|
||||
"form_timeout": "Step Timeout (seconds)",
|
||||
"form_timeout_placeholder": "Default: 60",
|
||||
"form_timeout_hint": "Max seconds for this step (default: 60)"
|
||||
},
|
||||
"runs": {
|
||||
"title": "Runs",
|
||||
"loading": "Loading…",
|
||||
"empty": "No runs yet.",
|
||||
"action_run": "Run scenario",
|
||||
"col_id": "ID",
|
||||
"col_scenario": "Scenario",
|
||||
"col_status": "Status",
|
||||
"col_steps": "Steps",
|
||||
"col_created": "Started",
|
||||
"field_id": "ID",
|
||||
"field_status": "Status",
|
||||
"field_steps": "Steps",
|
||||
"field_created": "Started",
|
||||
"field_updated": "Updated",
|
||||
"steps_heading": "Step runs",
|
||||
"step_title": "Title",
|
||||
"logs_heading": "Logs",
|
||||
"logs_search_placeholder": "Filter logs…",
|
||||
"step_order": "#",
|
||||
"step_type": "Type",
|
||||
"step_session": "Session",
|
||||
"step_status": "Status",
|
||||
"step_description": "Result",
|
||||
"log_level": "Level",
|
||||
"log_message": "Message",
|
||||
"log_time": "Time"
|
||||
},
|
||||
"snippets": {
|
||||
"title": "Snippets",
|
||||
"created": "Snippet created",
|
||||
"updated": "Snippet updated",
|
||||
"empty": "No snippets yet.",
|
||||
"loading": "Loading…",
|
||||
"menu_label": "Snippet options",
|
||||
"action_edit": "Edit",
|
||||
"action_delete": "Delete",
|
||||
"action_add": "Add snippet",
|
||||
"action_save": "Create",
|
||||
"action_update": "Save",
|
||||
"action_cancel": "Cancel",
|
||||
"create_title": "New Snippet",
|
||||
"edit_title": "Edit Snippet",
|
||||
"form_alias": "Alias",
|
||||
"form_alias_placeholder": "e.g. clickLoginButton",
|
||||
"form_alias_required": "Alias is required",
|
||||
"form_title": "Title",
|
||||
"form_title_placeholder": "e.g. Click Login Button",
|
||||
"form_title_required": "Title is required",
|
||||
"form_description": "Description",
|
||||
"form_description_placeholder": "What does this snippet do?",
|
||||
"form_code": "Code",
|
||||
"form_code_placeholder": "await page.click('#login-btn');",
|
||||
"form_code_required": "Code is required",
|
||||
"field_id": "ID",
|
||||
"field_alias": "Alias",
|
||||
"field_title": "Title",
|
||||
"field_description": "Description",
|
||||
"field_created": "Created",
|
||||
"field_updated": "Updated",
|
||||
"section_code": "Code",
|
||||
"action_export": "Export",
|
||||
"action_import": "Import",
|
||||
"import_error": "Failed to import snippet"
|
||||
},
|
||||
"files": {
|
||||
"title": "Files",
|
||||
"upload": "Upload",
|
||||
"uploadTitle": "Upload File",
|
||||
"uploadSuccess": "File uploaded successfully",
|
||||
"name": "Name",
|
||||
"mimeType": "MIME Type",
|
||||
"size": "Size",
|
||||
"expiresAt": "Expires At",
|
||||
"expiresAtLabel": "Expires At (optional)",
|
||||
"createdAt": "Created",
|
||||
"download": "Download",
|
||||
"expiredTooltip": "File is expired",
|
||||
"empty": "No files uploaded.",
|
||||
"totalCount": "Total: {{count}} file(s)",
|
||||
"artifactsTitle": "Artifacts"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import hljs from 'highlight.js/lib/core';
|
||||
import javascript from 'highlight.js/lib/languages/javascript';
|
||||
import json from 'highlight.js/lib/languages/json';
|
||||
|
||||
hljs.registerLanguage('javascript', javascript);
|
||||
hljs.registerLanguage('json', json);
|
||||
|
||||
export default hljs;
|
||||
@@ -0,0 +1,30 @@
|
||||
export const API_ERROR_TOAST_EVENT = 'liqa:api-error-toast';
|
||||
|
||||
export interface ApiErrorToastDetail {
|
||||
message: string;
|
||||
}
|
||||
|
||||
export function emitApiErrorToast(message: string): void {
|
||||
if (typeof window === 'undefined') return;
|
||||
|
||||
window.dispatchEvent(
|
||||
new CustomEvent<ApiErrorToastDetail>(API_ERROR_TOAST_EVENT, {
|
||||
detail: { message },
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export function subscribeApiErrorToasts(handler: (message: string) => void): () => void {
|
||||
if (typeof window === 'undefined') return () => {};
|
||||
|
||||
const listener = (event: Event) => {
|
||||
const custom = event as CustomEvent<ApiErrorToastDetail>;
|
||||
const message = custom.detail?.message;
|
||||
if (message) handler(message);
|
||||
};
|
||||
|
||||
window.addEventListener(API_ERROR_TOAST_EVENT, listener);
|
||||
return () => {
|
||||
window.removeEventListener(API_ERROR_TOAST_EVENT, listener);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { StrictMode } from 'react';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import { BrowserRouter } from 'react-router-dom';
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||
import './i18n';
|
||||
import './ui/tokens.css';
|
||||
import App from './App';
|
||||
import { ToastProvider } from './ui';
|
||||
|
||||
const queryClient = new QueryClient();
|
||||
|
||||
createRoot(document.getElementById('root')!).render(
|
||||
<StrictMode>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<ToastProvider>
|
||||
<BrowserRouter>
|
||||
<App />
|
||||
</BrowserRouter>
|
||||
</ToastProvider>
|
||||
</QueryClientProvider>
|
||||
</StrictMode>,
|
||||
);
|
||||
@@ -0,0 +1,367 @@
|
||||
.heading {
|
||||
margin: 0 0 var(--space-4);
|
||||
font-size: var(--font-size-lg);
|
||||
font-weight: 700;
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.sectionHeading {
|
||||
margin: 0 0 var(--space-3);
|
||||
line-height: 1;
|
||||
font-size: var(--font-size-md);
|
||||
font-weight: 600;
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.stepsSection {
|
||||
margin-top: var(--space-6);
|
||||
}
|
||||
|
||||
.sectionHeadingRow {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: var(--space-3);
|
||||
}
|
||||
|
||||
.breadcrumbs {
|
||||
margin-bottom: var(--space-4);
|
||||
}
|
||||
|
||||
.pageToolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: var(--space-4);
|
||||
}
|
||||
|
||||
.toolbarActions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
|
||||
.error {
|
||||
margin-bottom: var(--space-4);
|
||||
padding: var(--space-3) var(--space-4);
|
||||
background: var(--color-error-bg);
|
||||
color: var(--color-error-fg);
|
||||
border-radius: var(--radius-md);
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
.muted {
|
||||
color: var(--color-text-muted);
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
.codeInline {
|
||||
font-family: var(--font-mono, ui-monospace, monospace);
|
||||
font-size: 0.85em;
|
||||
padding: 0.15em 0.45em;
|
||||
background: var(--color-code-bg, color-mix(in srgb, var(--color-bg-raised) 60%, var(--color-secondary) 40%));
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: var(--radius-sm);
|
||||
color: var(--color-secondary-fg);
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
/* ── Environment cards ──────────────────────────────────────── */
|
||||
|
||||
.envGrid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
||||
gap: var(--space-4);
|
||||
}
|
||||
|
||||
.envCard {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
|
||||
.envCardAdd {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 120px;
|
||||
border: 2px dashed var(--color-border);
|
||||
border-radius: var(--radius-lg);
|
||||
transition: border-color var(--transition), background var(--transition);
|
||||
}
|
||||
|
||||
.envCardAdd:hover {
|
||||
border-color: var(--color-primary);
|
||||
background: color-mix(in srgb, var(--color-primary) 6%, transparent);
|
||||
}
|
||||
|
||||
.envCardHeader {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.envCardId {
|
||||
font-size: var(--font-size-xs);
|
||||
font-weight: 700;
|
||||
color: var(--color-text-muted);
|
||||
flex-shrink: 0;
|
||||
border: var(--border-width) solid var(--color-border);
|
||||
border-radius: 9999px;
|
||||
padding: 1px var(--space-2);
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.envCardFooter {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.envCardHeader button {
|
||||
color: inherit;
|
||||
padding: var(--space-1);
|
||||
aspect-ratio: 1;
|
||||
margin-right: calc(-1 * var(--space-1));
|
||||
}
|
||||
|
||||
.pageTitle {
|
||||
margin: 0;
|
||||
font-size: var(--font-size-lg);
|
||||
font-weight: 700;
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.linkCell {
|
||||
color: var(--color-link);
|
||||
cursor: pointer;
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 2px;
|
||||
}
|
||||
|
||||
.linkCell:hover {
|
||||
color: var(--color-link-hover);
|
||||
}
|
||||
|
||||
.dragHandle {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border-radius: var(--radius-sm);
|
||||
cursor: grab;
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
.dragHandle:hover {
|
||||
background: color-mix(in srgb, var(--color-secondary) 18%, transparent);
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.dragHandle:active {
|
||||
cursor: grabbing;
|
||||
}
|
||||
|
||||
.dragHandleDisabled {
|
||||
opacity: 0.45;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.dragOverRow {
|
||||
background: color-mix(in srgb, var(--color-primary) 16%, transparent) !important;
|
||||
}
|
||||
|
||||
.envCardHeader button:hover {
|
||||
background: color-mix(in srgb, currentColor 15%, transparent) !important;
|
||||
}
|
||||
|
||||
.envCardName {
|
||||
font-weight: 700;
|
||||
font-size: var(--font-size-sm);
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.envCardUrls {
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-1);
|
||||
}
|
||||
|
||||
.envCardUrlRow {
|
||||
display: flex;
|
||||
gap: var(--space-2);
|
||||
align-items: baseline;
|
||||
font-size: var(--font-size-xs);
|
||||
}
|
||||
|
||||
.envCardUrlKey {
|
||||
color: var(--color-text-muted);
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
|
||||
.envCardUrlVal {
|
||||
margin: 0;
|
||||
color: var(--color-text);
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.envCardEmpty {
|
||||
margin: 0;
|
||||
font-size: var(--font-size-xs);
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
/* ── Environment form ───────────────────────────────────────────────────── */
|
||||
|
||||
.formCard {
|
||||
max-width: 540px;
|
||||
}
|
||||
|
||||
.formCardFull {
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.formFields {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-4);
|
||||
margin-bottom: var(--space-6);
|
||||
}
|
||||
|
||||
.formActions {
|
||||
display: flex;
|
||||
gap: var(--space-3);
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.formField {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-1);
|
||||
}
|
||||
|
||||
.fieldLabel {
|
||||
font-size: var(--font-size-sm);
|
||||
font-weight: 500;
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.textarea {
|
||||
width: 100%;
|
||||
padding: var(--space-2) var(--space-3);
|
||||
font-family: var(--font-mono, ui-monospace, monospace);
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--color-text);
|
||||
background: var(--color-bg-input, var(--color-bg-raised));
|
||||
border: var(--border-width) solid var(--color-border);
|
||||
border-radius: var(--radius-md);
|
||||
resize: vertical;
|
||||
transition: border-color var(--transition), box-shadow var(--transition);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.textarea:focus {
|
||||
outline: none;
|
||||
border-color: var(--color-primary);
|
||||
box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 20%, transparent);
|
||||
}
|
||||
|
||||
/* ── Section toolbar ─────────────────────────────────────────────────────── */
|
||||
|
||||
.sectionToolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: var(--space-3);
|
||||
}
|
||||
|
||||
/* ── Environment detail page ────────────────────────────────────────────── */
|
||||
|
||||
.detailToolbar {
|
||||
margin-bottom: var(--space-4);
|
||||
}
|
||||
|
||||
.detailHeader {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-4);
|
||||
margin-bottom: var(--space-4);
|
||||
}
|
||||
|
||||
.detailHeader .heading {
|
||||
margin: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.detailMeta {
|
||||
display: grid;
|
||||
grid-template-columns: max-content 1fr;
|
||||
gap: var(--space-1) var(--space-4);
|
||||
margin-bottom: var(--space-6);
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
.metaLabel {
|
||||
color: var(--color-text-muted);
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
font-size: var(--font-size-xs);
|
||||
letter-spacing: 0.04em;
|
||||
align-self: center;
|
||||
}
|
||||
|
||||
.sectionHeading {
|
||||
margin: 0 0 var(--space-3);
|
||||
font-size: var(--font-size-md);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.envDetailUrls {
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
|
||||
.envDetailUrlRow {
|
||||
display: grid;
|
||||
grid-template-columns: 140px 1fr;
|
||||
gap: var(--space-2);
|
||||
align-items: baseline;
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
.envDetailUrlVal {
|
||||
margin: 0;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.envDetailUrlVal a {
|
||||
color: var(--color-text-muted);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.envDetailUrlVal a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/* ── Code block ────────────────────────────────────────────────────────── */
|
||||
|
||||
.codeBlock {
|
||||
margin: 0;
|
||||
font-family: var(--font-mono, ui-monospace, monospace);
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--color-text);
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
overflow-x: auto;
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
import { useState, SubmitEvent } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { usePageTitle } from '../../hooks/usePageTitle';
|
||||
import { KeyRound, X, Save } from 'lucide-react';
|
||||
import { credentials } from '../../api';
|
||||
import { Breadcrumbs, Button, Card, Input, CodeEditor, useToast } from '../../ui';
|
||||
import styles from '../Page.module.css';
|
||||
|
||||
export function CreateCredentialPage() {
|
||||
const { t } = useTranslation();
|
||||
usePageTitle(t('credentials.create_title'));
|
||||
const navigate = useNavigate();
|
||||
const toast = useToast();
|
||||
|
||||
const [name, setName] = useState('');
|
||||
const [data, setData] = useState('');
|
||||
const [nameError, setNameError] = useState('');
|
||||
const [dataError, setDataError] = useState('');
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
const handleSubmit = async (e: SubmitEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
let valid = true;
|
||||
if (!name.trim()) {
|
||||
setNameError(t('credentials.form_name_required'));
|
||||
valid = false;
|
||||
}
|
||||
if (data.trim()) {
|
||||
try {
|
||||
JSON.parse(data.trim());
|
||||
} catch {
|
||||
setDataError(t('credentials.form_data_invalid_json'));
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
if (!valid) return;
|
||||
setSaving(true);
|
||||
try {
|
||||
const credential = await credentials.create(name.trim(), data.trim() || undefined);
|
||||
toast.success(t('credentials.created'));
|
||||
navigate(`/credentials/${credential.id}`);
|
||||
} catch (err) {
|
||||
const message = (err as Error).message;
|
||||
toast.error(message);
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={styles.pageToolbar}>
|
||||
<Breadcrumbs
|
||||
items={[
|
||||
{
|
||||
label: t('credentials.title'),
|
||||
icon: <KeyRound size={14} />,
|
||||
onClick: () => navigate('/credentials'),
|
||||
},
|
||||
{ label: t('credentials.create_title') },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<form onSubmit={handleSubmit} noValidate>
|
||||
<Card className={styles.formCardFull}>
|
||||
<div className={styles.formFields}>
|
||||
<Input
|
||||
label={t('credentials.form_name')}
|
||||
placeholder={t('credentials.form_name_placeholder')}
|
||||
value={name}
|
||||
onChange={(e) => {
|
||||
setName(e.target.value);
|
||||
setNameError('');
|
||||
}}
|
||||
error={nameError || undefined}
|
||||
required
|
||||
autoFocus
|
||||
/>
|
||||
<div className={styles.formField}>
|
||||
<label className={styles.fieldLabel}>
|
||||
{t('credentials.form_data')}
|
||||
<span className={styles.requiredMark}> *</span>
|
||||
</label>
|
||||
<CodeEditor
|
||||
language="json"
|
||||
value={data}
|
||||
onChange={(v) => {
|
||||
setData(v);
|
||||
setDataError('');
|
||||
}}
|
||||
rows={6}
|
||||
error={!!dataError}
|
||||
/>
|
||||
{dataError && <span className={styles.fieldError}>{dataError}</span>}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className={styles.formActions}>
|
||||
<Button type="button" variant="secondary" onClick={() => navigate('/credentials')}>
|
||||
<X size={14} />
|
||||
{t('credentials.action_cancel')}
|
||||
</Button>
|
||||
<Button type="submit" loading={saving}>
|
||||
<Save size={14} />
|
||||
{t('credentials.action_save')}
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { usePageTitle } from '../../hooks/usePageTitle';
|
||||
import { Upload, Pencil, Trash2, KeyRound } from 'lucide-react';
|
||||
import { CodeBlock } from '../../ui';
|
||||
import { stringify as yamlStringify } from 'yaml';
|
||||
import { credentials } from '../../api';
|
||||
import type { Credential } from '../../api';
|
||||
import { Breadcrumbs, Button, Card, DescriptionList, Timestamp, UuidBadge } from '../../ui';
|
||||
import { DeleteConfirmationModal } from '../../components/modals';
|
||||
import styles from '../Page.module.css';
|
||||
|
||||
export function CredentialDetailPage() {
|
||||
const { t } = useTranslation();
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const [credential, setCredential] = useState<Credential | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
usePageTitle(credential?.name ?? null);
|
||||
const [confirmDeleteOpen, setConfirmDeleteOpen] = useState(false);
|
||||
const [deleting, setDeleting] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!id) return;
|
||||
credentials
|
||||
.get(id)
|
||||
.then(setCredential)
|
||||
.finally(() => setLoading(false));
|
||||
}, [id]);
|
||||
|
||||
const handleDelete = async () => {
|
||||
if (!credential) return;
|
||||
setDeleting(true);
|
||||
try {
|
||||
await credentials.remove(credential.id);
|
||||
navigate('/credentials');
|
||||
} finally {
|
||||
setDeleting(false);
|
||||
setConfirmDeleteOpen(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleExport = async () => {
|
||||
if (!credential) return;
|
||||
const data = await credentials.exportCredential(credential.id);
|
||||
const blob = new Blob([yamlStringify(data)], { type: 'application/yaml' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `credential-${credential.name}.yaml`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={styles.pageToolbar}>
|
||||
<Breadcrumbs
|
||||
items={[
|
||||
{
|
||||
label: t('credentials.title'),
|
||||
icon: <KeyRound size={14} />,
|
||||
onClick: () => navigate('/credentials'),
|
||||
},
|
||||
{ label: credential?.name ?? `#${id}` },
|
||||
]}
|
||||
/>
|
||||
{credential && (
|
||||
<div className={styles.toolbarActions}>
|
||||
<Button variant="secondary" size="sm" onClick={handleExport}>
|
||||
<Upload size={14} />
|
||||
{t('credentials.action_export')}
|
||||
</Button>
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
onClick={() => navigate(`/credentials/${credential.id}/edit`)}
|
||||
>
|
||||
<Pencil size={14} />
|
||||
{t('credentials.action_edit')}
|
||||
</Button>
|
||||
<Button variant="danger" size="sm" onClick={() => setConfirmDeleteOpen(true)}>
|
||||
<Trash2 size={14} />
|
||||
{t('credentials.action_delete')}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{loading && <p className={styles.muted}>{t('credentials.loading')}</p>}
|
||||
|
||||
{credential && (
|
||||
<>
|
||||
<Card>
|
||||
<DescriptionList
|
||||
layout="grid"
|
||||
items={[
|
||||
{ term: t('credentials.field_id'), detail: <UuidBadge id={credential.id} /> },
|
||||
{
|
||||
term: t('credentials.field_last_used'),
|
||||
detail: credential.lastUsedAt ? <Timestamp value={credential.lastUsedAt} /> : '—',
|
||||
},
|
||||
{
|
||||
term: t('credentials.field_created'),
|
||||
detail: <Timestamp value={credential.createdAt} />,
|
||||
},
|
||||
{
|
||||
term: t('credentials.field_updated'),
|
||||
detail: <Timestamp value={credential.updatedAt} />,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</Card>
|
||||
|
||||
{credential.data && (
|
||||
<div className={styles.stepsSection}>
|
||||
<h2 className={styles.sectionHeading}>{t('credentials.section_data')}</h2>
|
||||
<Card>
|
||||
<CodeBlock
|
||||
language="json"
|
||||
code={(() => {
|
||||
try {
|
||||
return JSON.stringify(JSON.parse(credential.data), null, 2);
|
||||
} catch {
|
||||
return credential.data;
|
||||
}
|
||||
})()}
|
||||
/>
|
||||
</Card>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
<DeleteConfirmationModal
|
||||
open={confirmDeleteOpen}
|
||||
title={t('credentials.action_delete')}
|
||||
message={t('common.confirm_delete_credential')}
|
||||
onClose={() => setConfirmDeleteOpen(false)}
|
||||
onConfirm={handleDelete}
|
||||
isDeleting={deleting}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { usePageTitle } from '../../hooks/usePageTitle';
|
||||
import { Settings, Pencil, Trash2, Plus, Download, KeyRound } from 'lucide-react';
|
||||
import { parse as yamlParse } from 'yaml';
|
||||
import { credentials } from '../../api';
|
||||
import type { Credential } from '../../api';
|
||||
import {
|
||||
Breadcrumbs,
|
||||
Button,
|
||||
Card,
|
||||
ContextMenu,
|
||||
DescriptionList,
|
||||
Timestamp,
|
||||
UuidBadge,
|
||||
} from '../../ui';
|
||||
import { DeleteConfirmationModal } from '../../components/modals';
|
||||
import styles from '../Page.module.css';
|
||||
|
||||
function CredentialCard({
|
||||
credential,
|
||||
onDelete,
|
||||
}: {
|
||||
credential: Credential;
|
||||
onDelete: (id: string) => void;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const header = (
|
||||
<div className={styles.envCardHeader}>
|
||||
<span className={styles.envCardName}>{credential.name}</span>
|
||||
<div onClick={(e) => e.stopPropagation()}>
|
||||
<ContextMenu
|
||||
align="right"
|
||||
trigger={
|
||||
<Button variant="ghost" size="sm" aria-label={t('credentials.menu_label')}>
|
||||
<Settings size={14} />
|
||||
</Button>
|
||||
}
|
||||
items={[
|
||||
{
|
||||
label: t('credentials.action_edit'),
|
||||
icon: <Pencil size={14} />,
|
||||
onClick: () => navigate(`/credentials/${credential.id}/edit`),
|
||||
},
|
||||
{
|
||||
label: t('credentials.action_delete'),
|
||||
icon: <Trash2 size={14} />,
|
||||
variant: 'danger',
|
||||
onClick: () => onDelete(credential.id),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
const footer = (
|
||||
<div className={styles.envCardFooter}>
|
||||
<UuidBadge id={credential.id} />
|
||||
<Timestamp value={credential.updatedAt} />
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<Card
|
||||
className={styles.envCard}
|
||||
header={header}
|
||||
headerVariant="primary"
|
||||
footer={footer}
|
||||
onClick={() => navigate(`/credentials/${credential.id}`)}
|
||||
>
|
||||
<DescriptionList
|
||||
layout="compact"
|
||||
truncate
|
||||
items={[
|
||||
{
|
||||
term: t('credentials.field_last_used'),
|
||||
detail: credential.lastUsedAt ? <Timestamp value={credential.lastUsedAt} /> : '—',
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function AddCredentialCard() {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
return (
|
||||
<div className={styles.envCardAdd}>
|
||||
<Button variant="ghost" onClick={() => navigate('/credentials/new')}>
|
||||
<Plus size={16} />
|
||||
{t('credentials.action_add')}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function CredentialsPage() {
|
||||
const { t } = useTranslation();
|
||||
usePageTitle(t('credentials.title'));
|
||||
const navigate = useNavigate();
|
||||
const [items, setItems] = useState<Credential[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [deleteId, setDeleteId] = useState<string | null>(null);
|
||||
const [deleting, setDeleting] = useState(false);
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
const load = () => {
|
||||
credentials
|
||||
.list()
|
||||
.then((res) => setItems(res.data))
|
||||
.finally(() => setLoading(false));
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
load();
|
||||
}, []);
|
||||
|
||||
const requestDelete = (id: string) => {
|
||||
setDeleteId(id);
|
||||
};
|
||||
|
||||
const handleDelete = async () => {
|
||||
if (!deleteId) return;
|
||||
setDeleting(true);
|
||||
try {
|
||||
await credentials.remove(deleteId);
|
||||
setItems((prev) => prev.filter((c) => c.id !== deleteId));
|
||||
setDeleteId(null);
|
||||
} finally {
|
||||
setDeleting(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleImport = async (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const file = e.target.files?.[0];
|
||||
if (!file) return;
|
||||
e.target.value = '';
|
||||
try {
|
||||
const text = await file.text();
|
||||
const payload = yamlParse(text) as unknown;
|
||||
const imported = await credentials.importCredential(payload);
|
||||
navigate(`/credentials/${imported.id}`);
|
||||
} catch {
|
||||
// Import errors are silently ignored
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={styles.pageToolbar}>
|
||||
<Breadcrumbs items={[{ label: t('credentials.title'), icon: <KeyRound size={14} /> }]} />
|
||||
<div className={styles.toolbarActions}>
|
||||
<input
|
||||
ref={fileInputRef}
|
||||
type="file"
|
||||
accept=".yaml,.yml,.json"
|
||||
style={{ display: 'none' }}
|
||||
onChange={handleImport}
|
||||
/>
|
||||
<Button variant="secondary" size="sm" onClick={() => fileInputRef.current?.click()}>
|
||||
<Download size={14} />
|
||||
{t('credentials.action_import')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
{loading ? (
|
||||
<p className={styles.muted}>{t('credentials.loading')}</p>
|
||||
) : (
|
||||
<div className={styles.envGrid}>
|
||||
{items.map((credential) => (
|
||||
<CredentialCard key={credential.id} credential={credential} onDelete={requestDelete} />
|
||||
))}
|
||||
<AddCredentialCard />
|
||||
</div>
|
||||
)}
|
||||
|
||||
<DeleteConfirmationModal
|
||||
open={deleteId != null}
|
||||
title={t('credentials.action_delete')}
|
||||
message={t('common.confirm_delete_credential')}
|
||||
onClose={() => setDeleteId(null)}
|
||||
onConfirm={handleDelete}
|
||||
isDeleting={deleting}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
import { useEffect, useState, SubmitEvent } from 'react';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { usePageTitle } from '../../hooks/usePageTitle';
|
||||
import { KeyRound, X, Save } from 'lucide-react';
|
||||
import { credentials } from '../../api';
|
||||
import type { Credential } from '../../api';
|
||||
import { Breadcrumbs, Button, Card, Input, CodeEditor, useToast } from '../../ui';
|
||||
import styles from '../Page.module.css';
|
||||
|
||||
export function EditCredentialPage() {
|
||||
const { t } = useTranslation();
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const toast = useToast();
|
||||
|
||||
const [credential, setCredential] = useState<Credential | null>(null);
|
||||
const [name, setName] = useState('');
|
||||
usePageTitle(
|
||||
credential
|
||||
? `${t('credentials.edit_title')} — ${credential.name}`
|
||||
: t('credentials.edit_title'),
|
||||
);
|
||||
const [data, setData] = useState('');
|
||||
const [nameError, setNameError] = useState('');
|
||||
const [dataError, setDataError] = useState('');
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!id) return;
|
||||
credentials
|
||||
.get(id)
|
||||
.then((c) => {
|
||||
setCredential(c);
|
||||
setName(c.name);
|
||||
setData(c.data ?? '');
|
||||
})
|
||||
.finally(() => setLoading(false));
|
||||
}, [id]);
|
||||
|
||||
const handleSubmit = async (e: SubmitEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
let valid = true;
|
||||
if (!name.trim()) {
|
||||
setNameError(t('credentials.form_name_required'));
|
||||
valid = false;
|
||||
}
|
||||
if (data.trim()) {
|
||||
try {
|
||||
JSON.parse(data.trim());
|
||||
} catch {
|
||||
setDataError(t('credentials.form_data_invalid_json'));
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
if (!valid) return;
|
||||
setSaving(true);
|
||||
try {
|
||||
await credentials.update(id!, {
|
||||
name: name.trim(),
|
||||
data: data.trim() || null,
|
||||
});
|
||||
toast.success(t('credentials.updated'));
|
||||
navigate(`/credentials/${id}`);
|
||||
} catch (err) {
|
||||
const message = (err as Error).message;
|
||||
toast.error(message);
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={styles.pageToolbar}>
|
||||
<Breadcrumbs
|
||||
items={[
|
||||
{
|
||||
label: t('credentials.title'),
|
||||
icon: <KeyRound size={14} />,
|
||||
onClick: () => navigate('/credentials'),
|
||||
},
|
||||
{
|
||||
label: credential?.name ?? `#${id}`,
|
||||
onClick: () => navigate(`/credentials/${id}`),
|
||||
},
|
||||
{ label: t('credentials.edit_title') },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{loading && <p className={styles.muted}>{t('credentials.loading')}</p>}
|
||||
|
||||
{!loading && credential && (
|
||||
<form onSubmit={handleSubmit} noValidate>
|
||||
<Card className={styles.formCardFull}>
|
||||
<div className={styles.formFields}>
|
||||
<Input
|
||||
label={t('credentials.form_name')}
|
||||
placeholder={t('credentials.form_name_placeholder')}
|
||||
value={name}
|
||||
onChange={(e) => {
|
||||
setName(e.target.value);
|
||||
setNameError('');
|
||||
}}
|
||||
error={nameError || undefined}
|
||||
required
|
||||
autoFocus
|
||||
/>
|
||||
<div className={styles.formField}>
|
||||
<label className={styles.fieldLabel}>
|
||||
{t('credentials.form_data')}
|
||||
<span className={styles.requiredMark}> *</span>
|
||||
</label>
|
||||
<CodeEditor
|
||||
language="json"
|
||||
value={data}
|
||||
onChange={(v) => {
|
||||
setData(v);
|
||||
setDataError('');
|
||||
}}
|
||||
rows={6}
|
||||
error={!!dataError}
|
||||
/>
|
||||
{dataError && <span className={styles.fieldError}>{dataError}</span>}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className={styles.formActions}>
|
||||
<Button
|
||||
type="button"
|
||||
variant="secondary"
|
||||
onClick={() => navigate(`/credentials/${id}`)}
|
||||
>
|
||||
<X size={14} />
|
||||
{t('credentials.action_cancel')}
|
||||
</Button>
|
||||
<Button type="submit" loading={saving}>
|
||||
<Save size={14} />
|
||||
{t('credentials.action_update')}
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
</form>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
import { useState, SubmitEvent } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { usePageTitle } from '../../hooks/usePageTitle';
|
||||
import { X, Globe, Save } from 'lucide-react';
|
||||
import { environments } from '../../api';
|
||||
import { Breadcrumbs, Button, Card, Input, CodeEditor, useToast } from '../../ui';
|
||||
import styles from '../Page.module.css';
|
||||
|
||||
export function CreateEnvironmentPage() {
|
||||
const { t } = useTranslation();
|
||||
usePageTitle(t('environments.create_title'));
|
||||
const navigate = useNavigate();
|
||||
const toast = useToast();
|
||||
|
||||
const [name, setName] = useState('');
|
||||
const [description, setDescription] = useState('');
|
||||
const [dataJson, setDataJson] = useState('{\n "id": "https://id.example.com"\n}');
|
||||
const [nameError, setNameError] = useState('');
|
||||
const [dataError, setDataError] = useState('');
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
const handleSubmit = async (e: SubmitEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
if (!name.trim()) {
|
||||
setNameError(t('environments.form_name_required'));
|
||||
return;
|
||||
}
|
||||
let parsedData: Record<string, string | undefined>;
|
||||
try {
|
||||
const raw = dataJson.trim() ? JSON.parse(dataJson.trim()) : {};
|
||||
if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {
|
||||
throw new Error('invalid');
|
||||
}
|
||||
parsedData = Object.fromEntries(
|
||||
Object.entries(raw as Record<string, unknown>).map(([k, v]) => [
|
||||
k,
|
||||
v == null ? undefined : String(v),
|
||||
]),
|
||||
);
|
||||
setDataError('');
|
||||
} catch {
|
||||
setDataError(t('environments.form_data_invalid_json'));
|
||||
return;
|
||||
}
|
||||
setSaving(true);
|
||||
try {
|
||||
const env = await environments.create(
|
||||
name.trim(),
|
||||
parsedData,
|
||||
description.trim() || undefined,
|
||||
);
|
||||
toast.success(t('environments.created'));
|
||||
navigate(`/environments/${env.id}`);
|
||||
} catch (err) {
|
||||
const message = (err as Error).message;
|
||||
toast.error(message);
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={styles.pageToolbar}>
|
||||
<Breadcrumbs
|
||||
items={[
|
||||
{
|
||||
label: t('environments.title'),
|
||||
icon: <Globe size={14} />,
|
||||
onClick: () => navigate('/environments'),
|
||||
},
|
||||
{ label: t('environments.create_title') },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<form onSubmit={handleSubmit} noValidate>
|
||||
<Card className={styles.formCardFull}>
|
||||
<div className={styles.formFields}>
|
||||
<Input
|
||||
label={t('environments.form_name')}
|
||||
placeholder={t('environments.form_name_placeholder')}
|
||||
value={name}
|
||||
onChange={(e) => {
|
||||
setName(e.target.value);
|
||||
setNameError('');
|
||||
}}
|
||||
error={nameError || undefined}
|
||||
required
|
||||
autoFocus
|
||||
/>
|
||||
<div className={styles.formField}>
|
||||
<label className={styles.fieldLabel}>{t('environments.form_description')}</label>
|
||||
<CodeEditor
|
||||
language="markdown"
|
||||
value={description}
|
||||
onChange={setDescription}
|
||||
rows={6}
|
||||
/>
|
||||
</div>
|
||||
<div className={styles.formField}>
|
||||
<label className={styles.fieldLabel}>{t('environments.form_data')}</label>
|
||||
<CodeEditor
|
||||
language="json"
|
||||
value={dataJson}
|
||||
onChange={(v) => {
|
||||
setDataJson(v);
|
||||
setDataError('');
|
||||
}}
|
||||
rows={8}
|
||||
error={!!dataError}
|
||||
/>
|
||||
{dataError && <span className={styles.fieldError}>{dataError}</span>}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className={styles.formActions}>
|
||||
<Button type="button" variant="secondary" onClick={() => navigate('/environments')}>
|
||||
<X size={14} />
|
||||
{t('environments.action_cancel')}
|
||||
</Button>
|
||||
<Button type="submit" loading={saving}>
|
||||
<Save size={14} />
|
||||
{t('environments.action_save')}
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
import { useEffect, useState, SubmitEvent } from 'react';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { usePageTitle } from '../../hooks/usePageTitle';
|
||||
import { X, Globe, Save } from 'lucide-react';
|
||||
import { environments } from '../../api';
|
||||
import type { Environment } from '../../api';
|
||||
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('');
|
||||
usePageTitle(
|
||||
env ? `${t('environments.edit_title')} — ${env.name}` : t('environments.edit_title'),
|
||||
);
|
||||
const [description, setDescription] = useState('');
|
||||
const [dataJson, setDataJson] = useState('{}');
|
||||
const [nameError, setNameError] = useState('');
|
||||
const [dataError, setDataError] = useState('');
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!id) return;
|
||||
environments
|
||||
.get(id)
|
||||
.then((data) => {
|
||||
setEnv(data);
|
||||
setName(data.name);
|
||||
setDescription(data.description || '');
|
||||
setDataJson(JSON.stringify(data.data ?? {}, null, 2));
|
||||
})
|
||||
.finally(() => setLoading(false));
|
||||
}, [id]);
|
||||
|
||||
const handleSubmit = async (e: SubmitEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
if (!name.trim()) {
|
||||
setNameError(t('environments.form_name_required'));
|
||||
return;
|
||||
}
|
||||
let parsedData: Record<string, string | undefined>;
|
||||
try {
|
||||
const raw = dataJson.trim() ? JSON.parse(dataJson.trim()) : {};
|
||||
if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {
|
||||
throw new Error('invalid');
|
||||
}
|
||||
parsedData = Object.fromEntries(
|
||||
Object.entries(raw as Record<string, unknown>).map(([k, v]) => [
|
||||
k,
|
||||
v == null ? undefined : String(v),
|
||||
]),
|
||||
);
|
||||
setDataError('');
|
||||
} catch {
|
||||
setDataError(t('environments.form_data_invalid_json'));
|
||||
return;
|
||||
}
|
||||
setSaving(true);
|
||||
try {
|
||||
await environments.update(id!, {
|
||||
name: name.trim(),
|
||||
description: description.trim() || undefined,
|
||||
data: parsedData,
|
||||
});
|
||||
toast.success(t('environments.updated'));
|
||||
navigate(`/environments/${id}`);
|
||||
} catch (err) {
|
||||
const message = (err as Error).message;
|
||||
toast.error(message);
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={styles.pageToolbar}>
|
||||
<Breadcrumbs
|
||||
items={[
|
||||
{
|
||||
label: t('environments.title'),
|
||||
icon: <Globe size={14} />,
|
||||
onClick: () => navigate('/environments'),
|
||||
},
|
||||
{
|
||||
label: env?.name ?? `#${id}`,
|
||||
onClick: () => navigate(`/environments/${id}`),
|
||||
},
|
||||
{ label: t('environments.edit_title') },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{loading && <p className={styles.muted}>{t('environments.loading')}</p>}
|
||||
|
||||
{!loading && env && (
|
||||
<form onSubmit={handleSubmit} noValidate>
|
||||
<Card className={styles.formCardFull}>
|
||||
<div className={styles.formFields}>
|
||||
<Input
|
||||
label={t('environments.form_name')}
|
||||
placeholder={t('environments.form_name_placeholder')}
|
||||
value={name}
|
||||
onChange={(e) => {
|
||||
setName(e.target.value);
|
||||
setNameError('');
|
||||
}}
|
||||
error={nameError || undefined}
|
||||
required
|
||||
autoFocus
|
||||
/>
|
||||
<div className={styles.formField}>
|
||||
<label className={styles.fieldLabel}>{t('environments.form_description')}</label>
|
||||
<CodeEditor
|
||||
language="markdown"
|
||||
value={description}
|
||||
onChange={setDescription}
|
||||
rows={6}
|
||||
/>
|
||||
</div>
|
||||
<div className={styles.formField}>
|
||||
<label className={styles.fieldLabel}>{t('environments.form_data')}</label>
|
||||
<CodeEditor
|
||||
language="json"
|
||||
value={dataJson}
|
||||
onChange={(v) => {
|
||||
setDataJson(v);
|
||||
setDataError('');
|
||||
}}
|
||||
rows={8}
|
||||
error={!!dataError}
|
||||
/>
|
||||
{dataError && <span className={styles.fieldError}>{dataError}</span>}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className={styles.formActions}>
|
||||
<Button
|
||||
type="button"
|
||||
variant="secondary"
|
||||
onClick={() => navigate(`/environments/${id}`)}
|
||||
>
|
||||
<X size={14} />
|
||||
{t('environments.action_cancel')}
|
||||
</Button>
|
||||
<Button type="submit" loading={saving}>
|
||||
<Save size={14} />
|
||||
{t('environments.action_update')}
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
</form>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
import { Globe, Pencil, Trash2, Upload } from 'lucide-react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { usePageTitle } from '../../hooks/usePageTitle';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { stringify as yamlStringify } from 'yaml';
|
||||
import type { Environment } from '../../api';
|
||||
import { environments } from '../../api';
|
||||
import { DeleteConfirmationModal } from '../../components/modals';
|
||||
import {
|
||||
Breadcrumbs,
|
||||
Button,
|
||||
Card,
|
||||
DescriptionList,
|
||||
Timestamp,
|
||||
UuidBadge,
|
||||
MarkdownContent,
|
||||
useToast,
|
||||
} from '../../ui';
|
||||
import styles from '../Page.module.css';
|
||||
|
||||
export function EnvironmentDetailPage() {
|
||||
const { t } = useTranslation();
|
||||
const toast = useToast();
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const [env, setEnv] = useState<Environment | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
usePageTitle(env?.name ?? null);
|
||||
const [confirmDeleteOpen, setConfirmDeleteOpen] = useState(false);
|
||||
const [deleting, setDeleting] = useState(false);
|
||||
const dataEntries = Object.entries(env?.data ?? {}).filter(([, v]) => v);
|
||||
|
||||
useEffect(() => {
|
||||
if (!id) return;
|
||||
environments
|
||||
.get(id)
|
||||
.then(setEnv)
|
||||
.catch((err: Error) => toast.error((err as Error).message))
|
||||
.finally(() => setLoading(false));
|
||||
}, [id, toast]);
|
||||
|
||||
const handleDelete = async () => {
|
||||
if (!env) return;
|
||||
setDeleting(true);
|
||||
try {
|
||||
await environments.remove(env.id);
|
||||
navigate('/environments');
|
||||
} finally {
|
||||
setDeleting(false);
|
||||
setConfirmDeleteOpen(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleExport = async () => {
|
||||
if (!env) return;
|
||||
const data = await environments.exportEnvironment(env.id);
|
||||
const blob = new Blob([yamlStringify(data)], { type: 'application/yaml' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `environment-${env.name}.yaml`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={styles.pageToolbar}>
|
||||
<Breadcrumbs
|
||||
items={[
|
||||
{
|
||||
label: t('environments.title'),
|
||||
icon: <Globe size={14} />,
|
||||
onClick: () => navigate('/environments'),
|
||||
},
|
||||
{ label: env?.name ?? `#${id}` },
|
||||
]}
|
||||
/>
|
||||
{env && (
|
||||
<div className={styles.toolbarActions}>
|
||||
<Button variant="secondary" size="sm" onClick={handleExport}>
|
||||
<Upload size={14} />
|
||||
{t('environments.action_export')}
|
||||
</Button>
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
onClick={() => navigate(`/environments/${env.id}/edit`)}
|
||||
>
|
||||
<Pencil size={14} />
|
||||
{t('environments.action_edit')}
|
||||
</Button>
|
||||
<Button variant="danger" size="sm" onClick={() => setConfirmDeleteOpen(true)}>
|
||||
<Trash2 size={14} />
|
||||
{t('environments.action_delete')}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{loading && <p className={styles.muted}>{t('environments.loading')}</p>}
|
||||
|
||||
{env && (
|
||||
<>
|
||||
<Card>
|
||||
<DescriptionList
|
||||
layout="grid"
|
||||
items={[
|
||||
{ term: t('environments.field_id'), detail: <UuidBadge id={env.id} /> },
|
||||
{
|
||||
term: t('environments.field_created'),
|
||||
detail: <Timestamp value={env.createdAt} />,
|
||||
},
|
||||
{
|
||||
term: t('environments.field_updated'),
|
||||
detail: <Timestamp value={env.updatedAt} />,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</Card>
|
||||
|
||||
{env.description && (
|
||||
<div className={styles.stepsSection}>
|
||||
<div className={styles.sectionHeadingRow}>
|
||||
<h2 className={styles.sectionHeading}>{t('environments.field_description')}</h2>
|
||||
</div>
|
||||
<Card>
|
||||
<MarkdownContent content={env.description} />
|
||||
</Card>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className={styles.stepsSection}>
|
||||
<h2 className={styles.sectionHeading}>{t('environments.section_data')}</h2>
|
||||
<Card>
|
||||
{dataEntries.length === 0 ? (
|
||||
<p className={styles.muted}>{t('environments.no_data')}</p>
|
||||
) : (
|
||||
<DescriptionList
|
||||
layout="grid"
|
||||
items={dataEntries.map(([key, value]) => ({
|
||||
term: key,
|
||||
detail: (
|
||||
<a href={value} target="_blank" rel="noopener noreferrer">
|
||||
{value}
|
||||
</a>
|
||||
),
|
||||
}))}
|
||||
/>
|
||||
)}
|
||||
</Card>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
<DeleteConfirmationModal
|
||||
open={confirmDeleteOpen}
|
||||
title={t('environments.action_delete')}
|
||||
message={t('common.confirm_delete_environment')}
|
||||
onClose={() => setConfirmDeleteOpen(false)}
|
||||
onConfirm={handleDelete}
|
||||
isDeleting={deleting}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { usePageTitle } from '../../hooks/usePageTitle';
|
||||
import { Settings, ExternalLink, Pencil, Trash2, Plus, Globe, Download } from 'lucide-react';
|
||||
import { parse as yamlParse } from 'yaml';
|
||||
import { stringify as yamlStringify } from 'yaml';
|
||||
import { environments } from '../../api';
|
||||
import type { Environment } from '../../api';
|
||||
import {
|
||||
Breadcrumbs,
|
||||
Button,
|
||||
Card,
|
||||
ContextMenu,
|
||||
DescriptionList,
|
||||
Timestamp,
|
||||
UuidBadge,
|
||||
} from '../../ui';
|
||||
import { DeleteConfirmationModal } from '../../components/modals';
|
||||
import styles from '../Page.module.css';
|
||||
|
||||
function EnvironmentCard({ env, onDelete }: { env: Environment; onDelete: (id: string) => void }) {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const dataEntries = Object.entries(env.data ?? {}).filter(([, v]) => v);
|
||||
|
||||
const handleExport = async () => {
|
||||
const data = await environments.exportEnvironment(env.id);
|
||||
const blob = new Blob([yamlStringify(data)], { type: 'application/yaml' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `environment-${env.name}.yaml`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
};
|
||||
|
||||
const header = (
|
||||
<div className={styles.envCardHeader}>
|
||||
<span className={styles.envCardName}>{env.name}</span>
|
||||
<div onClick={(e) => e.stopPropagation()}>
|
||||
<ContextMenu
|
||||
align="right"
|
||||
trigger={
|
||||
<Button variant="ghost" size="sm" aria-label={t('environments.menu_label')}>
|
||||
<Settings size={14} />
|
||||
</Button>
|
||||
}
|
||||
items={[
|
||||
{
|
||||
label: t('environments.action_view'),
|
||||
icon: <ExternalLink size={14} />,
|
||||
onClick: () => navigate(`/environments/${env.id}`),
|
||||
},
|
||||
{
|
||||
label: t('environments.action_edit'),
|
||||
icon: <Pencil size={14} />,
|
||||
onClick: () => navigate(`/environments/${env.id}/edit`),
|
||||
},
|
||||
{
|
||||
label: t('environments.action_export'),
|
||||
icon: <Download size={14} />,
|
||||
onClick: () => void handleExport(),
|
||||
},
|
||||
{
|
||||
label: t('environments.action_delete'),
|
||||
icon: <Trash2 size={14} />,
|
||||
variant: 'danger',
|
||||
onClick: () => onDelete(env.id),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
const footer = (
|
||||
<div className={styles.envCardFooter}>
|
||||
<UuidBadge id={env.id} />
|
||||
<Timestamp value={env.updatedAt} />
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<Card
|
||||
className={styles.envCard}
|
||||
header={header}
|
||||
headerVariant="primary"
|
||||
footer={footer}
|
||||
onClick={() => navigate(`/environments/${env.id}`)}
|
||||
>
|
||||
{dataEntries.length > 0 && (
|
||||
<DescriptionList
|
||||
layout="compact"
|
||||
truncate
|
||||
items={dataEntries.map(([key, value]) => ({ term: key, detail: value }))}
|
||||
/>
|
||||
)}
|
||||
{dataEntries.length === 0 && (
|
||||
<p className={styles.envCardEmpty}>{t('environments.no_data')}</p>
|
||||
)}
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function AddEnvironmentCard() {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
return (
|
||||
<div className={styles.envCardAdd}>
|
||||
<Button variant="ghost" onClick={() => navigate('/environments/new')}>
|
||||
<Plus size={16} />
|
||||
{t('environments.action_add')}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function EnvironmentsPage() {
|
||||
const { t } = useTranslation();
|
||||
usePageTitle(t('environments.title'));
|
||||
const navigate = useNavigate();
|
||||
const [items, setItems] = useState<Environment[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [deleteId, setDeleteId] = useState<string | null>(null);
|
||||
const [deleting, setDeleting] = useState(false);
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
const load = () => {
|
||||
environments
|
||||
.list()
|
||||
.then((res) => setItems(res.data))
|
||||
.finally(() => setLoading(false));
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
load();
|
||||
}, []);
|
||||
|
||||
const requestDelete = (id: string) => {
|
||||
setDeleteId(id);
|
||||
};
|
||||
|
||||
const handleDelete = async () => {
|
||||
if (!deleteId) return;
|
||||
setDeleting(true);
|
||||
try {
|
||||
await environments.remove(deleteId);
|
||||
setItems((prev) => prev.filter((e) => e.id !== deleteId));
|
||||
setDeleteId(null);
|
||||
} finally {
|
||||
setDeleting(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleImport = async (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const file = e.target.files?.[0];
|
||||
if (!file) return;
|
||||
e.target.value = '';
|
||||
try {
|
||||
const text = await file.text();
|
||||
const payload = yamlParse(text) as unknown;
|
||||
const imported = await environments.importEnvironment(payload);
|
||||
navigate(`/environments/${imported.id}`);
|
||||
} catch {
|
||||
// Import errors are silently ignored
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={styles.pageToolbar}>
|
||||
<Breadcrumbs items={[{ label: t('environments.title'), icon: <Globe size={14} /> }]} />
|
||||
<div className={styles.toolbarActions}>
|
||||
<input
|
||||
ref={fileInputRef}
|
||||
type="file"
|
||||
accept=".yaml,.yml,.json"
|
||||
style={{ display: 'none' }}
|
||||
onChange={handleImport}
|
||||
/>
|
||||
<Button variant="secondary" size="sm" onClick={() => fileInputRef.current?.click()}>
|
||||
<Download size={14} />
|
||||
{t('environments.action_import')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
{loading ? (
|
||||
<p className={styles.muted}>{t('environments.loading')}</p>
|
||||
) : (
|
||||
<div className={styles.envGrid}>
|
||||
{items.map((env) => (
|
||||
<EnvironmentCard key={env.id} env={env} onDelete={requestDelete} />
|
||||
))}
|
||||
<AddEnvironmentCard />
|
||||
</div>
|
||||
)}
|
||||
|
||||
<DeleteConfirmationModal
|
||||
open={deleteId != null}
|
||||
title={t('environments.action_delete')}
|
||||
message={t('common.confirm_delete_environment')}
|
||||
onClose={() => setDeleteId(null)}
|
||||
onConfirm={handleDelete}
|
||||
isDeleting={deleting}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
import { useState } from 'react';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { usePageTitle } from '../../hooks/usePageTitle';
|
||||
import { Activity } from 'lucide-react';
|
||||
import { runs } from '../../api';
|
||||
import type { ScenarioRun, ScenarioRunStatus } from '../../api';
|
||||
import {
|
||||
AutoRefreshIndicator,
|
||||
Badge,
|
||||
Breadcrumbs,
|
||||
Table,
|
||||
Timestamp,
|
||||
UuidBadge,
|
||||
type TableColumn,
|
||||
type SortDirection,
|
||||
} from '../../ui';
|
||||
import type { BadgeVariant } from '../../ui';
|
||||
import styles from '../Page.module.css';
|
||||
|
||||
const STATUS_VARIANT: Record<ScenarioRunStatus, BadgeVariant> = {
|
||||
pending: 'neutral',
|
||||
in_progress: 'info',
|
||||
pass: 'success',
|
||||
fail: 'error',
|
||||
};
|
||||
|
||||
const STATUS_LABEL: Record<ScenarioRunStatus, string> = {
|
||||
pending: 'Pending',
|
||||
in_progress: 'Running',
|
||||
pass: 'Pass',
|
||||
fail: 'Fail',
|
||||
};
|
||||
|
||||
type AllRunRow = ScenarioRun & {
|
||||
scenario: { id: string; name: string };
|
||||
};
|
||||
|
||||
export function AllRunsPage() {
|
||||
const { t } = useTranslation();
|
||||
usePageTitle(t('runs.title'));
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [sortBy, setSortBy] = useState('createdAt');
|
||||
const [sortDir, setSortDir] = useState<SortDirection>('desc');
|
||||
const [page, setPage] = useState(1);
|
||||
const [pageSize, setPageSize] = useState(20);
|
||||
|
||||
const { data, isLoading, error, refetch } = useQuery({
|
||||
queryKey: ['runs', sortBy, sortDir, page, pageSize],
|
||||
queryFn: () =>
|
||||
runs.listAll(page, pageSize, undefined, sortBy, sortDir === 'asc' ? 'ASC' : 'DESC'),
|
||||
refetchInterval: 10_000,
|
||||
staleTime: 0,
|
||||
});
|
||||
|
||||
const items = (data?.data ?? []) as AllRunRow[];
|
||||
const total = data?.total ?? 0;
|
||||
|
||||
const handleSort = (key: string, dir: SortDirection) => {
|
||||
setSortBy(key);
|
||||
setSortDir(dir);
|
||||
setPage(1);
|
||||
};
|
||||
|
||||
const handlePageChange = (p: number) => setPage(p);
|
||||
|
||||
const handlePageSizeChange = (size: number) => {
|
||||
setPageSize(size);
|
||||
setPage(1);
|
||||
};
|
||||
|
||||
const columns: TableColumn<AllRunRow>[] = [
|
||||
{ key: 'id', header: t('runs.col_id'), render: (r) => <UuidBadge id={r.id} />, width: 60 },
|
||||
{
|
||||
key: 'scenario.name',
|
||||
header: t('runs.col_scenario'),
|
||||
sortable: true,
|
||||
render: (r) => (
|
||||
<span
|
||||
className={styles.linkCell}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
navigate(`/scenarios/${r.scenario.id}`);
|
||||
}}
|
||||
>
|
||||
{r.scenario.name}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'status',
|
||||
header: t('runs.col_status'),
|
||||
width: 110,
|
||||
sortable: true,
|
||||
render: (r) => <Badge variant={STATUS_VARIANT[r.status]}>{STATUS_LABEL[r.status]}</Badge>,
|
||||
},
|
||||
{
|
||||
key: 'createdAt',
|
||||
header: t('runs.col_created'),
|
||||
width: 160,
|
||||
sortable: true,
|
||||
render: (r) => <Timestamp value={r.createdAt} />,
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={styles.pageToolbar}>
|
||||
<Breadcrumbs items={[{ label: t('runs.title'), icon: <Activity size={14} /> }]} />
|
||||
<AutoRefreshIndicator
|
||||
active
|
||||
pulseKey={items.length}
|
||||
error={!!error}
|
||||
onClick={() => refetch()}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Table
|
||||
columns={columns}
|
||||
data={items}
|
||||
rowKey={(r) => r.id}
|
||||
loading={isLoading}
|
||||
emptyMessage={t('runs.empty')}
|
||||
pageSize={pageSize}
|
||||
pageSizeOptions={[10, 20, 50]}
|
||||
onRowClick={(r) => navigate(`/scenarios/${r.scenarioId}/runs/${r.id}`)}
|
||||
sortBy={sortBy}
|
||||
sortDir={sortDir}
|
||||
onSort={handleSort}
|
||||
total={total}
|
||||
page={page}
|
||||
onPageChange={handlePageChange}
|
||||
onPageSizeChange={handlePageSizeChange}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,528 @@
|
||||
import { useEffect, useRef, useState, useCallback } from 'react';
|
||||
import { useNavigate, useParams, Link } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { usePageTitle } from '../../hooks/usePageTitle';
|
||||
import { runs, runFiles } from '../../api';
|
||||
import type {
|
||||
Scenario,
|
||||
ScenarioRunDetail,
|
||||
ScenarioRunStep,
|
||||
ScenarioRunLog,
|
||||
ScenarioRunStatus,
|
||||
RunStepStatus,
|
||||
LogLevel,
|
||||
FileMetadata,
|
||||
} from '../../api';
|
||||
import { scenarios } from '../../api';
|
||||
import {
|
||||
AutoRefreshIndicator,
|
||||
Badge,
|
||||
Button,
|
||||
Breadcrumbs,
|
||||
Card,
|
||||
CodeBlock,
|
||||
DescriptionList,
|
||||
Pagination,
|
||||
Search,
|
||||
Table,
|
||||
Timestamp,
|
||||
UuidBadge,
|
||||
type TableColumn,
|
||||
} from '../../ui';
|
||||
import type { BadgeVariant } from '../../ui';
|
||||
import { ChevronDown, ChevronRight, ClipboardList, Activity, Download } from 'lucide-react';
|
||||
import styles from '../Page.module.css';
|
||||
|
||||
const RUN_STATUS_VARIANT: Record<ScenarioRunStatus, BadgeVariant> = {
|
||||
pending: 'neutral',
|
||||
in_progress: 'info',
|
||||
pass: 'success',
|
||||
fail: 'error',
|
||||
};
|
||||
|
||||
const RUN_STATUS_LABEL: Record<ScenarioRunStatus, string> = {
|
||||
pending: 'Pending',
|
||||
in_progress: 'Running',
|
||||
pass: 'Pass',
|
||||
fail: 'Fail',
|
||||
};
|
||||
|
||||
const STEP_STATUS_VARIANT: Record<RunStepStatus, BadgeVariant> = {
|
||||
waiting: 'neutral',
|
||||
pending: 'neutral',
|
||||
in_progress: 'info',
|
||||
pass: 'success',
|
||||
fail: 'error',
|
||||
cancelled: 'warning',
|
||||
};
|
||||
|
||||
const LOG_LEVEL_VARIANT: Record<LogLevel, BadgeVariant> = {
|
||||
log: 'neutral',
|
||||
warn: 'warning',
|
||||
error: 'error',
|
||||
};
|
||||
|
||||
const FINAL: ScenarioRunStatus[] = ['pass', 'fail'];
|
||||
|
||||
export function RunDetailPage() {
|
||||
const { t } = useTranslation();
|
||||
const { id, runId } = useParams<{ id: string; runId: string }>();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [scenario, setScenario] = useState<Scenario | null>(null);
|
||||
const [run, setRun] = useState<ScenarioRunDetail | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
usePageTitle(scenario ? `${t('runs.title')} — ${scenario.name}` : t('runs.title'));
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [polling, setPolling] = useState(false);
|
||||
const [pulseKey, setPulseKey] = useState(0);
|
||||
const [logPage, setLogPage] = useState(1);
|
||||
const [logSearch, setLogSearch] = useState('');
|
||||
const [debouncedSearch, setDebouncedSearch] = useState('');
|
||||
const [expandAll, setExpandAll] = useState(false);
|
||||
const [expandedStepIds, setExpandedStepIds] = useState<Set<string>>(new Set());
|
||||
const [artifacts, setArtifacts] = useState<FileMetadata[]>([]);
|
||||
const [artifactsTotal, setArtifactsTotal] = useState(0);
|
||||
const [artifactsLoading, setArtifactsLoading] = useState(false);
|
||||
const logSearchRef = useRef('');
|
||||
const LOG_PAGE_SIZE = 25;
|
||||
const pollRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
||||
|
||||
const stopPolling = () => {
|
||||
if (pollRef.current) {
|
||||
clearInterval(pollRef.current);
|
||||
pollRef.current = null;
|
||||
setPolling(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleFileDownload = (url: string, filename: string) => {
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = filename;
|
||||
link.click();
|
||||
};
|
||||
|
||||
const isFileExpired = (file: FileMetadata) =>
|
||||
file.expiresAt != null && new Date(file.expiresAt).getTime() <= Date.now();
|
||||
|
||||
const manualRefresh = () => {
|
||||
if (!id || !runId) return;
|
||||
runs
|
||||
.get(id, runId, logSearchRef.current)
|
||||
.then((r) => {
|
||||
setRun(r);
|
||||
setError(null);
|
||||
setPulseKey((k) => k + 1);
|
||||
})
|
||||
.catch((err: Error) => setError(err.message));
|
||||
};
|
||||
|
||||
const loadArtifacts = useCallback(async () => {
|
||||
if (!id || !runId) return;
|
||||
setArtifactsLoading(true);
|
||||
try {
|
||||
const result = await runFiles.list(id, runId);
|
||||
setArtifacts(result.items);
|
||||
setArtifactsTotal(result.total);
|
||||
} catch {
|
||||
// Silently fail - artifacts are not critical
|
||||
setArtifacts([]);
|
||||
setArtifactsTotal(0);
|
||||
} finally {
|
||||
setArtifactsLoading(false);
|
||||
}
|
||||
}, [id, runId]);
|
||||
|
||||
useEffect(() => {
|
||||
const t = setTimeout(() => {
|
||||
setDebouncedSearch(logSearch);
|
||||
logSearchRef.current = logSearch;
|
||||
setLogPage(1);
|
||||
}, 300);
|
||||
return () => clearTimeout(t);
|
||||
}, [logSearch]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!id || !runId || polling) return;
|
||||
runs
|
||||
.get(id, runId, debouncedSearch)
|
||||
.then(setRun)
|
||||
.catch(() => undefined);
|
||||
}, [id, runId, polling, debouncedSearch]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!id || !runId) return;
|
||||
let cancelled = false;
|
||||
|
||||
Promise.all([scenarios.get(id), runs.get(id, runId)])
|
||||
.then(([sc, r]) => {
|
||||
if (cancelled) return;
|
||||
setScenario(sc);
|
||||
setRun(r);
|
||||
loadArtifacts();
|
||||
if (!FINAL.includes(r.status)) {
|
||||
setPolling(true);
|
||||
pollRef.current = setInterval(async () => {
|
||||
try {
|
||||
const updated = await runs.get(id, runId, logSearchRef.current);
|
||||
if (cancelled) return;
|
||||
setRun(updated);
|
||||
setPulseKey((k) => k + 1);
|
||||
if (FINAL.includes(updated.status)) {
|
||||
stopPolling();
|
||||
await loadArtifacts();
|
||||
}
|
||||
} catch {
|
||||
stopPolling();
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
})
|
||||
.catch((err: Error) => {
|
||||
if (!cancelled) setError(err.message);
|
||||
})
|
||||
.finally(() => {
|
||||
if (!cancelled) setLoading(false);
|
||||
});
|
||||
|
||||
return () => {
|
||||
cancelled = true;
|
||||
stopPolling();
|
||||
};
|
||||
}, [id, runId, loadArtifacts]);
|
||||
|
||||
const stepColumns: TableColumn<ScenarioRunStep>[] = [
|
||||
{ key: 'order', header: t('runs.step_order'), render: (s) => s.order, width: 50 },
|
||||
{
|
||||
key: 'title',
|
||||
header: t('runs.step_title'),
|
||||
width: 220,
|
||||
render: (s) => s.scenarioStep?.title ?? <span className={styles.muted}>–</span>,
|
||||
},
|
||||
{
|
||||
key: 'status',
|
||||
header: t('runs.step_status'),
|
||||
width: 110,
|
||||
render: (s) => (
|
||||
<Badge variant={STEP_STATUS_VARIANT[s.status]}>{s.status.replace('_', ' ')}</Badge>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'description',
|
||||
header: (
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
gap: '8px',
|
||||
}}
|
||||
>
|
||||
<span>{t('runs.step_description')}</span>
|
||||
{run?.stepRuns.some((s) => s.output) && (
|
||||
<button
|
||||
onClick={() => {
|
||||
if (expandAll) {
|
||||
setExpandAll(false);
|
||||
setExpandedStepIds(new Set());
|
||||
} else {
|
||||
setExpandAll(true);
|
||||
setExpandedStepIds(
|
||||
new Set(run?.stepRuns.filter((s) => s.output).map((s) => s.id) ?? []),
|
||||
);
|
||||
}
|
||||
}}
|
||||
style={{
|
||||
background: 'none',
|
||||
border: 'none',
|
||||
padding: '0 4px',
|
||||
cursor: 'pointer',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
color: 'inherit',
|
||||
}}
|
||||
title={expandAll ? 'Collapse all' : 'Expand all'}
|
||||
>
|
||||
{expandAll ? <ChevronDown size={16} /> : <ChevronRight size={16} />}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
),
|
||||
render: (s) => {
|
||||
const isExpanded = expandAll || expandedStepIds.has(s.id);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'flex-start',
|
||||
gap: '8px',
|
||||
marginBottom: isExpanded && s.output ? '8px' : 0,
|
||||
}}
|
||||
>
|
||||
{s.output && (
|
||||
<button
|
||||
onClick={() => {
|
||||
const newSet = new Set(expandedStepIds);
|
||||
if (newSet.has(s.id)) {
|
||||
newSet.delete(s.id);
|
||||
} else {
|
||||
newSet.add(s.id);
|
||||
}
|
||||
setExpandedStepIds(newSet);
|
||||
}}
|
||||
style={{
|
||||
background: 'none',
|
||||
border: 'none',
|
||||
padding: 0,
|
||||
cursor: 'pointer',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
flexShrink: 0,
|
||||
marginTop: '2px',
|
||||
}}
|
||||
>
|
||||
{isExpanded ? <ChevronDown size={16} /> : <ChevronRight size={16} />}
|
||||
</button>
|
||||
)}
|
||||
<code style={{ wordBreak: 'break-word' }}>
|
||||
{s.description ? (
|
||||
s.description
|
||||
) : s.output ? (
|
||||
<span title={`${s.output.length} bytes`}>{s.output.length} bytes</span>
|
||||
) : (
|
||||
<span className={styles.muted}>–</span>
|
||||
)}
|
||||
</code>
|
||||
</div>
|
||||
{isExpanded && s.output && (
|
||||
<div style={{ marginLeft: '24px' }}>
|
||||
<CodeBlock
|
||||
code={(() => {
|
||||
try {
|
||||
return JSON.stringify(JSON.parse(s.output), null, 2);
|
||||
} catch {
|
||||
return s.output;
|
||||
}
|
||||
})()}
|
||||
language="json"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const logColumns: TableColumn<ScenarioRunLog>[] = [
|
||||
{
|
||||
key: 'level',
|
||||
header: t('runs.log_level'),
|
||||
width: 70,
|
||||
render: (l) => <Badge variant={LOG_LEVEL_VARIANT[l.level]}>{l.level}</Badge>,
|
||||
},
|
||||
{
|
||||
key: 'message',
|
||||
header: t('runs.log_message'),
|
||||
render: (l) => <code style={{ wordBreak: 'break-word' }}>{l.message}</code>,
|
||||
},
|
||||
{
|
||||
key: 'time',
|
||||
header: t('runs.log_time'),
|
||||
width: 160,
|
||||
render: (l) => <Timestamp value={l.createdAt} />,
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={styles.pageToolbar}>
|
||||
<Breadcrumbs
|
||||
items={[
|
||||
{
|
||||
label: t('scenarios.title'),
|
||||
icon: <ClipboardList size={14} />,
|
||||
onClick: () => navigate('/scenarios'),
|
||||
},
|
||||
{
|
||||
label: scenario?.name ?? `${id}`,
|
||||
onClick: () => navigate(`/scenarios/${id}`),
|
||||
},
|
||||
{
|
||||
label: t('runs.title'),
|
||||
icon: <Activity size={14} />,
|
||||
onClick: () => navigate(`/scenarios/${id}/runs`),
|
||||
},
|
||||
{ label: `${runId}` },
|
||||
]}
|
||||
/>
|
||||
<AutoRefreshIndicator
|
||||
active={polling}
|
||||
pulseKey={pulseKey}
|
||||
error={!!error}
|
||||
onClick={manualRefresh}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{loading && <p className={styles.muted}>{t('runs.loading')}</p>}
|
||||
|
||||
{run && (
|
||||
<>
|
||||
<Card>
|
||||
<DescriptionList
|
||||
layout="grid"
|
||||
items={(() => {
|
||||
const items = [
|
||||
{ term: t('runs.field_id'), detail: <UuidBadge id={run.id} /> },
|
||||
{
|
||||
term: t('runs.field_status'),
|
||||
detail: (
|
||||
<Badge variant={RUN_STATUS_VARIANT[run.status]}>
|
||||
{RUN_STATUS_LABEL[run.status]}
|
||||
</Badge>
|
||||
),
|
||||
},
|
||||
{ term: t('runs.field_created'), detail: <Timestamp value={run.createdAt} /> },
|
||||
{ term: t('runs.field_updated'), detail: <Timestamp value={run.updatedAt} /> },
|
||||
];
|
||||
if (run.environment) {
|
||||
items.push({
|
||||
term: 'Environment',
|
||||
detail: (
|
||||
<Link
|
||||
to={`/environments/${run.environment.id}`}
|
||||
style={{ color: 'var(--color-link)' }}
|
||||
>
|
||||
{run.environment.name}
|
||||
</Link>
|
||||
),
|
||||
});
|
||||
}
|
||||
if (run.session) {
|
||||
items.push({
|
||||
term: 'Session',
|
||||
detail: (
|
||||
<Link
|
||||
to={`/sessions/${run.session.id}`}
|
||||
style={{ color: 'var(--color-link)' }}
|
||||
>
|
||||
{run.session.sessionName}
|
||||
</Link>
|
||||
),
|
||||
});
|
||||
}
|
||||
return items;
|
||||
})()}
|
||||
/>
|
||||
</Card>
|
||||
|
||||
{run.stepRuns.length > 0 && (
|
||||
<div className={styles.stepsSection}>
|
||||
<h2 className={styles.sectionHeading}>{t('runs.steps_heading')}</h2>
|
||||
<Table
|
||||
columns={stepColumns}
|
||||
data={run.stepRuns}
|
||||
rowKey={(s) => s.id}
|
||||
loading={false}
|
||||
emptyMessage=""
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{run.logs.length > 0 && (
|
||||
<div className={styles.stepsSection}>
|
||||
<div className={styles.sectionHeadingRow}>
|
||||
<h2 className={styles.sectionHeading}>{t('runs.logs_heading')}</h2>
|
||||
<Search
|
||||
value={logSearch}
|
||||
onChange={setLogSearch}
|
||||
placeholder={t('runs.logs_search_placeholder')}
|
||||
/>
|
||||
</div>
|
||||
<Table
|
||||
columns={logColumns}
|
||||
data={run.logs.slice((logPage - 1) * LOG_PAGE_SIZE, logPage * LOG_PAGE_SIZE)}
|
||||
rowKey={(l) => l.id}
|
||||
loading={false}
|
||||
emptyMessage=""
|
||||
/>
|
||||
{run.logs.length > LOG_PAGE_SIZE && (
|
||||
<Pagination
|
||||
page={logPage}
|
||||
pageSize={LOG_PAGE_SIZE}
|
||||
total={run.logs.length}
|
||||
onPageChange={setLogPage}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{(artifactsTotal > 0 || artifactsLoading) && (
|
||||
<div className={styles.stepsSection}>
|
||||
<h2 className={styles.sectionHeading}>{t('files.artifactsTitle')}</h2>
|
||||
<Table<FileMetadata>
|
||||
loading={artifactsLoading}
|
||||
data={artifacts}
|
||||
rowKey={(f) => f.id}
|
||||
columns={
|
||||
[
|
||||
{ key: 'name', header: t('files.name'), render: (f) => f.name },
|
||||
{
|
||||
key: 'mimeType',
|
||||
header: t('files.mimeType'),
|
||||
render: (f) => f.mimeType,
|
||||
},
|
||||
{
|
||||
key: 'size',
|
||||
header: t('files.size'),
|
||||
render: (f) => `${(f.size / 1024).toFixed(1)} KB`,
|
||||
},
|
||||
{
|
||||
key: 'expiresAt',
|
||||
header: t('files.expiresAt'),
|
||||
render: (f) => (f.expiresAt ? <Timestamp value={f.expiresAt} /> : '—'),
|
||||
},
|
||||
{
|
||||
key: 'createdAt',
|
||||
header: t('files.createdAt'),
|
||||
render: (f) => <Timestamp value={f.createdAt} />,
|
||||
},
|
||||
{
|
||||
key: 'download',
|
||||
header: '',
|
||||
render: (f) => {
|
||||
const expired = isFileExpired(f);
|
||||
const tooltip = expired ? t('files.expiredTooltip') : t('files.download');
|
||||
|
||||
return (
|
||||
<span title={tooltip}>
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
title={tooltip}
|
||||
aria-label={tooltip}
|
||||
disabled={expired}
|
||||
onClick={() =>
|
||||
handleFileDownload(runFiles.contentUrl(id!, runId!, f.id), f.name)
|
||||
}
|
||||
>
|
||||
<Download size={14} />
|
||||
</Button>
|
||||
</span>
|
||||
);
|
||||
},
|
||||
},
|
||||
] satisfies TableColumn<FileMetadata>[]
|
||||
}
|
||||
emptyMessage={t('files.empty')}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { usePageTitle } from '../../hooks/usePageTitle';
|
||||
import { Play, ClipboardList, Activity } from 'lucide-react';
|
||||
import { environments, scenarios, runs } from '../../api';
|
||||
import type { Environment, Scenario, ScenarioRun, ScenarioRunStatus } from '../../api';
|
||||
import {
|
||||
AutoRefreshIndicator,
|
||||
Badge,
|
||||
Breadcrumbs,
|
||||
Button,
|
||||
Modal,
|
||||
Select,
|
||||
Table,
|
||||
Timestamp,
|
||||
UuidBadge,
|
||||
useToast,
|
||||
type TableColumn,
|
||||
type SortDirection,
|
||||
} from '../../ui';
|
||||
import type { BadgeVariant } from '../../ui';
|
||||
import styles from '../Page.module.css';
|
||||
|
||||
const STATUS_VARIANT: Record<ScenarioRunStatus, BadgeVariant> = {
|
||||
pending: 'neutral',
|
||||
in_progress: 'info',
|
||||
pass: 'success',
|
||||
fail: 'error',
|
||||
};
|
||||
|
||||
const STATUS_LABEL: Record<ScenarioRunStatus, string> = {
|
||||
pending: 'Pending',
|
||||
in_progress: 'Running',
|
||||
pass: 'Pass',
|
||||
fail: 'Fail',
|
||||
};
|
||||
|
||||
type RunRow = ScenarioRun;
|
||||
|
||||
export function RunsPage() {
|
||||
const { t } = useTranslation();
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const toast = useToast();
|
||||
|
||||
const [scenario, setScenario] = useState<Scenario | null>(null);
|
||||
const [items, setItems] = useState<RunRow[]>([]);
|
||||
usePageTitle(scenario ? `${t('runs.title')} — ${scenario.name}` : t('runs.title'));
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [pulseKey, setPulseKey] = useState(0);
|
||||
const [runModalOpen, setRunModalOpen] = useState(false);
|
||||
const [running, setRunning] = useState(false);
|
||||
const [envs, setEnvs] = useState<Environment[]>([]);
|
||||
const [selectedEnvId, setSelectedEnvId] = useState('');
|
||||
const pollRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
||||
const hasDataRef = useRef(false);
|
||||
|
||||
const [sortBy, setSortBy] = useState('createdAt');
|
||||
const [sortDir, setSortDir] = useState<SortDirection>('desc');
|
||||
const [page, setPage] = useState(1);
|
||||
const [pageSize, setPageSize] = useState(20);
|
||||
const [total, setTotal] = useState(0);
|
||||
|
||||
// Keep refs so the poll interval always reads current values
|
||||
const sortByRef = useRef(sortBy);
|
||||
const sortDirRef = useRef(sortDir);
|
||||
const pageRef = useRef(page);
|
||||
const pageSizeRef = useRef(pageSize);
|
||||
sortByRef.current = sortBy;
|
||||
sortDirRef.current = sortDir;
|
||||
pageRef.current = page;
|
||||
pageSizeRef.current = pageSize;
|
||||
|
||||
const load = useCallback(
|
||||
(orderBy: string, orderDir: SortDirection, p: number, limit: number) => {
|
||||
if (!id) return;
|
||||
if (!hasDataRef.current) setLoading(true);
|
||||
Promise.all([
|
||||
scenarios.get(id!),
|
||||
runs.list(id!, p, limit, orderBy, orderDir === 'asc' ? 'ASC' : 'DESC'),
|
||||
])
|
||||
.then(([sc, res]) => {
|
||||
setScenario(sc);
|
||||
setItems(res.data);
|
||||
setTotal(res.total);
|
||||
setError(null);
|
||||
setPulseKey((k) => k + 1);
|
||||
hasDataRef.current = true;
|
||||
})
|
||||
.catch((err: Error) => setError(err.message))
|
||||
.finally(() => setLoading(false));
|
||||
},
|
||||
[id],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
load('createdAt', 'desc', 1, 20);
|
||||
pollRef.current = setInterval(
|
||||
() => load(sortByRef.current, sortDirRef.current, pageRef.current, pageSizeRef.current),
|
||||
10_000,
|
||||
);
|
||||
return () => {
|
||||
if (pollRef.current) clearInterval(pollRef.current);
|
||||
};
|
||||
}, [load]);
|
||||
|
||||
const handleSort = (key: string, dir: SortDirection) => {
|
||||
setSortBy(key);
|
||||
setSortDir(dir);
|
||||
setPage(1);
|
||||
load(key, dir, 1, pageSize);
|
||||
};
|
||||
|
||||
const handlePageChange = (p: number) => {
|
||||
setPage(p);
|
||||
load(sortBy, sortDir, p, pageSize);
|
||||
};
|
||||
|
||||
const handlePageSizeChange = (size: number) => {
|
||||
setPageSize(size);
|
||||
setPage(1);
|
||||
load(sortBy, sortDir, 1, size);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
environments
|
||||
.list(1, 200)
|
||||
.then((res) => {
|
||||
setEnvs(res.data);
|
||||
setSelectedEnvId((prev) => prev || res.data[0]?.id || '');
|
||||
})
|
||||
.catch(() => {});
|
||||
}, []);
|
||||
|
||||
const handleRun = async () => {
|
||||
if (!selectedEnvId) {
|
||||
toast.error(t('scenarios.run_modal_env_required'));
|
||||
return;
|
||||
}
|
||||
setRunning(true);
|
||||
try {
|
||||
const run = await scenarios.run(id!, selectedEnvId);
|
||||
toast.success(t('scenarios.run_started'));
|
||||
navigate(`/scenarios/${id}/runs/${run.id}`);
|
||||
setRunModalOpen(false);
|
||||
} catch (err) {
|
||||
toast.error((err as Error).message);
|
||||
} finally {
|
||||
setRunning(false);
|
||||
}
|
||||
};
|
||||
|
||||
const columns: TableColumn<RunRow>[] = [
|
||||
{ key: 'id', header: t('runs.col_id'), render: (r) => <UuidBadge id={r.id} />, width: 60 },
|
||||
{
|
||||
key: 'status',
|
||||
header: t('runs.col_status'),
|
||||
width: 100,
|
||||
sortable: true,
|
||||
render: (r) => <Badge variant={STATUS_VARIANT[r.status]}>{STATUS_LABEL[r.status]}</Badge>,
|
||||
},
|
||||
{
|
||||
key: 'createdAt',
|
||||
header: t('runs.col_created'),
|
||||
width: 160,
|
||||
sortable: true,
|
||||
render: (r) => <Timestamp value={r.createdAt} />,
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={styles.pageToolbar}>
|
||||
<Breadcrumbs
|
||||
items={[
|
||||
{
|
||||
label: t('scenarios.title'),
|
||||
icon: <ClipboardList size={14} />,
|
||||
onClick: () => navigate('/scenarios'),
|
||||
},
|
||||
{
|
||||
label: scenario?.name ?? `#${id}`,
|
||||
onClick: () => navigate(`/scenarios/${id}`),
|
||||
},
|
||||
{ label: t('runs.title'), icon: <Activity size={14} /> },
|
||||
]}
|
||||
/>
|
||||
<div className={styles.toolbarActions}>
|
||||
<AutoRefreshIndicator
|
||||
active
|
||||
pulseKey={pulseKey}
|
||||
error={!!error}
|
||||
onClick={() => load(sortBy, sortDir, page, pageSize)}
|
||||
/>
|
||||
<Button size="sm" onClick={() => setRunModalOpen(true)}>
|
||||
<Play size={14} />
|
||||
{t('runs.action_run')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Table
|
||||
columns={columns}
|
||||
data={items}
|
||||
rowKey={(r) => r.id}
|
||||
loading={loading}
|
||||
emptyMessage={t('runs.empty')}
|
||||
pageSize={pageSize}
|
||||
pageSizeOptions={[10, 20, 50]}
|
||||
onRowClick={(r) => navigate(`/scenarios/${id}/runs/${r.id}`)}
|
||||
sortBy={sortBy}
|
||||
sortDir={sortDir}
|
||||
onSort={handleSort}
|
||||
total={total}
|
||||
page={page}
|
||||
onPageChange={handlePageChange}
|
||||
onPageSizeChange={handlePageSizeChange}
|
||||
/>
|
||||
|
||||
<Modal
|
||||
open={runModalOpen}
|
||||
title={t('scenarios.run_modal_title')}
|
||||
onClose={() => !running && setRunModalOpen(false)}
|
||||
footer={
|
||||
<>
|
||||
<Button variant="secondary" onClick={() => setRunModalOpen(false)} disabled={running}>
|
||||
{t('common.button_cancel')}
|
||||
</Button>
|
||||
<Button variant="primary" onClick={handleRun} disabled={running || !selectedEnvId}>
|
||||
{t('runs.action_run')}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
{envs.length === 0 ? (
|
||||
<p>{t('scenarios.run_modal_no_env')}</p>
|
||||
) : (
|
||||
<Select
|
||||
label={t('scenarios.run_modal_env_label')}
|
||||
value={selectedEnvId}
|
||||
onChange={(e) => setSelectedEnvId(e.target.value)}
|
||||
options={envs.map((env) => ({ value: env.id, label: env.name }))}
|
||||
/>
|
||||
)}
|
||||
</Modal>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
import { useEffect, useState, SubmitEvent } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { usePageTitle } from '../../hooks/usePageTitle';
|
||||
import { X, Save, ClipboardList } from 'lucide-react';
|
||||
import { scenarios, environments } from '../../api';
|
||||
import type { Environment } from '../../api';
|
||||
import { Breadcrumbs, Button, Card, Input, CodeEditor, Select, useToast } from '../../ui';
|
||||
import styles from '../Page.module.css';
|
||||
|
||||
export function CreateScenarioPage() {
|
||||
const { t } = useTranslation();
|
||||
usePageTitle(t('scenarios.create_title'));
|
||||
const navigate = useNavigate();
|
||||
const toast = useToast();
|
||||
|
||||
const [name, setName] = useState('');
|
||||
const [description, setDescription] = useState('');
|
||||
const [environmentId, setEnvironmentId] = useState('');
|
||||
const [envs, setEnvs] = useState<Environment[]>([]);
|
||||
const [nameError, setNameError] = useState('');
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
environments
|
||||
.list(1, 200)
|
||||
.then((r) => setEnvs(r?.data ?? []))
|
||||
.catch(() => {});
|
||||
}, []);
|
||||
|
||||
const handleSubmit = async (e: SubmitEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
if (!name.trim()) {
|
||||
setNameError(t('scenarios.form_name_required'));
|
||||
return;
|
||||
}
|
||||
setSaving(true);
|
||||
try {
|
||||
const scenario = await scenarios.create(
|
||||
name.trim(),
|
||||
description.trim() || undefined,
|
||||
environmentId || undefined,
|
||||
);
|
||||
toast.success(t('scenarios.created'));
|
||||
navigate(`/scenarios/${scenario.id}`);
|
||||
} catch (err) {
|
||||
const message = (err as Error).message;
|
||||
toast.error(message);
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={styles.pageToolbar}>
|
||||
<Breadcrumbs
|
||||
items={[
|
||||
{
|
||||
label: t('scenarios.title'),
|
||||
icon: <ClipboardList size={14} />,
|
||||
onClick: () => navigate('/scenarios'),
|
||||
},
|
||||
{ label: t('scenarios.create_title') },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<form onSubmit={handleSubmit} noValidate>
|
||||
<Card className={styles.formCard}>
|
||||
<div className={styles.formFields}>
|
||||
<Input
|
||||
label={t('scenarios.form_name')}
|
||||
placeholder={t('scenarios.form_name_placeholder')}
|
||||
value={name}
|
||||
onChange={(e) => {
|
||||
setName(e.target.value);
|
||||
setNameError('');
|
||||
}}
|
||||
error={nameError || undefined}
|
||||
required
|
||||
autoFocus
|
||||
/>
|
||||
<div className={styles.formField}>
|
||||
<label className={styles.fieldLabel}>{t('scenarios.form_description')}</label>
|
||||
<CodeEditor
|
||||
language="markdown"
|
||||
value={description}
|
||||
onChange={setDescription}
|
||||
rows={8}
|
||||
/>
|
||||
</div>
|
||||
<Select
|
||||
label={t('scenarios.form_environment')}
|
||||
value={environmentId}
|
||||
onChange={(e) => setEnvironmentId(e.target.value)}
|
||||
options={[
|
||||
{ value: '', label: t('scenarios.form_environment_none') },
|
||||
...envs.map((env) => ({ value: env.id, label: env.name })),
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className={styles.formActions}>
|
||||
<Button type="button" variant="secondary" onClick={() => navigate('/scenarios')}>
|
||||
<X size={14} />
|
||||
{t('scenarios.action_cancel')}
|
||||
</Button>
|
||||
<Button type="submit" loading={saving}>
|
||||
<Save size={14} />
|
||||
{t('scenarios.action_save')}
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
import { useEffect, useState, SubmitEvent } from 'react';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { usePageTitle } from '../../hooks/usePageTitle';
|
||||
import { X, Save, ClipboardList } from 'lucide-react';
|
||||
import { scenarios, steps } from '../../api';
|
||||
import type { Scenario } from '../../api';
|
||||
import { Breadcrumbs, Button, Card, Input, CodeEditor, useToast } from '../../ui';
|
||||
import styles from '../Page.module.css';
|
||||
|
||||
export function CreateStepPage() {
|
||||
const { t } = useTranslation();
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const toast = useToast();
|
||||
|
||||
const [scenario, setScenario] = useState<Scenario | null>(null);
|
||||
usePageTitle(t('steps.create_title'));
|
||||
const [title, setTitle] = useState('');
|
||||
const [execCode, setExecCode] = useState('');
|
||||
const [timeoutSeconds, setTimeoutSeconds] = useState<string>('');
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!id) return;
|
||||
scenarios
|
||||
.get(id)
|
||||
.then(setScenario)
|
||||
.catch(() => null);
|
||||
}, [id]);
|
||||
|
||||
const handleSubmit = async (e: SubmitEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
setSaving(true);
|
||||
try {
|
||||
await steps.create(id!, {
|
||||
title: title.trim() || undefined,
|
||||
execCode: execCode.trim() || undefined,
|
||||
timeoutSeconds: timeoutSeconds.trim() ? Number(timeoutSeconds) : undefined,
|
||||
});
|
||||
toast.success(t('steps.created'));
|
||||
navigate(`/scenarios/${id}`);
|
||||
} catch (err) {
|
||||
const message = (err as Error).message;
|
||||
toast.error(message);
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={styles.pageToolbar}>
|
||||
<Breadcrumbs
|
||||
items={[
|
||||
{
|
||||
label: t('scenarios.title'),
|
||||
icon: <ClipboardList size={14} />,
|
||||
onClick: () => navigate('/scenarios'),
|
||||
},
|
||||
{
|
||||
label: scenario?.name ?? `#${id}`,
|
||||
onClick: () => navigate(`/scenarios/${id}`),
|
||||
},
|
||||
{ label: t('steps.create_title') },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<form onSubmit={handleSubmit} noValidate>
|
||||
<Card className={styles.formCardFull}>
|
||||
<div className={styles.formFields}>
|
||||
<Input
|
||||
label={t('steps.form_title')}
|
||||
placeholder={t('steps.form_title_placeholder')}
|
||||
value={title}
|
||||
onChange={(e) => setTitle(e.target.value)}
|
||||
/>
|
||||
<div className={styles.formField}>
|
||||
<label className={styles.fieldLabel}>{t('steps.form_exec_code')}</label>
|
||||
<CodeEditor value={execCode} onChange={setExecCode} rows={6} />
|
||||
</div>
|
||||
<Input
|
||||
label={t('steps.form_timeout')}
|
||||
placeholder={t('steps.form_timeout_placeholder')}
|
||||
type="number"
|
||||
min={1}
|
||||
value={timeoutSeconds}
|
||||
onChange={(e) => setTimeoutSeconds(e.target.value)}
|
||||
hint={t('steps.form_timeout_hint')}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className={styles.formActions}>
|
||||
<Button type="button" variant="secondary" onClick={() => navigate(`/scenarios/${id}`)}>
|
||||
<X size={14} />
|
||||
{t('steps.action_cancel')}
|
||||
</Button>
|
||||
<Button type="submit" loading={saving}>
|
||||
<Save size={14} />
|
||||
{t('steps.action_save')}
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
import { useEffect, useState, SubmitEvent } from 'react';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { usePageTitle } from '../../hooks/usePageTitle';
|
||||
import { X, Save, ClipboardList } from 'lucide-react';
|
||||
import { scenarios, environments } from '../../api';
|
||||
import type { Scenario, Environment } from '../../api';
|
||||
import { Breadcrumbs, Button, Card, Input, CodeEditor, Select, useToast } from '../../ui';
|
||||
import styles from '../Page.module.css';
|
||||
|
||||
export function EditScenarioPage() {
|
||||
const { t } = useTranslation();
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const toast = useToast();
|
||||
|
||||
const [scenario, setScenario] = useState<Scenario | null>(null);
|
||||
const [name, setName] = useState('');
|
||||
usePageTitle(
|
||||
scenario ? `${t('scenarios.edit_title')} — ${scenario.name}` : t('scenarios.edit_title'),
|
||||
);
|
||||
const [description, setDescription] = useState('');
|
||||
const [environmentId, setEnvironmentId] = useState<string>('');
|
||||
const [timeoutSeconds, setTimeoutSeconds] = useState<string>('');
|
||||
const [envs, setEnvs] = useState<Environment[]>([]);
|
||||
const [nameError, setNameError] = useState('');
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!id) return;
|
||||
scenarios
|
||||
.get(id)
|
||||
.then((data) => {
|
||||
setScenario(data);
|
||||
setName(data.name);
|
||||
setDescription(data.description || '');
|
||||
setEnvironmentId(data.environmentId ?? '');
|
||||
setTimeoutSeconds(data.timeoutSeconds != null ? String(data.timeoutSeconds) : '');
|
||||
})
|
||||
.finally(() => setLoading(false));
|
||||
environments
|
||||
.list(1, 200)
|
||||
.then((r) => setEnvs(r?.data ?? []))
|
||||
.catch(() => {});
|
||||
}, [id]);
|
||||
|
||||
const handleSubmit = async (e: SubmitEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
if (!name.trim()) {
|
||||
setNameError(t('scenarios.form_name_required'));
|
||||
return;
|
||||
}
|
||||
setSaving(true);
|
||||
try {
|
||||
await scenarios.update(id!, {
|
||||
name: name.trim(),
|
||||
description: description.trim() || undefined,
|
||||
environmentId: environmentId || null,
|
||||
timeoutSeconds: timeoutSeconds.trim() ? Number(timeoutSeconds) : null,
|
||||
});
|
||||
toast.success(t('scenarios.updated'));
|
||||
navigate(`/scenarios/${id}`);
|
||||
} catch (err) {
|
||||
const message = (err as Error).message;
|
||||
toast.error(message);
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={styles.pageToolbar}>
|
||||
<Breadcrumbs
|
||||
items={[
|
||||
{
|
||||
label: t('scenarios.title'),
|
||||
icon: <ClipboardList size={14} />,
|
||||
onClick: () => navigate('/scenarios'),
|
||||
},
|
||||
{
|
||||
label: scenario?.name ?? `#${id}`,
|
||||
onClick: () => navigate(`/scenarios/${id}`),
|
||||
},
|
||||
{ label: t('scenarios.edit_title') },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{loading && <p className={styles.muted}>{t('scenarios.loading')}</p>}
|
||||
|
||||
{!loading && scenario && (
|
||||
<form onSubmit={handleSubmit} noValidate>
|
||||
<Card className={styles.formCard}>
|
||||
<div className={styles.formFields}>
|
||||
<Input
|
||||
label={t('scenarios.form_name')}
|
||||
placeholder={t('scenarios.form_name_placeholder')}
|
||||
value={name}
|
||||
onChange={(e) => {
|
||||
setName(e.target.value);
|
||||
setNameError('');
|
||||
}}
|
||||
error={nameError || undefined}
|
||||
required
|
||||
autoFocus
|
||||
/>
|
||||
<div className={styles.formField}>
|
||||
<label className={styles.fieldLabel}>{t('scenarios.form_description')}</label>
|
||||
<CodeEditor
|
||||
language="markdown"
|
||||
value={description}
|
||||
onChange={setDescription}
|
||||
rows={8}
|
||||
/>
|
||||
</div>
|
||||
<Select
|
||||
label={t('scenarios.form_environment')}
|
||||
value={environmentId}
|
||||
onChange={(e) => setEnvironmentId(e.target.value)}
|
||||
options={[
|
||||
{ value: '', label: t('scenarios.form_environment_none') },
|
||||
...envs.map((env) => ({ value: env.id, label: env.name })),
|
||||
]}
|
||||
/>
|
||||
<Input
|
||||
label={t('scenarios.form_timeout')}
|
||||
placeholder={t('scenarios.form_timeout_placeholder')}
|
||||
type="number"
|
||||
min={1}
|
||||
value={timeoutSeconds}
|
||||
onChange={(e) => setTimeoutSeconds(e.target.value)}
|
||||
hint={t('scenarios.form_timeout_hint')}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className={styles.formActions}>
|
||||
<Button
|
||||
type="button"
|
||||
variant="secondary"
|
||||
onClick={() => navigate(`/scenarios/${id}`)}
|
||||
>
|
||||
<X size={14} />
|
||||
{t('scenarios.action_cancel')}
|
||||
</Button>
|
||||
<Button type="submit" loading={saving}>
|
||||
<Save size={14} />
|
||||
{t('scenarios.action_update')}
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
</form>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
import { useEffect, useState, SubmitEvent } from 'react';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { usePageTitle } from '../../hooks/usePageTitle';
|
||||
import { X, Save, ClipboardList } from 'lucide-react';
|
||||
import { scenarios, steps } from '../../api';
|
||||
import type { Scenario, ScenarioStep } from '../../api';
|
||||
import { Breadcrumbs, Button, Card, Input, CodeEditor, useToast } from '../../ui';
|
||||
import styles from '../Page.module.css';
|
||||
|
||||
export function EditStepPage() {
|
||||
const { t } = useTranslation();
|
||||
const { id, stepId } = useParams<{ id: string; stepId: string }>();
|
||||
const navigate = useNavigate();
|
||||
const toast = useToast();
|
||||
|
||||
const [scenario, setScenario] = useState<Scenario | null>(null);
|
||||
const [step, setStep] = useState<ScenarioStep | null>(null);
|
||||
usePageTitle(
|
||||
step ? t('steps.edit_title', { order: step.order }) : t('steps.edit_title', { order: '' }),
|
||||
);
|
||||
const [title, setTitle] = useState('');
|
||||
const [execCode, setExecCode] = useState('');
|
||||
const [timeoutSeconds, setTimeoutSeconds] = useState<string>('');
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!id || !stepId) return;
|
||||
Promise.all([scenarios.get(id), steps.get(id, stepId)])
|
||||
.then(([sc, st]) => {
|
||||
setScenario(sc);
|
||||
setStep(st);
|
||||
setTitle(st.title ?? '');
|
||||
setExecCode(st.execCode ?? '');
|
||||
setTimeoutSeconds(st.timeoutSeconds != null ? String(st.timeoutSeconds) : '');
|
||||
})
|
||||
.finally(() => setLoading(false));
|
||||
}, [id, stepId]);
|
||||
|
||||
const handleSubmit = async (e: SubmitEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
setSaving(true);
|
||||
try {
|
||||
await steps.update(id!, stepId!, {
|
||||
title: title.trim() || undefined,
|
||||
execCode: execCode.trim() || undefined,
|
||||
timeoutSeconds: timeoutSeconds.trim() ? Number(timeoutSeconds) : null,
|
||||
});
|
||||
toast.success(t('steps.updated'));
|
||||
navigate(`/scenarios/${id}`);
|
||||
} catch (err) {
|
||||
const message = (err as Error).message;
|
||||
toast.error(message);
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={styles.pageToolbar}>
|
||||
<Breadcrumbs
|
||||
items={[
|
||||
{
|
||||
label: t('scenarios.title'),
|
||||
icon: <ClipboardList size={14} />,
|
||||
onClick: () => navigate('/scenarios'),
|
||||
},
|
||||
{
|
||||
label: scenario?.name ?? `#${id}`,
|
||||
onClick: () => navigate(`/scenarios/${id}`),
|
||||
},
|
||||
{ label: t('steps.edit_title', { order: step ? step.order : stepId }) },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{loading && <p className={styles.muted}>{t('steps.loading')}</p>}
|
||||
|
||||
{!loading && step && (
|
||||
<form onSubmit={handleSubmit} noValidate>
|
||||
<Card className={styles.formCardFull}>
|
||||
<div className={styles.formFields}>
|
||||
<Input
|
||||
label={t('steps.form_title')}
|
||||
placeholder={t('steps.form_title_placeholder')}
|
||||
value={title}
|
||||
onChange={(e) => setTitle(e.target.value)}
|
||||
/>
|
||||
<div className={styles.formField}>
|
||||
<label className={styles.fieldLabel}>{t('steps.form_exec_code')}</label>
|
||||
<CodeEditor value={execCode} onChange={setExecCode} rows={6} />
|
||||
</div>
|
||||
<Input
|
||||
label={t('steps.form_timeout')}
|
||||
placeholder={t('steps.form_timeout_placeholder')}
|
||||
type="number"
|
||||
min={1}
|
||||
value={timeoutSeconds}
|
||||
onChange={(e) => setTimeoutSeconds(e.target.value)}
|
||||
hint={t('steps.form_timeout_hint')}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className={styles.formActions}>
|
||||
<Button
|
||||
type="button"
|
||||
variant="secondary"
|
||||
onClick={() => navigate(`/scenarios/${id}`)}
|
||||
>
|
||||
<X size={14} />
|
||||
{t('steps.action_cancel')}
|
||||
</Button>
|
||||
<Button type="submit" loading={saving}>
|
||||
<Save size={14} />
|
||||
{t('steps.action_update')}
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
</form>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,840 @@
|
||||
import { useEffect, useRef, useState, useCallback, SubmitEvent } from 'react';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { usePageTitle } from '../../hooks/usePageTitle';
|
||||
import {
|
||||
Play,
|
||||
Pencil,
|
||||
Plus,
|
||||
History,
|
||||
Download,
|
||||
Trash2,
|
||||
Upload,
|
||||
GripVertical,
|
||||
ClipboardList,
|
||||
} from 'lucide-react';
|
||||
import {
|
||||
environments,
|
||||
scenarios,
|
||||
steps,
|
||||
scenarioCredentials,
|
||||
scenarioFiles,
|
||||
credentials as credentialsApi,
|
||||
} from '../../api';
|
||||
import type {
|
||||
Scenario,
|
||||
ScenarioStep,
|
||||
ScenarioCredential,
|
||||
Credential,
|
||||
Environment,
|
||||
FileMetadata,
|
||||
} from '../../api';
|
||||
import {
|
||||
Breadcrumbs,
|
||||
Button,
|
||||
Card,
|
||||
DescriptionList,
|
||||
Input,
|
||||
Modal,
|
||||
Select,
|
||||
Table,
|
||||
Timestamp,
|
||||
UuidBadge,
|
||||
MarkdownContent,
|
||||
useToast,
|
||||
type TableColumn,
|
||||
} from '../../ui';
|
||||
import { ExportScenarioModal } from '../../components/modals';
|
||||
import styles from '../Page.module.css';
|
||||
|
||||
export function ScenarioDetailPage() {
|
||||
const { t } = useTranslation();
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const toast = useToast();
|
||||
const [scenario, setScenario] = useState<(Scenario & { steps: ScenarioStep[] }) | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
usePageTitle(scenario?.name ?? null);
|
||||
|
||||
// Credentials state
|
||||
const [scenarioCreds, setScenarioCreds] = useState<ScenarioCredential[]>([]);
|
||||
const [allCredentials, setAllCredentials] = useState<Credential[]>([]);
|
||||
const [addCredOpen, setAddCredOpen] = useState(false);
|
||||
const [addCredId, setAddCredId] = useState('');
|
||||
const [addAlias, setAddAlias] = useState('');
|
||||
const [addCredError, setAddCredError] = useState('');
|
||||
const [addAliasError, setAddAliasError] = useState('');
|
||||
const [addCredSaving, setAddCredSaving] = useState(false);
|
||||
const [draggedStepId, setDraggedStepId] = useState<string | null>(null);
|
||||
const [dragOverStepId, setDragOverStepId] = useState<string | null>(null);
|
||||
const [reorderingSteps, setReorderingSteps] = useState(false);
|
||||
const [runModalOpen, setRunModalOpen] = useState(false);
|
||||
const [running, setRunning] = useState(false);
|
||||
const [saveSessionFlag, setSaveSessionFlag] = useState(false);
|
||||
const [envs, setEnvs] = useState<Environment[]>([]);
|
||||
const [selectedEnvId, setSelectedEnvId] = useState('');
|
||||
const envInitRef = useRef(false);
|
||||
const [pendingDelete, setPendingDelete] = useState<
|
||||
{ type: 'scenario' } | { type: 'step'; id: string } | { type: 'credential'; id: string } | null
|
||||
>(null);
|
||||
const [deleting, setDeleting] = useState(false);
|
||||
|
||||
// Export modal state
|
||||
const [exportModalOpen, setExportModalOpen] = useState(false);
|
||||
const [includeEnvironment, setIncludeEnvironment] = useState(true);
|
||||
const [includedCredentialIds, setIncludedCredentialIds] = useState<Set<string>>(new Set());
|
||||
const [isExporting, setIsExporting] = useState(false);
|
||||
|
||||
// Files state
|
||||
const [files, setFiles] = useState<FileMetadata[]>([]);
|
||||
const [filesTotal, setFilesTotal] = useState(0);
|
||||
const [filesLoading, setFilesLoading] = useState(false);
|
||||
const [uploadOpen, setUploadOpen] = useState(false);
|
||||
const [uploadFile, setUploadFile] = useState<File | null>(null);
|
||||
const [uploadExpiresAt, setUploadExpiresAt] = useState('');
|
||||
const [uploading, setUploading] = useState(false);
|
||||
|
||||
const loadFiles = useCallback(async () => {
|
||||
if (!id) return;
|
||||
setFilesLoading(true);
|
||||
try {
|
||||
const result = await scenarioFiles.list(id);
|
||||
setFiles(result.items);
|
||||
setFilesTotal(result.total);
|
||||
} finally {
|
||||
setFilesLoading(false);
|
||||
}
|
||||
}, [id]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!id) return;
|
||||
void scenarios
|
||||
.get(id)
|
||||
.then((s) => {
|
||||
setScenario(s);
|
||||
setScenarioCreds(s.scenarioCredentials ?? []);
|
||||
})
|
||||
.finally(() => setLoading(false));
|
||||
void loadFiles();
|
||||
credentialsApi
|
||||
.list(1, 200)
|
||||
.then((r) => setAllCredentials(r.data))
|
||||
.catch(() => {});
|
||||
environments
|
||||
.list(1, 200)
|
||||
.then((r) => {
|
||||
setEnvs(r.data);
|
||||
})
|
||||
.catch(() => {});
|
||||
}, [id, loadFiles]);
|
||||
|
||||
// Default selected env to scenario's linked environment (or first env) once both are loaded
|
||||
useEffect(() => {
|
||||
if (envInitRef.current || envs.length === 0) return;
|
||||
envInitRef.current = true;
|
||||
const preferred = scenario?.environmentId ?? null;
|
||||
const exists = preferred ? envs.some((e) => e.id === preferred) : false;
|
||||
setSelectedEnvId(exists ? preferred! : envs[0].id);
|
||||
}, [scenario, envs]);
|
||||
|
||||
const reloadScenario = async () => {
|
||||
if (!id) return;
|
||||
const s = await scenarios.get(id);
|
||||
setScenario(s);
|
||||
setScenarioCreds(s.scenarioCredentials ?? []);
|
||||
};
|
||||
|
||||
const handleRun = async () => {
|
||||
if (!scenario) return;
|
||||
if (!selectedEnvId) {
|
||||
toast.error(t('scenarios.run_modal_env_required'));
|
||||
return;
|
||||
}
|
||||
setRunning(true);
|
||||
try {
|
||||
const run = await scenarios.run(scenario.id, selectedEnvId, saveSessionFlag);
|
||||
toast.success(t('scenarios.run_started'));
|
||||
navigate(`/scenarios/${id}/runs/${run.id}`);
|
||||
setRunModalOpen(false);
|
||||
setSaveSessionFlag(false);
|
||||
} catch (err) {
|
||||
toast.error((err as Error).message);
|
||||
} finally {
|
||||
setRunning(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleDelete = async () => {
|
||||
if (!scenario) return;
|
||||
await scenarios.remove(scenario.id);
|
||||
navigate('/scenarios');
|
||||
};
|
||||
|
||||
const handleOpenExportModal = () => {
|
||||
if (!scenario) return;
|
||||
// Initialise all credential checkboxes to checked
|
||||
setIncludedCredentialIds(new Set(scenarioCreds.map((sc) => sc.credentialId)));
|
||||
setIncludeEnvironment(true);
|
||||
setExportModalOpen(true);
|
||||
};
|
||||
|
||||
const handleExport = async () => {
|
||||
if (!scenario) return;
|
||||
setIsExporting(true);
|
||||
try {
|
||||
const credIds = Array.from(includedCredentialIds);
|
||||
const yamlContent = await scenarios.exportScenario(scenario.id, {
|
||||
includeEnvironment,
|
||||
credentialIds: credIds,
|
||||
});
|
||||
const blob = new Blob([yamlContent], { type: 'application/yaml' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `${scenario.name}.yaml`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
setExportModalOpen(false);
|
||||
} catch (err) {
|
||||
toast.error((err as Error).message);
|
||||
} finally {
|
||||
setIsExporting(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleFileDownload = (url: string, filename: string) => {
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = filename;
|
||||
link.click();
|
||||
};
|
||||
|
||||
const isFileExpired = (file: FileMetadata) =>
|
||||
file.expiresAt != null && new Date(file.expiresAt).getTime() <= Date.now();
|
||||
|
||||
async function handleUpload(e: SubmitEvent) {
|
||||
e.preventDefault();
|
||||
if (!id || !uploadFile) return;
|
||||
setUploading(true);
|
||||
try {
|
||||
await scenarioFiles.upload(
|
||||
id,
|
||||
uploadFile,
|
||||
uploadExpiresAt ? new Date(uploadExpiresAt) : undefined,
|
||||
);
|
||||
setUploadOpen(false);
|
||||
setUploadFile(null);
|
||||
setUploadExpiresAt('');
|
||||
await loadFiles();
|
||||
toast.success(t('files.uploadSuccess'));
|
||||
} catch {
|
||||
// error toast already emitted by API client
|
||||
} finally {
|
||||
setUploading(false);
|
||||
}
|
||||
}
|
||||
|
||||
const handleDeleteStep = async (stepId: string) => {
|
||||
await steps.remove(id!, stepId);
|
||||
await reloadScenario();
|
||||
};
|
||||
|
||||
const handleMoveStep = async (fromStepId: string, toStepId: string) => {
|
||||
if (!scenario || reorderingSteps) return;
|
||||
setReorderingSteps(true);
|
||||
try {
|
||||
const orderedSteps = [...scenario.steps].sort((a, b) => a.order - b.order);
|
||||
const toIndex = orderedSteps.findIndex((step) => step.id === toStepId);
|
||||
if (toIndex < 0) return;
|
||||
await steps.update(id!, fromStepId, { order: toIndex });
|
||||
await reloadScenario();
|
||||
} finally {
|
||||
setReorderingSteps(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleAddCredential = async (e: SubmitEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
let valid = true;
|
||||
if (!addCredId) {
|
||||
setAddCredError(t('scenarios.cred_form_cred_required'));
|
||||
valid = false;
|
||||
}
|
||||
if (!addAlias.trim()) {
|
||||
setAddAliasError(t('scenarios.cred_form_alias_required'));
|
||||
valid = false;
|
||||
}
|
||||
if (!valid) return;
|
||||
setAddCredSaving(true);
|
||||
try {
|
||||
const sc = await scenarioCredentials.add(id!, addCredId, addAlias.trim());
|
||||
// Re-fetch the credential object since the response may not include it
|
||||
const full = await scenarioCredentials.list(id!);
|
||||
setScenarioCreds(full);
|
||||
void sc;
|
||||
setAddCredOpen(false);
|
||||
setAddCredId('');
|
||||
setAddAlias('');
|
||||
} catch (err) {
|
||||
setAddCredError((err as Error).message);
|
||||
} finally {
|
||||
setAddCredSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleRemoveCredential = async (scCredId: string) => {
|
||||
await scenarioCredentials.remove(id!, scCredId);
|
||||
setScenarioCreds((prev) => prev.filter((sc) => sc.id !== scCredId));
|
||||
};
|
||||
|
||||
const confirmDelete = async () => {
|
||||
if (!pendingDelete) return;
|
||||
setDeleting(true);
|
||||
try {
|
||||
if (pendingDelete.type === 'scenario') {
|
||||
await handleDelete();
|
||||
return;
|
||||
}
|
||||
if (pendingDelete.type === 'step') {
|
||||
await handleDeleteStep(pendingDelete.id);
|
||||
}
|
||||
if (pendingDelete.type === 'credential') {
|
||||
await handleRemoveCredential(pendingDelete.id);
|
||||
}
|
||||
setPendingDelete(null);
|
||||
} finally {
|
||||
setDeleting(false);
|
||||
}
|
||||
};
|
||||
|
||||
const stepColumns: TableColumn<ScenarioStep>[] = [
|
||||
{
|
||||
key: 'drag',
|
||||
header: '',
|
||||
width: 44,
|
||||
align: 'center',
|
||||
render: (s) => (
|
||||
<span
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
aria-label="Drag to reorder step"
|
||||
className={[styles.dragHandle, reorderingSteps ? styles.dragHandleDisabled : '']
|
||||
.filter(Boolean)
|
||||
.join(' ')}
|
||||
draggable={!reorderingSteps}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
onDragStart={(e) => {
|
||||
if (reorderingSteps) {
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
setDraggedStepId(s.id);
|
||||
e.dataTransfer.effectAllowed = 'move';
|
||||
e.dataTransfer.setData('text/plain', s.id);
|
||||
}}
|
||||
onDragEnd={() => {
|
||||
setDraggedStepId(null);
|
||||
setDragOverStepId(null);
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
e.preventDefault();
|
||||
}
|
||||
}}
|
||||
>
|
||||
<GripVertical size={14} />
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{ key: 'order', header: t('scenarios.step_order'), render: (s) => s.order, width: 60 },
|
||||
{
|
||||
key: 'title',
|
||||
header: t('scenarios.step_title'),
|
||||
render: (s) =>
|
||||
s.title ?? (
|
||||
<span style={{ color: 'var(--color-text-muted)', fontStyle: 'italic' }}>{'—'}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'updated',
|
||||
header: t('scenarios.step_updated'),
|
||||
width: 140,
|
||||
render: (s) => <Timestamp value={s.updatedAt} />,
|
||||
},
|
||||
{
|
||||
key: 'actions',
|
||||
header: '',
|
||||
width: 80,
|
||||
align: 'right',
|
||||
render: (s) => (
|
||||
<span style={{ display: 'inline-flex', gap: 6 }}>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
title={t('steps.action_edit')}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
navigate(`/scenarios/${id}/steps/${s.id}/edit`);
|
||||
}}
|
||||
>
|
||||
<Pencil size={14} />
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="danger"
|
||||
title={t('steps.action_delete')}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setPendingDelete({ type: 'step', id: s.id });
|
||||
}}
|
||||
>
|
||||
<Trash2 size={14} />
|
||||
</Button>
|
||||
</span>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
const credColumns: TableColumn<ScenarioCredential>[] = [
|
||||
{ key: 'alias', header: t('scenarios.cred_col_alias'), render: (sc) => sc.alias },
|
||||
{
|
||||
key: 'name',
|
||||
header: t('scenarios.cred_col_name'),
|
||||
render: (sc) => sc.credential?.name ?? `#${sc.credentialId}`,
|
||||
},
|
||||
{
|
||||
key: 'added',
|
||||
header: t('scenarios.cred_col_added'),
|
||||
width: 140,
|
||||
render: (sc) => <Timestamp value={sc.createdAt} />,
|
||||
},
|
||||
{
|
||||
key: 'actions',
|
||||
header: '',
|
||||
width: 60,
|
||||
align: 'right',
|
||||
render: (sc) => (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="danger"
|
||||
title={t('scenarios.cred_action_remove')}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setPendingDelete({ type: 'credential', id: sc.id });
|
||||
}}
|
||||
>
|
||||
<Trash2 size={14} />
|
||||
</Button>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={styles.pageToolbar}>
|
||||
<Breadcrumbs
|
||||
items={[
|
||||
{
|
||||
label: t('scenarios.title'),
|
||||
icon: <ClipboardList size={14} />,
|
||||
onClick: () => navigate('/scenarios'),
|
||||
},
|
||||
{ label: scenario?.name ?? `#${id}` },
|
||||
]}
|
||||
/>
|
||||
{scenario && (
|
||||
<div className={styles.toolbarActions}>
|
||||
<Button size="sm" onClick={() => setRunModalOpen(true)}>
|
||||
<Play size={14} />
|
||||
{t('scenarios.action_run')}
|
||||
</Button>
|
||||
<Button variant="secondary" size="sm" onClick={() => navigate(`/scenarios/${id}/runs`)}>
|
||||
<History size={14} />
|
||||
{t('scenarios.action_runs')}
|
||||
</Button>
|
||||
<Button variant="secondary" size="sm" onClick={handleOpenExportModal}>
|
||||
<Upload size={14} />
|
||||
{t('scenarios.action_export')}
|
||||
</Button>
|
||||
<Button variant="secondary" size="sm" onClick={() => navigate(`/scenarios/${id}/edit`)}>
|
||||
<Pencil size={14} />
|
||||
{t('scenarios.action_edit')}
|
||||
</Button>
|
||||
<Button
|
||||
variant="danger"
|
||||
size="sm"
|
||||
onClick={() => setPendingDelete({ type: 'scenario' })}
|
||||
>
|
||||
<Trash2 size={14} />
|
||||
{t('scenarios.action_delete')}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{loading && <p className={styles.muted}>{t('scenarios.loading')}</p>}
|
||||
|
||||
{scenario && (
|
||||
<>
|
||||
<Card>
|
||||
<DescriptionList
|
||||
layout="grid"
|
||||
items={[
|
||||
{ term: t('scenarios.field_id'), detail: <UuidBadge id={scenario.id} /> },
|
||||
{ term: t('scenarios.field_name'), detail: scenario.name },
|
||||
...(scenario.environment
|
||||
? [
|
||||
{
|
||||
term: t('scenarios.field_environment'),
|
||||
detail: (
|
||||
<a
|
||||
href={`/environments/${scenario.environment.id}`}
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
navigate(`/environments/${scenario.environment!.id}`);
|
||||
}}
|
||||
>
|
||||
{scenario.environment.name}
|
||||
</a>
|
||||
),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
term: t('scenarios.field_created'),
|
||||
detail: <Timestamp value={scenario.createdAt} />,
|
||||
},
|
||||
{
|
||||
term: t('scenarios.field_updated'),
|
||||
detail: <Timestamp value={scenario.updatedAt} />,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</Card>
|
||||
|
||||
{scenario.description && (
|
||||
<div className={styles.stepsSection}>
|
||||
<div className={styles.sectionHeadingRow}>
|
||||
<h2 className={styles.sectionHeading}>{t('scenarios.field_description')}</h2>
|
||||
</div>
|
||||
<Card>
|
||||
<MarkdownContent content={scenario.description} />
|
||||
</Card>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{scenario.steps.length > 0 && (
|
||||
<div className={styles.stepsSection}>
|
||||
<div className={styles.sectionToolbar}>
|
||||
<h2 className={styles.sectionHeading}>{t('scenarios.steps_heading')}</h2>
|
||||
<Button size="sm" onClick={() => navigate(`/scenarios/${id}/steps/new`)}>
|
||||
<Plus size={14} />
|
||||
{t('steps.action_add')}
|
||||
</Button>
|
||||
</div>
|
||||
<Table
|
||||
columns={stepColumns}
|
||||
data={scenario.steps}
|
||||
rowKey={(s) => s.id}
|
||||
loading={false}
|
||||
emptyMessage=""
|
||||
getRowProps={(s) => ({
|
||||
className: dragOverStepId === s.id ? styles.dragOverRow : undefined,
|
||||
onDragOver: (e) => {
|
||||
if (reorderingSteps) return;
|
||||
e.preventDefault();
|
||||
if (draggedStepId && draggedStepId !== s.id) {
|
||||
setDragOverStepId(s.id);
|
||||
}
|
||||
},
|
||||
onDragLeave: () => {
|
||||
if (dragOverStepId === s.id) {
|
||||
setDragOverStepId(null);
|
||||
}
|
||||
},
|
||||
onDrop: async (e) => {
|
||||
if (reorderingSteps) return;
|
||||
e.preventDefault();
|
||||
const fromId = draggedStepId ?? e.dataTransfer.getData('text/plain');
|
||||
setDragOverStepId(null);
|
||||
setDraggedStepId(null);
|
||||
if (!fromId || fromId === s.id) return;
|
||||
await handleMoveStep(fromId, s.id);
|
||||
},
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{scenario.steps.length === 0 && (
|
||||
<div className={styles.stepsSection}>
|
||||
<div className={styles.sectionToolbar}>
|
||||
<h2 className={styles.sectionHeading}>{t('scenarios.steps_heading')}</h2>
|
||||
<Button size="sm" onClick={() => navigate(`/scenarios/${id}/steps/new`)}>
|
||||
<Plus size={14} />
|
||||
{t('steps.action_add')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ── Credentials section ──────────────────────────────────── */}
|
||||
<div className={styles.stepsSection}>
|
||||
<div className={styles.sectionToolbar}>
|
||||
<h2 className={styles.sectionHeading}>{t('scenarios.credentials_heading')}</h2>
|
||||
<Button size="sm" onClick={() => setAddCredOpen((v) => !v)}>
|
||||
<Plus size={14} />
|
||||
{t('scenarios.cred_action_add')}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{addCredOpen && (
|
||||
<div style={{ marginBottom: 'var(--space-4)' }}>
|
||||
<Card className={styles.formCard}>
|
||||
<form onSubmit={handleAddCredential} noValidate>
|
||||
<div className={styles.formFields}>
|
||||
<Select
|
||||
label={t('scenarios.cred_form_cred')}
|
||||
value={addCredId}
|
||||
onChange={(e) => {
|
||||
setAddCredId(e.target.value);
|
||||
setAddCredError('');
|
||||
}}
|
||||
error={addCredError || undefined}
|
||||
options={[
|
||||
{ value: '', label: t('scenarios.cred_form_cred_placeholder') },
|
||||
...allCredentials.map((c) => ({ value: String(c.id), label: c.name })),
|
||||
]}
|
||||
/>
|
||||
<Input
|
||||
label={t('scenarios.cred_form_alias')}
|
||||
placeholder={t('scenarios.cred_form_alias_placeholder')}
|
||||
value={addAlias}
|
||||
onChange={(e) => {
|
||||
setAddAlias(e.target.value);
|
||||
setAddAliasError('');
|
||||
}}
|
||||
error={addAliasError || undefined}
|
||||
/>
|
||||
</div>
|
||||
<div className={styles.formActions}>
|
||||
<Button
|
||||
type="button"
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
setAddCredOpen(false);
|
||||
setAddCredId('');
|
||||
setAddAlias('');
|
||||
}}
|
||||
>
|
||||
{t('scenarios.cred_action_cancel')}
|
||||
</Button>
|
||||
<Button type="submit" size="sm" loading={addCredSaving}>
|
||||
{t('scenarios.cred_action_save')}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</Card>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{scenarioCreds.length > 0 ? (
|
||||
<Table
|
||||
columns={credColumns}
|
||||
data={scenarioCreds}
|
||||
rowKey={(sc) => sc.id}
|
||||
loading={false}
|
||||
emptyMessage=""
|
||||
/>
|
||||
) : (
|
||||
<p className={styles.muted}>{t('scenarios.cred_empty')}</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* ── Files section ───────────────────────────────────────────────── */}
|
||||
<div className={styles.stepsSection}>
|
||||
<div className={styles.sectionToolbar}>
|
||||
<h2 className={styles.sectionHeading}>{t('files.title')}</h2>
|
||||
<Button size="sm" onClick={() => setUploadOpen(true)}>
|
||||
<Upload size={14} /> {t('files.upload')}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<Table<FileMetadata>
|
||||
loading={filesLoading}
|
||||
data={files}
|
||||
rowKey={(f) => f.id}
|
||||
columns={
|
||||
[
|
||||
{
|
||||
key: 'name',
|
||||
header: t('files.name'),
|
||||
render: (f) => f.name,
|
||||
},
|
||||
{
|
||||
key: 'mimeType',
|
||||
header: t('files.mimeType'),
|
||||
render: (f) => f.mimeType,
|
||||
},
|
||||
{
|
||||
key: 'size',
|
||||
header: t('files.size'),
|
||||
render: (f) => `${(f.size / 1024).toFixed(1)} KB`,
|
||||
},
|
||||
{
|
||||
key: 'expiresAt',
|
||||
header: t('files.expiresAt'),
|
||||
render: (f) => (f.expiresAt ? <Timestamp value={f.expiresAt} /> : '—'),
|
||||
},
|
||||
{
|
||||
key: 'createdAt',
|
||||
header: t('files.createdAt'),
|
||||
render: (f) => <Timestamp value={f.createdAt} />,
|
||||
},
|
||||
{
|
||||
key: 'download',
|
||||
header: '',
|
||||
render: (f) => {
|
||||
const expired = isFileExpired(f);
|
||||
const tooltip = expired ? t('files.expiredTooltip') : t('files.download');
|
||||
|
||||
return (
|
||||
<span title={tooltip}>
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
title={tooltip}
|
||||
aria-label={tooltip}
|
||||
disabled={expired}
|
||||
onClick={() =>
|
||||
handleFileDownload(scenarioFiles.contentUrl(id!, f.id), f.name)
|
||||
}
|
||||
>
|
||||
<Download size={14} />
|
||||
</Button>
|
||||
</span>
|
||||
);
|
||||
},
|
||||
},
|
||||
] satisfies TableColumn<FileMetadata>[]
|
||||
}
|
||||
emptyMessage={t('files.empty')}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* ── Upload modal ─────────────────────────────────────────────── */}
|
||||
<Modal
|
||||
open={uploadOpen}
|
||||
title={t('files.uploadTitle')}
|
||||
onClose={() => setUploadOpen(false)}
|
||||
>
|
||||
<form onSubmit={handleUpload}>
|
||||
<input
|
||||
type="file"
|
||||
required
|
||||
onChange={(e) => setUploadFile(e.target.files?.[0] ?? null)}
|
||||
/>
|
||||
<Input
|
||||
label={t('files.expiresAtLabel')}
|
||||
type="datetime-local"
|
||||
value={uploadExpiresAt}
|
||||
onChange={(e) => setUploadExpiresAt(e.target.value)}
|
||||
/>
|
||||
<Button type="submit" loading={uploading} disabled={!uploadFile}>
|
||||
{t('files.upload')}
|
||||
</Button>
|
||||
</form>
|
||||
</Modal>
|
||||
</>
|
||||
)}
|
||||
|
||||
<Modal
|
||||
open={pendingDelete != null}
|
||||
title={
|
||||
pendingDelete?.type === 'step'
|
||||
? t('steps.action_delete')
|
||||
: pendingDelete?.type === 'credential'
|
||||
? t('scenarios.cred_action_remove')
|
||||
: t('scenarios.action_delete')
|
||||
}
|
||||
onClose={() => !deleting && setPendingDelete(null)}
|
||||
footer={
|
||||
<>
|
||||
<Button variant="secondary" onClick={() => setPendingDelete(null)} disabled={deleting}>
|
||||
{t('common.button_cancel')}
|
||||
</Button>
|
||||
<Button variant="danger" onClick={confirmDelete} disabled={deleting}>
|
||||
{t('common.button_confirm')}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
{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={
|
||||
<>
|
||||
<Button variant="secondary" onClick={() => setRunModalOpen(false)} disabled={running}>
|
||||
{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>
|
||||
) : (
|
||||
<>
|
||||
<Select
|
||||
label={t('scenarios.run_modal_env_label')}
|
||||
value={selectedEnvId}
|
||||
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' }}
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={saveSessionFlag}
|
||||
onChange={(e) => setSaveSessionFlag(e.target.checked)}
|
||||
/>
|
||||
<span>{t('common.save_session')}</span>
|
||||
</label>
|
||||
</>
|
||||
)}
|
||||
</Modal>
|
||||
|
||||
<ExportScenarioModal
|
||||
open={exportModalOpen}
|
||||
scenario={scenario}
|
||||
scenarioCredentials={scenarioCreds}
|
||||
environment={
|
||||
scenario?.environment ?? envs.find((e) => e.id === scenario?.environmentId) ?? null
|
||||
}
|
||||
includeEnvironment={includeEnvironment}
|
||||
onIncludeEnvironmentChange={setIncludeEnvironment}
|
||||
includedCredentialIds={includedCredentialIds}
|
||||
onCredentialToggle={(credId, checked) => {
|
||||
setIncludedCredentialIds((prev) => {
|
||||
const next = new Set(prev);
|
||||
if (checked) next.add(credId);
|
||||
else next.delete(credId);
|
||||
return next;
|
||||
});
|
||||
}}
|
||||
onClose={() => setExportModalOpen(false)}
|
||||
onExport={handleExport}
|
||||
isExporting={isExporting}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,314 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { usePageTitle } from '../../hooks/usePageTitle';
|
||||
import { Play, Plus, Trash2, Download, ClipboardList } from 'lucide-react';
|
||||
import { parse as yamlParse } from 'yaml';
|
||||
import { environments, scenarios } from '../../api';
|
||||
import type { Environment, Scenario } from '../../api';
|
||||
import {
|
||||
Badge,
|
||||
Breadcrumbs,
|
||||
Button,
|
||||
Modal,
|
||||
Select,
|
||||
Table,
|
||||
type TableColumn,
|
||||
type SortDirection,
|
||||
Timestamp,
|
||||
UuidBadge,
|
||||
useToast,
|
||||
} from '../../ui';
|
||||
import type { BadgeVariant } from '../../ui';
|
||||
import type { ScenarioRunStatus } from '../../api';
|
||||
import styles from '../Page.module.css';
|
||||
|
||||
const LAST_RUN_VARIANT: Record<ScenarioRunStatus, BadgeVariant> = {
|
||||
pending: 'neutral',
|
||||
in_progress: 'info',
|
||||
pass: 'success',
|
||||
fail: 'error',
|
||||
};
|
||||
|
||||
const LAST_RUN_LABEL: Record<ScenarioRunStatus, string> = {
|
||||
pending: 'Pending',
|
||||
in_progress: 'Running',
|
||||
pass: 'Pass',
|
||||
fail: 'Fail',
|
||||
};
|
||||
|
||||
export function ScenariosPage() {
|
||||
const { t } = useTranslation();
|
||||
usePageTitle(t('scenarios.title'));
|
||||
const navigate = useNavigate();
|
||||
const toast = useToast();
|
||||
const [items, setItems] = useState<Scenario[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [deleteId, setDeleteId] = useState<string | null>(null);
|
||||
const [deleting, setDeleting] = useState(false);
|
||||
const [runScenarioId, setRunScenarioId] = useState<string | null>(null);
|
||||
const [running, setRunning] = useState(false);
|
||||
const [saveSessionFlag, setSaveSessionFlag] = useState(false);
|
||||
const [envs, setEnvs] = useState<Environment[]>([]);
|
||||
const [selectedEnvId, setSelectedEnvId] = useState('');
|
||||
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
const [sortBy, setSortBy] = useState('updatedAt');
|
||||
const [sortDir, setSortDir] = useState<SortDirection>('desc');
|
||||
const [page, setPage] = useState(1);
|
||||
const [pageSize, setPageSize] = useState(10);
|
||||
const [total, setTotal] = useState(0);
|
||||
|
||||
const load = useCallback(
|
||||
(orderBy: string, orderDir: SortDirection, p: number, limit: number) => {
|
||||
setLoading(true);
|
||||
Promise.all([
|
||||
scenarios.list(p, limit, orderBy, orderDir === 'asc' ? 'ASC' : 'DESC'),
|
||||
environments.list(1, 200),
|
||||
])
|
||||
.then(([scenarioRes, envRes]) => {
|
||||
setItems(scenarioRes?.data ?? []);
|
||||
setTotal(scenarioRes?.total ?? 0);
|
||||
setEnvs(envRes?.data ?? []);
|
||||
})
|
||||
.catch((err) => {
|
||||
toast.error((err as Error).message);
|
||||
})
|
||||
.finally(() => setLoading(false));
|
||||
},
|
||||
[toast],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
load('updatedAt', 'desc', 1, 10);
|
||||
}, [load]);
|
||||
|
||||
const handleSort = (key: string, dir: SortDirection) => {
|
||||
setSortBy(key);
|
||||
setSortDir(dir);
|
||||
setPage(1);
|
||||
load(key, dir, 1, pageSize);
|
||||
};
|
||||
|
||||
const handlePageChange = (p: number) => {
|
||||
setPage(p);
|
||||
load(sortBy, sortDir, p, pageSize);
|
||||
};
|
||||
|
||||
const handlePageSizeChange = (size: number) => {
|
||||
setPageSize(size);
|
||||
setPage(1);
|
||||
load(sortBy, sortDir, 1, size);
|
||||
};
|
||||
|
||||
const openRunModal = (id: string) => {
|
||||
setRunScenarioId(id);
|
||||
const scenario = items.find((s) => s.id === id);
|
||||
const preferred = scenario?.environmentId ?? null;
|
||||
const exists = preferred ? envs.some((e) => e.id === preferred) : false;
|
||||
setSelectedEnvId(exists ? preferred! : envs[0]?.id || '');
|
||||
};
|
||||
|
||||
const handleRun = async () => {
|
||||
if (!runScenarioId || !selectedEnvId) return;
|
||||
setRunning(true);
|
||||
try {
|
||||
const run = await scenarios.run(runScenarioId, selectedEnvId, saveSessionFlag);
|
||||
toast.success(t('scenarios.run_started'));
|
||||
navigate(`/scenarios/${runScenarioId}/runs/${run.id}`);
|
||||
setRunScenarioId(null);
|
||||
setSaveSessionFlag(false);
|
||||
} catch (err) {
|
||||
toast.error((err as Error).message);
|
||||
} finally {
|
||||
setRunning(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleDelete = async () => {
|
||||
if (!deleteId) return;
|
||||
setDeleting(true);
|
||||
try {
|
||||
await scenarios.remove(deleteId);
|
||||
load(sortBy, sortDir, page, pageSize);
|
||||
setDeleteId(null);
|
||||
} finally {
|
||||
setDeleting(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleImport = async (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const file = e.target.files?.[0];
|
||||
if (!file) return;
|
||||
e.target.value = '';
|
||||
try {
|
||||
const text = await file.text();
|
||||
const payload = yamlParse(text) as unknown;
|
||||
const imported = await scenarios.importScenario(payload);
|
||||
navigate(`/scenarios/${imported.id}`);
|
||||
} catch {
|
||||
// Import errors are silently ignored
|
||||
}
|
||||
};
|
||||
|
||||
const columns: TableColumn<Scenario>[] = [
|
||||
{ key: 'id', header: t('scenarios.col_id'), render: (s) => <UuidBadge id={s.id} />, width: 60 },
|
||||
{ key: 'name', header: t('scenarios.col_name'), render: (s) => s.name, sortable: true },
|
||||
{
|
||||
key: 'lastRunStatus',
|
||||
header: t('scenarios.col_last_run'),
|
||||
width: 160,
|
||||
render: (s) =>
|
||||
s.lastRunStatus ? (
|
||||
<span style={{ display: 'inline-flex', alignItems: 'center', gap: 6 }}>
|
||||
<span style={{ display: 'inline-flex', minWidth: 62 }}>
|
||||
<Badge variant={LAST_RUN_VARIANT[s.lastRunStatus]}>
|
||||
{LAST_RUN_LABEL[s.lastRunStatus]}
|
||||
</Badge>
|
||||
</span>
|
||||
{s.lastRunAt && <Timestamp value={s.lastRunAt} />}
|
||||
</span>
|
||||
) : (
|
||||
<span style={{ color: 'var(--color-text-muted)', fontSize: '0.8em' }}>—</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'updatedAt',
|
||||
header: t('scenarios.col_updated'),
|
||||
width: 140,
|
||||
sortable: true,
|
||||
render: (s) => <Timestamp value={s.updatedAt} />,
|
||||
},
|
||||
{
|
||||
key: 'actions',
|
||||
header: '',
|
||||
width: 100,
|
||||
align: 'right',
|
||||
render: (s) => (
|
||||
<span style={{ display: 'inline-flex', gap: 6 }}>
|
||||
<Button
|
||||
size="sm"
|
||||
title={t('scenarios.action_run')}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
openRunModal(s.id);
|
||||
}}
|
||||
>
|
||||
<Play size={14} />
|
||||
</Button>
|
||||
<Button
|
||||
variant="danger"
|
||||
size="sm"
|
||||
title={t('scenarios.action_delete')}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setDeleteId(s.id);
|
||||
}}
|
||||
>
|
||||
<Trash2 size={14} />
|
||||
</Button>
|
||||
</span>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={styles.pageToolbar}>
|
||||
<Breadcrumbs items={[{ label: t('scenarios.title'), icon: <ClipboardList size={14} /> }]} />
|
||||
<div className={styles.toolbarActions}>
|
||||
<input
|
||||
ref={fileInputRef}
|
||||
type="file"
|
||||
accept=".yaml,.yml,.json"
|
||||
style={{ display: 'none' }}
|
||||
onChange={handleImport}
|
||||
/>
|
||||
<Button variant="secondary" size="sm" onClick={() => fileInputRef.current?.click()}>
|
||||
<Download size={14} />
|
||||
{t('scenarios.action_import')}
|
||||
</Button>
|
||||
<Button size="sm" onClick={() => navigate('/scenarios/new')}>
|
||||
<Plus size={14} />
|
||||
{t('scenarios.action_add')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<Table
|
||||
columns={columns}
|
||||
data={items}
|
||||
rowKey={(s) => s.id}
|
||||
loading={loading}
|
||||
emptyMessage={t('scenarios.empty')}
|
||||
pageSize={pageSize}
|
||||
pageSizeOptions={[10, 25, 50]}
|
||||
onRowClick={(s) => navigate(`/scenarios/${s.id}`)}
|
||||
sortBy={sortBy}
|
||||
sortDir={sortDir}
|
||||
onSort={handleSort}
|
||||
total={total}
|
||||
page={page}
|
||||
onPageChange={handlePageChange}
|
||||
onPageSizeChange={handlePageSizeChange}
|
||||
/>
|
||||
|
||||
<Modal
|
||||
open={deleteId != null}
|
||||
title={t('scenarios.action_delete')}
|
||||
onClose={() => !deleting && setDeleteId(null)}
|
||||
footer={
|
||||
<>
|
||||
<Button variant="secondary" onClick={() => setDeleteId(null)} disabled={deleting}>
|
||||
{t('common.button_cancel')}
|
||||
</Button>
|
||||
<Button variant="danger" onClick={handleDelete} disabled={deleting}>
|
||||
{t('scenarios.action_delete')}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
{t('common.confirm_delete_scenario')}
|
||||
</Modal>
|
||||
|
||||
<Modal
|
||||
open={runScenarioId != null}
|
||||
title={t('scenarios.run_modal_title')}
|
||||
onClose={() => !running && setRunScenarioId(null)}
|
||||
footer={
|
||||
<>
|
||||
<Button variant="secondary" onClick={() => setRunScenarioId(null)} disabled={running}>
|
||||
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>
|
||||
) : (
|
||||
<>
|
||||
<Select
|
||||
label={t('scenarios.run_modal_env_label')}
|
||||
value={selectedEnvId}
|
||||
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' }}
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={saveSessionFlag}
|
||||
onChange={(e) => setSaveSessionFlag(e.target.checked)}
|
||||
/>
|
||||
<span>{t('common.save_session')}</span>
|
||||
</label>
|
||||
</>
|
||||
)}
|
||||
</Modal>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { usePageTitle } from '../../hooks/usePageTitle';
|
||||
import { Trash2, Monitor } from 'lucide-react';
|
||||
import { sessions } from '../../api';
|
||||
import type { Session } from '../../api';
|
||||
import { Badge, Breadcrumbs, Button, Card, DescriptionList, Timestamp, UuidBadge } from '../../ui';
|
||||
import { DeleteConfirmationModal } from '../../components/modals';
|
||||
import styles from '../Page.module.css';
|
||||
|
||||
export function SessionDetailPage() {
|
||||
const { t } = useTranslation();
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const [session, setSession] = useState<Session | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
usePageTitle(session?.sessionName ?? null);
|
||||
const [confirmDeleteOpen, setConfirmDeleteOpen] = useState(false);
|
||||
const [deleting, setDeleting] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!id) return;
|
||||
sessions
|
||||
.get(id)
|
||||
.then(setSession)
|
||||
.finally(() => setLoading(false));
|
||||
}, [id]);
|
||||
|
||||
const handleDelete = async () => {
|
||||
if (!session) return;
|
||||
setDeleting(true);
|
||||
try {
|
||||
await sessions.remove(session.id);
|
||||
navigate('/sessions');
|
||||
} finally {
|
||||
setDeleting(false);
|
||||
setConfirmDeleteOpen(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={styles.pageToolbar}>
|
||||
<Breadcrumbs
|
||||
items={[
|
||||
{
|
||||
label: t('sessions.title'),
|
||||
icon: <Monitor size={14} />,
|
||||
onClick: () => navigate('/sessions'),
|
||||
},
|
||||
{ label: session?.sessionName ?? `#${id}` },
|
||||
]}
|
||||
/>
|
||||
{session && (
|
||||
<Button variant="danger" size="sm" onClick={() => setConfirmDeleteOpen(true)}>
|
||||
<Trash2 size={14} />
|
||||
{t('sessions.action_delete')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{loading && <p className={styles.muted}>{t('sessions.loading')}</p>}
|
||||
|
||||
{session && (
|
||||
<Card>
|
||||
<DescriptionList
|
||||
layout="grid"
|
||||
items={[
|
||||
{ term: t('sessions.field_id'), detail: <UuidBadge id={session.id} /> },
|
||||
{ term: t('sessions.field_name'), detail: session.sessionName },
|
||||
{
|
||||
term: t('sessions.field_status'),
|
||||
detail: (
|
||||
<Badge variant={session.status === 'open' ? 'success' : 'error'}>
|
||||
{session.status}
|
||||
</Badge>
|
||||
),
|
||||
},
|
||||
{
|
||||
term: t('sessions.field_token'),
|
||||
detail: <code className={styles.codeInline}>{session.token}</code>,
|
||||
},
|
||||
{
|
||||
term: t('sessions.field_lastUsed'),
|
||||
detail: session.lastUsedAt ? <Timestamp value={session.lastUsedAt} /> : '—',
|
||||
},
|
||||
{
|
||||
term: t('sessions.field_created'),
|
||||
detail: <Timestamp value={session.createdAt} />,
|
||||
},
|
||||
{
|
||||
term: t('sessions.field_updated'),
|
||||
detail: <Timestamp value={session.updatedAt} />,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
<DeleteConfirmationModal
|
||||
open={confirmDeleteOpen}
|
||||
title={t('sessions.action_delete')}
|
||||
message={t('common.confirm_delete_session')}
|
||||
onClose={() => setConfirmDeleteOpen(false)}
|
||||
onConfirm={handleDelete}
|
||||
isDeleting={deleting}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { usePageTitle } from '../../hooks/usePageTitle';
|
||||
import { Trash2, Monitor } from 'lucide-react';
|
||||
import { sessions } from '../../api';
|
||||
import type { Session } from '../../api';
|
||||
import {
|
||||
Badge,
|
||||
Breadcrumbs,
|
||||
Button,
|
||||
Table,
|
||||
type TableColumn,
|
||||
type SortDirection,
|
||||
Timestamp,
|
||||
UuidBadge,
|
||||
} from '../../ui';
|
||||
import { DeleteConfirmationModal } from '../../components/modals';
|
||||
import styles from '../Page.module.css';
|
||||
|
||||
export function SessionsPage() {
|
||||
const { t } = useTranslation();
|
||||
usePageTitle(t('sessions.title'));
|
||||
const navigate = useNavigate();
|
||||
const [items, setItems] = useState<Session[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [deleteId, setDeleteId] = useState<string | null>(null);
|
||||
const [deleting, setDeleting] = useState(false);
|
||||
const [sortBy, setSortBy] = useState('id');
|
||||
const [sortDir, setSortDir] = useState<SortDirection>('desc');
|
||||
const [page, setPage] = useState(1);
|
||||
const [pageSize, setPageSize] = useState(10);
|
||||
const [total, setTotal] = useState(0);
|
||||
|
||||
const load = useCallback((orderBy: string, orderDir: SortDirection, p: number, limit: number) => {
|
||||
setLoading(true);
|
||||
sessions
|
||||
.list(p, limit, orderBy, orderDir === 'asc' ? 'ASC' : 'DESC')
|
||||
.then((res) => {
|
||||
setItems(res.data);
|
||||
setTotal(res.total);
|
||||
})
|
||||
.finally(() => setLoading(false));
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
load(sortBy, sortDir, page, pageSize);
|
||||
}, [load, sortBy, sortDir, page, pageSize]);
|
||||
|
||||
const handleSort = (col: string, dir: SortDirection) => {
|
||||
setSortBy(col);
|
||||
setSortDir(dir);
|
||||
setPage(1);
|
||||
};
|
||||
|
||||
const handleDelete = async () => {
|
||||
if (!deleteId) return;
|
||||
setDeleting(true);
|
||||
try {
|
||||
await sessions.remove(deleteId);
|
||||
load(sortBy, sortDir, page, pageSize);
|
||||
setDeleteId(null);
|
||||
} finally {
|
||||
setDeleting(false);
|
||||
}
|
||||
};
|
||||
|
||||
const columns: TableColumn<Session>[] = [
|
||||
{ key: 'id', header: t('sessions.col_id'), render: (s) => <UuidBadge id={s.id} />, width: 60 },
|
||||
{
|
||||
key: 'sessionName',
|
||||
header: t('sessions.col_name'),
|
||||
sortable: true,
|
||||
render: (s) => s.sessionName,
|
||||
},
|
||||
{
|
||||
key: 'status',
|
||||
header: t('sessions.col_status'),
|
||||
width: 100,
|
||||
sortable: true,
|
||||
render: (s) => <Badge variant={s.status === 'open' ? 'success' : 'error'}>{s.status}</Badge>,
|
||||
},
|
||||
{
|
||||
key: 'lastUsedAt',
|
||||
header: t('sessions.col_lastUsed'),
|
||||
width: 160,
|
||||
sortable: true,
|
||||
render: (s) => (s.lastUsedAt ? <Timestamp value={s.lastUsedAt} /> : '—'),
|
||||
},
|
||||
{
|
||||
key: 'actions',
|
||||
header: '',
|
||||
width: 48,
|
||||
align: 'right',
|
||||
render: (s) => (
|
||||
<Button
|
||||
variant="danger"
|
||||
size="sm"
|
||||
title={t('sessions.action_delete')}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setDeleteId(s.id);
|
||||
}}
|
||||
>
|
||||
<Trash2 size={14} />
|
||||
</Button>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={styles.pageToolbar}>
|
||||
<Breadcrumbs items={[{ label: t('sessions.title'), icon: <Monitor size={14} /> }]} />
|
||||
</div>
|
||||
<Table
|
||||
columns={columns}
|
||||
data={items}
|
||||
rowKey={(s) => s.id}
|
||||
loading={loading}
|
||||
emptyMessage={t('sessions.empty')}
|
||||
sortBy={sortBy}
|
||||
sortDir={sortDir}
|
||||
onSort={handleSort}
|
||||
total={total}
|
||||
page={page}
|
||||
onPageChange={setPage}
|
||||
onPageSizeChange={(s) => {
|
||||
setPageSize(s);
|
||||
setPage(1);
|
||||
}}
|
||||
pageSizeOptions={[10, 25, 50]}
|
||||
onRowClick={(s) => navigate(`/sessions/${s.id}`)}
|
||||
/>
|
||||
|
||||
<DeleteConfirmationModal
|
||||
open={deleteId != null}
|
||||
title={t('sessions.action_delete')}
|
||||
message={t('common.confirm_delete_session')}
|
||||
onClose={() => setDeleteId(null)}
|
||||
onConfirm={handleDelete}
|
||||
isDeleting={deleting}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
import { useState, SubmitEvent } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { usePageTitle } from '../../hooks/usePageTitle';
|
||||
import { X, Save, Braces } from 'lucide-react';
|
||||
import { snippets } from '../../api';
|
||||
import { Breadcrumbs, Button, Card, Input, CodeEditor, useToast } from '../../ui';
|
||||
import styles from '../Page.module.css';
|
||||
|
||||
export function CreateSnippetPage() {
|
||||
const { t } = useTranslation();
|
||||
usePageTitle(t('snippets.create_title'));
|
||||
const navigate = useNavigate();
|
||||
const toast = useToast();
|
||||
|
||||
const [alias, setAlias] = useState('');
|
||||
const [title, setTitle] = useState('');
|
||||
const [description, setDescription] = useState('');
|
||||
const [code, setCode] = useState('');
|
||||
const [aliasError, setAliasError] = useState('');
|
||||
const [titleError, setTitleError] = useState('');
|
||||
const [codeError, setCodeError] = useState('');
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
const handleSubmit = async (e: SubmitEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
let valid = true;
|
||||
if (!alias.trim()) {
|
||||
setAliasError(t('snippets.form_alias_required'));
|
||||
valid = false;
|
||||
}
|
||||
if (!title.trim()) {
|
||||
setTitleError(t('snippets.form_title_required'));
|
||||
valid = false;
|
||||
}
|
||||
if (!code.trim()) {
|
||||
setCodeError(t('snippets.form_code_required'));
|
||||
valid = false;
|
||||
}
|
||||
if (!valid) return;
|
||||
setSaving(true);
|
||||
try {
|
||||
const snippet = await snippets.create({
|
||||
alias: alias.trim(),
|
||||
title: title.trim(),
|
||||
description: description.trim() || undefined,
|
||||
code: code.trim(),
|
||||
});
|
||||
toast.success(t('snippets.created'));
|
||||
navigate(`/snippets/${snippet.id}`);
|
||||
} catch (err) {
|
||||
const message = (err as Error).message;
|
||||
toast.error(message);
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={styles.pageToolbar}>
|
||||
<Breadcrumbs
|
||||
items={[
|
||||
{
|
||||
label: t('snippets.title'),
|
||||
icon: <Braces size={14} />,
|
||||
onClick: () => navigate('/snippets'),
|
||||
},
|
||||
{ label: t('snippets.create_title') },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<form onSubmit={handleSubmit} noValidate>
|
||||
<Card className={styles.formCardFull}>
|
||||
<div className={styles.formFields}>
|
||||
<Input
|
||||
label={t('snippets.form_alias')}
|
||||
placeholder={t('snippets.form_alias_placeholder')}
|
||||
value={alias}
|
||||
onChange={(e) => {
|
||||
setAlias(e.target.value);
|
||||
setAliasError('');
|
||||
}}
|
||||
error={aliasError || undefined}
|
||||
required
|
||||
autoFocus
|
||||
/>
|
||||
<Input
|
||||
label={t('snippets.form_title')}
|
||||
placeholder={t('snippets.form_title_placeholder')}
|
||||
value={title}
|
||||
onChange={(e) => {
|
||||
setTitle(e.target.value);
|
||||
setTitleError('');
|
||||
}}
|
||||
error={titleError || undefined}
|
||||
required
|
||||
/>
|
||||
<div className={styles.formField}>
|
||||
<label className={styles.fieldLabel}>{t('snippets.form_description')}</label>
|
||||
<CodeEditor
|
||||
value={description}
|
||||
onChange={setDescription}
|
||||
language="markdown"
|
||||
rows={10}
|
||||
/>
|
||||
</div>
|
||||
<div className={styles.formField}>
|
||||
<label className={styles.fieldLabel}>
|
||||
{t('snippets.form_code')}
|
||||
<span className={styles.requiredMark}> *</span>
|
||||
</label>
|
||||
<CodeEditor
|
||||
value={code}
|
||||
onChange={(v) => {
|
||||
setCode(v);
|
||||
setCodeError('');
|
||||
}}
|
||||
rows={14}
|
||||
error={!!codeError}
|
||||
/>
|
||||
{codeError && <span className={styles.fieldError}>{codeError}</span>}
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.formActions}>
|
||||
<Button type="button" variant="secondary" onClick={() => navigate('/snippets')}>
|
||||
<X size={14} />
|
||||
{t('snippets.action_cancel')}
|
||||
</Button>
|
||||
<Button type="submit" disabled={saving}>
|
||||
<Save size={14} />
|
||||
{t('snippets.action_save')}
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
import { useEffect, useState, SubmitEvent } from 'react';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { usePageTitle } from '../../hooks/usePageTitle';
|
||||
import { X, Save, Braces } from 'lucide-react';
|
||||
import { snippets } from '../../api';
|
||||
import type { Snippet } from '../../api';
|
||||
import { Breadcrumbs, Button, Card, Input, CodeEditor, useToast } from '../../ui';
|
||||
import styles from '../Page.module.css';
|
||||
|
||||
export function EditSnippetPage() {
|
||||
const { t } = useTranslation();
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const toast = useToast();
|
||||
|
||||
const [snippet, setSnippet] = useState<Snippet | null>(null);
|
||||
const [alias, setAlias] = useState('');
|
||||
usePageTitle(
|
||||
snippet ? `${t('snippets.edit_title')} — ${snippet.title}` : t('snippets.edit_title'),
|
||||
);
|
||||
const [title, setTitle] = useState('');
|
||||
const [description, setDescription] = useState('');
|
||||
const [code, setCode] = useState('');
|
||||
const [aliasError, setAliasError] = useState('');
|
||||
const [titleError, setTitleError] = useState('');
|
||||
const [codeError, setCodeError] = useState('');
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!id) return;
|
||||
snippets
|
||||
.get(id)
|
||||
.then((s) => {
|
||||
setSnippet(s);
|
||||
setAlias(s.alias);
|
||||
setTitle(s.title);
|
||||
setDescription(s.description ?? '');
|
||||
setCode(s.code);
|
||||
})
|
||||
.finally(() => setLoading(false));
|
||||
}, [id]);
|
||||
|
||||
const handleSubmit = async (e: SubmitEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
let valid = true;
|
||||
if (!alias.trim()) {
|
||||
setAliasError(t('snippets.form_alias_required'));
|
||||
valid = false;
|
||||
}
|
||||
if (!title.trim()) {
|
||||
setTitleError(t('snippets.form_title_required'));
|
||||
valid = false;
|
||||
}
|
||||
if (!code.trim()) {
|
||||
setCodeError(t('snippets.form_code_required'));
|
||||
valid = false;
|
||||
}
|
||||
if (!valid) return;
|
||||
setSaving(true);
|
||||
try {
|
||||
await snippets.update(id!, {
|
||||
alias: alias.trim(),
|
||||
title: title.trim(),
|
||||
description: description.trim() || undefined,
|
||||
code: code.trim(),
|
||||
});
|
||||
toast.success(t('snippets.updated'));
|
||||
navigate(`/snippets/${id}`);
|
||||
} catch (err) {
|
||||
const message = (err as Error).message;
|
||||
toast.error(message);
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={styles.pageToolbar}>
|
||||
<Breadcrumbs
|
||||
items={[
|
||||
{
|
||||
label: t('snippets.title'),
|
||||
icon: <Braces size={14} />,
|
||||
onClick: () => navigate('/snippets'),
|
||||
},
|
||||
{
|
||||
label: snippet?.title ?? `#${id}`,
|
||||
onClick: () => navigate(`/snippets/${id}`),
|
||||
},
|
||||
{ label: t('snippets.edit_title') },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{loading && <p className={styles.muted}>{t('snippets.loading')}</p>}
|
||||
|
||||
{!loading && snippet && (
|
||||
<form onSubmit={handleSubmit} noValidate>
|
||||
<Card className={styles.formCardFull}>
|
||||
<div className={styles.formFields}>
|
||||
<Input
|
||||
label={t('snippets.form_alias')}
|
||||
placeholder={t('snippets.form_alias_placeholder')}
|
||||
value={alias}
|
||||
onChange={(e) => {
|
||||
setAlias(e.target.value);
|
||||
setAliasError('');
|
||||
}}
|
||||
error={aliasError || undefined}
|
||||
required
|
||||
autoFocus
|
||||
/>
|
||||
<Input
|
||||
label={t('snippets.form_title')}
|
||||
placeholder={t('snippets.form_title_placeholder')}
|
||||
value={title}
|
||||
onChange={(e) => {
|
||||
setTitle(e.target.value);
|
||||
setTitleError('');
|
||||
}}
|
||||
error={titleError || undefined}
|
||||
required
|
||||
/>
|
||||
<div className={styles.formField}>
|
||||
<label className={styles.fieldLabel}>{t('snippets.form_description')}</label>
|
||||
<CodeEditor
|
||||
value={description}
|
||||
onChange={setDescription}
|
||||
language="markdown"
|
||||
rows={10}
|
||||
/>
|
||||
</div>
|
||||
<div className={styles.formField}>
|
||||
<label className={styles.fieldLabel}>
|
||||
{t('snippets.form_code')}
|
||||
<span className={styles.requiredMark}> *</span>
|
||||
</label>
|
||||
<CodeEditor
|
||||
value={code}
|
||||
onChange={(v) => {
|
||||
setCode(v);
|
||||
setCodeError('');
|
||||
}}
|
||||
rows={14}
|
||||
error={!!codeError}
|
||||
/>
|
||||
{codeError && <span className={styles.fieldError}>{codeError}</span>}
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.formActions}>
|
||||
<Button type="button" variant="secondary" onClick={() => navigate(`/snippets/${id}`)}>
|
||||
<X size={14} />
|
||||
{t('snippets.action_cancel')}
|
||||
</Button>
|
||||
<Button type="submit" disabled={saving}>
|
||||
<Save size={14} />
|
||||
{t('snippets.action_update')}
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
</form>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { usePageTitle } from '../../hooks/usePageTitle';
|
||||
import { Upload, Pencil, Trash2, Braces } from 'lucide-react';
|
||||
import { CodeBlock } from '../../ui';
|
||||
import { stringify as yamlStringify } from 'yaml';
|
||||
import { snippets } from '../../api';
|
||||
import type { Snippet } from '../../api';
|
||||
import {
|
||||
Breadcrumbs,
|
||||
Button,
|
||||
Card,
|
||||
DescriptionList,
|
||||
MarkdownContent,
|
||||
Modal,
|
||||
Timestamp,
|
||||
UuidBadge,
|
||||
} from '../../ui';
|
||||
import styles from '../Page.module.css';
|
||||
|
||||
export function SnippetDetailPage() {
|
||||
const { t } = useTranslation();
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const [snippet, setSnippet] = useState<Snippet | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
usePageTitle(snippet?.title ?? null);
|
||||
const [confirmDeleteOpen, setConfirmDeleteOpen] = useState(false);
|
||||
const [deleting, setDeleting] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!id) return;
|
||||
snippets
|
||||
.get(id)
|
||||
.then(setSnippet)
|
||||
.finally(() => setLoading(false));
|
||||
}, [id]);
|
||||
|
||||
const handleDelete = async () => {
|
||||
if (!snippet) return;
|
||||
setDeleting(true);
|
||||
try {
|
||||
await snippets.remove(snippet.id);
|
||||
navigate('/snippets');
|
||||
} finally {
|
||||
setDeleting(false);
|
||||
setConfirmDeleteOpen(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleExport = async () => {
|
||||
if (!snippet) return;
|
||||
const data = await snippets.exportSnippet(snippet.id);
|
||||
const blob = new Blob([yamlStringify(data)], { type: 'application/yaml' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `snippet-${snippet.alias}.yaml`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={styles.pageToolbar}>
|
||||
<Breadcrumbs
|
||||
items={[
|
||||
{
|
||||
label: t('snippets.title'),
|
||||
icon: <Braces size={14} />,
|
||||
onClick: () => navigate('/snippets'),
|
||||
},
|
||||
{ label: snippet?.title ?? `#${id}` },
|
||||
]}
|
||||
/>
|
||||
{snippet && (
|
||||
<div className={styles.toolbarActions}>
|
||||
<Button variant="secondary" size="sm" onClick={handleExport}>
|
||||
<Upload size={14} />
|
||||
{t('snippets.action_export')}
|
||||
</Button>
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
onClick={() => navigate(`/snippets/${snippet.id}/edit`)}
|
||||
>
|
||||
<Pencil size={14} />
|
||||
{t('snippets.action_edit')}
|
||||
</Button>
|
||||
<Button variant="danger" size="sm" onClick={() => setConfirmDeleteOpen(true)}>
|
||||
<Trash2 size={14} />
|
||||
{t('snippets.action_delete')}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{loading && <p className={styles.muted}>{t('snippets.loading')}</p>}
|
||||
|
||||
{snippet && (
|
||||
<>
|
||||
<Card>
|
||||
<DescriptionList
|
||||
layout="grid"
|
||||
items={[
|
||||
{ term: t('snippets.field_id'), detail: <UuidBadge id={snippet.id} /> },
|
||||
{ term: t('snippets.field_alias'), detail: snippet.alias },
|
||||
{ term: t('snippets.field_title'), detail: snippet.title },
|
||||
{
|
||||
term: t('snippets.field_created'),
|
||||
detail: <Timestamp value={snippet.createdAt} />,
|
||||
},
|
||||
{
|
||||
term: t('snippets.field_updated'),
|
||||
detail: <Timestamp value={snippet.updatedAt} />,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</Card>
|
||||
|
||||
{snippet.description && (
|
||||
<div className={styles.stepsSection}>
|
||||
<div className={styles.sectionHeadingRow}>
|
||||
<h2 className={styles.sectionHeading}>{t('snippets.field_description')}</h2>
|
||||
</div>
|
||||
<Card>
|
||||
<MarkdownContent content={snippet.description} />
|
||||
</Card>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className={styles.stepsSection}>
|
||||
<div className={styles.sectionHeadingRow}>
|
||||
<h2 className={styles.sectionHeading}>{t('snippets.section_code')}</h2>
|
||||
</div>
|
||||
<Card>
|
||||
<CodeBlock code={snippet.code} />
|
||||
</Card>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
<Modal
|
||||
open={confirmDeleteOpen}
|
||||
title={t('snippets.action_delete')}
|
||||
onClose={() => !deleting && setConfirmDeleteOpen(false)}
|
||||
footer={
|
||||
<>
|
||||
<Button
|
||||
variant="secondary"
|
||||
onClick={() => setConfirmDeleteOpen(false)}
|
||||
disabled={deleting}
|
||||
>
|
||||
{t('common.button_cancel')}
|
||||
</Button>
|
||||
<Button variant="danger" onClick={handleDelete} disabled={deleting}>
|
||||
{t('snippets.action_delete')}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
{t('common.confirm_delete_snippet')}
|
||||
</Modal>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { usePageTitle } from '../../hooks/usePageTitle';
|
||||
import { Settings, Pencil, Trash2, Plus, Download, Braces } from 'lucide-react';
|
||||
import { parse as yamlParse } from 'yaml';
|
||||
import { snippets } from '../../api';
|
||||
import type { Snippet } from '../../api';
|
||||
import {
|
||||
Breadcrumbs,
|
||||
Button,
|
||||
Card,
|
||||
ContextMenu,
|
||||
MarkdownContent,
|
||||
Modal,
|
||||
Timestamp,
|
||||
UuidBadge,
|
||||
} from '../../ui';
|
||||
import styles from '../Page.module.css';
|
||||
|
||||
function firstParagraphBlocks(
|
||||
markdown: string,
|
||||
limit = 2,
|
||||
): { preview: string; truncated: boolean } {
|
||||
const blocks = markdown
|
||||
.split(/\n\s*\n/g)
|
||||
.map((block) => block.trim())
|
||||
.filter(Boolean);
|
||||
|
||||
const sliced = blocks.slice(0, limit);
|
||||
return {
|
||||
preview: sliced.join('\n\n'),
|
||||
truncated: blocks.length > limit,
|
||||
};
|
||||
}
|
||||
|
||||
function SnippetCard({ snippet, onDelete }: { snippet: Snippet; onDelete: (id: string) => void }) {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const header = (
|
||||
<div className={styles.envCardHeader}>
|
||||
<span className={styles.envCardName}>{snippet.title}</span>
|
||||
<div onClick={(e) => e.stopPropagation()}>
|
||||
<ContextMenu
|
||||
align="right"
|
||||
trigger={
|
||||
<Button variant="ghost" size="sm" aria-label={t('snippets.menu_label')}>
|
||||
<Settings size={14} />
|
||||
</Button>
|
||||
}
|
||||
items={[
|
||||
{
|
||||
label: t('snippets.action_edit'),
|
||||
icon: <Pencil size={14} />,
|
||||
onClick: () => navigate(`/snippets/${snippet.id}/edit`),
|
||||
},
|
||||
{
|
||||
label: t('snippets.action_delete'),
|
||||
icon: <Trash2 size={14} />,
|
||||
variant: 'danger',
|
||||
onClick: () => onDelete(snippet.id),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
const footer = (
|
||||
<div className={styles.envCardFooter}>
|
||||
<UuidBadge id={snippet.id} />
|
||||
<Timestamp value={snippet.updatedAt} />
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<Card
|
||||
className={styles.envCard}
|
||||
header={header}
|
||||
headerVariant="primary"
|
||||
footer={footer}
|
||||
onClick={() => navigate(`/snippets/${snippet.id}`)}
|
||||
>
|
||||
<p className={styles.muted}>
|
||||
{t('snippets.field_alias')}: <code className={styles.codeInline}>{snippet.alias}</code>
|
||||
</p>
|
||||
{snippet.description &&
|
||||
(() => {
|
||||
const { preview, truncated } = firstParagraphBlocks(snippet.description, 2);
|
||||
if (!preview) return null;
|
||||
return (
|
||||
<>
|
||||
<MarkdownContent content={preview} />
|
||||
{truncated && <p className={styles.muted}>...</p>}
|
||||
</>
|
||||
);
|
||||
})()}
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function AddSnippetCard() {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
return (
|
||||
<div className={styles.envCardAdd}>
|
||||
<Button variant="ghost" onClick={() => navigate('/snippets/new')}>
|
||||
<Plus size={16} />
|
||||
{t('snippets.action_add')}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function SnippetsPage() {
|
||||
const { t } = useTranslation();
|
||||
usePageTitle(t('snippets.title'));
|
||||
const navigate = useNavigate();
|
||||
const [items, setItems] = useState<Snippet[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [deleteId, setDeleteId] = useState<string | null>(null);
|
||||
const [deleting, setDeleting] = useState(false);
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
const load = () => {
|
||||
snippets
|
||||
.list()
|
||||
.then((res) => setItems(res.data))
|
||||
.finally(() => setLoading(false));
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
load();
|
||||
}, []);
|
||||
|
||||
const requestDelete = (id: string) => {
|
||||
setDeleteId(id);
|
||||
};
|
||||
|
||||
const handleDelete = async () => {
|
||||
if (!deleteId) return;
|
||||
setDeleting(true);
|
||||
try {
|
||||
await snippets.remove(deleteId);
|
||||
load();
|
||||
setDeleteId(null);
|
||||
} finally {
|
||||
setDeleting(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleImport = async (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const file = e.target.files?.[0];
|
||||
if (!file) return;
|
||||
e.target.value = '';
|
||||
try {
|
||||
const text = await file.text();
|
||||
const payload = yamlParse(text) as unknown;
|
||||
const imported = await snippets.importSnippet(payload);
|
||||
navigate(`/snippets/${imported.id}`);
|
||||
} catch {
|
||||
// Import errors are silently ignored
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={styles.pageToolbar}>
|
||||
<Breadcrumbs items={[{ label: t('snippets.title'), icon: <Braces size={14} /> }]} />
|
||||
<div className={styles.toolbarActions}>
|
||||
<input
|
||||
ref={fileInputRef}
|
||||
type="file"
|
||||
accept=".yaml,.yml,.json"
|
||||
style={{ display: 'none' }}
|
||||
onChange={handleImport}
|
||||
/>
|
||||
<Button variant="secondary" size="sm" onClick={() => fileInputRef.current?.click()}>
|
||||
<Download size={14} />
|
||||
{t('snippets.action_import')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{loading && <p className={styles.muted}>{t('snippets.loading')}</p>}
|
||||
|
||||
{!loading && (
|
||||
<div className={styles.envGrid}>
|
||||
{items.map((s) => (
|
||||
<SnippetCard key={s.id} snippet={s} onDelete={requestDelete} />
|
||||
))}
|
||||
{items.length === 0 && <p className={styles.muted}>{t('snippets.empty')}</p>}
|
||||
<AddSnippetCard />
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Modal
|
||||
open={deleteId != null}
|
||||
title={t('snippets.action_delete')}
|
||||
onClose={() => !deleting && setDeleteId(null)}
|
||||
footer={
|
||||
<>
|
||||
<Button variant="secondary" onClick={() => setDeleteId(null)} disabled={deleting}>
|
||||
{t('common.button_cancel')}
|
||||
</Button>
|
||||
<Button variant="danger" onClick={handleDelete} disabled={deleting}>
|
||||
{t('snippets.action_delete')}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
{t('common.confirm_delete_snippet')}
|
||||
</Modal>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
.root {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: var(--font-size-xs);
|
||||
font-family: var(--font-family);
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
/* ── Dot ──────────────────────────────────────────────────── */
|
||||
|
||||
.dot {
|
||||
position: relative;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.dot::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
border-radius: 50%;
|
||||
transition: background var(--transition);
|
||||
}
|
||||
|
||||
/* ── Pulse ring ───────────────────────────────────────────── */
|
||||
|
||||
.ring {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
border-radius: 50%;
|
||||
animation: pulse 0.8s ease-out 1;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0% {
|
||||
box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-primary) 70%, transparent);
|
||||
}
|
||||
70% {
|
||||
box-shadow: 0 0 0 7px color-mix(in srgb, var(--color-primary) 0%, transparent);
|
||||
}
|
||||
100% {
|
||||
box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-primary) 0%, transparent);
|
||||
}
|
||||
}
|
||||
|
||||
/* ── Clickable / hover ────────────────────────────────────── */
|
||||
|
||||
.clickable {
|
||||
cursor: pointer;
|
||||
border-radius: 99px;
|
||||
padding: 2px 6px;
|
||||
margin: -2px -6px;
|
||||
transition: background var(--transition);
|
||||
}
|
||||
|
||||
.clickable:hover {
|
||||
background: color-mix(in srgb, var(--color-text) 8%, transparent);
|
||||
}
|
||||
|
||||
.clickable:focus-visible {
|
||||
outline: 2px solid var(--color-primary);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
/* ── Active state ─────────────────────────────────────────── */
|
||||
|
||||
.active .dot::before {
|
||||
background: var(--color-primary);
|
||||
}
|
||||
|
||||
.active .label {
|
||||
color: var(--color-primary);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* ── Inactive / disabled state ────────────────────────────── */
|
||||
|
||||
.inactive .dot::before {
|
||||
background: var(--color-text-muted);
|
||||
opacity: 0.4;
|
||||
}
|
||||
|
||||
.inactive .label {
|
||||
color: var(--color-text-muted);
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
/* ── Error state ──────────────────────────────────────────── */
|
||||
|
||||
.error .dot::before {
|
||||
background: var(--color-error-fg);
|
||||
}
|
||||
|
||||
.error .ring {
|
||||
animation: none;
|
||||
}
|
||||
|
||||
.error .label {
|
||||
color: var(--color-error-fg);
|
||||
font-weight: 600;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import styles from './AutoRefreshIndicator.module.css';
|
||||
|
||||
export interface AutoRefreshIndicatorProps {
|
||||
active: boolean;
|
||||
pulseKey?: number;
|
||||
label?: string;
|
||||
error?: boolean;
|
||||
onClick?: () => void;
|
||||
}
|
||||
|
||||
export function AutoRefreshIndicator({
|
||||
active,
|
||||
pulseKey,
|
||||
label = 'Live',
|
||||
error = false,
|
||||
onClick,
|
||||
}: AutoRefreshIndicatorProps) {
|
||||
const stateClass = error ? styles.error : active ? styles.active : styles.inactive;
|
||||
const titleText = error
|
||||
? 'Refresh failed — click to retry'
|
||||
: active
|
||||
? 'Auto-refreshing'
|
||||
: 'Auto-refresh stopped';
|
||||
|
||||
return (
|
||||
<div
|
||||
className={[styles.root, stateClass, onClick ? styles.clickable : ''].join(' ')}
|
||||
title={titleText}
|
||||
aria-label={titleText}
|
||||
aria-live="polite"
|
||||
role={onClick ? 'button' : undefined}
|
||||
tabIndex={onClick ? 0 : undefined}
|
||||
onClick={onClick}
|
||||
onKeyDown={onClick ? (e) => (e.key === 'Enter' || e.key === ' ') && onClick() : undefined}
|
||||
>
|
||||
<span className={styles.dot}>
|
||||
{pulseKey !== undefined && pulseKey > 0 && <span key={pulseKey} className={styles.ring} />}
|
||||
</span>
|
||||
<span className={styles.label}>{error ? 'Error' : label}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
.badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
font-family: var(--font-family);
|
||||
font-size: var(--font-size-xs);
|
||||
font-weight: 500;
|
||||
padding: 2px var(--space-2);
|
||||
border-radius: var(--radius-full);
|
||||
white-space: nowrap;
|
||||
line-height: 1.6;
|
||||
box-shadow: var(--shadow-xs);
|
||||
}
|
||||
|
||||
.dot {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
background: currentColor;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.success { background: var(--color-success-bg); color: var(--color-success-fg); }
|
||||
.error { background: var(--color-error-bg); color: var(--color-error-fg); }
|
||||
.warning { background: var(--color-warning-bg); color: var(--color-warning-fg); }
|
||||
.info { background: var(--color-info-bg); color: var(--color-info-fg); }
|
||||
.neutral { background: var(--color-neutral-bg); color: var(--color-neutral-fg); }
|
||||
.running { background: var(--color-running-bg); color: var(--color-running-fg); }
|
||||
@@ -0,0 +1,19 @@
|
||||
import React from 'react';
|
||||
import styles from './Badge.module.css';
|
||||
|
||||
export type BadgeVariant = 'success' | 'error' | 'warning' | 'info' | 'neutral' | 'running';
|
||||
|
||||
export interface BadgeProps {
|
||||
variant?: BadgeVariant;
|
||||
dot?: boolean;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
export function Badge({ variant = 'neutral', dot = false, children }: BadgeProps) {
|
||||
return (
|
||||
<span className={[styles.badge, styles[variant]].join(' ')}>
|
||||
{dot && <span className={styles.dot} aria-hidden="true" />}
|
||||
{children}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
.nav {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-family: var(--font-family);
|
||||
}
|
||||
|
||||
.list {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-1);
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
}
|
||||
|
||||
.link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--color-text-muted);
|
||||
text-decoration: none;
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0;
|
||||
cursor: pointer;
|
||||
font-family: inherit;
|
||||
border-radius: var(--radius-sm);
|
||||
transition: color var(--transition);
|
||||
}
|
||||
|
||||
.link:hover {
|
||||
color: var(--color-text);
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.link:focus-visible {
|
||||
outline: 2px solid var(--color-primary);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.current {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
font-size: var(--font-size-sm);
|
||||
font-weight: 600;
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.separator {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
color: var(--color-border);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
import React from 'react';
|
||||
import styles from './Breadcrumbs.module.css';
|
||||
|
||||
export interface BreadcrumbItem {
|
||||
label: string;
|
||||
icon?: React.ReactNode;
|
||||
href?: string;
|
||||
onClick?: (e: React.MouseEvent) => void;
|
||||
}
|
||||
|
||||
export interface BreadcrumbsProps {
|
||||
items: BreadcrumbItem[];
|
||||
separator?: React.ReactNode;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function Breadcrumbs({ items, separator, className }: BreadcrumbsProps) {
|
||||
const sep = separator ?? (
|
||||
<svg width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true">
|
||||
<path
|
||||
d="M4 2L8 6L4 10"
|
||||
stroke="currentColor"
|
||||
strokeWidth="1.5"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
|
||||
return (
|
||||
<nav aria-label="Breadcrumb" className={[styles.nav, className].filter(Boolean).join(' ')}>
|
||||
<ol className={styles.list}>
|
||||
{items.map((item, i) => {
|
||||
const isLast = i === items.length - 1;
|
||||
return (
|
||||
<li key={i} className={styles.item}>
|
||||
{isLast ? (
|
||||
<span className={styles.current} aria-current="page">
|
||||
{item.icon}
|
||||
{item.label}
|
||||
</span>
|
||||
) : item.href ? (
|
||||
<a href={item.href} className={styles.link} onClick={item.onClick}>
|
||||
{item.icon}
|
||||
{item.label}
|
||||
</a>
|
||||
) : (
|
||||
<button type="button" className={styles.link} onClick={item.onClick}>
|
||||
{item.icon}
|
||||
{item.label}
|
||||
</button>
|
||||
)}
|
||||
{!isLast && <span className={styles.separator}>{sep}</span>}
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ol>
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
.button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: var(--space-2);
|
||||
font-family: var(--font-family);
|
||||
font-weight: 700;
|
||||
border: var(--border-width) solid transparent;
|
||||
border-radius: var(--radius-md);
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
outline: none;
|
||||
text-decoration: none;
|
||||
box-shadow: var(--shadow-xs);
|
||||
transition:
|
||||
background var(--transition),
|
||||
border-color var(--transition),
|
||||
color var(--transition),
|
||||
opacity var(--transition);
|
||||
}
|
||||
|
||||
.button:focus-visible {
|
||||
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.35);
|
||||
}
|
||||
|
||||
.button:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
/* Sizes */
|
||||
.sm {
|
||||
font-size: var(--font-size-sm);
|
||||
padding: var(--space-1) var(--space-3);
|
||||
height: 28px;
|
||||
}
|
||||
.md {
|
||||
font-size: var(--font-size-md);
|
||||
padding: var(--space-2) var(--space-4);
|
||||
height: 36px;
|
||||
}
|
||||
.lg {
|
||||
font-size: var(--font-size-lg);
|
||||
padding: var(--space-3) var(--space-5);
|
||||
height: 44px;
|
||||
}
|
||||
|
||||
/* Variants */
|
||||
.primary {
|
||||
background: var(--color-primary);
|
||||
color: var(--color-primary-fg);
|
||||
}
|
||||
.primary:hover:not(:disabled) { background: var(--color-primary-hover); }
|
||||
.primary:active:not(:disabled) { background: var(--color-primary-active); }
|
||||
|
||||
.secondary {
|
||||
background: var(--color-secondary);
|
||||
color: var(--color-secondary-fg);
|
||||
border-color: var(--color-secondary-border);
|
||||
}
|
||||
.secondary:hover:not(:disabled) { background: var(--color-secondary-hover); }
|
||||
.secondary:active:not(:disabled) { background: var(--color-secondary-active); }
|
||||
|
||||
.ghost {
|
||||
background: transparent;
|
||||
color: var(--color-text);
|
||||
}
|
||||
.ghost:hover:not(:disabled) { background: var(--color-secondary); }
|
||||
.ghost:active:not(:disabled) { background: var(--color-secondary-hover); }
|
||||
|
||||
.danger {
|
||||
background: var(--color-danger);
|
||||
color: var(--color-danger-fg);
|
||||
}
|
||||
.danger:hover:not(:disabled) { background: var(--color-danger-hover); }
|
||||
|
||||
/* Loading spinner */
|
||||
.spinner {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
border: 2px solid currentColor;
|
||||
border-top-color: transparent;
|
||||
border-radius: 50%;
|
||||
animation: spin 0.6s linear infinite;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import React from 'react';
|
||||
import styles from './Button.module.css';
|
||||
|
||||
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
||||
variant?: 'primary' | 'secondary' | 'ghost' | 'danger';
|
||||
size?: 'sm' | 'md' | 'lg';
|
||||
loading?: boolean;
|
||||
}
|
||||
|
||||
export function Button({
|
||||
variant = 'primary',
|
||||
size = 'md',
|
||||
loading = false,
|
||||
disabled,
|
||||
children,
|
||||
className,
|
||||
...props
|
||||
}: ButtonProps) {
|
||||
return (
|
||||
<button
|
||||
className={[styles.button, styles[variant], styles[size], className]
|
||||
.filter(Boolean)
|
||||
.join(' ')}
|
||||
disabled={disabled || loading}
|
||||
{...props}
|
||||
>
|
||||
{loading && <span className={styles.spinner} aria-hidden="true" />}
|
||||
{children}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
.card {
|
||||
background: var(--color-bg-subtle);
|
||||
border: var(--border-width) solid var(--color-border);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-sm);
|
||||
font-family: var(--font-family);
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
padding: var(--space-3) var(--space-6);
|
||||
font-weight: 600;
|
||||
font-size: var(--font-size-sm);
|
||||
border-radius: calc(var(--radius-lg) - var(--border-width)) calc(var(--radius-lg) - var(--border-width)) 0 0;
|
||||
}
|
||||
|
||||
.header-primary {
|
||||
background: var(--color-primary);
|
||||
color: var(--color-primary-fg);
|
||||
border-bottom: var(--border-width) solid var(--color-primary-active);
|
||||
}
|
||||
|
||||
.header-secondary {
|
||||
background: var(--color-secondary);
|
||||
color: var(--color-secondary-fg);
|
||||
border-bottom: var(--border-width) solid var(--color-secondary-border);
|
||||
}
|
||||
|
||||
.withFooter {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.withFooter .body {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.body { }
|
||||
|
||||
.footer {
|
||||
padding: var(--space-2) var(--space-6);
|
||||
border-top: var(--border-width) solid var(--color-border);
|
||||
font-size: var(--font-size-xs);
|
||||
color: var(--color-text-muted);
|
||||
background: var(--color-bg-subtle);
|
||||
}
|
||||
|
||||
.sm { padding: var(--space-3) var(--space-4); }
|
||||
.md { padding: var(--space-4) var(--space-6); }
|
||||
.lg { padding: var(--space-6) var(--space-8); }
|
||||
|
||||
.hoverable {
|
||||
cursor: pointer;
|
||||
transition: border-color var(--transition), box-shadow var(--transition);
|
||||
}
|
||||
.hoverable:hover {
|
||||
border-color: var(--color-primary);
|
||||
box-shadow: var(--shadow-sm), 0 0 0 1px var(--color-primary);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import React from 'react';
|
||||
import styles from './Card.module.css';
|
||||
|
||||
export interface CardProps {
|
||||
children: React.ReactNode;
|
||||
className?: string;
|
||||
padding?: 'sm' | 'md' | 'lg';
|
||||
header?: React.ReactNode;
|
||||
headerVariant?: 'primary' | 'secondary';
|
||||
footer?: React.ReactNode;
|
||||
onClick?: React.MouseEventHandler<HTMLDivElement>;
|
||||
}
|
||||
|
||||
export function Card({
|
||||
children,
|
||||
className,
|
||||
padding = 'md',
|
||||
header,
|
||||
headerVariant = 'primary',
|
||||
footer,
|
||||
onClick,
|
||||
}: CardProps) {
|
||||
return (
|
||||
<div
|
||||
onClick={onClick}
|
||||
className={[
|
||||
styles.card,
|
||||
footer !== undefined ? styles.withFooter : '',
|
||||
onClick ? styles.hoverable : '',
|
||||
className,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ')}
|
||||
>
|
||||
{header !== undefined && (
|
||||
<div className={[styles.header, styles[`header-${headerVariant}`]].join(' ')}>{header}</div>
|
||||
)}
|
||||
<div className={[styles.body, styles[padding]].join(' ')}>{children}</div>
|
||||
{footer !== undefined && <div className={styles.footer}>{footer}</div>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
.pre {
|
||||
margin: 0;
|
||||
overflow-x: auto;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.code {
|
||||
font-family: var(--font-mono, ui-monospace, 'Cascadia Code', 'Fira Code', monospace);
|
||||
font-size: var(--font-size-sm);
|
||||
line-height: 1.6;
|
||||
display: block;
|
||||
background: transparent !important;
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
/* ── highlight.js token overrides (theme-aware) ─────────────────────── */
|
||||
|
||||
.code :global(.hljs-comment),
|
||||
.code :global(.hljs-quote) {
|
||||
color: var(--hl-comment, #6A8072);
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.code :global(.hljs-keyword),
|
||||
.code :global(.hljs-selector-tag),
|
||||
.code :global(.hljs-built_in),
|
||||
.code :global(.hljs-name),
|
||||
.code :global(.hljs-tag) {
|
||||
color: var(--hl-keyword, #A67DCC);
|
||||
}
|
||||
|
||||
.code :global(.hljs-string),
|
||||
.code :global(.hljs-title),
|
||||
.code :global(.hljs-section),
|
||||
.code :global(.hljs-attribute),
|
||||
.code :global(.hljs-literal),
|
||||
.code :global(.hljs-template-tag),
|
||||
.code :global(.hljs-template-variable),
|
||||
.code :global(.hljs-type),
|
||||
.code :global(.hljs-addition) {
|
||||
color: var(--hl-string, #9BB870);
|
||||
}
|
||||
|
||||
.code :global(.hljs-number),
|
||||
.code :global(.hljs-regexp),
|
||||
.code :global(.hljs-link) {
|
||||
color: var(--hl-number, #E8A85F);
|
||||
}
|
||||
|
||||
.code :global(.hljs-function),
|
||||
.code :global(.hljs-title.hljs-function_) {
|
||||
color: var(--hl-function, #5BB8D4);
|
||||
}
|
||||
|
||||
.code :global(.hljs-variable),
|
||||
.code :global(.hljs-params) {
|
||||
color: var(--hl-variable, #D4A0A0);
|
||||
}
|
||||
|
||||
.code :global(.hljs-property) {
|
||||
color: var(--hl-property, #79C0C8);
|
||||
}
|
||||
|
||||
.code :global(.hljs-deletion),
|
||||
.code :global(.hljs-meta) {
|
||||
color: var(--hl-meta, #A9A3C9);
|
||||
}
|
||||
|
||||
.code :global(.hljs-emphasis) {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.code :global(.hljs-strong) {
|
||||
font-weight: 700;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import { useMemo } from 'react';
|
||||
import hljs from '../../lib/hljs';
|
||||
import styles from './CodeBlock.module.css';
|
||||
|
||||
export interface CodeBlockProps {
|
||||
code: string;
|
||||
language?: string;
|
||||
}
|
||||
|
||||
export function CodeBlock({ code, language = 'javascript' }: CodeBlockProps) {
|
||||
const highlighted = useMemo(() => {
|
||||
try {
|
||||
return hljs.highlight(code, { language }).value;
|
||||
} catch {
|
||||
return code.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
||||
}
|
||||
}, [code, language]);
|
||||
|
||||
return (
|
||||
<pre className={styles.pre}>
|
||||
<code
|
||||
className={`${styles.code} hljs language-${language}`}
|
||||
dangerouslySetInnerHTML={{ __html: highlighted }}
|
||||
/>
|
||||
</pre>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
.wrapper {
|
||||
width: 100%;
|
||||
border: var(--border-width) solid var(--color-border);
|
||||
border-radius: var(--radius-md);
|
||||
overflow: hidden;
|
||||
resize: vertical;
|
||||
min-height: 80px;
|
||||
transition: border-color var(--transition), box-shadow var(--transition);
|
||||
}
|
||||
|
||||
.focused {
|
||||
border-color: var(--color-primary);
|
||||
box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 20%, transparent);
|
||||
}
|
||||
|
||||
.hasError {
|
||||
border-color: var(--color-danger);
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import Editor, { OnMount } from '@monaco-editor/react';
|
||||
import styles from './CodeEditor.module.css';
|
||||
|
||||
export interface CodeEditorProps {
|
||||
value: string;
|
||||
onChange: (value: string) => void;
|
||||
language?: string;
|
||||
rows?: number;
|
||||
error?: boolean;
|
||||
}
|
||||
|
||||
function useMonacoTheme() {
|
||||
const [theme, setTheme] = useState(() =>
|
||||
document.documentElement.getAttribute('data-theme') === 'dark' ? 'vs-dark' : 'vs-light',
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const observer = new MutationObserver(() => {
|
||||
setTheme(
|
||||
document.documentElement.getAttribute('data-theme') === 'dark' ? 'vs-dark' : 'vs-light',
|
||||
);
|
||||
});
|
||||
observer.observe(document.documentElement, {
|
||||
attributes: true,
|
||||
attributeFilter: ['data-theme'],
|
||||
});
|
||||
return () => observer.disconnect();
|
||||
}, []);
|
||||
|
||||
return theme;
|
||||
}
|
||||
|
||||
export function CodeEditor({
|
||||
value,
|
||||
onChange,
|
||||
language = 'javascript',
|
||||
rows = 6,
|
||||
error = false,
|
||||
}: CodeEditorProps) {
|
||||
const theme = useMonacoTheme();
|
||||
const [focused, setFocused] = useState(false);
|
||||
const height = rows * 20 + 16;
|
||||
|
||||
const handleMount: OnMount = (editor) => {
|
||||
editor.onDidFocusEditorWidget(() => setFocused(true));
|
||||
editor.onDidBlurEditorWidget(() => setFocused(false));
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
className={[styles.wrapper, focused ? styles.focused : '', error ? styles.hasError : '']
|
||||
.filter(Boolean)
|
||||
.join(' ')}
|
||||
style={{ height }}
|
||||
>
|
||||
<Editor
|
||||
height="100%"
|
||||
theme={theme}
|
||||
language={language}
|
||||
value={value}
|
||||
onChange={(v) => onChange(v ?? '')}
|
||||
onMount={handleMount}
|
||||
options={{
|
||||
minimap: { enabled: false },
|
||||
scrollBeyondLastLine: false,
|
||||
fontSize: 14,
|
||||
lineHeight: 20,
|
||||
wordWrap: 'on',
|
||||
padding: { top: 8, bottom: 8 },
|
||||
folding: false,
|
||||
renderLineHighlight: 'line',
|
||||
scrollbar: { vertical: 'auto', horizontal: 'hidden' },
|
||||
automaticLayout: true,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
.root {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
.triggerWrap {
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
.menu {
|
||||
z-index: 9999;
|
||||
min-width: 160px;
|
||||
margin: 0;
|
||||
padding: var(--space-1) 0;
|
||||
list-style: none;
|
||||
background: var(--color-bg-subtle);
|
||||
border: var(--border-width) solid var(--color-border);
|
||||
border-radius: var(--radius-md);
|
||||
box-shadow: var(--shadow-md);
|
||||
}
|
||||
|
||||
.item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
width: 100%;
|
||||
padding: var(--space-2) var(--space-4);
|
||||
background: transparent;
|
||||
border: none;
|
||||
text-align: left;
|
||||
font-family: var(--font-family);
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--color-text);
|
||||
cursor: pointer;
|
||||
transition: background var(--transition), color var(--transition);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.item:hover {
|
||||
background: var(--color-secondary);
|
||||
}
|
||||
|
||||
.item.danger {
|
||||
color: var(--color-danger);
|
||||
}
|
||||
|
||||
.item.danger:hover {
|
||||
background: var(--color-error-bg);
|
||||
}
|
||||
|
||||
.icon {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
opacity: 0.75;
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
import styles from './ContextMenu.module.css';
|
||||
|
||||
export interface ContextMenuItem {
|
||||
label: string;
|
||||
onClick: () => void;
|
||||
variant?: 'default' | 'danger';
|
||||
icon?: React.ReactNode;
|
||||
}
|
||||
|
||||
export interface ContextMenuProps {
|
||||
items: ContextMenuItem[];
|
||||
/** The trigger element — a button rendered by the component */
|
||||
trigger: React.ReactNode;
|
||||
align?: 'left' | 'right';
|
||||
}
|
||||
|
||||
export function ContextMenu({ items, trigger, align = 'right' }: ContextMenuProps) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const [coords, setCoords] = useState({ top: 0, left: 0, right: 0 });
|
||||
const triggerRef = useRef<HTMLDivElement>(null);
|
||||
const menuRef = useRef<HTMLUListElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
function handleOutside(e: MouseEvent) {
|
||||
const target = e.target as Node;
|
||||
if (
|
||||
triggerRef.current &&
|
||||
!triggerRef.current.contains(target) &&
|
||||
menuRef.current &&
|
||||
!menuRef.current.contains(target)
|
||||
) {
|
||||
setOpen(false);
|
||||
}
|
||||
}
|
||||
document.addEventListener('mousedown', handleOutside);
|
||||
return () => document.removeEventListener('mousedown', handleOutside);
|
||||
}, [open]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
function handleKey(e: KeyboardEvent) {
|
||||
if (e.key === 'Escape') setOpen(false);
|
||||
}
|
||||
document.addEventListener('keydown', handleKey);
|
||||
return () => document.removeEventListener('keydown', handleKey);
|
||||
}, [open]);
|
||||
|
||||
function openMenu() {
|
||||
if (!triggerRef.current) return;
|
||||
const rect = triggerRef.current.getBoundingClientRect();
|
||||
setCoords({
|
||||
top: rect.bottom + window.scrollY + 4,
|
||||
left: rect.left + window.scrollX,
|
||||
right: window.innerWidth - rect.right - window.scrollX,
|
||||
});
|
||||
setOpen((v) => !v);
|
||||
}
|
||||
|
||||
const menuStyle =
|
||||
align === 'right'
|
||||
? { top: coords.top, right: coords.right }
|
||||
: { top: coords.top, left: coords.left };
|
||||
|
||||
return (
|
||||
<div className={styles.root} ref={triggerRef}>
|
||||
<div
|
||||
className={styles.triggerWrap}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
openMenu();
|
||||
}}
|
||||
>
|
||||
{trigger}
|
||||
</div>
|
||||
{open &&
|
||||
createPortal(
|
||||
<ul
|
||||
ref={menuRef}
|
||||
className={styles.menu}
|
||||
style={{ ...menuStyle, position: 'fixed' }}
|
||||
role="menu"
|
||||
>
|
||||
{items.map((item, i) => (
|
||||
<li key={i} role="none">
|
||||
<button
|
||||
role="menuitem"
|
||||
className={`${styles.item} ${item.variant === 'danger' ? styles.danger : ''}`}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setOpen(false);
|
||||
item.onClick();
|
||||
}}
|
||||
>
|
||||
{item.icon && (
|
||||
<span className={styles.icon} aria-hidden="true">
|
||||
{item.icon}
|
||||
</span>
|
||||
)}
|
||||
{item.label}
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>,
|
||||
document.body,
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
.list {
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
|
||||
.row {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 0;
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
.term {
|
||||
color: var(--color-text-muted);
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
font-size: var(--font-size-xs);
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.detail {
|
||||
margin: 0;
|
||||
color: var(--color-text);
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.detail a {
|
||||
color: var(--color-link);
|
||||
}
|
||||
|
||||
.detail a:hover {
|
||||
color: var(--color-link-hover);
|
||||
}
|
||||
|
||||
.truncate {
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
word-break: normal;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
/* ── Grid layout ───────────────────────────────────────────── */
|
||||
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
|
||||
gap: var(--space-4) var(--space-6);
|
||||
}
|
||||
|
||||
.grid .row {
|
||||
flex-direction: column;
|
||||
gap: var(--space-1);
|
||||
}
|
||||
|
||||
.grid .term {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.grid .detail {
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
.inline .row {
|
||||
flex-direction: row;
|
||||
align-items: baseline;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
|
||||
.inline .term {
|
||||
min-width: 120px;
|
||||
}
|
||||
|
||||
.comfortable {
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.comfortable .row {
|
||||
padding: var(--space-4) 0;
|
||||
}
|
||||
|
||||
.comfortable .row:first-child {
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.comfortable .term {
|
||||
margin-bottom: var(--space-1);
|
||||
}
|
||||
|
||||
.comfortable .detail {
|
||||
font-size: var(--font-size-md);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
import React from 'react';
|
||||
import styles from './DescriptionList.module.css';
|
||||
|
||||
function extractText(node: React.ReactNode): string {
|
||||
if (typeof node === 'string' || typeof node === 'number') return String(node);
|
||||
if (Array.isArray(node)) return node.map(extractText).join('');
|
||||
if (React.isValidElement<{ children?: React.ReactNode }>(node))
|
||||
return extractText(node.props.children);
|
||||
return '';
|
||||
}
|
||||
|
||||
export interface DescriptionListItem {
|
||||
term: React.ReactNode;
|
||||
detail: React.ReactNode;
|
||||
}
|
||||
|
||||
export interface DescriptionListProps {
|
||||
items: DescriptionListItem[];
|
||||
/** 'compact' stacks term above detail; 'inline' places them side by side; 'comfortable' adds generous spacing with dividers (default); 'grid' flows items into a responsive multi-column grid */
|
||||
layout?: 'inline' | 'compact' | 'comfortable' | 'grid';
|
||||
/** Truncate detail values with ellipsis; full value shown in a tooltip on hover */
|
||||
truncate?: boolean;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function DescriptionList({
|
||||
items,
|
||||
layout = 'inline',
|
||||
truncate,
|
||||
className,
|
||||
}: DescriptionListProps) {
|
||||
return (
|
||||
<dl className={[styles.list, styles[layout], className].filter(Boolean).join(' ')}>
|
||||
{items.map((item, i) => (
|
||||
<div key={i} className={styles.row}>
|
||||
<dt className={styles.term}>{item.term}</dt>
|
||||
<dd
|
||||
className={[styles.detail, truncate ? styles.truncate : ''].filter(Boolean).join(' ')}
|
||||
title={truncate ? extractText(item.detail) : undefined}
|
||||
>
|
||||
{item.detail}
|
||||
</dd>
|
||||
</div>
|
||||
))}
|
||||
</dl>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
.wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-1);
|
||||
font-family: var(--font-family);
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.label {
|
||||
font-size: var(--font-size-sm);
|
||||
font-weight: 500;
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.input {
|
||||
font-family: var(--font-family);
|
||||
font-size: var(--font-size-md);
|
||||
color: var(--color-text);
|
||||
background: var(--color-bg);
|
||||
border: var(--border-width) solid var(--color-border);
|
||||
border-radius: var(--radius-md);
|
||||
padding: var(--space-2) var(--space-3);
|
||||
height: 36px;
|
||||
width: 100%;
|
||||
outline: none;
|
||||
box-shadow: var(--shadow-xs);
|
||||
transition: border-color var(--transition), box-shadow var(--transition);
|
||||
}
|
||||
|
||||
.input::placeholder {
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
.input:focus {
|
||||
border-color: var(--color-primary);
|
||||
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
|
||||
}
|
||||
|
||||
.input:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
background: var(--color-bg-subtle);
|
||||
}
|
||||
|
||||
.hasError {
|
||||
border-color: var(--color-error-fg);
|
||||
}
|
||||
.hasError:focus {
|
||||
border-color: var(--color-error-fg);
|
||||
box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
|
||||
}
|
||||
|
||||
.hint {
|
||||
font-size: var(--font-size-xs);
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
.error {
|
||||
font-size: var(--font-size-xs);
|
||||
color: var(--color-error-fg);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import React, { useId } from 'react';
|
||||
import styles from './Input.module.css';
|
||||
|
||||
export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'id'> {
|
||||
label?: string;
|
||||
hint?: string;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export function Input({ label, hint, error, className, ...props }: InputProps) {
|
||||
const id = useId();
|
||||
return (
|
||||
<div className={styles.wrapper}>
|
||||
{label && (
|
||||
<label htmlFor={id} className={styles.label}>
|
||||
{label}
|
||||
</label>
|
||||
)}
|
||||
<input
|
||||
id={id}
|
||||
className={[styles.input, error ? styles.hasError : '', className]
|
||||
.filter(Boolean)
|
||||
.join(' ')}
|
||||
aria-describedby={error ? `${id}-error` : hint ? `${id}-hint` : undefined}
|
||||
aria-invalid={error ? true : undefined}
|
||||
{...props}
|
||||
/>
|
||||
{error ? (
|
||||
<span id={`${id}-error`} className={styles.error} role="alert">
|
||||
{error}
|
||||
</span>
|
||||
) : hint ? (
|
||||
<span id={`${id}-hint`} className={styles.hint}>
|
||||
{hint}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
.markdown {
|
||||
color: var(--color-text);
|
||||
line-height: 1.65;
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
.markdown > :first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.markdown > :last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.markdown h1,
|
||||
.markdown h2,
|
||||
.markdown h3,
|
||||
.markdown h4,
|
||||
.markdown h5,
|
||||
.markdown h6 {
|
||||
line-height: 1.25;
|
||||
margin: var(--space-5) 0 var(--space-3);
|
||||
}
|
||||
|
||||
.markdown h1 {
|
||||
font-size: var(--font-size-lg);
|
||||
}
|
||||
|
||||
.markdown h2 {
|
||||
font-size: var(--font-size-md);
|
||||
}
|
||||
|
||||
.markdown h3,
|
||||
.markdown h4,
|
||||
.markdown h5,
|
||||
.markdown h6 {
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
.markdown p {
|
||||
margin: 0 0 var(--space-3);
|
||||
}
|
||||
|
||||
.markdown ul,
|
||||
.markdown ol {
|
||||
margin: 0 0 var(--space-3);
|
||||
padding-left: 1.35rem;
|
||||
}
|
||||
|
||||
.markdown li + li {
|
||||
margin-top: var(--space-1);
|
||||
}
|
||||
|
||||
.markdown blockquote {
|
||||
margin: 0 0 var(--space-3);
|
||||
padding: var(--space-2) var(--space-3);
|
||||
border-left: 3px solid var(--color-primary);
|
||||
background: color-mix(in srgb, var(--color-primary) 8%, transparent);
|
||||
border-radius: var(--radius-sm);
|
||||
}
|
||||
|
||||
.markdown pre {
|
||||
margin: 0 0 var(--space-3);
|
||||
padding: var(--space-3);
|
||||
border-radius: var(--radius-md);
|
||||
background: var(--color-code-bg, var(--color-bg-raised));
|
||||
border: var(--border-width) solid var(--color-border);
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.markdown code {
|
||||
font-family: var(--font-mono, ui-monospace, monospace);
|
||||
font-size: 0.92em;
|
||||
}
|
||||
|
||||
.markdown :not(pre) > code {
|
||||
padding: 0.12em 0.4em;
|
||||
border-radius: var(--radius-sm);
|
||||
background: color-mix(in srgb, var(--color-bg-raised) 60%, var(--color-secondary) 40%);
|
||||
border: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
.markdown table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin: 0 0 var(--space-3);
|
||||
}
|
||||
|
||||
.markdown th,
|
||||
.markdown td {
|
||||
border: var(--border-width) solid var(--color-border);
|
||||
padding: var(--space-2) var(--space-3);
|
||||
text-align: left;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.markdown th {
|
||||
background: color-mix(in srgb, var(--color-bg-raised) 85%, var(--color-secondary) 15%);
|
||||
}
|
||||
|
||||
.markdown a {
|
||||
color: var(--color-link);
|
||||
}
|
||||
|
||||
.markdown a:hover {
|
||||
color: var(--color-link-hover);
|
||||
}
|
||||
|
||||
.markdown hr {
|
||||
border: 0;
|
||||
border-top: var(--border-width) solid var(--color-border);
|
||||
margin: var(--space-4) 0;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import ReactMarkdown from 'react-markdown';
|
||||
import remarkGfm from 'remark-gfm';
|
||||
import styles from './MarkdownContent.module.css';
|
||||
|
||||
export interface MarkdownContentProps {
|
||||
content: string;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function MarkdownContent({ content, className }: MarkdownContentProps) {
|
||||
return (
|
||||
<div className={`${styles.markdown}${className ? ` ${className}` : ''}`}>
|
||||
<ReactMarkdown remarkPlugins={[remarkGfm]}>{content}</ReactMarkdown>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
.overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 2000;
|
||||
background: color-mix(in srgb, #000 45%, transparent);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: var(--space-4);
|
||||
}
|
||||
|
||||
.dialog {
|
||||
width: min(520px, 100%);
|
||||
background-color: var(--color-bg-subtle, #ffffff);
|
||||
border: var(--border-width) solid var(--color-border);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: 0 20px 48px color-mix(in srgb, #000 28%, transparent);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.header {
|
||||
padding: var(--space-4) var(--space-5) var(--space-2);
|
||||
}
|
||||
|
||||
.title {
|
||||
margin: 0;
|
||||
font-size: var(--font-size-md);
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.body {
|
||||
padding: var(--space-2) var(--space-5) var(--space-4);
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
.footer {
|
||||
padding: var(--space-3) var(--space-5) var(--space-4);
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import { useEffect } from 'react';
|
||||
import styles from './Modal.module.css';
|
||||
|
||||
export interface ModalProps {
|
||||
open: boolean;
|
||||
title: string;
|
||||
children?: React.ReactNode;
|
||||
onClose: () => void;
|
||||
footer?: React.ReactNode;
|
||||
}
|
||||
|
||||
export function Modal({ open, title, children, onClose, footer }: ModalProps) {
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
const onKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.key === 'Escape') onClose();
|
||||
};
|
||||
window.addEventListener('keydown', onKeyDown);
|
||||
return () => window.removeEventListener('keydown', onKeyDown);
|
||||
}, [open, onClose]);
|
||||
|
||||
if (!open) return null;
|
||||
|
||||
return (
|
||||
<div className={styles.overlay} role="presentation" onClick={onClose}>
|
||||
<div
|
||||
className={styles.dialog}
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-label={title}
|
||||
onClick={(event) => event.stopPropagation()}
|
||||
>
|
||||
<div className={styles.header}>
|
||||
<h3 className={styles.title}>{title}</h3>
|
||||
</div>
|
||||
<div className={styles.body}>{children}</div>
|
||||
{footer && <div className={styles.footer}>{footer}</div>}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
.notification {
|
||||
display: flex;
|
||||
gap: var(--space-3);
|
||||
padding: var(--space-3) var(--space-4);
|
||||
border-radius: var(--radius-md);
|
||||
border-left: 3px solid;
|
||||
font-size: var(--font-size-sm);
|
||||
margin-bottom: var(--space-4);
|
||||
}
|
||||
|
||||
.icon {
|
||||
flex-shrink: 0;
|
||||
margin-top: 1px;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-1);
|
||||
}
|
||||
|
||||
.title {
|
||||
margin: 0;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.message {
|
||||
margin: 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
/* ── Variants ───────────────────────────────────────────────── */
|
||||
|
||||
.info {
|
||||
background: var(--color-info-bg);
|
||||
color: var(--color-info-fg);
|
||||
border-left-color: var(--color-secondary-fg);
|
||||
}
|
||||
|
||||
.success {
|
||||
background: var(--color-success-bg);
|
||||
color: var(--color-success-fg);
|
||||
border-left-color: var(--color-primary-hover);
|
||||
}
|
||||
|
||||
.error {
|
||||
background: var(--color-error-bg);
|
||||
color: var(--color-error-fg);
|
||||
border-left-color: var(--color-danger);
|
||||
}
|
||||
|
||||
.warning {
|
||||
background: var(--color-warning-bg);
|
||||
color: var(--color-warning-fg);
|
||||
border-left-color: #E09000;
|
||||
}
|
||||
|
||||
.note {
|
||||
background: var(--color-neutral-bg);
|
||||
color: var(--color-neutral-fg);
|
||||
border-left-color: var(--color-border);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import { AlertCircle, AlertTriangle, CheckCircle2, Info, StickyNote } from 'lucide-react';
|
||||
import styles from './Notification.module.css';
|
||||
|
||||
export type NotificationVariant = 'info' | 'success' | 'error' | 'warning' | 'note';
|
||||
|
||||
export interface NotificationProps {
|
||||
variant?: NotificationVariant;
|
||||
title?: string;
|
||||
children: React.ReactNode;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const ICONS: Record<NotificationVariant, React.ReactNode> = {
|
||||
info: <Info size={16} />,
|
||||
success: <CheckCircle2 size={16} />,
|
||||
error: <AlertCircle size={16} />,
|
||||
warning: <AlertTriangle size={16} />,
|
||||
note: <StickyNote size={16} />,
|
||||
};
|
||||
|
||||
export function Notification({ variant = 'info', title, children, className }: NotificationProps) {
|
||||
return (
|
||||
<div className={[styles.notification, styles[variant], className].filter(Boolean).join(' ')}>
|
||||
<span className={styles.icon}>{ICONS[variant]}</span>
|
||||
<div className={styles.body}>
|
||||
{title && <p className={styles.title}>{title}</p>}
|
||||
<p className={styles.message}>{children}</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Loaded 100 of 264 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user