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

Composition: Allow refs versions in config #11294

Merged
merged 8 commits into from
Jun 24, 2020
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
4 changes: 4 additions & 0 deletions examples/dev-kits/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ module.exports = {
id: 'ember',
title: 'Ember',
url: 'https://next--storybookjs.netlify.app/ember-cli',
versions: {
next: 'https://next--storybookjs.netlify.app/ember-cli',
master: 'https://master--storybookjs.netlify.app/ember-cli',
},
},
cra: 'https://next--storybookjs.netlify.app/cra-ts-kitchen-sink',
},
Expand Down
5 changes: 3 additions & 2 deletions lib/api/src/modules/refs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ export const init: ModuleFn = ({ store, provider, fullAPI }, { runCheck = true }
return Object.values(refs).find(({ url }) => url.match(source));
},
changeRefVersion: (id, url) => {
const previous = api.getRefs()[id];
const ref = { ...previous, stories: {}, url } as SetRefData;
const { versions, title } = api.getRefs()[id];
const ref = { id, url, versions, title, stories: {} } as SetRefData;

api.checkRef(ref);
},
Expand Down Expand Up @@ -192,6 +192,7 @@ export const init: ModuleFn = ({ store, provider, fullAPI }, { runCheck = true }
id,
url,
...loadedData,
error: loadedData.error,
type: !loadedData.stories ? 'auto-inject' : 'lazy',
});
},
Expand Down
4 changes: 4 additions & 0 deletions lib/api/src/tests/refs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ describe('Refs API', () => {
Object {
"refs": Object {
"fake": Object {
"error": undefined,
"id": "fake",
"ready": false,
"stories": Object {},
Expand Down Expand Up @@ -423,6 +424,7 @@ describe('Refs API', () => {
Object {
"refs": Object {
"fake": Object {
"error": undefined,
"id": "fake",
"loginUrl": "https://example.com/login",
"ready": false,
Expand Down Expand Up @@ -516,6 +518,7 @@ describe('Refs API', () => {
Object {
"refs": Object {
"fake": Object {
"error": undefined,
"id": "fake",
"ready": false,
"stories": Object {},
Expand Down Expand Up @@ -603,6 +606,7 @@ describe('Refs API', () => {
Object {
"refs": Object {
"fake": Object {
"error": undefined,
"id": "fake",
"ready": false,
"stories": undefined,
Expand Down
2 changes: 1 addition & 1 deletion lib/api/src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version = '6.0.0-beta.34';
export const version = '6.0.0-beta.35';
30 changes: 15 additions & 15 deletions lib/cli/versions.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"@storybook/angular": "6.0.0-beta.34",
"@storybook/aurelia": "6.0.0-beta.34",
"@storybook/ember": "6.0.0-beta.34",
"@storybook/html": "6.0.0-beta.34",
"@storybook/marionette": "6.0.0-beta.34",
"@storybook/marko": "6.0.0-beta.34",
"@storybook/mithril": "6.0.0-beta.34",
"@storybook/preact": "6.0.0-beta.34",
"@storybook/rax": "6.0.0-beta.34",
"@storybook/react": "6.0.0-beta.34",
"@storybook/riot": "6.0.0-beta.34",
"@storybook/server": "6.0.0-beta.34",
"@storybook/svelte": "6.0.0-beta.34",
"@storybook/vue": "6.0.0-beta.34",
"@storybook/web-components": "6.0.0-beta.34"
"@storybook/angular": "6.0.0-beta.35",
"@storybook/aurelia": "6.0.0-beta.35",
"@storybook/ember": "6.0.0-beta.35",
"@storybook/html": "6.0.0-beta.35",
"@storybook/marionette": "6.0.0-beta.35",
"@storybook/marko": "6.0.0-beta.35",
"@storybook/mithril": "6.0.0-beta.35",
"@storybook/preact": "6.0.0-beta.35",
"@storybook/rax": "6.0.0-beta.35",
"@storybook/react": "6.0.0-beta.35",
"@storybook/riot": "6.0.0-beta.35",
"@storybook/server": "6.0.0-beta.35",
"@storybook/svelte": "6.0.0-beta.35",
"@storybook/vue": "6.0.0-beta.35",
"@storybook/web-components": "6.0.0-beta.35"
}
7 changes: 5 additions & 2 deletions lib/core/src/server/manager/manager-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,14 @@ async function getManagerWebpackConfig(options, presets) {
if (definedRefs) {
Object.entries(definedRefs).forEach(([key, value]) => {
const url = typeof value === 'string' ? value : value.url;
const title = typeof value === 'string' ? toTitle(key) : value.title || toTitle(value.key);
const rest =
typeof value === 'string'
? { title: toTitle(key) }
: { ...value, title: value.title || toTitle(value.key) };

refs[key] = {
id: key,
title,
...rest,
url: stripTrailingSlash(url),
};
});
Expand Down