+ The following error occurred, make sure you have
+ 1) configured CORS in Superset to receive requests from this domain.
+ 2) set the Superset host correctly below.
+ 3) debug the CORS configuration under the `@superset-ui/connection` stories.
+
+
+
+
+ This example requires CORS requests from this domain.
+
+ 1) enable CORS requests in your Superset App from {`${window.location.origin}`}
+
+ 2) configure your Superset App host name below
+ 3) click below to verify authentication. You may debug CORS further using the
+ `@superset-ui/connection` story.
+
+
+
+
+
+
+ {error && (
+
+
+
+ )}
+
+ );
+ }
+}
diff --git a/packages/superset-ui-demo/storybook/stories/index.js b/packages/superset-ui-demo/storybook/stories/index.js
index 37ce71217..25480a59d 100644
--- a/packages/superset-ui-demo/storybook/stories/index.js
+++ b/packages/superset-ui-demo/storybook/stories/index.js
@@ -1,3 +1,4 @@
+import '@babel/polyfill';
import { setAddon, storiesOf } from '@storybook/react';
import { withKnobs } from '@storybook/addon-knobs';
import JSXAddon from 'storybook-addon-jsx';
@@ -36,7 +37,7 @@ requireContext.keys().forEach(packageName => {
storiesOf(storyPath, module)
.addParameters({ options })
- .addDecorator(withKnobs)
+ .addDecorator(withKnobs({ escapeHTML: false }))
.addWithJSX(storyName, renderStory);
});
}
diff --git a/packages/superset-ui-demo/storybook/stories/mocks/formData.js b/packages/superset-ui-demo/storybook/stories/mocks/formData.js
new file mode 100644
index 000000000..59070cdf7
--- /dev/null
+++ b/packages/superset-ui-demo/storybook/stories/mocks/formData.js
@@ -0,0 +1,35 @@
+/* eslint sort-keys: 'off' */
+/** The form data defined here is based on default visualizations packaged with Apache Superset */
+
+export const bigNumberFormData = {
+ datasource: '3__table',
+ viz_type: 'big_number',
+ slice_id: 54,
+ granularity_sqla: 'ds',
+ time_grain_sqla: 'P1D',
+ time_range: '100 years ago : now',
+ metric: 'sum__num',
+ adhoc_filters: [],
+ compare_lag: '5',
+ compare_suffix: 'over 5Y',
+ y_axis_format: '.3s',
+ show_trend_line: true,
+ start_y_axis_at_zero: true,
+};
+
+export const wordCloudFormData = {
+ datasource: '3__table',
+ viz_type: 'word_cloud',
+ slice_id: 60,
+ url_params: {},
+ granularity_sqla: 'ds',
+ time_grain_sqla: 'P1D',
+ time_range: '100 years ago : now',
+ series: 'name',
+ metric: 'sum__num',
+ adhoc_filters: [],
+ row_limit: 50,
+ size_from: 10,
+ size_to: 70,
+ rotation: 'square',
+};
diff --git a/packages/superset-ui-demo/storybook/stories/superset-ui-connection/ConnectionStories.jsx b/packages/superset-ui-demo/storybook/stories/superset-ui-connection/ConnectionStories.jsx
new file mode 100644
index 000000000..cb3e9eea6
--- /dev/null
+++ b/packages/superset-ui-demo/storybook/stories/superset-ui-connection/ConnectionStories.jsx
@@ -0,0 +1,46 @@
+import React from 'react';
+import { select, text } from '@storybook/addon-knobs';
+
+import VerifyCORS from '../../shared/components/VerifyCORS';
+import Expandable from '../../shared/components/Expandable';
+import { bigNumberFormData } from '../mocks/formData';
+
+const REQUEST_METHODS = ['GET', 'POST'];
+
+export default [
+ {
+ renderStory: () => {
+ const host = text('Superset App host for CORS request', 'localhost:9000');
+ const endpoint = text('Endpoint to test (blank to test auth only)', undefined);
+ const method = endpoint ? select('Request method', REQUEST_METHODS, 'POST') : undefined;
+ const postPayload =
+ endpoint && method === 'POST'
+ ? text('Optional POST payload', JSON.stringify({ form_data: bigNumberFormData }))
+ : undefined;
+
+ return (
+