Skip to content

Commit

Permalink
fix(core): branding should be applied after loading plugins
Browse files Browse the repository at this point in the history
It is because plugins may customise hawtconfig, so otherwise the
customisation may be ignored.
  • Loading branch information
tadayosi committed Dec 21, 2023
1 parent ac32dd6 commit 14e83cd
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
25 changes: 23 additions & 2 deletions app/src/examples/example2/Example2.tsx
Original file line number Diff line number Diff line change
@@ -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 = () => (
<PageSection variant={PageSectionVariants.light}>
<TextContent>
<Text component='h1'>Example 2</Text>
<Text component='p'>This is another example plugin.</Text>
<Text component='p'>
This is another example plugin that demonstrates how you can customise <code>hawtconfig.json</code> from an
external plugin.
</Text>
<Text component='p'>
See: <code>app/src/examples/example2/index.ts</code>
</Text>
<CodeBlock>
<CodeBlockCode>
{`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' })
})`}
</CodeBlockCode>
</CodeBlock>
</TextContent>
</PageSection>
)
4 changes: 4 additions & 0 deletions app/src/examples/example2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' })
})
7 changes: 4 additions & 3 deletions packages/hawtio/src/core/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}

Expand Down

0 comments on commit 14e83cd

Please sign in to comment.