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

Some Storybook components do not render correctly after migration #12594

Merged
merged 36 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f7b675d
Remove install as storybook start script
cnotv Oct 17, 2024
ee668e7
Install Storybook8 with Webpack5
cnotv Oct 21, 2024
9815e3c
Correct issue in importing a node style within the SCSS instead of vu…
cnotv Oct 22, 2024
412f7e2
Add existing configuration for Webpack
cnotv Oct 22, 2024
099cd87
Convert first component to SFC/MDX new model
cnotv Oct 22, 2024
b18cad3
Add remaining plugins, directives and components
cnotv Oct 22, 2024
27fe4d2
Correct store import in the Rancher Dashboard way
cnotv Nov 7, 2024
4d0ebb9
Complete input migration
cnotv Nov 7, 2024
bfda24c
Add buttons
cnotv Nov 7, 2024
9546c61
Correct assets import
cnotv Nov 7, 2024
fae5fb0
Move foundation
cnotv Nov 7, 2024
a8c2978
Fix path for assets import
cnotv Nov 7, 2024
12a5ae1
Move example assets within the folder
cnotv Nov 7, 2024
0b4424d
Migrate Form
cnotv Nov 8, 2024
99c0341
Move first components
cnotv Nov 8, 2024
53af8ec
Migrate to proper file naming
cnotv Nov 8, 2024
a7d8d09
Remove visual tests
cnotv Nov 11, 2024
fb3e79d
Migrate components
cnotv Nov 11, 2024
39f88f1
Remove title for Labeled Select
cnotv Nov 11, 2024
009c934
Add welcome page
cnotv Nov 11, 2024
ccbcf38
Bump Storybook to 8.4.2 with auto migration script
cnotv Nov 12, 2024
0a0bbfe
Add MDX support for tables
cnotv Nov 12, 2024
1133194
Add iframe for rancher icons
cnotv Nov 12, 2024
d451676
Rename component as modal to avoid confusion
cnotv Nov 12, 2024
f968b26
Enable themes and custom Rancher theme
cnotv Nov 12, 2024
323ef16
Correct MDX markdown errors
cnotv Nov 12, 2024
7df068e
Correct i18n import
cnotv Nov 12, 2024
bde5a3c
ESLint fiuxes
cnotv Nov 13, 2024
2941fc7
Change import of debounce from lodash
cnotv Nov 13, 2024
c33d9b9
Code cleanup
cnotv Nov 13, 2024
8aabebf
Remove unnecessary import about Code Mirror
cnotv Nov 13, 2024
ed36155
Replace old storybook
cnotv Nov 13, 2024
7bdb849
Add decorator for Vue routing and fix hash issues for the tabs
cnotv Nov 14, 2024
4a70b29
Change Webpack configuration to declarative format
cnotv Nov 15, 2024
603f6d3
Add ToC to the documentation
cnotv Nov 15, 2024
268ce49
Fix linting issue
cnotv Nov 27, 2024
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 .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ build/
public/
pkg/**/node_modules
elemental-ui/
kubewarden-ui/
kubewarden-ui/
styleguide/src/stories/Example/
storybook/src/stories/Example/
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"e2e:docker": "yarn docker:local:stop && ./scripts/e2e-docker-start $RANCHER_VERSION_E2E",
"e2e:prod": "BUILD_DASHBOARD=$BUILD_DASHBOARD GREP_TAGS=$GREP_TAGS TEST_USERNAME=$TEST_USERNAME TEST_BASE_URL=https://127.0.0.1/dashboard yarn cy:run:sorry",
"coverage": "npx nyc merge coverage coverage/coverage.json",
"storybook": "cd storybook && yarn install && yarn storybook",
"storybook": "cd storybook && yarn storybook",
"build-storybook": "cd storybook && yarn install --no-lockfile && NODE_OPTIONS=--max_old_space_size=4096 yarn build-storybook --quiet",
"storybook-test": "cd storybook && yarn test-storybook --stories-json ",
"docs:install": "cd docusaurus/ && yarn install",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { defineComponent, inject, PropType } from 'vue';
import debounce from 'lodash/debounce';
import { debounce } from 'lodash';
import { _EDIT, _VIEW } from '@shell/config/query-params';

