Skip to content

Commit

Permalink
Restored and deprecated clearDecorators
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeasday committed Jul 6, 2020
1 parent 1f68045 commit 1d08802
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
- [Deprecated polymer](#deprecated-polymer)
- [Deprecated immutable options parameters](#deprecated-immutable-options-parameters)
- [Deprecated addParameters and addDecorator](#deprecated-addparameters-and-adddecorator)
- [Deprecated clearDecorators](#deprecated-cleardecorators)
- [Deprecated configure](#deprecated-configure)
- [From version 5.2.x to 5.3.x](#from-version-52x-to-53x)
- [To main.js configuration](#to-mainjs-configuration)
Expand Down Expand Up @@ -651,6 +652,10 @@ The `addParameters` and `addDecorator` APIs to add global decorators and paramet
Instead, use `export const parameters = {};` and `export const decorators = [];` in your `.storybook/preview.js`. Addon authors similarly should use such an export in a `previewEntry` file.
#### Deprecated clearDecorators
Similarly, `clearDecorators`, exported by the various frameworks (e.g. `@storybook/react`) is deprecated.
#### Deprecated configure
The `configure` API to load stories from `preview.js`, exported by the various frameworks (e.g. `@storybook/react`) is now deprecated.
Expand Down
13 changes: 12 additions & 1 deletion lib/client-api/src/client_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default class ClientApi {
};
},
dedent`
setAddon is deprecated and will be removed in Storybook 7.0
\`setAddon\` is deprecated and will be removed in Storybook 7.0.
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-setaddon
`
Expand All @@ -102,6 +102,17 @@ export default class ClientApi {
this._storyStore.addGlobalMetadata({ decorators: [decorator], parameters: {} });
};

clearDecorators = deprecate(
() => {
this._storyStore.clearGlobalDecorators();
},
dedent`
\`clearDecorators\` is deprecated and will be removed in Storybook 7.0.
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-cleardecorators
`
);

addParameters = (parameters: Parameters) => {
this._storyStore.addGlobalMetadata({ decorators: [], parameters });
};
Expand Down
4 changes: 4 additions & 0 deletions lib/client-api/src/story_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ export default class StoryStore {
this._globalMetadata.decorators.push(...decorators);
}

clearGlobalDecorators() {
this._globalMetadata.decorators = [];
}

ensureKind(kind: string) {
if (!this._kinds[kind]) {
this._kinds[kind] = {
Expand Down

0 comments on commit 1d08802

Please sign in to comment.