Skip to content

Commit 6f4b7b0

Browse files
authored
chore(yarn): align dependencies with Console (#895)
* set cryostat-web as a workspace of plugin * deduplicate package.json from cryostat-web workspace * use single openshift dependency family
1 parent 795dbb5 commit 6f4b7b0

6 files changed

Lines changed: 3726 additions & 309 deletions

File tree

package.json

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"description": "OpenShift Console plugin for Cryostat",
55
"private": true,
66
"license": "Apache-2.0",
7+
"workspaces": [
8+
"src/cryostat-web"
9+
],
710
"repository": {
811
"type": "git",
912
"url": "https://github.com/cryostatio/cryostat-openshift-console-plugin.git"
@@ -45,26 +48,18 @@
4548
"mock-server": "prism mock -d -p 8181 $npm_package_config_api_schema_path"
4649
},
4750
"devDependencies": {
51+
"@babel/core": "^7.26.0",
52+
"@babel/preset-env": "^7.26.0",
4853
"@cypress/webpack-preprocessor": "^6.0.4",
4954
"@monaco-editor/react": "^4.6.0",
5055
"@openshift-console/dynamic-plugin-sdk": "4.19.0",
5156
"@openshift-console/dynamic-plugin-sdk-webpack": "4.19.0",
52-
"@openshift/dynamic-plugin-sdk": "5.0.1",
53-
"@openshift/dynamic-plugin-sdk-extensions": "1.4.1",
54-
"@openshift/dynamic-plugin-sdk-utils": "5.0.1",
5557
"@patternfly/patternfly": "^6.0.0",
56-
"@patternfly/quickstarts": "6.4.0",
57-
"@patternfly/react-catalog-view-extension": "^6.0.0",
58-
"@patternfly/react-charts": "^8.0.0",
59-
"@patternfly/react-code-editor": "^6.4.1",
6058
"@patternfly/react-core": "^6.0.0",
6159
"@patternfly/react-icons": "^6.0.0",
62-
"@patternfly/react-styles": "^6.0.0",
63-
"@patternfly/react-table": "^6.0.0",
64-
"@patternfly/react-templates": "^6.4.1",
6560
"@patternfly/react-topology": "^6.0.0",
66-
"@reduxjs/toolkit": "^1.9.3",
6761
"@stoplight/prism-cli": "^5.14.2",
62+
"@testing-library/dom": "^10.4.1",
6863
"@testing-library/jest-dom": "^6.9.1",
6964
"@testing-library/react": "^12.1.2",
7065
"@testing-library/user-event": "^14.6.1",
@@ -75,6 +70,7 @@
7570
"@types/react-router-dom": "^5.3.2",
7671
"@typescript-eslint/eslint-plugin": "^8.53.1",
7772
"@typescript-eslint/parser": "^8.53.1",
73+
"babel-loader": "^9.2.1",
7874
"copy-webpack-plugin": "^13.0.1",
7975
"css-loader": "^7.1.2",
8076
"cypress": "^15.9.0",
@@ -88,25 +84,19 @@
8884
"eslint-plugin-react-hooks": "^7.0.1",
8985
"eslint-plugin-unused-imports": "^4.3.0",
9086
"flat": "6.0.1",
91-
"humanize-duration": "^3.33.2",
92-
"i18next": "^21.8.4",
93-
"i18next-browser-languagedetector": "^8.2.0",
9487
"i18next-parser": "^9.3.0",
9588
"jest": "^30.2.0",
9689
"jest-environment-jsdom": "^30.0.5",
90+
"mocha": "^10.5.1",
9791
"mocha-junit-reporter": "^2.2.0",
9892
"mochawesome": "^7.1.4",
9993
"mochawesome-merge": "^5.1.0",
100-
"monaco-editor": "^0.55.1",
101-
"monaco-editor-webpack-plugin": "^7.1.1",
10294
"pluralize": "^8.0.0",
10395
"prettier": "^3.8.1",
10496
"prettier-stylelint": "^0.4.2",
10597
"react": "^17.0.2",
10698
"react-dom": "^17.0.2",
10799
"react-helmet": "^6.1.0",
108-
"react-i18next": "^11.7.3",
109-
"react-joyride": "^2.9.2",
110100
"react-router": "5.3.x",
111101
"react-router-dom": "5.3.x",
112102
"style-loader": "^4.0.0",
@@ -124,24 +114,10 @@
124114
"dependencies": {
125115
"concurrently": "^9.2.1",
126116
"license-check-and-add": "^4.0.5",
127-
"rxjs": "^7.8.2",
128-
"victory-area": "^37.3.6",
129-
"victory-axis": "^37.3.6",
130-
"victory-bar": "^37.3.6",
131-
"victory-box-plot": "^37.3.6",
132-
"victory-chart": "^37.3.6",
133-
"victory-core": "^37.3.6",
134-
"victory-create-container": "^37.3.6",
135-
"victory-cursor-container": "^37.3.6",
136-
"victory-group": "^37.3.6",
137-
"victory-legend": "^37.3.6",
138-
"victory-line": "^37.3.6",
139-
"victory-pie": "^37.3.6",
140-
"victory-scatter": "^37.3.6",
141-
"victory-stack": "^37.3.6",
142-
"victory-tooltip": "^37.3.6",
143-
"victory-voronoi-container": "^37.3.6",
144-
"victory-zoom-container": "^37.3.6"
117+
"lodash": "^4.17.23",
118+
"monaco-editor": "^0.55.1",
119+
"react-redux": "7.2.9",
120+
"rxjs": "^7.8.2"
145121
},
146122
"peerDependencies": {
147123
"@babel/core": "^7.0.1",

src/openshift/actions/DeploymentLabelAction/DeploymentLabelActionModal.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@
1515
*/
1616
import { CryostatPluginUtilsConfig } from '@console-plugin/utils/CryostatPluginUtilsConfig';
1717
import { useCryostatTranslation } from '@i18n/i18nextUtil';
18-
import { isUtilsConfigSet, k8sPatchResource, setUtilsConfig } from '@openshift/dynamic-plugin-sdk-utils';
1918
import {
2019
K8sModel,
2120
K8sResourceCommon,
2221
K8sResourceKind,
2322
Patch,
2423
useAccessReview,
2524
useK8sWatchResource,
25+
k8sPatch,
2626
} from '@openshift-console/dynamic-plugin-sdk';
27+
import { setUtilsConfig } from '@openshift-console/dynamic-plugin-sdk/lib/app/configSetup';
2728
import {
2829
Button,
2930
Modal,
@@ -258,14 +259,11 @@ export const DeploymentLabelActionModal: React.FC<CryostatModalProps> = ({ kind,
258259
}
259260

260261
function patchResource(patches: Patch[]) {
261-
if (!isUtilsConfigSet()) {
262-
setUtilsConfig(CryostatPluginUtilsConfig);
263-
}
264-
k8sPatchResource({
265-
// @ts-ignore
262+
setUtilsConfig(CryostatPluginUtilsConfig);
263+
k8sPatch({
266264
model: kind,
267-
queryOptions: { name: resource.metadata?.name, ns: resource.metadata?.namespace },
268-
patches: patches,
265+
resource: resource,
266+
data: patches,
269267
});
270268
}
271269

src/openshift/test/actions/DeploymentLabelAction/DeploymentLabelActionModal.test.tsx

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ import {
2222
mockOperatorCryostatList,
2323
mockOperatorCryostatListWithoutTargetNamespaces,
2424
} from '@console-plugin/test/utils';
25-
import { k8sPatchResource } from '@openshift/dynamic-plugin-sdk-utils';
26-
import { K8sModel, useAccessReview, useK8sWatchResource } from '@openshift-console/dynamic-plugin-sdk';
25+
import { K8sModel, useAccessReview, useK8sWatchResource, k8sPatch } from '@openshift-console/dynamic-plugin-sdk';
2726
import { render, screen, waitFor } from '@testing-library/react';
2827
import userEvent from '@testing-library/user-event';
2928
import '@testing-library/jest-dom';
@@ -37,11 +36,11 @@ jest.mock('@i18n/i18nextUtil', () => ({
3736
jest.mock('@openshift-console/dynamic-plugin-sdk', () => ({
3837
useAccessReview: jest.fn(),
3938
useK8sWatchResource: jest.fn(),
39+
k8sPatch: jest.fn(),
4040
}));
4141

42-
jest.mock('@openshift/dynamic-plugin-sdk-utils', () => ({
43-
k8sPatchResource: jest.fn(),
44-
isUtilsConfigSet: jest.fn(() => true),
42+
jest.mock('@openshift-console/dynamic-plugin-sdk/lib/app/configSetup', () => ({
43+
setUtilsConfig: jest.fn(),
4544
}));
4645

4746
const mockDeploymentModel = {
@@ -117,7 +116,7 @@ describe('DeploymentLabelActionModal', () => {
117116
expect(screen.getByText('DEPLOYMENT_ACTION_HELM_CRYOSTAT_SELECTED')).toBeInTheDocument();
118117
});
119118

120-
it('should call k8sPatchResource to add labels and env vars when completing wizard', async () => {
119+
it('should call k8sPatch to add labels and env vars when completing wizard', async () => {
121120
renderModal(mockDeploymentWithoutLabels);
122121

123122
const select = screen.getByLabelText('Cryostat Instance Selection');
@@ -138,9 +137,9 @@ describe('DeploymentLabelActionModal', () => {
138137
const finishButton = screen.queryByRole('button', { name: /finish|submit/i });
139138
if (finishButton) {
140139
await userEvent.click(finishButton);
141-
expect(k8sPatchResource).toHaveBeenCalled();
140+
expect(k8sPatch).toHaveBeenCalled();
142141

143-
const callArgs = (k8sPatchResource as jest.Mock).mock.calls[0][0];
142+
const callArgs = (k8sPatch as jest.Mock).mock.calls[0][0];
144143
expect(callArgs.model).toEqual(mockDeploymentModel);
145144
expect(callArgs.queryOptions).toEqual({ name: 'test-app', ns: 'test-namespace' });
146145

@@ -164,7 +163,7 @@ describe('DeploymentLabelActionModal', () => {
164163
}
165164
});
166165

167-
it('should call k8sPatchResource to remove labels when selecting the empty option', async () => {
166+
it('should call k8sPatch to remove labels when selecting the empty option', async () => {
168167
renderModal(mockDeploymentWithLabels);
169168

170169
const selectElement = screen.getByLabelText('Cryostat Instance Selection');
@@ -185,8 +184,8 @@ describe('DeploymentLabelActionModal', () => {
185184
const finishButton = screen.queryByRole('button', { name: /finish|submit/i });
186185
if (finishButton) {
187186
await userEvent.click(finishButton);
188-
expect(k8sPatchResource).toHaveBeenCalledTimes(1);
189-
expect(k8sPatchResource).toHaveBeenCalledWith({
187+
expect(k8sPatch).toHaveBeenCalledTimes(1);
188+
expect(k8sPatch).toHaveBeenCalledWith({
190189
model: mockDeploymentModel,
191190
queryOptions: { name: 'test-app', ns: 'test-namespace' },
192191
patches: [
@@ -259,10 +258,10 @@ describe('DeploymentLabelActionModal', () => {
259258
const finishButton = screen.queryByRole('button', { name: /finish|submit/i });
260259
if (finishButton) {
261260
await userEvent.click(finishButton);
262-
expect(k8sPatchResource).toHaveBeenCalled();
261+
expect(k8sPatch).toHaveBeenCalled();
263262

264-
const callArgs = (k8sPatchResource as jest.Mock).mock.calls[0][0];
265-
const patches = callArgs.patches;
263+
const callArgs = (k8sPatch as jest.Mock).mock.calls[0][0];
264+
const patches = callArgs.data;
266265

267266
// Verify callback port patch is included
268267
expect(patches).toEqual(
@@ -291,11 +290,11 @@ describe('DeploymentLabelActionModal', () => {
291290
await userEvent.click(quickRegisterButton);
292291

293292
await waitFor(() => {
294-
expect(k8sPatchResource).toHaveBeenCalled();
293+
expect(k8sPatch).toHaveBeenCalled();
295294
});
296295

297-
const callArgs = (k8sPatchResource as jest.Mock).mock.calls[0][0];
298-
const patches = callArgs.patches;
296+
const callArgs = (k8sPatch as jest.Mock).mock.calls[0][0];
297+
const patches = callArgs.data;
299298

300299
// Verify callback port patch is NOT included
301300
const hasCallbackPortPatch = patches.some((p) => p.path?.includes('callback-port'));
@@ -340,10 +339,10 @@ describe('DeploymentLabelActionModal', () => {
340339
const finishButton = screen.queryByRole('button', { name: /finish|submit/i });
341340
if (finishButton) {
342341
await userEvent.click(finishButton);
343-
expect(k8sPatchResource).toHaveBeenCalled();
342+
expect(k8sPatch).toHaveBeenCalled();
344343

345-
const callArgs = (k8sPatchResource as jest.Mock).mock.calls[0][0];
346-
const patches = callArgs.patches;
344+
const callArgs = (k8sPatch as jest.Mock).mock.calls[0][0];
345+
const patches = callArgs.data;
347346

348347
// Verify callback port removal patch is included
349348
expect(patches).toEqual(

src/openshift/utils/CryostatPluginUtilsConfig.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
import { UtilsConfig, WebSocketAppSettings } from '@openshift/dynamic-plugin-sdk-utils';
16+
import { UtilsConfig } from '@openshift-console/dynamic-plugin-sdk/lib/app/configSetup';
1717
import { getCSRFToken } from '@openshift-console/dynamic-plugin-sdk/lib/utils/fetch/console-fetch-utils';
1818
import * as _ from 'lodash';
1919

@@ -38,9 +38,6 @@ export const CryostatPluginUtilsConfig: UtilsConfig = {
3838
const allOptions = _.defaultsDeep({}, initDefaults, options);
3939
return await fetch(url, allOptions).then((resp) => validateStatus(resp));
4040
},
41-
wsAppSettings: function (): Promise<WebSocketAppSettings> {
42-
throw new Error('Function not implemented.');
43-
},
4441
};
4542

4643
/**

0 commit comments

Comments
 (0)