mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-03 05:04:51 +08:00
Deprecate disabled
parameters in favor of disable
This commit is contained in:
parent
4f6690ec24
commit
407482be68
17
MIGRATION.md
17
MIGRATION.md
@ -34,6 +34,7 @@
|
|||||||
- [6.0 Addon API changes](#60-addon-api-changes)
|
- [6.0 Addon API changes](#60-addon-api-changes)
|
||||||
- [Consistent local addon paths in main.js](#consistent-local-addon-paths-in-mainjs)
|
- [Consistent local addon paths in main.js](#consistent-local-addon-paths-in-mainjs)
|
||||||
- [Deprecated setAddon](#deprecated-setaddon)
|
- [Deprecated setAddon](#deprecated-setaddon)
|
||||||
|
- [Deprecated disabled parameter](#deprecated-disabled-parameter)
|
||||||
- [Actions addon uses parameters](#actions-addon-uses-parameters)
|
- [Actions addon uses parameters](#actions-addon-uses-parameters)
|
||||||
- [Removed action decorator APIs](#removed-action-decorator-apis)
|
- [Removed action decorator APIs](#removed-action-decorator-apis)
|
||||||
- [Removed withA11y decorator](#removed-witha11y-decorator)
|
- [Removed withA11y decorator](#removed-witha11y-decorator)
|
||||||
@ -599,6 +600,22 @@ We've deprecated the `setAddon` method of the `storiesOf` API and plan to remove
|
|||||||
|
|
||||||
Since early versions, Storybook shipped with a `setAddon` API, which allows you to extend `storiesOf` with arbitrary code. We've removed this from all core addons long ago and recommend writing stories in [Component Story Format](https://medium.com/storybookjs/component-story-format-66f4c32366df) rather than using the internal Storybook API.
|
Since early versions, Storybook shipped with a `setAddon` API, which allows you to extend `storiesOf` with arbitrary code. We've removed this from all core addons long ago and recommend writing stories in [Component Story Format](https://medium.com/storybookjs/component-story-format-66f4c32366df) rather than using the internal Storybook API.
|
||||||
|
|
||||||
|
#### Deprecated disabled parameter
|
||||||
|
|
||||||
|
Starting in 6.0.17, we've renamed the `disabled` parameter to `disable` to resolve an inconsistency where `disabled` had been used to hide the addon panel, whereas `disable` had been used to disable an addon's execution. Since `disable` was much more widespread in the code, we standardized on that.
|
||||||
|
|
||||||
|
So, for example:
|
||||||
|
|
||||||
|
```
|
||||||
|
Story.parameters = { actions: { disabled: true } }
|
||||||
|
```
|
||||||
|
|
||||||
|
Should be rewritten as:
|
||||||
|
|
||||||
|
```
|
||||||
|
Story.parameters = { actions: { disable: true } }
|
||||||
|
```
|
||||||
|
|
||||||
#### Actions addon uses parameters
|
#### Actions addon uses parameters
|
||||||
|
|
||||||
Leveraging the new preset `@storybook/addon-actions` uses parameters to pass action options. If you previously had:
|
Leveraging the new preset `@storybook/addon-actions` uses parameters to pass action options. If you previously had:
|
||||||
|
@ -1,10 +1,21 @@
|
|||||||
import { ReactElement } from 'react';
|
import { ReactElement } from 'react';
|
||||||
|
|
||||||
import { WindowLocation } from '@reach/router';
|
import { WindowLocation } from '@reach/router';
|
||||||
|
import deprecate from 'util-deprecate';
|
||||||
|
import dedent from 'ts-dedent';
|
||||||
|
|
||||||
import { ModuleFn } from '../index';
|
import { ModuleFn } from '../index';
|
||||||
import { Options } from '../store';
|
import { Options } from '../store';
|
||||||
import { isStory } from '../lib/stories';
|
import { isStory } from '../lib/stories';
|
||||||
|
|
||||||
|
const warnDisabledDeprecated = deprecate(
|
||||||
|
() => {},
|
||||||
|
dedent`
|
||||||
|
Use 'parameters.key.disable' instead of 'parameters.key.disabled'.
|
||||||
|
|
||||||
|
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-disabled-parameter
|
||||||
|
`
|
||||||
|
);
|
||||||
|
|
||||||
export type ViewMode = 'story' | 'info' | 'settings' | 'page' | undefined | string;
|
export type ViewMode = 'story' | 'info' | 'settings' | 'page' | undefined | string;
|
||||||
|
|
||||||
export enum types {
|
export enum types {
|
||||||
@ -110,6 +121,9 @@ export const init: ModuleFn = ({ provider, store, fullAPI }) => {
|
|||||||
parameters[paramKey] &&
|
parameters[paramKey] &&
|
||||||
(parameters[paramKey].disabled || parameters[paramKey].disable)
|
(parameters[paramKey].disabled || parameters[paramKey].disable)
|
||||||
) {
|
) {
|
||||||
|
if (parameters[paramKey].disabled) {
|
||||||
|
warnDisabledDeprecated();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
filteredPanels[id] = panel;
|
filteredPanels[id] = panel;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user