Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .storybook/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ export const handlers = [
// - /api/v1/data/:object (GET, POST)
// - /api/v1/data/:object/:id (GET, PUT, DELETE)
// - /api/v1/metadata/*
// - /api/v1/index.json (for ObjectStackClient.connect())
// - /api/bootstrap
];
11 changes: 11 additions & 0 deletions .storybook/msw-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ export async function startMockServer() {
baseUrl: '/api/v1',
logRequests: true,
customHandlers: [
// Handle /api/v1/index.json for ObjectStackClient.connect()
http.get('/api/v1/index.json', async () => {
return HttpResponse.json({
version: '1.0',
objects: ['contact', 'opportunity', 'account'],
endpoints: {
data: '/api/v1/data',
metadata: '/api/v1/metadata'
}
});
}),
// Explicitly handle all metadata requests to prevent pass-through
http.get('/api/v1/metadata/*', async () => {
return HttpResponse.json({});
Expand Down
12 changes: 10 additions & 2 deletions packages/components/src/stories-json/object-gantt.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Meta, StoryObj } from '@storybook/react';
import { SchemaRenderer } from '../SchemaRenderer';
import { SchemaRenderer, SchemaRendererProvider } from '@object-ui/react';
import type { BaseSchema } from '@object-ui/types';
import { createStorybookDataSource } from '@storybook-config/datasource';

const meta = {
title: 'Views/Gantt',
Expand All @@ -20,7 +21,14 @@ const meta = {
export default meta;
type Story = StoryObj<typeof meta>;

const renderStory = (args: any) => <SchemaRenderer schema={args as unknown as BaseSchema} />;
// Create a DataSource instance that connects to MSW
const dataSource = createStorybookDataSource();

const renderStory = (args: any) => (
<SchemaRendererProvider dataSource={dataSource}>
<SchemaRenderer schema={args as unknown as BaseSchema} />
</SchemaRendererProvider>
);

export const ProjectSchedule: Story = {
render: renderStory,
Expand Down
12 changes: 10 additions & 2 deletions packages/components/src/stories-json/object-map.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Meta, StoryObj } from '@storybook/react';
import { SchemaRenderer } from '../SchemaRenderer';
import { SchemaRenderer, SchemaRendererProvider } from '@object-ui/react';
import type { BaseSchema } from '@object-ui/types';
import { createStorybookDataSource } from '@storybook-config/datasource';

const meta = {
title: 'Views/Map',
Expand All @@ -20,7 +21,14 @@ const meta = {
export default meta;
type Story = StoryObj<typeof meta>;

const renderStory = (args: any) => <SchemaRenderer schema={args as unknown as BaseSchema} />;
// Create a DataSource instance that connects to MSW
const dataSource = createStorybookDataSource();

const renderStory = (args: any) => (
<SchemaRendererProvider dataSource={dataSource}>
<SchemaRenderer schema={args as unknown as BaseSchema} />
</SchemaRendererProvider>
);

export const StoreLocations: Story = {
render: renderStory,
Expand Down
6 changes: 5 additions & 1 deletion packages/components/src/stories-json/object-view.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Meta, StoryObj } from '@storybook/react';
import { SchemaRenderer, SchemaRendererProvider } from '@object-ui/react';
import type { BaseSchema } from '@object-ui/types';
import { createStorybookDataSource } from '@storybook-config/datasource';

const meta = {
title: 'Views/Object View',
Expand All @@ -17,8 +18,11 @@ const meta = {
export default meta;
type Story = StoryObj<typeof meta>;

// Create a DataSource instance that connects to MSW
const dataSource = createStorybookDataSource();

const renderStory = (args: any) => (
<SchemaRendererProvider dataSource={{}}>
<SchemaRendererProvider dataSource={dataSource}>
<SchemaRenderer schema={args as unknown as BaseSchema} />
</SchemaRendererProvider>
);
Expand Down