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

[feature][Canvas] Share Workpads in other Websites #46278

Merged
merged 27 commits into from
Oct 11, 2019
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
bb60377
[Canvas] Embedding Workpads in other Websites (#42545)
clintandrewhall Aug 28, 2019
a240a25
Testing for Workpad Snapshots
clintandrewhall Sep 3, 2019
99ceaf3
Merge remote-tracking branch 'elastic' into feature/canvas-snapshots
clintandrewhall Sep 24, 2019
73a9b77
Rename Snapshots to Shareables; update documentation. (#46513)
clintandrewhall Sep 25, 2019
6fa5257
[canvas][shareables] Add Localization + Tweaks (#46632)
clintandrewhall Sep 26, 2019
2350aaa
Merge remote-tracking branch 'elastic' into feature/canvas-snapshots
clintandrewhall Sep 27, 2019
f10dbcd
[shareables] Unsupported Renderer Warning (#46862)
clintandrewhall Sep 30, 2019
22e4200
[canvas][shareables] Simplify and complete testing (#47328)
clintandrewhall Oct 4, 2019
c0c1a2d
Merge branch 'master' into feature/canvas-snapshots
clintandrewhall Oct 4, 2019
ab41613
Merge branch 'feature/canvas-snapshots' of https://github.com/elastic…
clintandrewhall Oct 4, 2019
032eb3a
Merge remote-tracking branch 'elastic' into feature/canvas-snapshots
clintandrewhall Oct 7, 2019
4445357
Fix CI build of runtime; assorted visual tweaks
clintandrewhall Oct 7, 2019
8c497ba
Merge remote-tracking branch 'elastic' into feature/canvas-snapshots
clintandrewhall Oct 7, 2019
2806612
Merge remote-tracking branch 'elastic' into feature/canvas-snapshots
clintandrewhall Oct 7, 2019
c44fe2a
Update x-pack/legacy/plugins/canvas/shareable_runtime/test/index.ts
clintandrewhall Oct 8, 2019
031c000
Addressing feedback
clintandrewhall Oct 8, 2019
71da514
Merge branch 'feature/canvas-snapshots' of https://github.com/elastic…
clintandrewhall Oct 8, 2019
cb15592
Remove null-loader from root package
clintandrewhall Oct 8, 2019
c62a906
Merge remote-tracking branch 'elastic' into feature/canvas-snapshots
clintandrewhall Oct 8, 2019
5a40b2c
re-add null-loader until mitigation is found
clintandrewhall Oct 8, 2019
9fb50f9
Merge remote-tracking branch 'elastic' into feature/canvas-snapshots
clintandrewhall Oct 8, 2019
c647a73
[perf] Fix unsupported renderers performance issue (#47769)
clintandrewhall Oct 10, 2019
a37fe85
Addressing review feedback (#47775)
clintandrewhall Oct 10, 2019
247da14
Addressing feedback
clintandrewhall Oct 10, 2019
aace4b4
Merge remote-tracking branch 'elastic' into feature/canvas-snapshots
clintandrewhall Oct 10, 2019
dafa93d
Addressing feedback (#47883)
clintandrewhall Oct 10, 2019
6faca42
Branding Changes (#47913)
clintandrewhall Oct 11, 2019
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
2 changes: 2 additions & 0 deletions .sass-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ files:
- 'x-pack/legacy/plugins/rollup/**/*.s+(a|c)ss'
- 'x-pack/legacy/plugins/security/**/*.s+(a|c)ss'
- 'x-pack/legacy/plugins/canvas/**/*.s+(a|c)ss'
ignore:
- 'x-pack/legacy/plugins/canvas/shareable_runtime/**/*.s+(a|c)ss'
- 'x-pack/legacy/plugins/lens/**/*.s+(a|c)ss'
rules:
quotes:
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@
"nock": "10.0.6",
"node-sass": "^4.9.4",
"normalize-path": "^3.0.0",
"null-loader": "^3.0.0",
"nyc": "^14.1.1",
"pixelmatch": "4.0.2",
"pkg-up": "^2.0.0",
Expand Down
8 changes: 8 additions & 0 deletions renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,14 @@
'@types/zen-observable',
],
},
{
groupSlug: 'archiver',
groupName: 'archiver related packages',
packageNames: [
'archiver',
'@types/archiver',
],
},
{
groupSlug: 'base64-js',
groupName: 'base64-js related packages',
Expand Down
36 changes: 36 additions & 0 deletions src/dev/jest/mocks/css_module_mock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/**
* This proxy allows for CSS Modules to be interpreted properly by
* Jest. Given a CSS Module class `thisClass`, we'd expect it to
* be obfuscated at runtime. With this mock, `thisClass` will be
* returned. This allows for consistent enzyme and snapshot tests.
*/
module.exports = new Proxy(
{},
{
get: function getter(target, key) {
if (key === '__esModule') {
return false;
}
return key;
},
}
);
5 changes: 2 additions & 3 deletions x-pack/dev-tools/jest/create_jest_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ export function createJestConfig({ kibanaDirectory, xPackKibanaDirectory }) {
'^plugins/([^/.]*)(.*)': `${kibanaDirectory}/src/legacy/core_plugins/$1/public$2`,
'^legacy/plugins/xpack_main/(.*);': `${xPackKibanaDirectory}/legacy/plugins/xpack_main/public/$1`,
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': fileMockPath,
'\\.module.(css|scss)$': `${kibanaDirectory}/src/dev/jest/mocks/css_module_mock.js`,
'\\.(css|less|scss)$': `${kibanaDirectory}/src/dev/jest/mocks/style_mock.js`,
'^test_utils/enzyme_helpers': `${xPackKibanaDirectory}/test_utils/enzyme_helpers.tsx`,
'^test_utils/find_test_subject': `${xPackKibanaDirectory}/test_utils/find_test_subject.ts`,
},
coverageDirectory: '<rootDir>/../target/kibana-coverage/jest',
coverageReporters: [
'html',
],
coverageReporters: ['html'],
setupFiles: [
`${kibanaDirectory}/src/dev/jest/setup/babel_polyfill.js`,
`<rootDir>/dev-tools/jest/setup/polyfills.js`,
Expand Down
18 changes: 18 additions & 0 deletions x-pack/legacy/plugins/canvas/.storybook/storyshots.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ import initStoryshots, { multiSnapshotWithOptions } from '@storybook/addon-story
import styleSheetSerializer from 'jest-styled-components/src/styleSheetSerializer';
import { addSerializer } from 'jest-specific-snapshot';

// Several of the renderers, used by the runtime, use jQuery.
import jquery from 'jquery';
global.$ = jquery;
global.jQuery = jquery;

// Set our default timezone to UTC for tests so we can generate predictable snapshots
moment.tz.setDefault('UTC');

Expand Down Expand Up @@ -53,6 +58,19 @@ jest.mock(
}
);

// Disabling this test due to https://github.com/elastic/eui/issues/2242
jest.mock(
'../public/components/workpad_header/workpad_export/flyout/__examples__/share_website_flyout.examples',
() => {
return 'Disabled Panel';
}
);

// This element uses a `ref` and cannot be rendered by Jest snapshots.
import { RenderedElement } from '../shareable_runtime/components/rendered_element';
jest.mock('../shareable_runtime/components/rendered_element');
RenderedElement.mockImplementation(() => 'RenderedElement');

addSerializer(styleSheetSerializer);

// Initialize Storyshots and build the Jest Snapshots
Expand Down
54 changes: 52 additions & 2 deletions x-pack/legacy/plugins/canvas/.storybook/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,56 @@ module.exports = async ({ config }) => {
],
});

// Enable SASS, but exclude CSS Modules in Storybook
config.module.rules.push({
test: /\.scss$/,
exclude: /\.module.(s(a|c)ss)$/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader', options: { importLoaders: 2 } },
{
loader: 'postcss-loader',
options: {
path: path.resolve(KIBANA_ROOT, 'src/optimize/postcss.config.js'),
},
},
{ loader: 'sass-loader' },
],
});

// Enable CSS Modules in Storybook
config.module.rules.push({
test: /\.module\.s(a|c)ss$/,
loader: [
'style-loader',
{
loader: 'css-loader',
options: {
importLoaders: 2,
modules: true,
localIdentName: '[name]__[local]___[hash:base64:5]',
},
},
{
loader: 'postcss-loader',
options: {
path: path.resolve(KIBANA_ROOT, 'src/optimize/postcss.config.js'),
},
},
{
loader: 'sass-loader',
},
],
});

// Ensure jQuery is global for Storybook, specifically for the runtime.
config.plugins.push(
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
})
);

// Reference the built DLL file of static(ish) dependencies, which are removed
// during kbn:bootstrap and rebuilt if missing.
config.plugins.push(
Expand Down Expand Up @@ -109,8 +159,8 @@ module.exports = async ({ config }) => {
})
);

// Tell Webpack about the ts/x extensions
config.resolve.extensions.push('.ts', '.tsx');
// Tell Webpack about relevant extensions
config.resolve.extensions.push('.ts', '.tsx', '.scss');

// Alias imports to either a mock or the proper module or directory.
// NOTE: order is important here - `ui/notify` will override `ui/notify/foo` if it
Expand Down
6 changes: 6 additions & 0 deletions x-pack/legacy/plugins/canvas/common/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SHAREABLE_RUNTIME_NAME } from '../../shareable_runtime/constants';

export const CANVAS_TYPE = 'canvas-workpad';
export const CUSTOM_ELEMENT_TYPE = 'canvas-element';
export const CANVAS_APP = 'canvas';
Expand Down Expand Up @@ -33,3 +35,7 @@ export const CANVAS_LAYOUT_STAGE_CONTENT_SELECTOR = `canvasLayout__stageContent`
export const DATATABLE_COLUMN_TYPES = ['string', 'number', 'null', 'boolean', 'date'];
export const LAUNCHED_FULLSCREEN = 'workpad-full-screen-launch';
export const LAUNCHED_FULLSCREEN_AUTOPLAY = 'workpad-full-screen-launch-with-autoplay';
export const API_ROUTE_SHAREABLE_BASE = '/public/canvas';
export const API_ROUTE_SHAREABLE_ZIP = `${API_ROUTE_SHAREABLE_BASE}/zip`;
export const API_ROUTE_SHAREABLE_RUNTIME = `${API_ROUTE_SHAREABLE_BASE}/runtime`;
export const API_ROUTE_SHAREABLE_RUNTIME_DOWNLOAD = `${API_ROUTE_SHAREABLE_BASE}/${SHAREABLE_RUNTIME_NAME}.js`;
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,13 @@ export const fetch = axios.create({
},
timeout: FETCH_TIMEOUT,
});

export const arrayBufferFetch = axios.create({
responseType: 'arraybuffer',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
'kbn-xsrf': 'professionally-crafted-string-of-text',
},
timeout: FETCH_TIMEOUT,
});
Loading