Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHANGE to use getDataForManager over extract api on storyStore #11584

Merged
merged 7 commits into from
Jul 21, 2020
2 changes: 1 addition & 1 deletion lib/cli/src/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const read = async (url: string) => {
const data = JSON.parse(
await page.evaluate(async () => {
// eslint-disable-next-line no-undef
return JSON.stringify(window.__STORYBOOK_STORY_STORE__.getDataForManager(), null, 2);
return JSON.stringify(window.__STORYBOOK_STORY_STORE__.getStoriesJsonData(), null, 2);
})
);

Expand Down
30 changes: 30 additions & 0 deletions lib/client-api/src/story_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import memoize from 'memoizerific';
import dedent from 'ts-dedent';
import stable from 'stable';
import mapValues from 'lodash/mapValues';
import pick from 'lodash/pick';
import store from 'store2';

import { Channel } from '@storybook/channels';
Expand Down Expand Up @@ -569,6 +570,35 @@ export default class StoryStore {
};
};

getStoriesJsonData = () => {
const value = this.getDataForManager();
const allowed = ['fileName', 'docsOnly', 'framework', '__id'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__isArgsStory?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to know that for the sidebar?


return {
v: 2,
globalParameters: pick(value.globalParameters, allowed),
kindParameters: Object.entries(value.kindParameters).reduce(
ndelangen marked this conversation as resolved.
Show resolved Hide resolved
(acc, [k, v]) => ({
...acc,
[k]: pick(v, allowed),
}),
{}
),
stories: Object.entries(value.stories).reduce(
(acc, [k, v]) => ({
...acc,
// @ts-ignore
[k]: {
...pick(v, ['id', 'name', 'kind', 'story']),
// @ts-ignore
parameters: pick(v.parameters, allowed),
},
}),
{}
),
};
};

pushToManager = () => {
if (this._channel) {
// send to the parent frame.
Expand Down