Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdover committed Apr 19, 2020
1 parent 90938b7 commit 32c572a
Show file tree
Hide file tree
Showing 15 changed files with 152 additions and 142 deletions.
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/src/optimizer/get_bundles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function getBundles(plugins: KibanaPlatformPlugin[], repoRoot: string) {
entry: './public/entry_point',
sourceRoot: repoRoot,
contextDir: Path.resolve(repoRoot, 'src/core'),
outputDir: Path.resolve(repoRoot, 'src/core/public/target/public'),
outputDir: Path.resolve(repoRoot, 'src/core/target/public'),
});

const pluginBundles = plugins
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/core_system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('constructor', () => {
});
});

it('passes requireLegacyFiles, requireNewPlatformShimModule, requireLegacyBootstrapModule and a dom element to LegacyPlatformService', () => {
it('passes required params to LegacyPlatformService', () => {
const requireLegacyFiles = { requireLegacyFiles: true };
const requireLegacyBootstrapModule = { requireLegacyBootstrapModule: true };
const requireNewPlatformShimModule = { requireNewPlatformShimModule: true };
Expand Down
1 change: 1 addition & 0 deletions src/core/public/entry_point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* that lives in the Kibana Platform.
*/

import './index.scss';
import { i18n } from '@kbn/i18n';
import { CoreSystem } from './core_system';

Expand Down
49 changes: 48 additions & 1 deletion src/core/public/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,52 @@
// Mixins provide generic code expansion through helpers
@import '@elastic/eui/src/global_styling/mixins/index';

$kbnGlobalNavClosedWidth: 53px;
$kbnGlobalNavOpenWidth: 180px;
$kbnGlobalNavLogoHeight: 70px;
$kbnGlobalNavAppIconHeight: $euiSizeXXL + $euiSizeXS;

#kibana-body {
overflow-x: hidden;
min-height: 100%;
}

.app-wrapper {
display: flex;
flex-flow: column nowrap;
position: absolute;
left: $kbnGlobalNavClosedWidth;
top: 0;
right: 0;
bottom: 0;
z-index: 5;
margin: 0 auto;

/**
* 1. Dirty, but we need to override the .kbnGlobalNav-isOpen state
* when we're looking at the log-in screen.
*/
&.hidden-chrome {
left: 0 !important; /* 1 */
}

.navbar-right {
margin-right: 0;
}
}

.app-wrapper-panel {
display: flex;
flex-grow: 1;
flex-shrink: 0;
flex-basis: auto;
flex-direction: column;

> * {
flex-shrink: 0;
}
}


@import './chrome/index';
@import './overlays/index';
@import './overlays/index';
26 changes: 0 additions & 26 deletions src/core/public/legacy/__snapshots__/legacy_service.test.ts.snap

This file was deleted.

55 changes: 52 additions & 3 deletions src/core/public/legacy/legacy_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,21 @@ describe('#setup()', () => {
expect(mockUiNewPlatformSetup).toHaveBeenCalledTimes(1);
expect(mockUiNewPlatformSetup).toHaveBeenCalledWith(expect.any(Object), {});
});

it('throws error if requireNewPlatformShimModule is undefined', () => {
const legacyPlatform = new LegacyPlatformService({
...defaultParams,
requireNewPlatformShimModule: undefined,
});

expect(() => {
legacyPlatform.setup(defaultSetupDeps);
}).toThrowErrorMatchingInlineSnapshot(
`"requireNewPlatformShimModule must be specified when rendering a legacy application"`
);

expect(mockUiNewPlatformSetup).not.toHaveBeenCalled();
});
});
});

Expand Down Expand Up @@ -157,6 +172,21 @@ describe('#start()', () => {
expect(mockUiNewPlatformStart).toHaveBeenCalledWith(expect.any(Object), {});
});

