mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 02:09:32 -04:00
Moves styleSheetPath to uiExports (#23007)
This was previously defined in uiExports.app, which limited plugins which are not an app of providing a stylesheet. This allows any plugin to define a stylesheet which will be available on page load.
This commit is contained in:
parent
991e805669
commit
0e5fd324b1
28 changed files with 257 additions and 166 deletions
|
@ -12,9 +12,6 @@ export default function (kibana) {
|
||||||
title: '<%= startCase(name) %>',
|
title: '<%= startCase(name) %>',
|
||||||
description: '<%= description %>',
|
description: '<%= description %>',
|
||||||
main: 'plugins/<%= snakeCase(name) %>/app',
|
main: 'plugins/<%= snakeCase(name) %>/app',
|
||||||
<%_ if (generateScss) { -%>
|
|
||||||
styleSheetPath: require('path').resolve(__dirname, 'public/app.scss'),
|
|
||||||
<%_ } -%>
|
|
||||||
},
|
},
|
||||||
<%_ } -%>
|
<%_ } -%>
|
||||||
<%_ if (generateHack) { -%>
|
<%_ if (generateHack) { -%>
|
||||||
|
@ -22,6 +19,9 @@ export default function (kibana) {
|
||||||
'plugins/<%= snakeCase(name) %>/hack'
|
'plugins/<%= snakeCase(name) %>/hack'
|
||||||
]
|
]
|
||||||
<%_ } -%>
|
<%_ } -%>
|
||||||
|
<%_ if (generateScss) { -%>
|
||||||
|
styleSheetPaths: require('path').resolve(__dirname, 'public/app.scss'),
|
||||||
|
<%_ } -%>
|
||||||
},
|
},
|
||||||
|
|
||||||
config(Joi) {
|
config(Joi) {
|
||||||
|
|
|
@ -66,9 +66,8 @@ export default function (kibana) {
|
||||||
listed: false,
|
listed: false,
|
||||||
description: 'the kibana you know and love',
|
description: 'the kibana you know and love',
|
||||||
main: 'plugins/kibana/kibana',
|
main: 'plugins/kibana/kibana',
|
||||||
styleSheetPath: `${__dirname}/public/index.scss`,
|
|
||||||
},
|
},
|
||||||
|
styleSheetPaths: `${__dirname}/public/index.scss`,
|
||||||
links: [
|
links: [
|
||||||
{
|
{
|
||||||
id: 'kibana:discover',
|
id: 'kibana:discover',
|
||||||
|
|
|
@ -25,8 +25,8 @@ export default function (kibana) {
|
||||||
main: 'plugins/status_page/status_page',
|
main: 'plugins/status_page/status_page',
|
||||||
hidden: true,
|
hidden: true,
|
||||||
url: '/status',
|
url: '/status',
|
||||||
styleSheetPath: `${__dirname}/public/index.scss`
|
},
|
||||||
}
|
styleSheetPaths: `${__dirname}/public/index.scss`,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
@import 'ui/public/styles/styling_constants';
|
@import 'ui/public/styles/styling_constants';
|
||||||
|
|
||||||
// SASSTODO: Remove when K7 applies background color to body
|
// SASSTODO: Remove when K7 applies background color to body
|
||||||
.stsPage {
|
#status_page-app .stsPage {
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
}
|
}
|
|
@ -20,6 +20,7 @@
|
||||||
import { toArray } from 'rxjs/operators';
|
import { toArray } from 'rxjs/operators';
|
||||||
import { buildAll } from '../../../server/sass/build_all';
|
import { buildAll } from '../../../server/sass/build_all';
|
||||||
import { findPluginSpecs } from '../../../plugin_discovery/find_plugin_specs';
|
import { findPluginSpecs } from '../../../plugin_discovery/find_plugin_specs';
|
||||||
|
import { collectUiExports } from '../../../ui/ui_exports/collect_ui_exports';
|
||||||
|
|
||||||
export const TranspileScssTask = {
|
export const TranspileScssTask = {
|
||||||
description: 'Transpiling SCSS to CSS',
|
description: 'Transpiling SCSS to CSS',
|
||||||
|
@ -30,9 +31,10 @@ export const TranspileScssTask = {
|
||||||
|
|
||||||
const { spec$ } = findPluginSpecs({ plugins: { scanDirs, paths } });
|
const { spec$ } = findPluginSpecs({ plugins: { scanDirs, paths } });
|
||||||
const enabledPlugins = await spec$.pipe(toArray()).toPromise();
|
const enabledPlugins = await spec$.pipe(toArray()).toPromise();
|
||||||
|
const uiExports = collectUiExports(enabledPlugins);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const bundles = await buildAll(enabledPlugins);
|
const bundles = await buildAll(uiExports.styleSheetPaths);
|
||||||
bundles.forEach(bundle => log.info(`Compiled SCSS: ${bundle.source}`));
|
bundles.forEach(bundle => log.info(`Compiled SCSS: ${bundle.source}`));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const { message, line, file } = error;
|
const { message, line, file } = error;
|
||||||
|
|
|
@ -18,16 +18,15 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Build } from './build';
|
import { Build } from './build';
|
||||||
import { collectUiExports } from '../../ui/ui_exports';
|
|
||||||
|
|
||||||
export async function buildAll(enabledPluginSpecs) {
|
export async function buildAll(styleSheets = []) {
|
||||||
const { uiAppSpecs = [] } = collectUiExports(enabledPluginSpecs);
|
const bundles = await Promise.all(styleSheets.map(async styleSheet => {
|
||||||
const bundles = await Promise.all(uiAppSpecs.map(async uiAppSpec => {
|
|
||||||
if (!uiAppSpec.styleSheetPath) {
|
if (!styleSheet.localPath.endsWith('.scss')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bundle = new Build(uiAppSpec.styleSheetPath);
|
const bundle = new Build(styleSheet.localPath);
|
||||||
await bundle.build();
|
await bundle.build();
|
||||||
|
|
||||||
return bundle;
|
return bundle;
|
||||||
|
|
|
@ -24,7 +24,6 @@ export async function sassMixin(kbnServer, server, config) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build assets
|
* Build assets
|
||||||
*
|
*
|
||||||
|
@ -40,7 +39,7 @@ export async function sassMixin(kbnServer, server, config) {
|
||||||
let trackedFiles = new Set();
|
let trackedFiles = new Set();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
scssBundles = await buildAll(kbnServer.pluginSpecs);
|
scssBundles = await buildAll(kbnServer.uiExports.styleSheetPaths);
|
||||||
|
|
||||||
scssBundles.forEach(bundle => {
|
scssBundles.forEach(bundle => {
|
||||||
bundle.includedFiles.forEach(file => trackedFiles.add(file));
|
bundle.includedFiles.forEach(file => trackedFiles.add(file));
|
||||||
|
|
|
@ -83,6 +83,9 @@ const waitForBootstrap = new Promise(resolve => {
|
||||||
require('uiExports/chromeNavControls');
|
require('uiExports/chromeNavControls');
|
||||||
require('uiExports/hacks');
|
require('uiExports/hacks');
|
||||||
|
|
||||||
|
// sets attribute on body for stylesheet sandboxing
|
||||||
|
document.body.setAttribute('id', `${internals.app.id}-app`);
|
||||||
|
|
||||||
chrome.setupAngular();
|
chrome.setupAngular();
|
||||||
targetDomElement.setAttribute('id', 'kibana-body');
|
targetDomElement.setAttribute('id', 'kibana-body');
|
||||||
targetDomElement.setAttribute('kbn-chrome', 'true');
|
targetDomElement.setAttribute('kbn-chrome', 'true');
|
||||||
|
|
|
@ -90,10 +90,6 @@ describe('ui apps / UiApp', () => {
|
||||||
expect(app.getMainModuleId()).to.be(undefined);
|
expect(app.getMainModuleId()).to.be(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has no styleSheetPath', () => {
|
|
||||||
expect(app.getStyleSheetUrlPath()).to.be(undefined);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('has a mostly empty JSON representation', () => {
|
it('has a mostly empty JSON representation', () => {
|
||||||
expect(JSON.parse(JSON.stringify(app))).to.eql({
|
expect(JSON.parse(JSON.stringify(app))).to.eql({
|
||||||
id: spec.id,
|
id: spec.id,
|
||||||
|
@ -312,15 +308,4 @@ describe('ui apps / UiApp', () => {
|
||||||
expect(app.getMainModuleId()).to.be('bar');
|
expect(app.getMainModuleId()).to.be('bar');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#getStyleSheetUrlPath', () => {
|
|
||||||
it('returns public path to styleSheetPath', () => {
|
|
||||||
const app = createUiApp(
|
|
||||||
createStubUiAppSpec({ pluginId: 'foo', id: 'foo', styleSheetPath: '/bar/public/baz/style.scss' }),
|
|
||||||
createStubKbnServer({ plugins: [{ id: 'foo', publicDir: '/bar/public' }] })
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(app.getStyleSheetUrlPath()).to.eql('plugins/foo/baz/style.css');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import path from 'path';
|
|
||||||
import { UiNavLink } from '../ui_nav_links';
|
import { UiNavLink } from '../ui_nav_links';
|
||||||
|
|
||||||
export class UiApp {
|
export class UiApp {
|
||||||
|
@ -34,7 +33,6 @@ export class UiApp {
|
||||||
linkToLastSubUrl,
|
linkToLastSubUrl,
|
||||||
listed,
|
listed,
|
||||||
url = `/app/${id}`,
|
url = `/app/${id}`,
|
||||||
styleSheetPath,
|
|
||||||
} = spec;
|
} = spec;
|
||||||
|
|
||||||
if (!id) {
|
if (!id) {
|
||||||
|
@ -53,7 +51,6 @@ export class UiApp {
|
||||||
this._url = url;
|
this._url = url;
|
||||||
this._pluginId = pluginId;
|
this._pluginId = pluginId;
|
||||||
this._kbnServer = kbnServer;
|
this._kbnServer = kbnServer;
|
||||||
this._styleSheetPath = styleSheetPath;
|
|
||||||
|
|
||||||
if (this._pluginId && !this._getPlugin()) {
|
if (this._pluginId && !this._getPlugin()) {
|
||||||
throw new Error(`Unknown plugin id "${this._pluginId}"`);
|
throw new Error(`Unknown plugin id "${this._pluginId}"`);
|
||||||
|
@ -105,25 +102,6 @@ export class UiApp {
|
||||||
return this._main;
|
return this._main;
|
||||||
}
|
}
|
||||||
|
|
||||||
getStyleSheetUrlPath() {
|
|
||||||
if (!this._styleSheetPath) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const plugin = this._getPlugin();
|
|
||||||
|
|
||||||
// get the path of the stylesheet relative to the public dir for the plugin
|
|
||||||
let relativePath = path.relative(plugin.publicDir, this._styleSheetPath);
|
|
||||||
|
|
||||||
// replace back slashes on windows
|
|
||||||
relativePath = relativePath.split('\\').join('/');
|
|
||||||
|
|
||||||
// replace the extension of relativePath to be .css
|
|
||||||
relativePath = relativePath.slice(0, -path.extname(relativePath).length) + '.css';
|
|
||||||
|
|
||||||
return `plugins/${plugin.id}/${relativePath}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
_getPlugin() {
|
_getPlugin() {
|
||||||
const pluginId = this._pluginId;
|
const pluginId = this._pluginId;
|
||||||
const { plugins } = this._kbnServer;
|
const { plugins } = this._kbnServer;
|
||||||
|
@ -142,7 +120,6 @@ export class UiApp {
|
||||||
main: this._main,
|
main: this._main,
|
||||||
navLink: this._navLink,
|
navLink: this._navLink,
|
||||||
linkToLastSubUrl: this._linkToLastSubUrl,
|
linkToLastSubUrl: this._linkToLastSubUrl,
|
||||||
styleSheetPath: this._styleSheetPath,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,8 @@ export const UI_EXPORT_DEFAULTS = {
|
||||||
|
|
||||||
translationPaths: [],
|
translationPaths: [],
|
||||||
|
|
||||||
|
styleSheetPaths: [],
|
||||||
|
|
||||||
appExtensions: {
|
appExtensions: {
|
||||||
fieldFormatEditors: [
|
fieldFormatEditors: [
|
||||||
'ui/field_editor/components/field_format_editor/register'
|
'ui/field_editor/components/field_format_editor/register'
|
||||||
|
|
|
@ -68,6 +68,10 @@ export {
|
||||||
links,
|
links,
|
||||||
} from './ui_nav_links';
|
} from './ui_nav_links';
|
||||||
|
|
||||||
|
export {
|
||||||
|
styleSheetPaths
|
||||||
|
} from './style_sheet_paths';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
uiSettingDefaults,
|
uiSettingDefaults,
|
||||||
} from './ui_settings';
|
} from './ui_settings';
|
||||||
|
|
67
src/ui/ui_exports/ui_export_types/style_sheet_paths.js
Normal file
67
src/ui/ui_exports/ui_export_types/style_sheet_paths.js
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import path from 'path';
|
||||||
|
import { flatConcatAtType } from './reduce';
|
||||||
|
import { mapSpec, wrap } from './modify_reduce';
|
||||||
|
|
||||||
|
const OK_EXTNAMES = ['.css', '.scss'];
|
||||||
|
|
||||||
|
function normalize(localPath, type, pluginSpec) {
|
||||||
|
const pluginId = pluginSpec.getId();
|
||||||
|
const publicDir = pluginSpec.getPublicDir();
|
||||||
|
const extname = path.extname(localPath);
|
||||||
|
|
||||||
|
if (!OK_EXTNAMES.includes(extname)) {
|
||||||
|
throw new Error(
|
||||||
|
`[plugin:${pluginId}] uiExports.styleSheetPaths supported extensions [${OK_EXTNAMES.join(', ')}], got "${extname}"`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!path.isAbsolute(localPath)) {
|
||||||
|
throw new Error(
|
||||||
|
`[plugin:${pluginId}] uiExports.styleSheetPaths must be an absolute path, got "${localPath}"`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!localPath.startsWith(publicDir)) {
|
||||||
|
throw new Error(
|
||||||
|
`[plugin:${pluginId}] uiExports.styleSheetPaths must be child of publicDir [${publicDir}]`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the path of the stylesheet relative to the public dir for the plugin
|
||||||
|
let relativePath = path.relative(publicDir, localPath);
|
||||||
|
|
||||||
|
// replace back slashes on windows
|
||||||
|
relativePath = relativePath.split('\\').join('/');
|
||||||
|
|
||||||
|
// replace the extension of relativePath to be .css
|
||||||
|
// publicPath will always point to the css file
|
||||||
|
relativePath = relativePath.slice(0, -extname.length) + '.css';
|
||||||
|
|
||||||
|
const publicPath = `plugins/${pluginSpec.getId()}/${relativePath}`;
|
||||||
|
|
||||||
|
return {
|
||||||
|
localPath,
|
||||||
|
publicPath
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export const styleSheetPaths = wrap(mapSpec(normalize), flatConcatAtType);
|
60
src/ui/ui_exports/ui_export_types/style_sheet_paths.test.js
Normal file
60
src/ui/ui_exports/ui_export_types/style_sheet_paths.test.js
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { styleSheetPaths } from './style_sheet_paths';
|
||||||
|
|
||||||
|
describe('uiExports.styleSheetPaths', () => {
|
||||||
|
const pluginSpec = {
|
||||||
|
getId: () => 'test',
|
||||||
|
getPublicDir: () => '/kibana/public'
|
||||||
|
};
|
||||||
|
|
||||||
|
it('does not support relative paths', () => {
|
||||||
|
expect(() => styleSheetPaths([], 'public/bar.css', 'styleSheetPaths', pluginSpec))
|
||||||
|
.toThrowError('[plugin:test] uiExports.styleSheetPaths must be an absolute path, got "public/bar.css"');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('path must be child of public path', () => {
|
||||||
|
expect(() => styleSheetPaths([], '/another/public/bar.css', 'styleSheetPaths', pluginSpec))
|
||||||
|
.toThrowError('[plugin:test] uiExports.styleSheetPaths must be child of publicDir [/kibana/public]');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('only supports css or scss extensions', () => {
|
||||||
|
expect(() => styleSheetPaths([], '/kibana/public/bar.bad', 'styleSheetPaths', pluginSpec))
|
||||||
|
.toThrowError('[plugin:test] uiExports.styleSheetPaths supported extensions [.css, .scss], got ".bad"');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('provides publicPath for scss extensions', () => {
|
||||||
|
const localPath = '/kibana/public/bar.scss';
|
||||||
|
const uiExports = styleSheetPaths([], localPath, 'styleSheetPaths', pluginSpec);
|
||||||
|
|
||||||
|
expect(uiExports.styleSheetPaths).toHaveLength(1);
|
||||||
|
expect(uiExports.styleSheetPaths[0].localPath).toEqual(localPath);
|
||||||
|
expect(uiExports.styleSheetPaths[0].publicPath).toEqual('plugins/test/bar.css');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('provides publicPath for css extensions', () => {
|
||||||
|
const localPath = '/kibana/public/bar.css';
|
||||||
|
const uiExports = styleSheetPaths([], localPath, 'styleSheetPaths', pluginSpec);
|
||||||
|
|
||||||
|
expect(uiExports.styleSheetPaths).toHaveLength(1);
|
||||||
|
expect(uiExports.styleSheetPaths[0].localPath).toEqual(localPath);
|
||||||
|
expect(uiExports.styleSheetPaths[0].publicPath).toEqual('plugins/test/bar.css');
|
||||||
|
});
|
||||||
|
});
|
|
@ -17,7 +17,6 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { isAbsolute, normalize } from 'path';
|
|
||||||
import { flatConcatAtType } from './reduce';
|
import { flatConcatAtType } from './reduce';
|
||||||
import { alias, mapSpec, wrap } from './modify_reduce';
|
import { alias, mapSpec, wrap } from './modify_reduce';
|
||||||
|
|
||||||
|
@ -48,14 +47,6 @@ function applySpecDefaults(spec, type, pluginSpec) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const styleSheetPath = spec.styleSheetPath ? normalize(spec.styleSheetPath) : undefined;
|
|
||||||
|
|
||||||
if (styleSheetPath && (!isAbsolute(styleSheetPath) || !styleSheetPath.startsWith(pluginSpec.getPublicDir()))) {
|
|
||||||
throw new Error(
|
|
||||||
`[plugin:${pluginId}] uiExports.app.styleSheetPath must be an absolute path within the public directory`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
pluginId,
|
pluginId,
|
||||||
id,
|
id,
|
||||||
|
@ -68,7 +59,6 @@ function applySpecDefaults(spec, type, pluginSpec) {
|
||||||
linkToLastSubUrl,
|
linkToLastSubUrl,
|
||||||
listed,
|
listed,
|
||||||
url,
|
url,
|
||||||
styleSheetPath,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,28 +1,10 @@
|
||||||
window.onload = function () {
|
window.onload = function () {
|
||||||
function createAnchor(href) {
|
|
||||||
var anchor = document.createElement('a');
|
|
||||||
anchor.setAttribute('href', href);
|
|
||||||
return anchor.href;
|
|
||||||
}
|
|
||||||
|
|
||||||
var files = [
|
var files = [
|
||||||
createAnchor('{{bundlePath}}/vendors.style.css'),
|
'{{bundlePath}}/vendors.bundle.js',
|
||||||
createAnchor('{{bundlePath}}/commons.style.css'),
|
'{{bundlePath}}/commons.bundle.js',
|
||||||
createAnchor('{{bundlePath}}/{{appId}}.style.css'),
|
'{{bundlePath}}/{{appId}}.bundle.js'
|
||||||
|
|
||||||
createAnchor('{{bundlePath}}/vendors.bundle.js'),
|
|
||||||
createAnchor('{{bundlePath}}/commons.bundle.js'),
|
|
||||||
createAnchor('{{bundlePath}}/{{appId}}.bundle.js')
|
|
||||||
];
|
];
|
||||||
|
|
||||||
if ('{{styleSheetPath}}' !== '') {
|
|
||||||
files.push(createAnchor('{{styleSheetPath}}'));
|
|
||||||
}
|
|
||||||
|
|
||||||
(function next() {
|
|
||||||
var file = files.shift();
|
|
||||||
if (!file) return;
|
|
||||||
|
|
||||||
var failure = function () {
|
var failure = function () {
|
||||||
// make subsequent calls to failure() noop
|
// make subsequent calls to failure() noop
|
||||||
failure = function () {};
|
failure = function () {};
|
||||||
|
@ -38,20 +20,39 @@ window.onload = function () {
|
||||||
document.body.innerHTML = err.outerHTML;
|
document.body.innerHTML = err.outerHTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
var type = /\.js(\?.+)?$/.test(file) ? 'script' : 'link';
|
function loadStyleSheet(path) {
|
||||||
var dom = document.createElement(type);
|
var dom = document.createElement('link');
|
||||||
|
|
||||||
|
dom.addEventListener('error', failure);
|
||||||
|
dom.setAttribute('rel', 'stylesheet');
|
||||||
|
dom.setAttribute('href', path);
|
||||||
|
document.head.appendChild(dom);
|
||||||
|
}
|
||||||
|
|
||||||
|
function createJavascriptElement(path) {
|
||||||
|
var dom = document.createElement('script');
|
||||||
|
|
||||||
dom.setAttribute('async', '');
|
dom.setAttribute('async', '');
|
||||||
dom.addEventListener('error', failure);
|
dom.addEventListener('error', failure);
|
||||||
|
|
||||||
if (type === 'script') {
|
|
||||||
dom.setAttribute('src', file);
|
dom.setAttribute('src', file);
|
||||||
dom.addEventListener('load', next);
|
dom.addEventListener('load', next);
|
||||||
document.head.appendChild(dom);
|
document.head.appendChild(dom);
|
||||||
} else {
|
|
||||||
dom.setAttribute('rel', 'stylesheet');
|
|
||||||
dom.setAttribute('href', file);
|
|
||||||
document.head.appendChild(dom);
|
|
||||||
next();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{{#each styleSheetPaths}}
|
||||||
|
loadStyleSheet('{{this}}');
|
||||||
|
{{/each}}
|
||||||
|
|
||||||
|
(function next() {
|
||||||
|
var file = files.shift();
|
||||||
|
if (!file) return;
|
||||||
|
|
||||||
|
var dom = document.createElement('script');
|
||||||
|
|
||||||
|
dom.setAttribute('async', '');
|
||||||
|
dom.addEventListener('error', failure);
|
||||||
|
dom.setAttribute('src', file);
|
||||||
|
dom.addEventListener('load', next);
|
||||||
|
document.head.appendChild(dom);
|
||||||
}());
|
}());
|
||||||
};
|
};
|
||||||
|
|
|
@ -63,11 +63,18 @@ export function uiRenderMixin(kbnServer, server, config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const basePath = config.get('server.basePath');
|
const basePath = config.get('server.basePath');
|
||||||
|
const bundlePath = `${basePath}/bundles`;
|
||||||
|
const styleSheetPaths = [
|
||||||
|
`${bundlePath}/vendors.style.css`,
|
||||||
|
`${bundlePath}/commons.style.css`,
|
||||||
|
`${bundlePath}/${app.getId()}.style.css`,
|
||||||
|
].concat(kbnServer.uiExports.styleSheetPaths.map(path => `${basePath}/${path.publicPath}`).reverse());
|
||||||
|
|
||||||
const bootstrap = new AppBootstrap({
|
const bootstrap = new AppBootstrap({
|
||||||
templateData: {
|
templateData: {
|
||||||
appId: app.getId(),
|
appId: app.getId(),
|
||||||
bundlePath: `${basePath}/bundles`,
|
bundlePath,
|
||||||
styleSheetPath: app.getStyleSheetUrlPath() ? `${basePath}/${app.getStyleSheetUrlPath()}` : null,
|
styleSheetPaths,
|
||||||
},
|
},
|
||||||
translations: await server.getUiTranslations()
|
translations: await server.getUiTranslations()
|
||||||
});
|
});
|
||||||
|
|
|
@ -21,8 +21,8 @@ export function canvas(kibana) {
|
||||||
description: 'Data driven workpads',
|
description: 'Data driven workpads',
|
||||||
icon: 'plugins/canvas/icon.svg',
|
icon: 'plugins/canvas/icon.svg',
|
||||||
main: 'plugins/canvas/app',
|
main: 'plugins/canvas/app',
|
||||||
styleSheetPath: `${__dirname}/public/style/index.scss`,
|
|
||||||
},
|
},
|
||||||
|
styleSheetPaths: `${__dirname}/public/style/index.scss`,
|
||||||
hacks: [
|
hacks: [
|
||||||
// window.onerror override
|
// window.onerror override
|
||||||
'plugins/canvas/lib/window_error_handler.js',
|
'plugins/canvas/lib/window_error_handler.js',
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
when the UI framework implements everything we need
|
when the UI framework implements everything we need
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#canvas-app {
|
||||||
// Give buttons some room to the right
|
// Give buttons some room to the right
|
||||||
.euiAccordion__childWrapper {
|
.euiAccordion__childWrapper {
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
|
@ -26,6 +27,7 @@
|
||||||
.euiImageFullScreen {
|
.euiImageFullScreen {
|
||||||
min-width: 100px;
|
min-width: 100px;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Canvas has a few modals that necessitate a fixed height due to robust content
|
// Canvas has a few modals that necessitate a fixed height due to robust content
|
||||||
// These styles prevent height jumpiness when using search inside a modal
|
// These styles prevent height jumpiness when using search inside a modal
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
#canvas-app body {
|
||||||
overflow-y: hidden;
|
overflow-y: hidden;
|
||||||
|
|
||||||
// Todo: replace this with EuiToast
|
// Todo: replace this with EuiToast
|
||||||
|
|
|
@ -40,7 +40,6 @@ export function dashboardMode(kibana) {
|
||||||
hidden: true,
|
hidden: true,
|
||||||
description: 'view dashboards',
|
description: 'view dashboards',
|
||||||
main: 'plugins/dashboard_mode/dashboard_viewer',
|
main: 'plugins/dashboard_mode/dashboard_viewer',
|
||||||
styleSheetPath: `${__dirname}/public/index.scss`,
|
|
||||||
links: [
|
links: [
|
||||||
{
|
{
|
||||||
id: 'kibana:dashboard',
|
id: 'kibana:dashboard',
|
||||||
|
@ -52,7 +51,7 @@ export function dashboardMode(kibana) {
|
||||||
icon: 'plugins/kibana/assets/dashboard.svg',
|
icon: 'plugins/kibana/assets/dashboard.svg',
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
config(Joi) {
|
config(Joi) {
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
@import 'ui/public/styles/styling_constants';
|
|
||||||
|
|
||||||
@import 'core_plugins/kibana/public/dashboard/index';
|
|
|
@ -23,8 +23,8 @@ export function graph(kibana) {
|
||||||
icon: 'plugins/graph/icon.png',
|
icon: 'plugins/graph/icon.png',
|
||||||
description: 'Graph exploration',
|
description: 'Graph exploration',
|
||||||
main: 'plugins/graph/app',
|
main: 'plugins/graph/app',
|
||||||
styleSheetPath: `${__dirname}/public/index.scss`,
|
|
||||||
},
|
},
|
||||||
|
styleSheetPaths: `${__dirname}/public/index.scss`,
|
||||||
hacks: ['plugins/graph/hacks/toggle_app_link_in_nav'],
|
hacks: ['plugins/graph/hacks/toggle_app_link_in_nav'],
|
||||||
home: ['plugins/graph/register_feature'],
|
home: ['plugins/graph/register_feature'],
|
||||||
mappings
|
mappings
|
||||||
|
|
|
@ -38,7 +38,6 @@ export const ml = (kibana) => {
|
||||||
description: 'Machine Learning for the Elastic Stack',
|
description: 'Machine Learning for the Elastic Stack',
|
||||||
icon: 'plugins/ml/ml.svg',
|
icon: 'plugins/ml/ml.svg',
|
||||||
main: 'plugins/ml/app',
|
main: 'plugins/ml/app',
|
||||||
styleSheetPath: `${__dirname}/public/index.scss`,
|
|
||||||
},
|
},
|
||||||
hacks: ['plugins/ml/hacks/toggle_app_link_in_nav'],
|
hacks: ['plugins/ml/hacks/toggle_app_link_in_nav'],
|
||||||
home: ['plugins/ml/register_feature']
|
home: ['plugins/ml/register_feature']
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
@import 'ui/public/styles/styling_constants';
|
|
||||||
|
|
||||||
@import 'core_plugins/kibana/public/visualize/index';
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#monitoring-app {
|
||||||
// SASSTODO: We need background colors till more of Kibana is converted
|
// SASSTODO: We need background colors till more of Kibana is converted
|
||||||
.tab-no-data, .tab-overview, .tab-license {
|
.tab-no-data, .tab-overview, .tab-license {
|
||||||
background: $euiColorLightestShade;
|
background: $euiColorLightestShade;
|
||||||
|
@ -24,3 +25,4 @@
|
||||||
padding: 8px 10px;
|
padding: 8px 10px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ export const uiExports = {
|
||||||
icon: 'plugins/monitoring/icons/monitoring.svg',
|
icon: 'plugins/monitoring/icons/monitoring.svg',
|
||||||
linkToLastSubUrl: false,
|
linkToLastSubUrl: false,
|
||||||
main: 'plugins/monitoring/monitoring',
|
main: 'plugins/monitoring/monitoring',
|
||||||
styleSheetPath: `${__dirname}/public/index.scss`,
|
|
||||||
},
|
},
|
||||||
injectDefaultVars(server) {
|
injectDefaultVars(server) {
|
||||||
const config = server.config();
|
const config = server.config();
|
||||||
|
@ -27,5 +26,6 @@ export const uiExports = {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
hacks: [ 'plugins/monitoring/hacks/toggle_app_link_in_nav' ],
|
hacks: [ 'plugins/monitoring/hacks/toggle_app_link_in_nav' ],
|
||||||
home: [ 'plugins/monitoring/register_feature' ]
|
home: [ 'plugins/monitoring/register_feature' ],
|
||||||
|
styleSheetPaths: `${__dirname}/public/index.scss`,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue