Skip to content

Commit

Permalink
consolidate bootstrap templates
Browse files Browse the repository at this point in the history
Signed-off-by: Josh Romero <rmerqg@amazon.com>
  • Loading branch information
joshuarrrr committed Jan 5, 2024
1 parent 21a8740 commit c1987a9
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 230 deletions.
9 changes: 5 additions & 4 deletions src/legacy/ui/ui_render/bootstrap/app_bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ import { resolve } from 'path';
import { osdBundlesLoaderSource } from './osd_bundles_loader_source';

export class AppBootstrap {
constructor({ templateData }) {
constructor({ templateData }, templateName = 'bootstrap') {
this.templateData = { ...templateData, osdBundlesLoaderSource };
this._rawTemplate = undefined;
this.templateName = templateName;
}

async getJsFile() {
if (!this._rawTemplate) {
this._rawTemplate = await loadRawTemplate();
this._rawTemplate = await loadRawTemplate(this.templateName);
}

const template = Handlebars.compile(this._rawTemplate, {
Expand All @@ -63,8 +64,8 @@ export class AppBootstrap {
}
}

function loadRawTemplate() {
const templatePath = resolve(__dirname, 'template.js.hbs');
function loadRawTemplate(templateName) {
const templatePath = resolve(__dirname, `${templateName}.js.hbs`);
return readFileAsync(templatePath);
}

Expand Down
80 changes: 0 additions & 80 deletions src/legacy/ui/ui_render/startup/app_startup.js

This file was deleted.

131 changes: 0 additions & 131 deletions src/legacy/ui/ui_render/startup/app_startup.test.js

This file was deleted.

6 changes: 0 additions & 6 deletions src/legacy/ui/ui_render/startup/index.js

This file was deleted.

20 changes: 11 additions & 9 deletions src/legacy/ui/ui_render/ui_render_mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import * as v8dark from '@elastic/eui/dist/eui_theme_next_dark.json';
import * as UiSharedDeps from '@osd/ui-shared-deps';
import { OpenSearchDashboardsRequest } from '../../../core/server';
import { AppBootstrap } from './bootstrap';
import { AppStartup } from './startup';
import { getApmConfig } from '../apm';

/**
Expand Down Expand Up @@ -231,15 +230,18 @@ export function uiRenderMixin(osdServer, server, config) {
v8: 'Source Code Pro',
});

const startup = new AppStartup({
templateData: {
configDarkMode,
configThemeVersion,
THEME_SOURCES,
fontText,
fontCode,
const startup = new AppBootstrap(
{
templateData: {
configDarkMode,
configThemeVersion,
THEME_SOURCES,
fontText,
fontCode,
},
},
});
'startup'
);

const body = await startup.getJsFile();
const etag = await startup.getJsFileHash();
Expand Down

0 comments on commit c1987a9

Please sign in to comment.