Skip to content

🪟 🔧 Upgrade to Storybook 7 #22056

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

Merged
merged 9 commits into from
Jan 31, 2023
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: 3 additions & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,10 @@ jobs:
steps:
- name: Checkout Airbyte
uses: actions/checkout@v3
# We need to fetch at least one more commmit for the Chromatic action not to fail
# but since we don't do screenshot comparison we don't need to fetch the full history.
with:
fetch-depth: 0
fetch-depth: 2

- name: Cache Build Artifacts
uses: ./.github/actions/cache-build-artifacts
Expand Down
21 changes: 0 additions & 21 deletions airbyte-webapp/.storybook/main.js

This file was deleted.

12 changes: 12 additions & 0 deletions airbyte-webapp/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { StorybookConfig } from "@storybook/react-vite";

const config: StorybookConfig = {
framework: "@storybook/react-vite",
stories: ["../src/**/*.stories.@(ts|tsx)"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
],
};

export default config;
9 changes: 3 additions & 6 deletions airbyte-webapp/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { addDecorator } from "@storybook/react";

import { withProviders } from "./withProvider";

import "!style-loader!css-loader!sass-loader!../public/index.css";
import "../public/index.css";
import "../src/scss/global.scss";
import "../src/globals";

addDecorator(withProviders);
import "../src/dayjs-setup";

export const parameters = {};
export const decorators = [withProviders];
13 changes: 8 additions & 5 deletions airbyte-webapp/.storybook/withProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import { QueryClientProvider, QueryClient } from "react-query";
import { theme } from "../src/theme";
import messages from "../src/locales/en.json";
import { FeatureService } from "../src/hooks/services/Feature";
import { ConfigServiceProvider, defaultConfig } from "../src/config";
import { ConfigServiceProvider, config } from "../src/config";
import { DocumentationPanelProvider } from "../src/views/Connector/ConnectorDocumentationLayout/DocumentationPanelContext";
import { ServicesProvider } from "../src/core/servicesProvider";
import { analyticsServiceContext } from "../src/hooks/services/Analytics";
import { AppMonitoringServiceProvider } from "../src/hooks/services/AppMonitoringService";
import type { AnalyticsService } from "../src/core/analytics";

const analyticsContextMock: AnalyticsService = {
Expand All @@ -38,11 +39,13 @@ export const withProviders = (getStory) => (
<MemoryRouter>
<IntlProvider messages={messages} locale={"en"}>
<ThemeProvider theme={theme}>
<ConfigServiceProvider defaultConfig={defaultConfig} providers={[]}>
<ConfigServiceProvider config={config}>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ℹ️ This is kinda "funny" that this worked beforehand. So it seems that Storybook never did typecheck those files, until Storybook 7 (or use using a main.ts instead of main.js).

<DocumentationPanelProvider>
<FeatureService features={[]}>
{getStory()}
</FeatureService>
<AppMonitoringServiceProvider>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ℹ️ This broke the ConnectorForm which I think didn't work on master anymore.

<FeatureService features={[]}>
{getStory()}
</FeatureService>
</AppMonitoringServiceProvider>
</DocumentationPanelProvider>
</ConfigServiceProvider>
</ThemeProvider>
Expand Down
4 changes: 4 additions & 0 deletions airbyte-webapp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ task buildStorybook(type: NpmTask) {
inputs.dir 'src'

outputs.dir 'build/storybook'

environment = [
'NODE_OPTIONS': '--max_old_space_size=4096'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ℹ️ It seems storybooks compile process with Vite requires more memory. I saw CI failing with an heap out of memory error on this, so giving it more space here.

]
}

task copyBuildOutput(type: Copy) {
Expand Down
Loading