Skip to content

Commit 176fd77

Browse files
Merge pull request #25578 from storybookjs/valentin/remove-properties-from-api-stories-1
Remove deprecated properties from manager-api
2 parents a4585b3 + eec6aaa commit 176fd77

File tree

11 files changed

+9
-157
lines changed

11 files changed

+9
-157
lines changed

code/lib/manager-api/src/lib/stories.ts

-19
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,6 @@ export const transformStoryIndexToStoriesHash = (
221221
startCollapsed: collapsedRoots.includes(id),
222222
// Note that this will later get appended to the previous list of children (see below)
223223
children: [childId],
224-
225-
// deprecated fields
226-
isRoot: true,
227-
isComponent: false,
228-
isLeaf: false,
229224
});
230225
// Usually the last path/name pair will be displayed as a component,
231226
// *unless* there are other stories that are more deeply nested under it
@@ -246,10 +241,6 @@ export const transformStoryIndexToStoriesHash = (
246241
...(childId && {
247242
children: [childId],
248243
}),
249-
// deprecated fields
250-
isRoot: false,
251-
isComponent: true,
252-
isLeaf: false,
253244
});
254245
} else {
255246
acc[id] = merge<API_GroupEntry>((acc[id] || {}) as API_GroupEntry, {
@@ -262,10 +253,6 @@ export const transformStoryIndexToStoriesHash = (
262253
...(childId && {
263254
children: [childId],
264255
}),
265-
// deprecated fields
266-
isRoot: false,
267-
isComponent: false,
268-
isLeaf: false,
269256
});
270257
}
271258
});
@@ -278,12 +265,6 @@ export const transformStoryIndexToStoriesHash = (
278265
parent: paths[paths.length - 1],
279266
renderLabel,
280267
prepared: !!item.parameters,
281-
282-
// deprecated fields
283-
kind: item.title,
284-
isRoot: false,
285-
isComponent: false,
286-
isLeaf: true,
287268
} as API_DocsEntry | API_StoryEntry;
288269

289270
return acc;

code/lib/manager-api/src/tests/stories.test.ts

-29
Original file line numberDiff line numberDiff line change
@@ -1448,9 +1448,6 @@ describe('stories API', () => {
14481448
],
14491449
"depth": 0,
14501450
"id": "a",
1451-
"isComponent": true,
1452-
"isLeaf": false,
1453-
"isRoot": false,
14541451
"name": "a",
14551452
"parent": undefined,
14561453
"renderLabel": undefined,
@@ -1460,10 +1457,6 @@ describe('stories API', () => {
14601457
"depth": 1,
14611458
"id": "a--1",
14621459
"importPath": "./a.ts",
1463-
"isComponent": false,
1464-
"isLeaf": true,
1465-
"isRoot": false,
1466-
"kind": "a",
14671460
"name": "1",
14681461
"parent": "a",
14691462
"prepared": false,
@@ -1475,10 +1468,6 @@ describe('stories API', () => {
14751468
"depth": 1,
14761469
"id": "a--2",
14771470
"importPath": "./a.ts",
1478-
"isComponent": false,
1479-
"isLeaf": true,
1480-
"isRoot": false,
1481-
"kind": "a",
14821471
"name": "2",
14831472
"parent": "a",
14841473
"prepared": false,
@@ -1524,9 +1513,6 @@ describe('stories API', () => {
15241513
],
15251514
"depth": 0,
15261515
"id": "a",
1527-
"isComponent": true,
1528-
"isLeaf": false,
1529-
"isRoot": false,
15301516
"name": "a",
15311517
"parent": undefined,
15321518
"renderLabel": undefined,
@@ -1536,10 +1522,6 @@ describe('stories API', () => {
15361522
"depth": 1,
15371523
"id": "a--1",
15381524
"importPath": "./a.ts",
1539-
"isComponent": false,
1540-
"isLeaf": true,
1541-
"isRoot": false,
1542-
"kind": "a",
15431525
"name": "1",
15441526
"parent": "a",
15451527
"prepared": false,
@@ -1572,9 +1554,6 @@ describe('stories API', () => {
15721554
],
15731555
"depth": 0,
15741556
"id": "a",
1575-
"isComponent": true,
1576-
"isLeaf": false,
1577-
"isRoot": false,
15781557
"name": "a",
15791558
"parent": undefined,
15801559
"renderLabel": undefined,
@@ -1584,10 +1563,6 @@ describe('stories API', () => {
15841563
"depth": 1,
15851564
"id": "a--1",
15861565
"importPath": "./a.ts",
1587-
"isComponent": false,
1588-
"isLeaf": true,
1589-
"isRoot": false,
1590-
"kind": "a",
15911566
"name": "1",
15921567
"parent": "a",
15931568
"prepared": false,
@@ -1599,10 +1574,6 @@ describe('stories API', () => {
15991574
"depth": 1,
16001575
"id": "a--2",
16011576
"importPath": "./a.ts",
1602-
"isComponent": false,
1603-
"isLeaf": true,
1604-
"isRoot": false,
1605-
"kind": "a",
16061577
"name": "2",
16071578
"parent": "a",
16081579
"prepared": false,

code/lib/manager-api/src/tests/url.test.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ describe('initModule', () => {
157157
type: 'story',
158158
args: { a: 1, b: 2 },
159159
initialArgs: { a: 1, b: 1 },
160-
isLeaf: true,
161160
}),
162161
}),
163162
});
@@ -194,7 +193,7 @@ describe('initModule', () => {
194193
state: { location: {} },
195194
navigate,
196195
fullAPI: Object.assign(fullAPI, {
197-
getCurrentStoryData: () => ({ type: 'story', args: { a: 1 }, isLeaf: true }),
196+
getCurrentStoryData: () => ({ type: 'story', args: { a: 1 } }),
198197
}),
199198
});
200199

code/lib/types/src/modules/api-stories.ts

-55
Original file line numberDiff line numberDiff line change
@@ -9,81 +9,42 @@ export interface API_BaseEntry {
99
name: string;
1010
refId?: string;
1111
renderLabel?: (item: API_BaseEntry) => any;
12-
13-
/** @deprecated */
14-
isRoot: boolean;
15-
/** @deprecated */
16-
isComponent: boolean;
17-
/** @deprecated */
18-
isLeaf: boolean;
1912
}
2013

2114
export interface API_RootEntry extends API_BaseEntry {
2215
type: 'root';
2316
startCollapsed?: boolean;
2417
children: StoryId[];
25-
26-
/** @deprecated */
27-
isRoot: true;
28-
/** @deprecated */
29-
isComponent: false;
30-
/** @deprecated */
31-
isLeaf: false;
3218
}
3319

3420
export interface API_GroupEntry extends API_BaseEntry {
3521
type: 'group';
3622
parent?: StoryId;
3723
children: StoryId[];
38-
39-
/** @deprecated */
40-
isRoot: false;
41-
/** @deprecated */
42-
isComponent: false;
43-
/** @deprecated */
44-
isLeaf: false;
4524
}
4625

4726
export interface API_ComponentEntry extends API_BaseEntry {
4827
type: 'component';
4928
parent?: StoryId;
5029
children: StoryId[];
51-
52-
/** @deprecated */
53-
isRoot: false;
54-
/** @deprecated */
55-
isComponent: true;
56-
/** @deprecated */
57-
isLeaf: false;
5830
}
5931

6032
export interface API_DocsEntry extends API_BaseEntry {
6133
type: 'docs';
6234
parent: StoryId;
6335
title: ComponentTitle;
64-
/** @deprecated */
65-
kind: ComponentTitle;
6636
importPath: Path;
6737
tags: Tag[];
6838
prepared: boolean;
6939
parameters?: {
7040
[parameterName: string]: any;
7141
};
72-
73-
/** @deprecated */
74-
isRoot: false;
75-
/** @deprecated */
76-
isComponent: false;
77-
/** @deprecated */
78-
isLeaf: true;
7942
}
8043

8144
export interface API_StoryEntry extends API_BaseEntry {
8245
type: 'story';
8346
parent: StoryId;
8447
title: ComponentTitle;
85-
/** @deprecated */
86-
kind: ComponentTitle;
8748
importPath: Path;
8849
tags: Tag[];
8950
prepared: boolean;
@@ -93,13 +54,6 @@ export interface API_StoryEntry extends API_BaseEntry {
9354
args?: Args;
9455
argTypes?: ArgTypes;
9556
initialArgs?: Args;
96-
97-
/** @deprecated */
98-
isRoot: false;
99-
/** @deprecated */
100-
isComponent: false;
101-
/** @deprecated */
102-
isLeaf: true;
10357
}
10458

10559
export type API_LeafEntry = API_DocsEntry | API_StoryEntry;
@@ -110,15 +64,6 @@ export type API_HashEntry =
11064
| API_DocsEntry
11165
| API_StoryEntry;
11266

113-
/** @deprecated */
114-
export type API_Root = API_RootEntry;
115-
116-
/** @deprecated */
117-
export type API_Group = API_GroupEntry | API_ComponentEntry;
118-
119-
/** @deprecated */
120-
export type API_Story = API_LeafEntry;
121-
12267
/**
12368
* The `IndexHash` is our manager-side representation of the `StoryIndex`.
12469
* We create entries in the hash not only for each story or docs entry, but

code/ui/manager/src/components/mobile/navigation/MobileNavigation.stories.tsx

-18
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,20 @@ const mockManagerStore: any = {
2727
type: 'root',
2828
id: 'someRootId',
2929
name: 'root',
30-
isRoot: true,
31-
isComponent: false,
32-
isLeaf: false,
3330
renderLabel,
3431
},
3532
someComponentId: {
3633
type: 'component',
3734
id: 'someComponentId',
3835
name: 'component',
3936
parent: 'someRootId',
40-
isRoot: false,
41-
isComponent: true,
42-
isLeaf: false,
4337
renderLabel,
4438
},
4539
someStoryId: {
4640
type: 'story',
4741
id: 'someStoryId',
4842
name: 'story',
4943
parent: 'someComponentId',
50-
isRoot: false,
51-
isComponent: false,
52-
isLeaf: true,
5344
renderLabel,
5445
},
5546
},
@@ -110,29 +101,20 @@ export const LongStoryName: Story = {
110101
type: 'root',
111102
id: 'someRootId',
112103
name: 'someLongRootName',
113-
isRoot: true,
114-
isComponent: false,
115-
isLeaf: false,
116104
renderLabel,
117105
},
118106
someComponentId: {
119107
type: 'component',
120108
id: 'someComponentId',
121109
name: 'someComponentName',
122110
parent: 'someRootId',
123-
isRoot: false,
124-
isComponent: true,
125-
isLeaf: false,
126111
renderLabel,
127112
},
128113
someStoryId: {
129114
type: 'story',
130115
id: 'someStoryId',
131116
name: 'someLongStoryName',
132117
parent: 'someComponentId',
133-
isRoot: false,
134-
isComponent: false,
135-
isLeaf: true,
136118
renderLabel,
137119
},
138120
},

code/ui/manager/src/components/preview/Preview.mockdata.tsx

-4
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ export const previewProps: PreviewProps = {
3939
options: {},
4040
},
4141
args: {},
42-
kind: 'kind',
43-
isRoot: false,
44-
isComponent: false,
45-
isLeaf: true,
4642
},
4743
path: 'string',
4844
viewMode: 'story',

code/ui/manager/src/components/sidebar/SearchResults.tsx

+4-9
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,8 @@ const Result: FC<
177177

178178
const api = useStorybookApi();
179179
useEffect(() => {
180-
if (api && props.isHighlighted && item.isComponent) {
181-
api.emit(
182-
PRELOAD_ENTRIES,
183-
// @ts-expect-error (TODO)
184-
{ ids: [item.isLeaf ? item.id : item.children[0]] },
185-
{ options: { target: item.refId } }
186-
);
180+
if (api && props.isHighlighted && item.type === 'component') {
181+
api.emit(PRELOAD_ENTRIES, { ids: [item.children[0]] }, { options: { target: item.refId } });
187182
}
188183
}, [props.isHighlighted, item]);
189184

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

280-
if (item?.isComponent) {
275+
if (item?.type === 'component') {
281276
api.emit(PRELOAD_ENTRIES, {
282277
// @ts-expect-error (TODO)
283278
ids: [item.isLeaf ? item.id : item.children[0]],

0 commit comments

Comments
 (0)