Skip to content

Commit c70e001

Browse files
authored
Merge pull request #37 from yzhao583/DBAAS-144-upgrade-dynamic-plugin-sdk-to-newer-version
DBAAS-144: Upgrade dynamic-plugin-sdk to 0.0.2
2 parents 495fe34 + f511e73 commit c70e001

File tree

7 files changed

+307
-320
lines changed

7 files changed

+307
-320
lines changed

README.md

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -32,36 +32,6 @@ For more details, see the plugin development section in
3232
[Console Dynamic Plugins README](https://github.com/openshift/console/tree/master/frontend/packages/console-dynamic-plugin-sdk/README.md) for details
3333
on how to run Bridge using local plugins.
3434

35-
## Using Console's API
36-
37-
OpenShift Console exposes API via global window object in runtime. In order to use the API you need to configure [webpack externals](https://webpack.js.org/configuration/externals).
38-
39-
1. in webpack.config.js add [externals configuration](https://github.com/rawagner/console-dynamic-foo/blob/wp_externals/webpack.config.ts#L40-L42)
40-
41-
```
42-
externals: {
43-
'@openshift-console/dynamic-plugin-sdk/api': 'api',
44-
}
45-
```
46-
47-
2. Add path mapping to [tsconfig.json](https://github.com/rawagner/console-dynamic-foo/blob/wp_externals/tsconfig.json#L11-L14) - this step is needed because TS does not yet support node's package exports
48-
49-
```
50-
"paths": {
51-
"@openshift-console/dynamic-plugin-sdk/api": ["node_modules/@openshift-console/dynamic-plugin-sdk/lib/api/api"],
52-
}
53-
```
54-
55-
After following the steps above you will be able to import API in your components/functions like
56-
57-
```
58-
import { useK8sWatchResource } from '@openshift-console/dynamic-plugin-sdk/api';
59-
```
60-
61-
See the usage in [Foo component](https://github.com/rawagner/console-dynamic-foo/blob/wp_externals/src/components/Foo.tsx)
62-
63-
Every imported component/function from `@openshift-console/dynamic-plugin-sdk/api` will be replaced in runtime by an actual implementation.
64-
6535
## Deployment on cluster
6636

6737
Console dynamic plugins are supposed to be deployed via [OLM operators](https://github.com/operator-framework).

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
"style-loader": "^2.0.0"
3939
},
4040
"devDependencies": {
41-
"@openshift-console/dynamic-plugin-sdk": "0.0.0-alpha18",
41+
"@openshift-console/dynamic-plugin-sdk": "0.0.2",
42+
"@openshift-console/dynamic-plugin-sdk-webpack": "^0.0.2",
4243
"@types/react": "16.8.13",
4344
"@types/react-router-dom": "5.1.2",
4445
"babel-eslint": "^10.1.0",
@@ -67,7 +68,7 @@
6768
},
6869
"consolePlugin": {
6970
"name": "dbaas-dynamic-plugin",
70-
"version": "0.0.0",
71+
"version": "0.1.3",
7172
"displayName": "DBaaS Dynamic Plugin",
7273
"description": "Dynamic Plugin for Openshift Console to provide custom components for DBaaS",
7374
"exposedModules": {
@@ -80,4 +81,4 @@
8081
"@console/pluginAPI": "*"
8182
}
8283
}
83-
}
84+
}

src/catalog/providers/useDBaaSCatalog.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import * as React from 'react'
2-
import { useTranslation } from 'react-i18next'
32
import { TextContent, Text, TextVariants } from '@patternfly/react-core'
43
import { CatalogItem } from '@openshift-console/dynamic-plugin-sdk'
54
import { ExtensionHook } from '../../types'
6-
import { useK8sWatchResource } from '@openshift-console/dynamic-plugin-sdk/api'
5+
import { useK8sWatchResource } from '@openshift-console/dynamic-plugin-sdk'
76
import { CATALOG_TYPE, DBAAS_PROVIDER_KIND } from '../const'
87

98
const useDBaaSCatalog: ExtensionHook<CatalogItem[]> = ({ namespace }): [CatalogItem[], boolean, any] => {
10-
const { t } = useTranslation()
11-
129
const [dbaasProviders, loaded, errorMsg] = useK8sWatchResource({
1310
kind: DBAAS_PROVIDER_KIND,
1411
isList: false,
@@ -21,25 +18,25 @@ const useDBaaSCatalog: ExtensionHook<CatalogItem[]> = ({ namespace }): [CatalogI
2118

2219
const providerCards: CatalogItem[] = (dbaasProviders as any).items?.map((provider) => {
2320
return {
24-
name: t(provider.spec?.provider?.displayName),
21+
name: provider.spec?.provider?.displayName,
2522
type: CATALOG_TYPE,
2623
uid: provider.metadata?.uid,
27-
description: t(provider.spec?.provider?.displayDescription),
28-
provider: t(provider.spec?.provider?.name),
24+
description: provider.spec?.provider?.displayDescription,
25+
provider: provider.spec?.provider?.name,
2926
tags: ['mongodb', 'crunchy'],
3027
icon: {
3128
url: `data:${provider.spec?.provider?.icon?.mediatype};base64,${provider.spec?.provider?.icon?.base64data}`,
3229
},
3330
cta: {
34-
label: t('Connect'),
31+
label: 'Connect',
3532
href: `/k8s/ns/${namespace}/${provider.metadata?.name}`,
3633
},
3734
details: {
3835
descriptions: [
3936
{
4037
value: (
4138
<TextContent>
42-
<Text component={TextVariants.p}>{t(provider.spec?.provider?.displayDescription)}</Text>
39+
<Text component={TextVariants.p}>{provider.spec?.provider?.displayDescription}</Text>
4340
</TextContent>
4441
),
4542
},

src/components/instanceListPage.jsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
} from '@patternfly/react-core'
1919
import { InfoCircleIcon } from '@patternfly/react-icons'
2020
import './_dbaas-import-view.css'
21-
import { useTranslation } from 'react-i18next'
2221
import FormHeader from './form/formHeader'
2322
import FlexForm from './form/flexForm'
2423
import FormBody from './form/formBody'
@@ -171,7 +170,6 @@ function json(response) {
171170
}
172171

173172
const InstanceListPage = () => {
174-
const { t } = useTranslation()
175173
const [noInstances, setNoInstances] = React.useState(false)
176174
const [statusMsg, setStatusMsg] = React.useState('')
177175
const [fetchInstancesFailed, setFetchInstancesFailed] = React.useState(false)
@@ -189,7 +187,7 @@ const InstanceListPage = () => {
189187

190188
const dbProviderTitle = (
191189
<div>
192-
Connect {dbProviderName} <Label className="ocs-preview-badge extra-left-margin">{t('Alpha')}</Label>
190+
Connect {dbProviderName} <Label className="ocs-preview-badge extra-left-margin">Alpha</Label>
193191
</div>
194192
)
195193
const filteredInstances = React.useMemo(
@@ -221,7 +219,7 @@ const InstanceListPage = () => {
221219
let newServiceBindingList = serviceBindingList
222220
let newConnectionAndServiceBindingList = []
223221

224-
if (newDbaasConnectionList.length > 0 && newServiceBindingList.length > 0) {
222+
if (newDbaasConnectionList.length > 0) {
225223
newDbaasConnectionList.forEach((dbaasConnection) => {
226224
if (
227225
selectedInventory?.instances?.find((instance) => instance.instanceID === dbaasConnection.spec?.instanceID)

tsconfig.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@
77
"jsx": "react",
88
"allowJs": true,
99
"strict": false,
10-
"noUnusedLocals": true,
11-
"paths": {
12-
"@openshift-console/dynamic-plugin-sdk/api": ["node_modules/@openshift-console/dynamic-plugin-sdk/lib/api/api"],
13-
"@openshift-console/dynamic-plugin-sdk/webpack": ["node_modules/@openshift-console/dynamic-plugin-sdk/lib/webpack"],
14-
},
10+
"noUnusedLocals": true
1511
},
1612
"include": ["src"],
1713
}

webpack.config.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import * as webpack from 'webpack';
44
import * as path from 'path';
5-
import { ConsoleRemotePlugin } from '@openshift-console/dynamic-plugin-sdk/webpack';
5+
import { ConsoleRemotePlugin } from '@openshift-console/dynamic-plugin-sdk-webpack';
66

77
const config: webpack.Configuration = {
88
mode: 'development',
@@ -48,9 +48,6 @@ const config: webpack.Configuration = {
4848
optimization: {
4949
chunkIds: 'named',
5050
minimize: false,
51-
},
52-
externals: {
53-
'@openshift-console/dynamic-plugin-sdk/api': 'api'
5451
}
5552
};
5653

0 commit comments

Comments
 (0)