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

Manager API: Remove deprecated navigateToSettingsPage method #25467

Merged
merged 1 commit into from
Jan 5, 2024
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
18 changes: 18 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
- [LinkTo direct import from addon-links](#linkto-direct-import-from-addon-links)
- [DecoratorFn, Story, ComponentStory, ComponentStoryObj, ComponentStoryFn and ComponentMeta TypeScript types](#decoratorfn-story-componentstory-componentstoryobj-componentstoryfn-and-componentmeta-typescript-types)
- ["Framework" TypeScript types](#framework-typescript-types)
- [`navigateToSettingsPage` method from Storybook's manager-api](#navigatetosettingspage-method-from-storybooks-manager-api)
- [From version 7.5.0 to 7.6.0](#from-version-750-to-760)
- [CommonJS with Vite is deprecated](#commonjs-with-vite-is-deprecated)
- [Using implicit actions during rendering is deprecated](#using-implicit-actions-during-rendering-is-deprecated)
Expand Down Expand Up @@ -633,6 +634,23 @@ For React, the `ComponentStory`, `ComponentStoryObj`, `ComponentStoryFn` and `Co

The Framework types such as `ReactFramework` are now removed in favor of Renderer types such as `ReactRenderer`. This affects all frameworks. [More info](#renamed-xframework-to-xrenderer).

#### `navigateToSettingsPage` method from Storybook's manager-api

The `navigateToSettingsPage` method from manager-api is now removed in favor of `changeSettingsTab`.

```ts
export const Component = () => {
const api = useStorybookApi();

const someHandler = () => {
// Old method: api.navigateToSettingsPage('/settings/about');
api.changeSettingsTab('about'); // the /settings path is not necessary anymore
};

// ...
}
```

## From version 7.5.0 to 7.6.0

#### CommonJS with Vite is deprecated
Expand Down
18 changes: 0 additions & 18 deletions code/lib/manager-api/src/modules/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ export interface SubAPI {
* @returns A boolean indicating whether the settings screen is active.
*/
isSettingsScreenActive: () => boolean;
/**
* Navigates to the specified settings page.
* @param path - The path of the settings page to navigate to. The path should include the `/settings` prefix.
* @example navigateToSettingsPage(`/settings/about`).
* @deprecated Use `changeSettingsTab` instead.
*/
navigateToSettingsPage: (path: string) => Promise<void>;
}

export interface SubState {
Expand Down Expand Up @@ -53,17 +46,6 @@ export const init: ModuleFn<SubAPI, SubState> = ({ store, navigate, fullAPI }):
navigate(`/settings/${path}`);
},
isSettingsScreenActive,
navigateToSettingsPage: async (path) => {
if (!isSettingsScreenActive()) {
const { settings, storyId } = store.getState();

await store.setState({
settings: { ...settings, lastTrackedStoryId: storyId },
});
}

navigate(path);
},
retrieveSelection() {
const { settings } = store.getState();

Expand Down
6 changes: 3 additions & 3 deletions code/ui/manager/src/container/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const useMenu = (
() => ({
id: 'about',
title: 'About your Storybook',
onClick: () => api.navigateToSettingsPage('/settings/about'),
onClick: () => api.changeSettingsTab('about'),
}),
[api]
);
Expand All @@ -76,7 +76,7 @@ export const useMenu = (
() => ({
id: 'whats-new',
title: "What's new?",
onClick: () => api.navigateToSettingsPage('/settings/whats-new'),
onClick: () => api.changeSettingsTab('whats-new'),
right: whatsNewNotificationsEnabled && isWhatsNewUnread && (
<Badge status="positive">Check it out</Badge>
),
Expand All @@ -88,7 +88,7 @@ export const useMenu = (
() => ({
id: 'shortcuts',
title: 'Keyboard shortcuts',
onClick: () => api.navigateToSettingsPage('/settings/shortcuts'),
onClick: () => api.changeSettingsTab('shortcuts'),
right: enableShortcuts ? <Shortcut keys={shortcutKeys.shortcutsPage} /> : null,
style: {
borderBottom: `4px solid ${theme.appBorderColor}`,
Expand Down