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
19 changes: 0 additions & 19 deletions code/lib/manager-api/src/lib/stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,6 @@ export const transformStoryIndexToStoriesHash = (
startCollapsed: collapsedRoots.includes(id),
// Note that this will later get appended to the previous list of children (see below)
children: [childId],

// deprecated fields
isRoot: true,
isComponent: false,
isLeaf: false,
});
// Usually the last path/name pair will be displayed as a component,
// *unless* there are other stories that are more deeply nested under it
Expand All @@ -240,10 +235,6 @@ export const transformStoryIndexToStoriesHash = (
...(childId && {
children: [childId],
}),
// deprecated fields
isRoot: false,
isComponent: true,
isLeaf: false,
});
} else {
acc[id] = merge<API_GroupEntry>((acc[id] || {}) as API_GroupEntry, {
Expand All @@ -256,10 +247,6 @@ export const transformStoryIndexToStoriesHash = (
...(childId && {
children: [childId],
}),
// deprecated fields
isRoot: false,
isComponent: false,
isLeaf: false,
});
}
});
Expand All @@ -272,12 +259,6 @@ export const transformStoryIndexToStoriesHash = (
parent: paths[paths.length - 1],
renderLabel,
prepared: !!item.parameters,

// deprecated fields
kind: item.title,
isRoot: false,
isComponent: false,
isLeaf: true,
} as API_DocsEntry | API_StoryEntry;

