Skip to content

Commit

Permalink
Use 'console.flag/model' extension in all Console plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtechszocs committed Nov 16, 2020
1 parent e60106c commit f485e5a
Show file tree
Hide file tree
Showing 31 changed files with 436 additions and 443 deletions.
2 changes: 1 addition & 1 deletion frontend/dynamic-demo-plugin/package.json
@@ -1,6 +1,6 @@
{
"name": "@console/dynamic-demo-plugin",
"version": "0.0.0-fixed",
"version": "0.0.0",
"private": true,
"scripts": {
"clean": "rm -rf ./dist",
Expand Down
16 changes: 16 additions & 0 deletions frontend/packages/ceph-storage-plugin/console-extensions.json
@@ -0,0 +1,16 @@
{
"$schema": "../console-dynamic-plugin-sdk/dist/schema/console-extensions.json",
"data": [
{
"type": "console.flag/model",
"properties": {
"flag": "CEPH",
"model": {
"group": "ocs.openshift.io",
"version": "v1",
"kind": "StorageCluster"
}
}
}
]
}
9 changes: 0 additions & 9 deletions frontend/packages/ceph-storage-plugin/src/plugin.ts
Expand Up @@ -9,7 +9,6 @@ import {
HorizontalNavTab,
KebabActions,
ModelDefinition,
ModelFeatureFlag,
Plugin,
ResourceTabPage,
RoutePage,
Expand Down Expand Up @@ -38,7 +37,6 @@ import {
} from './features';

type ConsumedExtensions =
| ModelFeatureFlag
| HorizontalNavTab
| ModelDefinition
| DashboardsTab
Expand All @@ -65,13 +63,6 @@ const plugin: Plugin<ConsumedExtensions> = [
models: _.values(models),
},
},
{
type: 'FeatureFlag/Model',
properties: {
model: models.OCSServiceModel,
flag: CEPH_FLAG,
},
},
{
type: 'FeatureFlag/Custom',
properties: {
Expand Down
16 changes: 16 additions & 0 deletions frontend/packages/console-app/console-extensions.json
@@ -0,0 +1,16 @@
{
"$schema": "../console-dynamic-plugin-sdk/dist/schema/console-extensions.json",
"data": [
{
"type": "console.flag/model",
"properties": {
"flag": "DEVWORKSPACE",
"model": {
"group": "workspace.devfile.io",
"version": "v1alpha1",
"kind": "DevWorkspace"
}
}
}
]
}

This file was deleted.

10 changes: 0 additions & 10 deletions frontend/packages/console-app/src/plugin.tsx
Expand Up @@ -2,11 +2,9 @@ import * as React from 'react';
import * as _ from 'lodash';
import { CogsIcon } from '@patternfly/react-icons';
import { FLAGS } from '@console/shared/src/constants';
import { FLAG_DEVWORKSPACE } from './consts';
import {
Plugin,
Perspective,
ModelFeatureFlag,
ModelDefinition,
RoutePage,
DashboardsOverviewResourceActivity,
Expand Down Expand Up @@ -55,7 +53,6 @@ import '@console/internal/i18n.js';
type ConsumedExtensions =
| Perspective
| ModelDefinition
| ModelFeatureFlag
| RoutePage
| DashboardsOverviewResourceActivity
| DashboardsOverviewHealthURLSubsystem<any>
Expand All @@ -76,13 +73,6 @@ const plugin: Plugin<ConsumedExtensions> = [
models: _.values(models),
},
},
{
type: 'FeatureFlag/Model',
properties: {
model: models.WorkspaceModel,
flag: FLAG_DEVWORKSPACE,
},
},
{
type: 'Perspective',
properties: {
Expand Down
16 changes: 16 additions & 0 deletions frontend/packages/console-demo-plugin/console-extensions.json
@@ -0,0 +1,16 @@
{
"$schema": "../console-dynamic-plugin-sdk/dist/schema/console-extensions.json",
"data": [
{
"type": "console.flag/model",
"properties": {
"flag": "TEST_MODEL",
"model": {
"group": "core",
"version": "v1",
"kind": "Pod"
}
}
}
]
}
9 changes: 0 additions & 9 deletions frontend/packages/console-demo-plugin/src/plugin.tsx
Expand Up @@ -3,7 +3,6 @@ import * as _ from 'lodash';
import {
Plugin,
ModelDefinition,
ModelFeatureFlag,
HrefNavItem,
ResourceNSNavItem,
ResourceClusterNavItem,
Expand Down Expand Up @@ -36,7 +35,6 @@ import { DemoGroupIcon } from './components/dashboards/inventory';

type ConsumedExtensions =
| ModelDefinition
| ModelFeatureFlag
| HrefNavItem
| ResourceNSNavItem
| ResourceClusterNavItem
Expand Down Expand Up @@ -65,13 +63,6 @@ const plugin: Plugin<ConsumedExtensions> = [
models: [FooBarModel],
},
},
{
type: 'FeatureFlag/Model',
properties: {
model: PodModel,
flag: TEST_MODEL_FLAG,
},
},
{
type: 'NavItem/Href',
properties: {
Expand Down
9 changes: 5 additions & 4 deletions frontend/packages/console-dynamic-plugin-sdk/README.md
Expand Up @@ -28,7 +28,7 @@ declared via the `consolePlugin` object.
```jsonc
{
"name": "@console/dynamic-demo-plugin",
"version": "0.0.0-fixed",
"version": "0.0.0",
"private": true,
// scripts, dependencies, devDependencies, ...
"consolePlugin": {
Expand All @@ -46,7 +46,7 @@ declared via the `consolePlugin` object.

Dynamic plugins can expose modules representing additional code to be referenced, loaded and executed
at runtime. A separate [webpack chunk](https://webpack.js.org/guides/code-splitting/) is generated for
each exposed module.
each exposed module. Exposed modules are resolved relative to webpack `context` option.

## `console-extensions.json`

Expand Down Expand Up @@ -133,9 +133,10 @@ Provides asynchronous access to specific modules exposed by the plugin.

## Runtime constraints and specifics

- Loading two or more plugins with the same `name` is not allowed.
- Loading multiple plugins with the same `name` is not allowed.
- Console will [override](https://webpack.js.org/concepts/module-federation/#overriding) certain modules
to ensure a single version of React etc. is loaded and used by the application.
- Enabling a plugin makes all of its extensions available for consumption. Individual extensions cannot
be enabled or disabled separately.
- Failure to resolve a code reference (unable to load module or missing export) will disable the plugin.
- Failure to resolve a code reference (unable to load module, missing module export etc.) will disable
the plugin.

0 comments on commit f485e5a

Please sign in to comment.