Skip to content

Commit

Permalink
Merge pull request #79 from rszwajko/restructure
Browse files Browse the repository at this point in the history
Maintain dynamic plugin metadata inside module
  • Loading branch information
yaacov authored Nov 16, 2022
2 parents 74c8b54 + 92e0612 commit ec17aa7
Show file tree
Hide file tree
Showing 14 changed files with 156 additions and 100 deletions.
94 changes: 12 additions & 82 deletions console-extensions.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type { EncodedExtension } from '@openshift/dynamic-plugin-sdk';
import type {
HrefNavItem,
NavSection,
RoutePage,
Separator,
} from '@openshift-console/dynamic-plugin-sdk';
import type { HrefNavItem, NavSection, Separator } from '@openshift-console/dynamic-plugin-sdk';

import { extensions as hostExtensions } from './src/modules/Hosts/dynamic-plugin';
import { extensions as mappingExtensions } from './src/modules/Mappings/dynamic-plugin';
import { extensions as planExtensions } from './src/modules/Plans/dynamic-plugin';
import { extensions as providerExtensions } from './src/modules/Providers/dynamic-plugin';
import { extensions as vmMigrationDetailExtensions } from './src/modules/VmMigrationDetails/dynamic-plugin';

const extensions: EncodedExtension[] = [
{
Expand Down Expand Up @@ -72,82 +73,11 @@ const extensions: EncodedExtension[] = [
},
} as EncodedExtension<HrefNavItem>,

{
type: 'console.page/route',
properties: {
component: {
$codeRef: 'ProvidersPage',
},
path: ['/mtv/providers', '/mtv/providers/:providerType'],
exact: true,
},
} as EncodedExtension<RoutePage>,

{
type: 'console.page/route',
properties: {
component: {
$codeRef: 'HostsPage',
},
path: '/mtv/providers/vsphere/:providerName',
exact: false,
},
} as EncodedExtension<RoutePage>,

{
type: 'console.page/route',
properties: {
component: {
$codeRef: 'PlansPage',
},
path: '/mtv/plans',
exact: true,
},
} as EncodedExtension<RoutePage>,

{
type: 'console.page/route',
properties: {
component: {
$codeRef: 'PlanWizard',
},
path: '/mtv/plans/create',
exact: true,
},
} as EncodedExtension<RoutePage>,

{
type: 'console.page/route',
properties: {
component: {
$codeRef: 'PlanWizard',
},
path: ['/mtv/plans/:planName/edit', '/mtv/plans/:planName/duplicate'],
exact: false,
},
} as EncodedExtension<RoutePage>,

{
type: 'console.page/route',
properties: {
component: {
$codeRef: 'VMMigrationDetails',
},
path: '/mtv/plans/:planName',
exact: false,
},
} as EncodedExtension<RoutePage>,

{
type: 'console.page/route',
properties: {
component: {
$codeRef: 'MappingsPage',
},
path: '/mtv/mappings',
exact: true,
},
} as EncodedExtension<RoutePage>,
...providerExtensions,
...hostExtensions,
...planExtensions,
...mappingExtensions,
...vmMigrationDetailExtensions,
];

export default extensions;
17 changes: 11 additions & 6 deletions plugin.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
import type { ConsolePluginMetadata } from '@openshift-console/dynamic-plugin-sdk-webpack/lib/schema/plugin-package';

import { exposedModules as hostModules } from './src/modules/Hosts/dynamic-plugin';
import { exposedModules as mappingModules } from './src/modules/Mappings/dynamic-plugin';
import { exposedModules as planModules } from './src/modules/Plans/dynamic-plugin';
import { exposedModules as providerModules } from './src/modules/Providers/dynamic-plugin';
import { exposedModules as vmMigrationDetailsModules } from './src/modules/VmMigrationDetails/dynamic-plugin';

export default {
name: 'forklift-console-plugin',
version: '0.0.1',
displayName: 'OpenShift Console Plugin For Forklift',
description:
'Forklift is a suite of migration tools that facilitate the migration of VM workloads to KubeVirt.',
exposedModules: {
ProvidersPage: './extensions/ProvidersWrapper',
PlansPage: './extensions/PlansWrapper',
MappingsPage: './extensions/MappingsWrapper',
HostsPage: './extensions/HostsPageWrapper',
PlanWizard: './extensions/PlanWizardWrapper',
VMMigrationDetails: './extensions/VMMigrationDetailsWrapper',
...providerModules,
...planModules,
...mappingModules,
...hostModules,
...vmMigrationDetailsModules,
},
dependencies: {
'@console/pluginAPI': '*',
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HostsPage } from '@app/Providers/HostsPage';
import withQueryClient from 'src/components/QueryClientHoc';

import withQueryClient from './QueryClientHoc';
import { HostsPage } from '@app/Providers/HostsPage';

const Page = withQueryClient(HostsPage);

Expand Down
20 changes: 20 additions & 0 deletions src/modules/Hosts/dynamic-plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { EncodedExtension } from '@openshift/dynamic-plugin-sdk';
import { RoutePage } from '@openshift-console/dynamic-plugin-sdk';
import type { ConsolePluginMetadata } from '@openshift-console/dynamic-plugin-sdk-webpack/lib/schema/plugin-package';

export const exposedModules: ConsolePluginMetadata['exposedModules'] = {
HostsPage: './modules/Hosts/HostsPageWrapper',
};

export const extensions: EncodedExtension[] = [
{
type: 'console.page/route',
properties: {
component: {
$codeRef: 'HostsPage',
},
path: '/mtv/providers/vsphere/:providerName',
exact: false,
},
} as EncodedExtension<RoutePage>,
];
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MappingsPage } from '@app/Mappings/MappingsPage';
import withQueryClient from 'src/components/QueryClientHoc';