return acc;
Expand Down
29 changes: 0 additions & 29 deletions code/lib/manager-api/src/tests/stories.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1448,9 +1448,6 @@ describe('stories API', () => {
],
"depth": 0,
"id": "a",
"isComponent": true,
"isLeaf": false,
"isRoot": false,
"name": "a",
"parent": undefined,
"renderLabel": undefined,
Expand All @@ -1460,10 +1457,6 @@ describe('stories API', () => {
"depth": 1,
"id": "a--1",
"importPath": "./a.ts",
"isComponent": false,
"isLeaf": true,
"isRoot": false,
"kind": "a",
"name": "1",
"parent": "a",
"prepared": false,
Expand All @@ -1475,10 +1468,6 @@ describe('stories API', () => {
"depth": 1,
"id": "a--2",
"importPath": "./a.ts",
"isComponent": false,
"isLeaf": true,
"isRoot": false,
"kind": "a",
"name": "2",
"parent": "a",
"prepared": false,
Expand Down Expand Up @@ -1524,9 +1513,6 @@ describe('stories API', () => {
],
"depth": 0,
"id": "a",
"isComponent": true,
"isLeaf": false,
"isRoot": false,
"name": "a",
"parent": undefined,
"renderLabel": undefined,
Expand All @@ -1536,10 +1522,6 @@ describe('stories API', () => {
"depth": 1,
"id": "a--1",
"importPath": "./a.ts",
"isComponent": false,
"isLeaf": true,
"isRoot": false,
"kind": "a",
"name": "1",
"parent": "a",
"prepared": false,
Expand Down Expand Up @@ -1572,9 +1554,6 @@ describe('stories API', () => {
],
"depth": 0,
"id": "a",
"isComponent": true,
"isLeaf": false,
"isRoot": false,
"name": "a",
"parent": undefined,
"renderLabel": undefined,
Expand All @@ -1584,10 +1563,6 @@ describe('stories API', () => {
"depth": 1,
"id": "a--1",
"importPath": "./a.ts",
"isComponent": false,
"isLeaf": true,
"isRoot": false,
"kind": "a",
"name": "1",
"parent": "a",
"prepared": false,
Expand All @@ -1599,10 +1574,6 @@ describe('stories API', () => {
"depth": 1,
"id": "a--2",
"importPath": "./a.ts",
"isComponent": false,
"isLeaf": true,
"isRoot": false,
"kind": "a",
"name": "2",
"parent": "a",
"prepared": false,
Expand Down
3 changes: 1 addition & 2 deletions code/lib/manager-api/src/tests/url.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ describe('initModule', () => {
type: 'story',
args: { a: 1, b: 2 },
initialArgs: { a: 1, b: 1 },
isLeaf: true,
}),
}),
});
Expand Down Expand Up @@ -194,7 +193,7 @@ describe('initModule', () => {
state: { location: {} },
navigate,
fullAPI: Object.assign(fullAPI, {
getCurrentStoryData: () => ({ type: 'story', args: { a: 1 }, isLeaf: true }),
getCurrentStoryData: () => ({ type: 'story', args: { a: 1 } }),
}),
});

Expand Down
55 changes: 0 additions & 55 deletions code/lib/types/src/modules/api-stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,81 +9,42 @@ export interface API_BaseEntry {
name: string;
refId?: string;
renderLabel?: (item: API_BaseEntry) => any;

/** @deprecated */
isRoot: boolean;
/** @deprecated */
isComponent: boolean;
/** @deprecated */
isLeaf: boolean;
}

export interface API_RootEntry extends API_BaseEntry {
type: 'root';
startCollapsed?: boolean;
children: StoryId[];

/** @deprecated */
isRoot: true;
/** @deprecated */
isComponent: false;
/** @deprecated */
isLeaf: false;
}

export interface API_GroupEntry extends API_BaseEntry {
type: 'group';
parent?: StoryId;
children: StoryId[];

/** @deprecated */
isRoot: false;
/** @deprecated */
isComponent: false;
/** @deprecated */
isLeaf: false;
}

export interface API_ComponentEntry extends API_BaseEntry {
type: 'component';
parent?: StoryId;
children: StoryId[];

/** @deprecated */
isRoot: false;
/** @deprecated */
isComponent: true;
/** @deprecated */
isLeaf: false;
}

export interface API_DocsEntry extends API_BaseEntry {
type: 'docs';
parent: StoryId;
title: ComponentTitle;
/** @deprecated */
kind: ComponentTitle;
importPath: Path;
tags: Tag[];
prepared: boolean;
parameters?: {
[parameterName: string]: any;
};

/** @deprecated */
isRoot: false;
/** @deprecated */
isComponent: false;
/** @deprecated */
isLeaf: true;
}

export interface API_StoryEntry extends API_BaseEntry {
type: 'story';
parent: StoryId;
title: ComponentTitle;
/** @deprecated */
kind: ComponentTitle;
importPath: Path;
tags: Tag[];
prepared: boolean;
Expand All @@ -93,13 +54,6 @@ export interface API_StoryEntry extends API_BaseEntry {
args?: Args;
argTypes?: ArgTypes;
initialArgs?: Args;

/** @deprecated */
isRoot: false;
/** @deprecated */
isComponent: false;
/** @deprecated */
isLeaf: true;
}

export type API_LeafEntry = API_DocsEntry | API_StoryEntry;
Expand All @@ -110,15 +64,6 @@ export type API_HashEntry =
| API_DocsEntry
| API_StoryEntry;

/** @deprecated */
export type API_Root = API_RootEntry;

/** @deprecated */
export type API_Group = API_GroupEntry | API_ComponentEntry;

/** @deprecated */
export type API_Story = API_LeafEntry;

/**
* The `IndexHash` is our manager-side representation of the `StoryIndex`.
* We create entries in the hash not only for each story or docs entry, but
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,20 @@ const mockManagerStore: any = {
type: 'root',
id: 'someRootId',
name: 'root',
isRoot: true,
isComponent: false,
isLeaf: false,
renderLabel,
},
someComponentId: {
type: 'component',
id: 'someComponentId',
name: 'component',
parent: 'someRootId',
isRoot: false,
isComponent: true,
isLeaf: false,
renderLabel,
},
someStoryId: {
type: 'story',
id: 'someStoryId',
name: 'story',
parent: 'someComponentId',
isRoot: false,
isComponent: false,
isLeaf: true,
renderLabel,
},
},
Expand Down Expand Up @@ -110,29 +101,20 @@ export const LongStoryName: Story = {
type: 'root',
id: 'someRootId',
name: 'someLongRootName',
isRoot: true,
isComponent: false,
isLeaf: false,
renderLabel,
},
someComponentId: {
type: 'component',
id: 'someComponentId',
name: 'someComponentName',
parent: 'someRootId',
isRoot: false,
isComponent: true,
isLeaf: false,
renderLabel,
},
someStoryId: {
type: 'story',
id: 'someStoryId',
name: 'someLongStoryName',
parent: 'someComponentId',
isRoot: false,
isComponent: false,
isLeaf: true,
renderLabel,
},
},
Expand Down
4 changes: 0 additions & 4 deletions code/ui/manager/src/components/preview/Preview.mockdata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ export const previewProps: PreviewProps = {
options: {},
},
args: {},
kind: 'kind',
isRoot: false,
isComponent: false,
isLeaf: true,
},
path: 'string',
viewMode: 'story',
Expand Down
13 changes: 4 additions & 9 deletions code/ui/manager/src/components/sidebar/SearchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,8 @@ const Result: FC<

const api = useStorybookApi();
useEffect(() => {
if (api && props.isHighlighted && item.isComponent) {
api.emit(
PRELOAD_ENTRIES,
// @ts-expect-error (TODO)
{ ids: [item.isLeaf ? item.id : item.children[0]] },
{ options: { target: item.refId } }
);
if (api && props.isHighlighted && item.type === 'component') {
api.emit(PRELOAD_ENTRIES, { ids: [item.children[0]] }, { options: { target: item.refId } });
}
}, [props.isHighlighted, item]);

Expand Down Expand Up @@ -275,9 +270,9 @@ export const SearchResults: FC<{
const currentTarget = event.currentTarget as HTMLElement;
const storyId = currentTarget.getAttribute('data-id');
const refId = currentTarget.getAttribute('data-refid');
const item = api.getData(storyId, refId === 'storybook_internal' ? undefined : refId);
const item = api.resolveStory(storyId, refId === 'storybook_internal' ? undefined : refId);

if (item?.isComponent) {
if (item?.type === 'component') {
api.emit(PRELOAD_ENTRIES, {
// @ts-expect-error (TODO)
ids: [item.isLeaf ? item.id : item.children[0]],
Expand Down
Loading