Skip to content

Commit 2f4e6a3

Browse files
Merge pull request #15552 from logonoff/CONSOLE-4795-4801-4797-s1e2-diversity-day
CONSOLE-4795, CONSOLE-4801, CONSOLE-4797: Migrate some static extensions to dynamic
2 parents 6ce1737 + b4d4c63 commit 2f4e6a3

File tree

27 files changed

+115
-528
lines changed

27 files changed

+115
-528
lines changed

dynamic-demo-plugin/console-extensions.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,5 +473,17 @@
473473
"prop": "nodes"
474474
}
475475
}
476+
},
477+
{
478+
"type": "console.dashboards/overview/prometheus/activity/resource",
479+
"properties": {
480+
"queries": ["barQuery"],
481+
"isActivity": {
482+
"$codeRef": "PrometheusActivity.isDemoPrometheusActivity"
483+
},
484+
"component": {
485+
"$codeRef": "PrometheusActivity.DemoPrometheusActivity"
486+
}
487+
}
476488
}
477489
]

dynamic-demo-plugin/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@
7272
"modalPage": "./components/Modals/ModalPage",
7373
"sampleErrorBoundaryPage": "./components/ErrorBoundary/SampleErrorBoundaryPage",
7474
"createProjectModal": "./components/Modals/CreateProjectModal",
75-
"health": "./components/health"
75+
"health": "./components/health",
76+
"PrometheusActivity": "./components/PrometheusActivity"
7677
},
7778
"disableStaticPlugins": [
7879
"@console/demo-plugin"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { PrometheusActivityProps } from '@openshift-console/dynamic-plugin-sdk';
2+
3+
export const isDemoPrometheusActivity = () => true;
4+
5+
export const DemoPrometheusActivity: React.FC<PrometheusActivityProps> = () => (
6+
<div>Demo prometheus activity</div>
7+
);
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import * as React from 'react';
22
import { ResourceLink } from '@console/internal/components/utils';
33
import { NodeModel } from '@console/internal/models';
4-
import { PrometheusActivityProps, K8sActivityProps } from '@console/plugin-sdk';
4+
import { K8sActivityProps } from '@console/plugin-sdk';
55
import { getNamespace, getName } from '@console/shared';
6-
import ActivityItem, {
7-
ActivityProgress,
8-
} from '@console/shared/src/components/dashboard/activity-card/ActivityItem';
6+
import { ActivityProgress } from '@console/shared/src/components/dashboard/activity-card/ActivityItem';
97

108
export const DemoActivity: React.FC<K8sActivityProps> = ({ resource }) => (
119
<ActivityProgress title={`Demo activity for node ${getName(resource)}`} progress={30}>
@@ -16,7 +14,3 @@ export const DemoActivity: React.FC<K8sActivityProps> = ({ resource }) => (
1614
/>
1715
</ActivityProgress>
1816
);
19-
20-
export const DemoPrometheusActivity: React.FC<PrometheusActivityProps> = () => (
21-
<ActivityItem>Demo prometheus activity</ActivityItem>
22-
);

frontend/packages/console-demo-plugin/src/plugin.tsx

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
DashboardsOverviewInventoryItem,
1212
DashboardsInventoryItemGroup,
1313
DashboardsOverviewResourceActivity,
14-
DashboardsOverviewPrometheusActivity,
1514
} from '@console/plugin-sdk';
1615
import { DemoGroupIcon } from './components/dashboards/inventory';
1716
import { FooBarModel } from './models';
@@ -24,8 +23,7 @@ type ConsumedExtensions =
2423
| RoutePage
2524
| DashboardsOverviewInventoryItem
2625
| DashboardsInventoryItemGroup
27-
| DashboardsOverviewResourceActivity
28-
| DashboardsOverviewPrometheusActivity;
26+
| DashboardsOverviewResourceActivity;
2927

3028
const TEST_MODEL_FLAG = 'TEST_MODEL';
3129

@@ -118,20 +116,6 @@ const plugin: Plugin<ConsumedExtensions> = [
118116
required: [TEST_MODEL_FLAG],
119117
},
120118
},
121-
{
122-
type: 'Dashboards/Overview/Activity/Prometheus',
123-
properties: {
124-
queries: ['barQuery'],
125-
isActivity: () => true,
126-
loader: () =>
127-
import('./components/dashboards/activity' /* webpackChunkName: "demo" */).then(
128-
(m) => m.DemoPrometheusActivity,
129-
),
130-
},
131-
flags: {
132-
required: [TEST_MODEL_FLAG],
133-
},
134-
},
135119
];
136120

137121
export default plugin;

frontend/packages/console-dynamic-plugin-sdk/src/api/internal-types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ type OngoingActvityProps<T> = {
4040
export type OngoingActivityBodyProps = {
4141
resourceActivities?: (OngoingActvityProps<K8sResourceCommon> & {
4242
timestamp: Date;
43-
loader?: () => Promise<React.ComponentType<Partial<OngoingActvityProps<K8sResourceCommon>>>>;
4443
component?: React.ComponentType<Partial<OngoingActvityProps<K8sResourceCommon>>>;
4544
})[];
4645
prometheusActivities?: {

frontend/packages/console-plugin-sdk/src/typings/dashboards.ts

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { WatchK8sResources } from '@console/dynamic-plugin-sdk';
2-
import { PrometheusResponse } from '@console/internal/components/graphs';
32
import { FirehoseResource } from '@console/internal/components/utils';
43
import { K8sKind, K8sResourceKind } from '@console/internal/module/k8s';
54
import {
@@ -58,28 +57,6 @@ namespace ExtensionProperties {
5857
/** Loader for corresponding action component */
5958
loader: LazyLoader<K8sActivityProps>;
6059
}
61-
62-
export interface DashboardsOverviewPrometheusActivity {
63-
/** Queries to watch */
64-
queries: string[];
65-
66-
/** Function which will determine if given query results represent the action */
67-
isActivity: (results: PrometheusResponse[]) => boolean;
68-
69-
/** Loader for corresponding action component */
70-
loader: LazyLoader<PrometheusActivityProps>;
71-
}
72-
73-
export interface ProjectDashboardInventoryItem {
74-
/** The K8s model which will be scoped to project, fetched and passed to `mapper` function. */
75-
model: K8sKind;
76-
77-
/** Additional resources which will be fetched and passed to `mapper` function. */
78-
additionalResources?: FirehoseResource[];
79-
80-
/** Function which will map various statuses to groups. */
81-
mapper: StatusGroupMapper;
82-
}
8360
}
8461

8562
export interface DashboardsOverviewInventoryItem
@@ -108,24 +85,6 @@ export const isDashboardsOverviewResourceActivity = (
10885
e: Extension,
10986
): e is DashboardsOverviewResourceActivity => e.type === 'Dashboards/Overview/Activity/Resource';
11087

111-
export interface DashboardsOverviewPrometheusActivity
112-
extends Extension<ExtensionProperties.DashboardsOverviewPrometheusActivity> {
113-
type: 'Dashboards/Overview/Activity/Prometheus';
114-
}
115-
116-
export const isDashboardsOverviewPrometheusActivity = (
117-
e: Extension,
118-
): e is DashboardsOverviewPrometheusActivity =>
119-
e.type === 'Dashboards/Overview/Activity/Prometheus';
120-
121-
export interface ProjectDashboardInventoryItem
122-
extends Extension<ExtensionProperties.ProjectDashboardInventoryItem> {
123-
type: 'Project/Dashboard/Inventory/Item';
124-
}
125-
126-
export const isProjectDashboardInventoryItem = (e: Extension): e is ProjectDashboardInventoryItem =>
127-
e.type === 'Project/Dashboard/Inventory/Item';
128-
12988
export interface DashboardsOverviewInventoryItemReplacement
13089
extends Extension<ExtensionProperties.DashboardsOverviewInventoryItem> {
13190
type: 'Dashboards/Overview/Inventory/Item/Replacement';
@@ -139,7 +98,3 @@ export const isDashboardsOverviewInventoryItemReplacement = (
13998
export type K8sActivityProps = {
14099
resource: K8sResourceKind;
141100
};
142-
143-
export type PrometheusActivityProps = {
144-
results: PrometheusResponse[];
145-
};

frontend/packages/console-plugin-sdk/src/typings/detail-page-bread-crumbs.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.

frontend/packages/console-plugin-sdk/src/typings/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ export * from './base';
44
export * from './dashboards';
55
export * from './features';
66
export * from './models';
7-
export * from './overview';
87
export * from './pages';
98
export * from './global-configs';
109
export * from './guided-tour';
1110
export * from './post-form-submit';
12-
export * from './detail-page-bread-crumbs';

frontend/packages/console-plugin-sdk/src/typings/overview.ts

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)