import withQueryClient from './QueryClientHoc';
import { MappingsPage } from '@app/Mappings/MappingsPage';

const Page = withQueryClient(MappingsPage);

Expand Down
20 changes: 20 additions & 0 deletions src/modules/Mappings/dynamic-plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { EncodedExtension } from '@openshift/dynamic-plugin-sdk';
import { RoutePage } from '@openshift-console/dynamic-plugin-sdk';
import type { ConsolePluginMetadata } from '@openshift-console/dynamic-plugin-sdk-webpack/lib/schema/plugin-package';

export const exposedModules: ConsolePluginMetadata['exposedModules'] = {
MappingsPage: './modules/Mappings/MappingsWrapper',
};

export const extensions: EncodedExtension[] = [
{
type: 'console.page/route',
properties: {
component: {
$codeRef: 'MappingsPage',
},
path: '/mtv/mappings',
exact: true,
},
} as EncodedExtension<RoutePage>,
];
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PlanWizard } from '@app/Plans/components/Wizard/PlanWizard';
import withQueryClient from 'src/components/QueryClientHoc';

import withQueryClient from './QueryClientHoc';
import { PlanWizard } from '@app/Plans/components/Wizard/PlanWizard';

const Page = withQueryClient(PlanWizard);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from 'react';
import withQueryClient from 'src/components/QueryClientHoc';

import { MustGatherContextProvider } from '@app/common/context';
import { PlansPage } from '@app/Plans/PlansPage';

import withQueryClient from './QueryClientHoc';

const Page = withQueryClient(() => (
<MustGatherContextProvider>
<PlansPage />
Expand Down
43 changes: 43 additions & 0 deletions src/modules/Plans/dynamic-plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { EncodedExtension } from '@openshift/dynamic-plugin-sdk';
import { RoutePage } from '@openshift-console/dynamic-plugin-sdk';
import type { ConsolePluginMetadata } from '@openshift-console/dynamic-plugin-sdk-webpack/lib/schema/plugin-package';

export const exposedModules: ConsolePluginMetadata['exposedModules'] = {
PlansPage: './modules/Plans/PlansWrapper',
PlanWizard: './modules/Plans/PlanWizardWrapper',
};

export const extensions: EncodedExtension[] = [
{
type: 'console.page/route',
properties: {
component: {
$codeRef: 'PlansPage',
},
path: '/mtv/plans',
exact: true,
},
} as EncodedExtension<RoutePage>,

{
type: 'console.page/route',
properties: {
component: {
$codeRef: 'PlanWizard',
},
path: '/mtv/plans/create',
exact: true,
},
} as EncodedExtension<RoutePage>,

{
type: 'console.page/route',
properties: {
component: {
$codeRef: 'PlanWizard',
},
path: ['/mtv/plans/:planName/edit', '/mtv/plans/:planName/duplicate'],
exact: false,
},
} as EncodedExtension<RoutePage>,
];
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ProvidersPage } from '@app/Providers/ProvidersPage';
import withQueryClient from 'src/components/QueryClientHoc';

import withQueryClient from './QueryClientHoc';
import { ProvidersPage } from '@app/Providers/ProvidersPage';

const Page = withQueryClient(ProvidersPage);

Expand Down
20 changes: 20 additions & 0 deletions src/modules/Providers/dynamic-plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { EncodedExtension } from '@openshift/dynamic-plugin-sdk';
import { RoutePage } from '@openshift-console/dynamic-plugin-sdk';
import type { ConsolePluginMetadata } from '@openshift-console/dynamic-plugin-sdk-webpack/lib/schema/plugin-package';

export const exposedModules: ConsolePluginMetadata['exposedModules'] = {
ProvidersPage: './modules/Providers/ProvidersWrapper',
};

export const extensions: EncodedExtension[] = [
{
type: 'console.page/route',
properties: {
component: {
$codeRef: 'ProvidersPage',
},
path: ['/mtv/providers', '/mtv/providers/:providerType'],
exact: true,
},
} as EncodedExtension<RoutePage>,
];
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import * as React from 'react';
import withQueryClient from 'src/components/QueryClientHoc';

import { MustGatherContextProvider } from '@app/common/context';
import {
VMMigrationDetails,
VMMigrationDetailsProps,
} from '@app/Plans/components/VMMigrationDetails';

import withQueryClient from './QueryClientHoc';

const Page = withQueryClient((props: VMMigrationDetailsProps) => (
<MustGatherContextProvider>
<VMMigrationDetails match={props.match} />
Expand Down
20 changes: 20 additions & 0 deletions src/modules/VmMigrationDetails/dynamic-plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { EncodedExtension } from '@openshift/dynamic-plugin-sdk';
import { RoutePage } from '@openshift-console/dynamic-plugin-sdk';
import type { ConsolePluginMetadata } from '@openshift-console/dynamic-plugin-sdk-webpack/lib/schema/plugin-package';

export const exposedModules: ConsolePluginMetadata['exposedModules'] = {
VMMigrationDetails: './modules/VmMigrationDetails/VMMigrationDetailsWrapper',
};

export const extensions: EncodedExtension[] = [
{
type: 'console.page/route',
properties: {
component: {
$codeRef: 'VMMigrationDetails',
},
path: '/mtv/plans/:planName',
exact: false,
},
} as EncodedExtension<RoutePage>,
];

0 comments on commit ec17aa7

Please sign in to comment.