Fix ServerSettingsModal stories to use useArgs for action logging
Use args + useArgs pattern so onSettingsChange and onClose fire through Storybook's args system. Every form interaction now logs to the Actions panel with the full updated settings object. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d27018b4f2
commit
29ce55290f
1 changed files with 31 additions and 25 deletions
|
|
@ -1,8 +1,12 @@
|
||||||
import { useState } from "react";
|
|
||||||
import type { InspectorServerSettings } from "@inspector/core/mcp/types.js";
|
import type { InspectorServerSettings } from "@inspector/core/mcp/types.js";
|
||||||
import { AppShell } from "@mantine/core";
|
import { AppShell } from "@mantine/core";
|
||||||
import type { Meta, StoryObj } from "@storybook/react-vite";
|
import type { Meta, StoryObj } from "@storybook/react-vite";
|
||||||
import { ServerSettingsModal } from "./ServerSettingsModal";
|
import { fn } from "storybook/test";
|
||||||
|
import { useArgs } from "storybook/preview-api";
|
||||||
|
import {
|
||||||
|
ServerSettingsModal,
|
||||||
|
type ServerSettingsModalProps,
|
||||||
|
} from "./ServerSettingsModal";
|
||||||
|
|
||||||
const initialSettings: InspectorServerSettings = {
|
const initialSettings: InspectorServerSettings = {
|
||||||
connectionMode: "proxy",
|
connectionMode: "proxy",
|
||||||
|
|
@ -18,22 +22,18 @@ const initialSettings: InspectorServerSettings = {
|
||||||
oauthScopes: "read write",
|
oauthScopes: "read write",
|
||||||
};
|
};
|
||||||
|
|
||||||
function InteractiveModal({
|
function InteractiveRender(args: ServerSettingsModalProps) {
|
||||||
startSettings,
|
const [, updateArgs] = useArgs<ServerSettingsModalProps>();
|
||||||
}: {
|
|
||||||
startSettings: InspectorServerSettings;
|
|
||||||
}) {
|
|
||||||
const [settings, setSettings] =
|
|
||||||
useState<InspectorServerSettings>(startSettings);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppShell>
|
<AppShell>
|
||||||
<AppShell.Main>
|
<AppShell.Main>
|
||||||
<ServerSettingsModal
|
<ServerSettingsModal
|
||||||
opened
|
{...args}
|
||||||
settings={settings}
|
onSettingsChange={(settings) => {
|
||||||
onClose={() => {}}
|
args.onSettingsChange(settings);
|
||||||
onSettingsChange={setSettings}
|
updateArgs({ settings });
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</AppShell.Main>
|
</AppShell.Main>
|
||||||
</AppShell>
|
</AppShell>
|
||||||
|
|
@ -44,25 +44,31 @@ const meta: Meta<typeof ServerSettingsModal> = {
|
||||||
title: "Groups/ServerSettingsModal",
|
title: "Groups/ServerSettingsModal",
|
||||||
component: ServerSettingsModal,
|
component: ServerSettingsModal,
|
||||||
parameters: { layout: "fullscreen" },
|
parameters: { layout: "fullscreen" },
|
||||||
|
render: InteractiveRender,
|
||||||
|
args: {
|
||||||
|
opened: true,
|
||||||
|
onClose: fn(),
|
||||||
|
onSettingsChange: fn(),
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default meta;
|
export default meta;
|
||||||
type Story = StoryObj<typeof ServerSettingsModal>;
|
type Story = StoryObj<typeof ServerSettingsModal>;
|
||||||
|
|
||||||
export const FullyConfigured: Story = {
|
export const FullyConfigured: Story = {
|
||||||
render: () => <InteractiveModal startSettings={initialSettings} />,
|
args: {
|
||||||
|
settings: initialSettings,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const EmptySettings: Story = {
|
export const EmptySettings: Story = {
|
||||||
render: () => (
|
args: {
|
||||||
<InteractiveModal
|
settings: {
|
||||||
startSettings={{
|
connectionMode: "proxy",
|
||||||
connectionMode: "proxy",
|
headers: [],
|
||||||
headers: [],
|
metadata: [],
|
||||||
metadata: [],
|
connectionTimeout: 30000,
|
||||||
connectionTimeout: 30000,
|
requestTimeout: 60000,
|
||||||
requestTimeout: 60000,
|
},
|
||||||
}}
|
},
|
||||||
/>
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue