-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(app): polish Example 3 plugin
- Loading branch information
Showing
3 changed files
with
25 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,26 @@ | ||
import { PageSection, PageSectionVariants, Text, TextContent } from '@patternfly/react-core' | ||
import { CodeBlock, CodeBlockCode, PageSection, Text, TextContent } from '@patternfly/react-core' | ||
import React from 'react' | ||
|
||
export const Example3: React.FunctionComponent = () => ( | ||
<PageSection variant={PageSectionVariants.light}> | ||
<PageSection variant='light'> | ||
<TextContent> | ||
<Text component='h1'>Example 3</Text> | ||
<Text component='p'> | ||
This is another example plugin that also demonstrates the addition of custom components to the main header | ||
toolbar. | ||
</Text> | ||
<Text component='p'> | ||
Components should be added in to the Plugin structure using the `headerItems` array. Toolbar components should | ||
be created as single FunctionComponents and added to the array. | ||
Components should be added in to the Plugin structure using the <code>headerItems</code> array. Toolbar | ||
components should be created as single <code>FunctionComponent</code>s and added to the array. | ||
</Text> | ||
<Text component='p'> | ||
Header components will remain in the toolbar until the focus is changed to an alternative plugin. However, | ||
should you wish to persist the components despite the UI focus then an alternative structure can be added to the | ||
`headerItems` array in the form <code>{component: 'MyComponent', universal: true}</code>. | ||
should you wish to persist the components despite the UI focus then an alternative structure can be added to the{' '} | ||
<code>headerItems</code> array in the form: | ||
</Text> | ||
<CodeBlock> | ||
<CodeBlockCode>{component: MyComponent, universal: true}</CodeBlockCode> | ||
</CodeBlock> | ||
</TextContent> | ||
</PageSection> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,20 @@ | ||
import { hawtio, HawtioPlugin } from '@hawtio/react' | ||
import { Example3 } from './Example3' | ||
import { ToolbarItemComp1, ToolbarItemComp2 } from './ToolbarItemComp' | ||
import { Example3HeaderItem1, Example3HeaderItem2 } from './Example3HeaderItems' | ||
|
||
export const registerExample3: HawtioPlugin = () => { | ||
hawtio.addPlugin({ | ||
id: 'example3', | ||
title: 'Example 3', | ||
path: '/example3', | ||
component: Example3, | ||
headerItems: [ToolbarItemComp1, { component: ToolbarItemComp2, universal: true }], | ||
headerItems: [ | ||
// Header item local to the plugin | ||
Example3HeaderItem1, | ||
// Header item universal to the console | ||
// You can also make it local by setting universal=false | ||
{ component: Example3HeaderItem2, universal: true }, | ||
], | ||
isActive: async () => true, | ||
}) | ||
} |