it('throws error if requireNewPlatformShimeModule is undefined', () => {
const legacyPlatform = new LegacyPlatformService({
...defaultParams,
requireNewPlatformShimModule: undefined,
});

expect(() => {
legacyPlatform.start(defaultStartDeps);
}).toThrowErrorMatchingInlineSnapshot(
`"requireNewPlatformShimModule must be specified when rendering a legacy application"`
);

expect(mockUiNewPlatformStart).not.toHaveBeenCalled();
});

it('resolves getStartServices with core and plugin APIs', async () => {
const legacyPlatform = new LegacyPlatformService({
...defaultParams,
Expand Down Expand Up @@ -194,7 +224,12 @@ describe('#start()', () => {
legacyPlatform.setup(defaultSetupDeps);
legacyPlatform.start(defaultStartDeps);

expect(mockLoadOrder).toMatchSnapshot();
expect(mockLoadOrder).toMatchInlineSnapshot(`
Array [
"ui/chrome",
"legacy files",
]
`);
});
});
});
Expand All @@ -211,7 +246,17 @@ describe('#stop()', () => {
});

legacyPlatform.stop();
expect(targetDomElement).toMatchSnapshot();
expect(targetDomElement).toMatchInlineSnapshot(`
<div>
<h1>
this should not be removed
</h1>
</div>
`);
});

it('destroys the angular scope and empties the targetDomElement if angular is bootstrapped to targetDomElement', async () => {
Expand Down Expand Up @@ -240,7 +285,11 @@ describe('#stop()', () => {
legacyPlatform.start({ ...defaultStartDeps, targetDomElement });
legacyPlatform.stop();

expect(targetDomElement).toMatchSnapshot();
expect(targetDomElement).toMatchInlineSnapshot(`
<div
class="ng-scope"
/>
`);
expect(scopeDestroySpy).toHaveBeenCalledTimes(1);
});
});
1 change: 0 additions & 1 deletion src/legacy/ui/public/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// kbnChart__legend-isLoading

@import './accessibility/index';
@import './chrome/index';
@import './directives/index';
@import './error_auto_create_index/index';
@import './error_url_overflow/index';
Expand Down
3 changes: 0 additions & 3 deletions src/legacy/ui/public/chrome/_index.scss

This file was deleted.

4 changes: 0 additions & 4 deletions src/legacy/ui/public/chrome/_variables.scss

This file was deleted.

1 change: 0 additions & 1 deletion src/legacy/ui/public/chrome/directives/_index.scss

This file was deleted.

46 changes: 0 additions & 46 deletions src/legacy/ui/public/chrome/directives/_kbn_chrome.scss

This file was deleted.

37 changes: 5 additions & 32 deletions src/legacy/ui/ui_render/bootstrap/template.js.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -68,44 +68,17 @@ if (window.__kbnStrictCsp__ && window.__kbnCspNotEnforced__) {
});
}

