Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"build": "yarn build-libs && yarn build-samples",
"build-libs": "yarn workspaces foreach --from '@openshift/*' run build",
"build-samples": "yarn workspaces foreach --from '@monorepo/sample-*' run build",
"copy-api-reports": "cp ./**/**/dist/api/*.api.md ./reports/",
"run-samples": "yarn workspaces foreach -pvi --from '@monorepo/sample-*' run http-server",
"lint": "yarn eslint packages",
"test": "yarn jest",
Expand Down
31 changes: 31 additions & 0 deletions packages/sample-app/src/components/PageHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { usePluginStore } from '@openshift/dynamic-plugin-sdk';
import {
Brand,
Button,
Expand All @@ -20,11 +21,32 @@ import type { LoadPluginModalRefProps } from './LoadPluginModal';

const PageHeader: React.FC = () => {
const loadPluginModalRef = React.useRef<LoadPluginModalRefProps>(null);
const pluginStore = usePluginStore();

const openLoadPluginModal = () => {
loadPluginModalRef.current?.open();
};

const manuallyLoadPlugin = () => {
pluginStore.loadPlugin({
name: 'manual-plugin',
version: '0.0.0',
local: true,
extensions: [
{
type: 'core.telemetry/listener',
properties: {
listener: () => import('./manualPlugin').then((m) => m.default),
},
flags: {
required: ['TELEMETRY_FLAG'],
disallowed: [],
},
},
],
});
};

return (
<Masthead>
<MastheadToggle>
Expand Down Expand Up @@ -53,6 +75,15 @@ const PageHeader: React.FC = () => {
Load plugin
</Button>
</ToolbarItem>
<ToolbarItem>
<Button
variant="secondary"
onClick={manuallyLoadPlugin}
data-test-id="manual-plugin-load"
>
Manually add plugin
</Button>
</ToolbarItem>
</ToolbarGroup>
</ToolbarContent>
</Toolbar>
Expand Down
8 changes: 8 additions & 0 deletions packages/sample-app/src/components/manualPlugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { TelemetryEventListener } from '@openshift/dynamic-plugin-sdk-extensions';

const telemetryListener: TelemetryEventListener = (eventType, properties) => {
// eslint-disable-next-line no-console
console.info('Telemetry listener', eventType, properties);
};

export default telemetryListener;