Skip to content

Commit a63a8ad

Browse files
authored
Merge branch 'main' into addActionId
2 parents 513a3ef + b2a8d6d commit a63a8ad

File tree

34 files changed

+6699
-275
lines changed

34 files changed

+6699
-275
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ module.exports = {
379379
*/
380380
{
381381
files: [
382+
'**/*.stories.tsx',
382383
'test/*/config.ts',
383384
'test/*/config_open.ts',
384385
'test/*/{tests,test_suites,apis,apps}/**/*',

changelogs/fragments/9651.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fix:
2+
- Data source opensearch client honors the timeout settings in yaml file ([#9651](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9651))

changelogs/fragments/9697.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
feat:
2+
- Adding back storybook ([#9697](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9697))

docs/_sidebar.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
- [Osd pm](../packages/osd-pm/README.md)
130130
- [Osd spec to console](../packages/osd-spec-to-console/README.md)
131131
- [Osd std](../packages/osd-std/README.md)
132+
- [Osd storybook](../packages/osd-storybook/README.md)
132133
- [Osd stylelint config](../packages/osd-stylelint-config/README.md)
133134
- [Osd stylelint plugin stylelint](../packages/osd-stylelint-plugin-stylelint/README.md)
134135
- [Osd telemetry tools](../packages/osd-telemetry-tools/README.md)

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
"docs:generateDevDocs": "scripts/use_node scripts/generate_docs_sidebar.js",
8383
"osd:bootstrap": "scripts/use_node scripts/build_ts_refs && scripts/use_node scripts/register_git_hook",
8484
"spec_to_console": "scripts/use_node scripts/spec_to_console",
85+
"storybook": "node scripts/storybook",
8586
"pkg-version": "scripts/use_node -e \"console.log(require('./package.json').version)\"",
8687
"release_note:generate": "scripts/use_node scripts/generate_release_note",
8788
"cypress:run-without-security": "env TZ=America/Los_Angeles NO_COLOR=1 cypress run --env SECURITY_ENABLED=false",
@@ -108,7 +109,7 @@
108109
"**/@babel/helpers": "^7.27.0",
109110
"**/@babel/runtime": "^7.27.0",
110111
"**/@babel/runtime-corejs3": "^7.27.0",
111-
"**/@babel/traverse": "^7.23.2",
112+
"**/@babel/traverse": "^7.27.0",
112113
"**/@cypress/request": "^3.0.0",
113114
"**/@types/node": "~20.10.5",
114115
"**/ansi-regex": "^5.0.1",
@@ -318,6 +319,7 @@
318319
"@osd/optimizer": "1.0.0",
319320
"@osd/plugin-generator": "1.0.0",
320321
"@osd/pm": "1.0.0",
322+
"@osd/storybook": "1.0.0",
321323
"@osd/stylelint-config": "1.0.0",
322324
"@osd/stylelint-plugin-stylelint": "1.0.0",
323325
"@osd/telemetry-tools": "1.0.0",
@@ -405,6 +407,7 @@
405407
"@types/testing-library__jest-dom": "^5.14.2",
406408
"@types/tough-cookie": "^4.0.1",
407409
"@types/type-detect": "^4.0.1",
410+
"@types/unist": "^3.0.3",
408411
"@types/uuid": "^3.4.4",
409412
"@types/vinyl": "^2.0.4",
410413
"@types/vinyl-fs": "^2.4.11",

packages/osd-optimizer/src/worker/webpack.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,9 @@ export function getWebpackConfig(bundle: Bundle, bundleRefs: BundleRefs, worker:
222222

223223
// Don't attempt to look into release artifacts of the plugins
224224
/[\/\\]plugins[\/\\][^\/\\]+[\/\\]build[\/\\]/,
225+
226+
// exclude stories
227+
/\.stories\.(js|jsx|ts|tsx)$/,
225228
],
226229
use: {
227230
loader: 'babel-loader',

packages/osd-storybook/README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# OpenSearch Dashboards Storybook
2+
3+
This package provides ability to add [Storybook](https://storybook.js.org/) to any OpenSearch Dashboards plugin.
4+
5+
- [OpenSearch Dashboards Storybook](#opensearch-dashboards-storybook)
6+
- [Setup Instructions](#setup-instructions)
7+
- [Customizing configuration](#customizing-configuration)
8+
9+
## Setup Instructions
10+
11+
- Add a `.storybook/main.js` configuration file to your plugin. For example, create a file at
12+
`src/plugins/<plugin>/.storybook/main.js`, with the following contents:
13+
14+
```js
15+
module.exports = require('@osd/storybook').defaultConfig;
16+
```
17+
18+
- Add a `.storybook/preview.ts` file to your plugin, with the following contents:
19+
20+
```js
21+
// find the correct path to these css files
22+
import '../../../../packages/osd-ui-shared-deps/target/osd-ui-shared-deps.css';
23+
import '../../../../packages/osd-ui-shared-deps/target/osd-ui-shared-deps.v7.light.css';
24+
25+
export default {
26+
parameters: {},
27+
};
28+
```
29+
30+
- Add your plugin alias to `src/dev/storybook/aliases.ts` config.
31+
- Create sample Storybook stories. For example, in your plugin create a file at
32+
`src/plugins/<plugin>/public/components/hello_world/hello_world.stories.tsx` with
33+
the following [Component Story Format](https://storybook.js.org/docs/react/api/csf) contents:
34+
35+
```jsx
36+
import { MyComponent } from './my_component';
37+
38+
export default {
39+
component: MyComponent,
40+
title: 'Path/In/Side/Navigation/ToComponent',
41+
};
42+
43+
export function Example() {
44+
return <MyComponent />;
45+
}
46+
```
47+
48+
- Launch Storybook with `yarn storybook <plugin>`, or build a static site with `yarn storybook --site <plugin>`.
49+
50+
## Customizing configuration
51+
52+
The `defaultConfig` object provided by the @osd/storybook package should be all you need to get running, but you can
53+
override this in your .storybook/main.js. Using [Storybook's configuration options](https://storybook.js.org/docs/react/configure/overview).

packages/osd-storybook/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
export { defaultConfig } from './lib/default_config';
7+
export { runStorybookCli } from './lib/run_storybook_cli';
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import { resolve } from 'path';
7+
import { REPO_ROOT as OPENSEARCH_DASHBOARDS_ROOT } from '@osd/dev-utils';
8+
9+
export const REPO_ROOT = OPENSEARCH_DASHBOARDS_ROOT;
10+
export const ASSET_DIR = resolve(OPENSEARCH_DASHBOARDS_ROOT, 'built_assets/storybook');
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import { StorybookConfig } from '@storybook/core-common';
7+
8+
export const defaultConfig: StorybookConfig = {
9+
addons: [
10+
'@osd/storybook/preset',
11+
'@storybook/addon-knobs',
12+
'@storybook/addon-essentials',
13+
'@storybook/addon-postcss',
14+
],
15+
core: {
16+
builder: 'webpack4',
17+
},
18+
stories: ['../**/*.stories.tsx'],
19+
typescript: {
20+
reactDocgen: false,
21+
},
22+
webpackFinal: async (config) => {
23+
// Configure PostCSS
24+
config.module?.rules.push({
25+
test: /\.css$/,
26+
use: [
27+
{
28+
loader: 'postcss-loader',
29+
options: {
30+
postcssOptions: {
31+
plugins: [
32+
'postcss-flexbugs-fixes',
33+
[
34+
'autoprefixer',
35+
{
36+
flexbox: 'no-2009',
37+
},
38+
],
39+
],
40+
},
41+
},
42+
},
43+
],
44+
});
45+
46+
return config;
47+
},
48+
};

0 commit comments

Comments
 (0)