From 14e83cdab7374873678e026b636c25259c9e7f64 Mon Sep 17 00:00:00 2001 From: Tadayoshi Sato Date: Thu, 21 Dec 2023 13:25:40 +0900 Subject: [PATCH] fix(core): branding should be applied after loading plugins It is because plugins may customise hawtconfig, so otherwise the customisation may be ignored. --- app/src/examples/example2/Example2.tsx | 25 +++++++++++++++++++++++-- app/src/examples/example2/index.ts | 4 ++++ packages/hawtio/src/core/core.ts | 7 ++++--- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/app/src/examples/example2/Example2.tsx b/app/src/examples/example2/Example2.tsx index f7cb7f01..5842c95c 100644 --- a/app/src/examples/example2/Example2.tsx +++ b/app/src/examples/example2/Example2.tsx @@ -1,11 +1,32 @@ -import { PageSection, PageSectionVariants, Text, TextContent } from '@patternfly/react-core' +import { CodeBlock, CodeBlockCode, PageSection, PageSectionVariants, Text, TextContent } from '@patternfly/react-core' import React from 'react' export const Example2: React.FunctionComponent = () => ( Example 2 - This is another example plugin. + + This is another example plugin that demonstrates how you can customise hawtconfig.json from an + external plugin. + + + See: app/src/examples/example2/index.ts + + + + {`configManager.configure(config => { + if (!config.about) { + config.about = {} + } + const description = config.about.description + config.about.description = (description ?? '') + ' This text is added by the example 2 plugin.' + if (!config.about.productInfo) { + config.about.productInfo = [] + } + config.about.productInfo.push({ name: 'Example 2', value: '1.0.0' }) +})`} + + ) diff --git a/app/src/examples/example2/index.ts b/app/src/examples/example2/index.ts index 78062927..d0345c6a 100644 --- a/app/src/examples/example2/index.ts +++ b/app/src/examples/example2/index.ts @@ -18,4 +18,8 @@ configManager.configure(config => { } const description = config.about.description config.about.description = (description ?? '') + ' This text is added by the example 2 plugin.' + if (!config.about.productInfo) { + config.about.productInfo = [] + } + config.about.productInfo.push({ name: 'Example 2', value: '1.0.0' }) }) diff --git a/packages/hawtio/src/core/core.ts b/packages/hawtio/src/core/core.ts index 2e4a2f8d..4949d4c9 100644 --- a/packages/hawtio/src/core/core.ts +++ b/packages/hawtio/src/core/core.ts @@ -181,13 +181,14 @@ class HawtioCore { async bootstrap() { log.info('Bootstrapping Hawtio...') + // Load plugins + await this.loadPlugins() + // Apply branding + // Branding should be applied after loading plugins as plugins may customise hawtconfig. const brandingApplied = await configManager.applyBranding() log.info('Branding applied:', brandingApplied) - // Load plugins - await this.loadPlugins() - log.info('Bootstrapped Hawtio') }