interface NonReactiveProps {
Expand Down
1 change: 0 additions & 1 deletion shell/assets/styles/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@

@import "./vendor/vue-select";
@import "./vendor/code-mirror";
@import 'node_modules/xterm/css/xterm.css';
1 change: 1 addition & 0 deletions shell/vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ module.exports = function(dir, _appConfig) {
@import "~shell/assets/styles/base/_variables.scss";
@import "~shell/assets/styles/base/_functions.scss";
@import "~shell/assets/styles/base/_mixins.scss";
@import 'node_modules/xterm/css/xterm.css';
`
}
}
Expand Down
26 changes: 26 additions & 0 deletions storybook/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

*storybook.log
128 changes: 0 additions & 128 deletions storybook/.storybook/main.js

This file was deleted.

149 changes: 149 additions & 0 deletions storybook/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
import type { StorybookConfig } from "@storybook/vue3-webpack5";
import NodePolyfillPlugin from "node-polyfill-webpack-plugin";
import fs from "fs";
import path, { join, dirname } from "path";
import webpack from "webpack";
import remarkGfm from 'remark-gfm';
import { get } from "lodash";

const baseFolder = path.resolve(__dirname, '..', '..');

/**
* This function is used to resolve the absolute path of a package.
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
*/
function getAbsolutePath(value: string): any {
return dirname(require.resolve(join(value, "package.json")));
}

const sassLoader = {
loader: 'sass-loader',
options: {
additionalData: `@use "sass:math"; @import '~shell/assets/styles/app.scss';`,
sassOptions: {
importer: (url, prev, done) => {
if (url.indexOf('~/') === 0) {
const file = path.resolve(baseFolder, url.substr(2));
return fs.exists(file, (ok) => {
if (ok) {
return done({ file });
}
return done(null);
});
} else if (url.indexOf('@/node_modules') === 0) {
return done({ file: path.resolve(baseFolder, url.substr(2)) });
}

done(null);
}
}
},
};

/**
* Replace js-modal and xterm imports with absolute paths
* @param resource
*/
const replaceModulePath = (resource) => {
const modulePathSplit = resource.request.split('!');
const modulePath = modulePathSplit.pop();
if (modulePath) {
const match = modulePath.match(/node_modules\/(.*)/);
if (match) {
modulePathSplit.push(path.join(baseFolder, match[0]));
} else {
modulePathSplit.push(modulePath);
}

resource.request = modulePathSplit.join('!');
}
}

/**
* Add aliases
* https://storybook.js.org/docs/writing-stories/mocking-data-and-modules/mocking-modules#builder-aliases
*/
const webpackAliases = {
'~': baseFolder,
'@': baseFolder,
'@shell': path.join(baseFolder, 'shell'),
'@components': path.join(baseFolder, 'pkg', 'rancher-components', 'src', 'components'),
'~shell': path.join(baseFolder, 'shell'),
};

const webpackLoaders = [
{
test: /\.scss$/,
use: ['style-loader', 'css-loader', sassLoader],
include: baseFolder,
},
// Map YAML to JSON
{
test: /\.ya?ml$/i,
loader: 'js-yaml-loader',
options: { name: '[path][name].[ext]' },
}
];

const webpackPlugins = [
new NodePolyfillPlugin() as any,
// BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
new webpack.NormalModuleReplacementPlugin(/js-modal|xterm|diff2html/, replaceModulePath)
]

const config: StorybookConfig = {
framework: {
name: getAbsolutePath('@storybook/vue3-webpack5'),
options: {}
},
staticDirs: ['../public', '../../shell/assets'],
stories: [
"../src/**/*.mdx",
"../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"
],
addons: [
getAbsolutePath("@storybook/addon-onboarding"),
getAbsolutePath("@storybook/addon-links"),
getAbsolutePath("@storybook/addon-essentials"),
getAbsolutePath("@storybook/addon-interactions"),
getAbsolutePath('@storybook/addon-webpack5-compiler-babel'),
// Add support for table generation from markdown using MDX files
{
name: '@storybook/addon-docs',
options: {
mdxPluginOptions: {
mdxCompileOptions: {
remarkPlugins: [remarkGfm],
},
},
},
},
],
core: {
disableTelemetry: true,
},
docs: {},
// https://storybook.js.org/docs/builders/webpack#import-a-custom-webpack-configuration
webpackFinal: (config: webpack.Configuration) => ({
...config,
resolve: {
...config.resolve,
alias: {
...config.resolve?.alias,
...webpackAliases,
}
},
module: {
...config.module,
rules: [
...config.module?.rules || [],
...webpackLoaders,
],
},
plugins: [
...config.plugins || [],
...webpackPlugins,
]
}),
};
export default config;
2 changes: 0 additions & 2 deletions storybook/.storybook/manager-head.html

This file was deleted.

39 changes: 0 additions & 39 deletions storybook/.storybook/manager.js

This file was deleted.

6 changes: 6 additions & 0 deletions storybook/.storybook/manager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { addons } from '@storybook/manager-api';
import RancherTheme from './theme-rancher';

addons.setConfig({
theme: RancherTheme
});
Loading