// When rendering in Kibana Platform mode, only serve the assets needed by Core.
if ('{{appId}}' === 'core') {
load([
{{#each sharedJsDepFilenames}}
'{{../regularBundlePath}}/kbn-ui-shared-deps/{{this}}',
{{/each}}
'{{regularBundlePath}}/kbn-ui-shared-deps/{{sharedJsFilename}}',
'{{regularBundlePath}}/plugin/kibanaUtils/kibanaUtils.plugin.js',
'{{regularBundlePath}}/plugin/esUiShared/esUiShared.plugin.js',
'{{regularBundlePath}}/plugin/kibanaReact/kibanaReact.plugin.js',
'{{regularBundlePath}}/core/core.entry.js',
{{#each styleSheetPaths}}
'{{this}}',
{{/each}}
]);
return;
}

load([
{{#each sharedJsDepFilenames}}
'{{../regularBundlePath}}/kbn-ui-shared-deps/{{this}}',
{{/each}}
'{{regularBundlePath}}/kbn-ui-shared-deps/{{sharedJsFilename}}',
'{{dllBundlePath}}/vendors_runtime.bundle.dll.js',
{{#each dllJsChunks}}
{{#each jsDependencies}}
'{{this}}',
{{/each}}
'{{regularBundlePath}}/commons.bundle.js',
{{!-- '{{regularBundlePath}}/plugin:data/data.plugin.js', --}}
'{{regularBundlePath}}/plugin:kibanaUtils/kibanaUtils.plugin.js',
'{{regularBundlePath}}/plugin:esUiShared/esUiShared.plugin.js',
'{{regularBundlePath}}/plugin:kibanaReact/kibanaReact.plugin.js'
], function () {
load([
'{{regularBundlePath}}/{{appId}}.bundle.js',
'{{entryBundle}}',
{{#each styleSheetPaths}}
'{{this}}',
{{/each}}
]);
};
]);
});
}
}
60 changes: 41 additions & 19 deletions src/legacy/ui/ui_render/ui_render_mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ export function uiRenderMixin(kbnServer, server, config) {
const dllJsChunks = DllCompiler.getRawDllConfig().chunks.map(
chunk => `${dllBundlePath}/vendors${chunk}.bundle.dll.js`
);

const styleSheetPaths = [
...dllStyleChunks,
...(isCore ? [] : dllStyleChunks),
`${basePath}/bundles/kbn-ui-shared-deps/${UiSharedDeps.baseCssDistFilename}`,
...(darkMode
? [
Expand All @@ -115,29 +116,50 @@ export function uiRenderMixin(kbnServer, server, config) {
`${basePath}/bundles/kbn-ui-shared-deps/${UiSharedDeps.lightCssDistFilename}`,
`${basePath}/node_modules/@kbn/ui-framework/dist/kui_light.css`,
]),
`${regularBundlePath}/${darkMode ? 'dark' : 'light'}_theme.style.css`,
`${regularBundlePath}/commons.style.css`,
...(!isCore ? [`${regularBundlePath}/${app.getId()}.style.css`] : []),
...kbnServer.uiExports.styleSheetPaths
.filter(path => path.theme === '*' || path.theme === (darkMode ? 'dark' : 'light'))
.map(path =>
path.localPath.endsWith('.scss')
? `${basePath}/built_assets/css/${path.publicPath}`
: `${basePath}/${path.publicPath}`
)
.reverse(),
...(isCore
? []
: [
`${regularBundlePath}/${darkMode ? 'dark' : 'light'}_theme.style.css`,
`${regularBundlePath}/commons.style.css`,
`${regularBundlePath}/${app.getId()}.style.css`,
...kbnServer.uiExports.styleSheetPaths
.filter(
path => path.theme === '*' || path.theme === (darkMode ? 'dark' : 'light')
)
.map(path =>
path.localPath.endsWith('.scss')
? `${basePath}/built_assets/css/${path.publicPath}`
: `${basePath}/${path.publicPath}`
)
.reverse(),
]),
];

const jsDependencies = [
...UiSharedDeps.jsDepFilenames.map(
filename => `${regularBundlePath}/kbn-ui-shared-deps/${filename}`
),
`${regularBundlePath}/kbn-ui-shared-deps/${UiSharedDeps.jsFilename}`,
...(isCore
? []
: [
`${dllBundlePath}/vendors_runtime.bundle.dll.js`,
...dllJsChunks,
`${regularBundlePath}/commons.bundle.js`,
]),
`${regularBundlePath}/plugin:kibanaUtils/kibanaUtils.plugin.js`,
`${regularBundlePath}/plugin:esUiShared/esUiShared.plugin.js`,
`${regularBundlePath}/plugin:kibanaReact/kibanaReact.plugin.js`,
];

const bootstrap = new AppBootstrap({
templateData: {
appId: isCore ? 'core' : app.getId(),
regularBundlePath,
dllBundlePath,
dllJsChunks,
styleSheetPaths,
sharedJsFilename: UiSharedDeps.jsFilename,
sharedJsDepFilenames: UiSharedDeps.jsDepFilenames,
darkMode,
jsDependencies,
styleSheetPaths,
entryBundle: isCore
? `${regularBundlePath}/core/core.entry.js`
: `${regularBundlePath}/${app.getId()}.bundle.js`,
},
});

Expand Down
Loading

0 comments on commit 32c572a

Please sign in to comment.