inspector/clients/web/src/components/groups/ResourcePreviewPanel/ResourcePreviewPanel.stories.tsx
cliffhall d817c46911 Phase 2: Refactor Resources cluster to MCP SDK types
Replace ad hoc local types with MCP SDK schema types across the Resources
group components and ResourcesScreen, per the v2 UX interfaces plan.

- ResourceListItem: accept `resource: Resource | ResourceTemplate` instead
  of flat `name`/`uri`; render `title ?? name`; delete local
  `ResourceAnnotations` type
- ResourceControls: accept `Resource[]`, `ResourceTemplate[]`,
  `InspectorResourceSubscription[]` + `selectedUri`/`selectedTemplate`
  instead of `ResourceItem[]`/`TemplateListItem[]`/`SubscriptionItem[]`;
  no-op on re-selecting
- ResourcePreviewPanel: accept `resource: Resource` +
  `contents: (TextResourceContents | BlobResourceContents)[]` instead of
  flat `content: string`; use SDK `Annotations` (audience as Role[]);
  `lastUpdated` as `Date` not `string`
- ResourceTemplatePanel: accept `template: ResourceTemplate` instead of
  flat props; use SDK `Annotations`
- ResourceSubscribedItem: accept `subscription: InspectorResourceSubscription`
  instead of flat `name`/`lastUpdated`; `lastUpdated` as `Date`
- ResourcesScreen: accept `Resource[]`, `ResourceTemplate[]`,
  `InspectorResourceSubscription[]` + `selectedResourceUri`/
  `selectedTemplateUri` + `ReadResourceState`; derive selections via
  `find()`; add loading/error states
- Delete local `ResourceItem`, `TemplateListItem`, `SubscriptionItem`,
  `SelectedResource`, `SelectedTemplate`, `ResourceAnnotations` types
- Update all stories with real SDK fixtures
- Update ConnectedView ResourcesActive story

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-18 18:34:32 -04:00

112 lines
2.4 KiB
TypeScript

import type { Meta, StoryObj } from "@storybook/react-vite";
import { fn } from "storybook/test";
import { ResourcePreviewPanel } from "./ResourcePreviewPanel";
const meta: Meta<typeof ResourcePreviewPanel> = {
title: "Groups/ResourcePreviewPanel",
component: ResourcePreviewPanel,
args: {
onRefresh: fn(),
onSubscribe: fn(),
onUnsubscribe: fn(),
},
};
export default meta;
type Story = StoryObj<typeof ResourcePreviewPanel>;
export const JsonResource: Story = {
args: {
resource: {
name: "config.json",
uri: "file:///config.json",
},
contents: [
{
uri: "file:///config.json",
mimeType: "application/json",
text: JSON.stringify(
{ name: "mcp-inspector", version: "2.0.0", debug: true },
null,
2,
),
},
],
isSubscribed: false,
lastUpdated: new Date("2026-03-17T10:30:00Z"),
},
};
export const TextResource: Story = {
args: {
resource: {
name: "readme.txt",
uri: "file:///readme.txt",
},
contents: [
{
uri: "file:///readme.txt",
mimeType: "text/plain",
text: "This is a plain text resource with some example content.\nLine two of the content.",
},
],
isSubscribed: false,
},
};
export const Subscribed: Story = {
args: {
resource: {
name: "data.json",
uri: "file:///data.json",
},
contents: [
{
uri: "file:///data.json",
mimeType: "application/json",
text: JSON.stringify({ status: "active" }, null, 2),
},
],
isSubscribed: true,
lastUpdated: new Date("2026-03-17T12:00:00Z"),
},
};
export const NotSubscribed: Story = {
args: {
resource: {
name: "data.json",
uri: "file:///data.json",
},
contents: [
{
uri: "file:///data.json",
mimeType: "application/json",
text: JSON.stringify({ status: "active" }, null, 2),
},
],
isSubscribed: false,
},
};
export const WithAnnotations: Story = {
args: {
resource: {
name: "settings.json",
uri: "file:///settings.json",
annotations: {
audience: ["user"],
priority: 0.8,
},
},
contents: [
{
uri: "file:///settings.json",
mimeType: "application/json",
text: JSON.stringify({ theme: "dark", lang: "en" }, null, 2),
},
],
isSubscribed: false,
lastUpdated: new Date("2026-03-17T09:00:00Z"),
},
};