Skip to content

Commit a8eb5f0

Browse files
authored
Migrate storybook from webpack to rsbuild (#1554)
* Migrate storybook form webpack to rsbuild * Remove logging * Apply eslint-fixer changes * Automatic frontend build --------- Co-authored-by: vin0401 <[email protected]>
1 parent bdedb93 commit a8eb5f0

File tree

437 files changed

+60275
-752
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

437 files changed

+60275
-752
lines changed

assets/.storybook/main.ts

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
*/
1010

1111
import type { Options } from '@swc/core';
12-
import type { StorybookConfig } from "@storybook/react-webpack5";
13-
import path from "path";
12+
import type { StorybookConfig } from "storybook-react-rsbuild";
1413

1514
const config: StorybookConfig = {
1615
stories: ["../js/**/*.mdx", "../js/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
@@ -35,46 +34,51 @@ const config: StorybookConfig = {
3534
"@storybook/addon-webpack5-compiler-swc"
3635
],
3736
framework: {
38-
name: "@storybook/react-webpack5",
37+
name: "storybook-react-rsbuild",
3938
options: {
40-
builder: {},
39+
builder: {
40+
},
4141
},
4242
},
4343

4444
docs: {
4545
autodocs: "tag",
4646
},
4747

48-
webpackFinal: async (config) => {
49-
config.resolve!.alias = {
50-
...config.resolve!.alias,
51-
"@Pimcore": path.resolve(__dirname, "../js/src/core"),
52-
};
48+
rsbuildFinal: (config) => {
49+
const pluginsToFilterOut = [
50+
'entrypoints-generate',
51+
'rsbuild:module-federation-enhanced'
52+
]
5353

54-
// disable whatever is already set to load SVGs
55-
// Exclude inline SVGs for package "@svgr/webpack" from the default encore rule
56-
config?.module?.rules?.forEach(rule => {
57-
if (!rule || typeof rule !== 'object') return;
58-
if (rule.test instanceof RegExp && rule.test.test('.svg')) {
59-
rule.exclude = /\.inline.svg$/;
54+
const plugins = config.plugins!.filter((plugin) => {
55+
// Filter out specific plugins
56+
if (typeof plugin === 'object' && 'name' in plugin! && pluginsToFilterOut.includes(plugin!.name)) {
57+
return false;
6058
}
61-
});
6259

63-
// add SVGR instead
64-
config!.module!.rules!.push({
65-
test: /\.inline.svg$/,
66-
use: [
67-
{
68-
loader: '@svgr/webpack',
69-
options: {
70-
icon: true,
71-
typescript: true
72-
}
73-
},
74-
],
60+
return true;
7561
});
7662

77-
return config;
63+
return {
64+
...config,
65+
dev: {
66+
...config.dev,
67+
client: {
68+
port: 6006
69+
},
70+
writeToDisk: false,
71+
assetPrefix: '/storybook/'
72+
},
73+
output: {
74+
...config.output,
75+
sourceMap: false,
76+
assetPrefix: '/storybook/',
77+
},
78+
plugins: [
79+
...plugins
80+
]
81+
};
7882
},
7983

8084
// Enable typescript decorators for storybook

assets/js/src/__storybook__/core/concepts.mdx

Lines changed: 0 additions & 38 deletions
This file was deleted.

assets/js/src/__storybook__/overview.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@ Storybook helps us build, test, and showcase our components in isolation, ensuri
1212
- **Docs**: Contains the documentation to several topics like the Storybook itself, the components, the design system and the development process.
1313
- **Components**: Contains purely presentational components that are used in the application.
1414
- **Tools**: Contains Tools that help with the daily work.
15-
- **Modules**: Contains the primary business logic of the different features.
15+
16+
## Pimcore Docs
17+
18+
For more information about Pimcore Studio, please refer to the [Pimcore Studio UI Docs](https://docs.pimcore.com/platform/Studio_UI/).

assets/js/src/__storybook__/sdk/sdk-overview.mdx

Lines changed: 0 additions & 8 deletions
This file was deleted.

assets/js/src/core/app/config/services/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ import { HardlinkTabManager } from '@Pimcore/modules/document/editor/types/hardl
170170
import { LinkTabManager } from '@Pimcore/modules/document/editor/types/link/tab-manager/link-tab-manager'
171171
import { SnippetTabManager } from '@Pimcore/modules/document/editor/types/snippet/tab-manager/snippet-tab-manager'
172172

173+
// Component registry
174+
container.bind(serviceIds['App/ComponentRegistry/ComponentRegistry']).to(ComponentRegistry).inSingletonScope()
175+
173176
// Main nav
174177
container.bind(serviceIds.mainNavRegistry).to(MainNavRegistry).inSingletonScope()
175178

@@ -361,6 +364,3 @@ container.bind(serviceIds['DynamicTypes/Object/Variant']).to(DynamicTypeObjectVa
361364

362365
// Execution engine
363366
container.bind(serviceIds['ExecutionEngine/JobComponentRegistry']).to(JobComponentRegistry).inSingletonScope()
364-
365-
// Component registry
366-
container.bind(serviceIds['App/ComponentRegistry/ComponentRegistry']).to(ComponentRegistry).inSingletonScope()

assets/js/src/core/bootstrap.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import '@Pimcore/app/config/app-config'
1313
import '@Pimcore/app/module-system/module-system'
1414
import '@Pimcore/app/config/services'
1515
import '@Pimcore/app/i18n'
16+
import '@Pimcore/modules/app/base-layout'
1617
import '@Pimcore/modules/app/base-layout/main-nav'
1718
import '@Pimcore/modules/icon-library'
1819
import '@Pimcore/modules/asset'

assets/js/src/core/components/modal-upload/components/modal-upload-button/modal-upload-button.stories.tsx

Lines changed: 0 additions & 26 deletions
This file was deleted.

assets/js/src/core/modules/ant-design/hooks/use-css-component-hash.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@
99
*/
1010

1111
import { theme } from 'antd'
12+
import useTableStyle from 'antd/es/table/style'
13+
import usePaginationStyle from 'antd/es/pagination/style'
1214
const { useToken } = theme
1315

1416
export const useCssComponentHash = (): string => {
17+
useTableStyle('ant-table')
18+
usePaginationStyle('ant-pagination')
1519
const { hashId } = useToken()
1620

1721
return hashId
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* This source file is available under the terms of the
3+
* Pimcore Open Core License (POCL)
4+
* Full copyright and license information is available in
5+
* LICENSE.md which is distributed with this source code.
6+
*
7+
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
8+
* @license Pimcore Open Core License (POCL)
9+
*/
10+
11+
import { serviceIds } from '@Pimcore/app/config/services/service-ids'
12+
import { container } from '@Pimcore/app/depency-injection'
13+
import { moduleSystem } from '@Pimcore/app/module-system/module-system'
14+
import { type ComponentRegistry } from '@Pimcore/modules/app/component-registry/component-registry'
15+
import { MainNav } from '@Pimcore/modules/app/base-layout/main-nav/main-nav'
16+
import { Search } from '@Pimcore/modules/search/search'
17+
18+
moduleSystem.registerModule({
19+
onInit: () => {
20+
const componentRegistry = container.get<ComponentRegistry>(serviceIds['App/ComponentRegistry/ComponentRegistry'])
21+
22+
componentRegistry.registerToSlot('leftSidebar.slot', {
23+
name: 'mainNav',
24+
priority: 100,
25+
component: MainNav
26+
})
27+
28+
componentRegistry.registerToSlot('leftSidebar.slot', {
29+
name: 'search',
30+
priority: 200,
31+
component: Search
32+
})
33+
}
34+
})

assets/js/src/core/modules/app/base-layout/left-sidebar-view.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const LeftSidebarView = (): React.JSX.Element => {
3636
context={ context }
3737
/>
3838
) }
39-
slot={ componentConfig.leftSidebar.slot }
39+
slot={ componentConfig.leftSidebar.slot.name }
4040
/>
4141
</ul>
4242
</div>

assets/js/src/core/modules/app/component-registry/component-config.ts renamed to assets/js/src/core/modules/app/component-registry/component-config.tsx

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@
1010

1111
import { type ComponentRegistryConfig } from './component-registry'
1212
import { ComponentType } from './enums/component-type'
13-
import { EditorToolbarContextMenu as AssetEditorToolbarContextMenu } from '@Pimcore/modules/asset/editor/toolbar/context-menu/context-menu'
14-
import { EditorToolbarContextMenu as DataObjectEditorToolbarContextMenu } from '@Pimcore/modules/data-object/editor/toolbar/context-menu/context-menu'
15-
import { ConditionalLanguageSelection } from '@Pimcore/modules/data-object/editor/toolbar/language-selection/conditional-language-selection'
16-
import { MainNav } from '@Pimcore/modules/app/base-layout/main-nav/main-nav'
17-
import { Search } from '@Pimcore/modules/search/search'
18-
import { EditorToolbarWorkflowMenu } from '@Pimcore/modules/asset/editor/toolbar/workflow-menu/workflow-menu'
19-
import { EditorToolbarSaveButton as AssetEditorToolbarSaveButton } from '@Pimcore/modules/asset/editor/toolbar/save-button/save-button'
20-
import { EditorToolbarSaveButtons as DataObjectEditorToolbarSaveButtons } from '@Pimcore/modules/data-object/editor/toolbar/save-buttons/save-buttons'
2113

2214
const defaultComponentConfig = {
2315
asset: {
@@ -34,15 +26,15 @@ const defaultComponentConfig = {
3426
type: ComponentType.SLOT,
3527
name: 'asset.editor.toolbar.slots.left',
3628
defaultEntries: [
37-
{ name: 'contextMenu', priority: 100, component: AssetEditorToolbarContextMenu }
29+
{ name: 'contextMenu', priority: 100 }
3830
]
3931
},
4032
right: {
4133
type: ComponentType.SLOT,
4234
name: 'asset.editor.toolbar.slots.right',
4335
defaultEntries: [
44-
{ name: 'workflowMenu', priority: 100, component: EditorToolbarWorkflowMenu },
45-
{ name: 'saveButton', priority: 200, component: AssetEditorToolbarSaveButton }
36+
{ name: 'workflowMenu', priority: 100 },
37+
{ name: 'saveButton', priority: 200 }
4638
]
4739
}
4840
}
@@ -60,16 +52,16 @@ const defaultComponentConfig = {
6052
type: ComponentType.SLOT,
6153
name: 'dataObject.editor.toolbar.slots.left',
6254
defaultEntries: [
63-
{ name: 'contextMenu', priority: 100, component: DataObjectEditorToolbarContextMenu },
64-
{ name: 'languageSelection', priority: 200, component: ConditionalLanguageSelection }
55+
{ name: 'contextMenu', priority: 100 },
56+
{ name: 'languageSelection', priority: 200 }
6557
]
6658
},
6759
right: {
6860
type: ComponentType.SLOT,
6961
name: 'dataObject.editor.toolbar.slots.right',
7062
defaultEntries: [
71-
{ name: 'workflowMenu', priority: 100, component: EditorToolbarWorkflowMenu },
72-
{ name: 'saveButtons', priority: 200, component: DataObjectEditorToolbarSaveButtons }
63+
{ name: 'workflowMenu', priority: 100 },
64+
{ name: 'saveButtons', priority: 200 }
7365
]
7466
}
7567
}
@@ -92,8 +84,8 @@ const defaultComponentConfig = {
9284
type: ComponentType.SLOT,
9385
name: 'leftSidebar.slot',
9486
defaultEntries: [
95-
{ name: 'mainNav', priority: 100, component: MainNav },
96-
{ name: 'search', priority: 200, component: Search }
87+
{ name: 'mainNav', priority: 100 },
88+
{ name: 'search', priority: 200 }
9789
]
9890
}
9991
},

assets/js/src/core/modules/app/component-registry/component-registry.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ interface ComponentRegistryConfigEntrySingle {
2626
type: ComponentType.SINGLE
2727
}
2828

29+
interface ComponentRegistryConfigEntrySlotItem extends Omit<ComponentRegistryEntry<any>, 'component'> {}
30+
2931
interface ComponentRegistryConfigEntrySlot {
3032
name: string
3133
type: ComponentType.SLOT
32-
defaultEntries?: Array<ComponentRegistryEntry<any>>
34+
defaultEntries?: ComponentRegistryConfigEntrySlotItem[]
3335
}
3436

3537
export type ComponentRegistryConfigEntry = ComponentRegistryConfigEntrySingle | ComponentRegistryConfigEntrySlot

assets/js/src/core/modules/app/component-registry/slot-renderer.tsx

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,20 @@
88
* @license Pimcore Open Core License (POCL)
99
*/
1010

11-
import React, { useRef } from 'react'
12-
import { type ComponentRegistryEntry, useComponentRegistry } from './component-registry'
11+
import React from 'react'
12+
import { useComponentRegistry } from './component-registry'
1313
import { isUndefined } from 'lodash'
1414

1515
interface SlotRendererProps {
16-
slot: {
17-
name: string
18-
defaultEntries?: Array<ComponentRegistryEntry<any>>
19-
}
16+
slot: string
2017
props?: Record<string, any>
2118
onRenderComponent?: (Component: React.JSX.Element, context: { name?: string, index?: number, props?: Record<string, any> }) => React.JSX.Element
2219
}
2320

2421
export const SlotRenderer = ({ slot, props, onRenderComponent }: SlotRendererProps): React.JSX.Element => {
25-
const { name, defaultEntries } = slot
22+
const name = slot
2623
const ComponentRegistry = useComponentRegistry()
2724

28-
const hasRegisteredDefaults = useRef(false)
29-
30-
if (!hasRegisteredDefaults.current && !isUndefined(defaultEntries)) {
31-
const existingEntries = ComponentRegistry.getSlotComponents(name).map(({ name }) => name)
32-
defaultEntries.forEach((entry) => {
33-
if (!existingEntries.includes(entry.name)) {
34-
ComponentRegistry.registerToSlot(name, entry)
35-
}
36-
})
37-
hasRegisteredDefaults.current = true
38-
}
39-
4025
const components = ComponentRegistry.getSlotComponents(name)
4126

4227
return (

assets/js/src/core/modules/app/default-page.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,9 @@ import React from 'react'
1414
import { ClassDefinitionsProvider } from '../data-object/utils/provider/class-defintions/class-definitions-provider'
1515
import { ElementSelectorProvider } from '@sdk/modules/element'
1616
import { useHandleDeepLink } from './hook/use-handle-deeplink'
17-
import useTableStyle from 'antd/es/table/style'
18-
import usePaginationStyle from 'antd/es/pagination/style'
1917

2018
export const DefaultPage = (): React.JSX.Element => {
2119
useHandleDeepLink()
22-
useTableStyle('ant-table')
23-
usePaginationStyle('ant-pagination')
2420

2521
const preventDrop = (event: React.DragEvent<HTMLDivElement>): void => {
2622
event.preventDefault()

0 commit comments

Comments
 (0)