Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 12 additions & 36 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"description": "OpenShift Console plugin for Cryostat",
"private": true,
"license": "Apache-2.0",
"workspaces": [
"src/cryostat-web"
],
"repository": {
"type": "git",
"url": "https://github.com/cryostatio/cryostat-openshift-console-plugin.git"
Expand Down Expand Up @@ -45,26 +48,18 @@
"mock-server": "prism mock -d -p 8181 $npm_package_config_api_schema_path"
},
"devDependencies": {
"@babel/core": "^7.26.0",
"@babel/preset-env": "^7.26.0",
"@cypress/webpack-preprocessor": "^6.0.4",
"@monaco-editor/react": "^4.6.0",
"@openshift-console/dynamic-plugin-sdk": "4.19.0",
"@openshift-console/dynamic-plugin-sdk-webpack": "4.19.0",
"@openshift/dynamic-plugin-sdk": "5.0.1",
"@openshift/dynamic-plugin-sdk-extensions": "1.4.1",
"@openshift/dynamic-plugin-sdk-utils": "5.0.1",
"@patternfly/patternfly": "^6.0.0",
"@patternfly/quickstarts": "6.4.0",
"@patternfly/react-catalog-view-extension": "^6.0.0",
"@patternfly/react-charts": "^8.0.0",
"@patternfly/react-code-editor": "^6.4.1",
"@patternfly/react-core": "^6.0.0",
"@patternfly/react-icons": "^6.0.0",
"@patternfly/react-styles": "^6.0.0",
"@patternfly/react-table": "^6.0.0",
"@patternfly/react-templates": "^6.4.1",
"@patternfly/react-topology": "^6.0.0",
"@reduxjs/toolkit": "^1.9.3",
"@stoplight/prism-cli": "^5.14.2",
"@testing-library/dom": "^10.4.1",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^14.6.1",
Expand All @@ -75,6 +70,7 @@
"@types/react-router-dom": "^5.3.2",
"@typescript-eslint/eslint-plugin": "^8.53.1",
"@typescript-eslint/parser": "^8.53.1",
"babel-loader": "^9.2.1",
"copy-webpack-plugin": "^13.0.1",
"css-loader": "^7.1.2",
"cypress": "^15.9.0",
Expand All @@ -88,25 +84,19 @@
"eslint-plugin-react-hooks": "^7.0.1",
"eslint-plugin-unused-imports": "^4.3.0",
"flat": "6.0.1",
"humanize-duration": "^3.33.2",
"i18next": "^21.8.4",
"i18next-browser-languagedetector": "^8.2.0",
"i18next-parser": "^9.3.0",
"jest": "^30.2.0",
"jest-environment-jsdom": "^30.0.5",
"mocha": "^10.5.1",
"mocha-junit-reporter": "^2.2.0",
"mochawesome": "^7.1.4",
"mochawesome-merge": "^5.1.0",
"monaco-editor": "^0.55.1",
"monaco-editor-webpack-plugin": "^7.1.1",
"pluralize": "^8.0.0",
"prettier": "^3.8.1",
"prettier-stylelint": "^0.4.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-helmet": "^6.1.0",
"react-i18next": "^11.7.3",
"react-joyride": "^2.9.2",
"react-router": "5.3.x",
"react-router-dom": "5.3.x",
"style-loader": "^4.0.0",
Expand All @@ -124,24 +114,10 @@
"dependencies": {
"concurrently": "^9.2.1",
"license-check-and-add": "^4.0.5",
"rxjs": "^7.8.2",
"victory-area": "^37.3.6",
"victory-axis": "^37.3.6",
"victory-bar": "^37.3.6",
"victory-box-plot": "^37.3.6",
"victory-chart": "^37.3.6",
"victory-core": "^37.3.6",
"victory-create-container": "^37.3.6",
"victory-cursor-container": "^37.3.6",
"victory-group": "^37.3.6",
"victory-legend": "^37.3.6",
"victory-line": "^37.3.6",
"victory-pie": "^37.3.6",
"victory-scatter": "^37.3.6",
"victory-stack": "^37.3.6",
"victory-tooltip": "^37.3.6",
"victory-voronoi-container": "^37.3.6",
"victory-zoom-container": "^37.3.6"
"lodash": "^4.17.23",
"monaco-editor": "^0.55.1",
"react-redux": "7.2.9",
"rxjs": "^7.8.2"
},
"peerDependencies": {
"@babel/core": "^7.0.1",
Expand Down
2 changes: 1 addition & 1 deletion src/cryostat-web
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
*/
import { CryostatPluginUtilsConfig } from '@console-plugin/utils/CryostatPluginUtilsConfig';
import { useCryostatTranslation } from '@i18n/i18nextUtil';
import { isUtilsConfigSet, k8sPatchResource, setUtilsConfig } from '@openshift/dynamic-plugin-sdk-utils';
import {
K8sModel,
K8sResourceCommon,
K8sResourceKind,
Patch,
useAccessReview,
useK8sWatchResource,
k8sPatch,
} from '@openshift-console/dynamic-plugin-sdk';
import { setUtilsConfig } from '@openshift-console/dynamic-plugin-sdk/lib/app/configSetup';
import {
Button,
Modal,
Expand Down Expand Up @@ -258,14 +259,11 @@ export const DeploymentLabelActionModal: React.FC<CryostatModalProps> = ({ kind,
}

function patchResource(patches: Patch[]) {
if (!isUtilsConfigSet()) {
setUtilsConfig(CryostatPluginUtilsConfig);
}
k8sPatchResource({
// @ts-ignore
setUtilsConfig(CryostatPluginUtilsConfig);
k8sPatch({
model: kind,
queryOptions: { name: resource.metadata?.name, ns: resource.metadata?.namespace },
patches: patches,
resource: resource,
data: patches,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import {
mockOperatorCryostatList,
mockOperatorCryostatListWithoutTargetNamespaces,
} from '@console-plugin/test/utils';
import { k8sPatchResource } from '@openshift/dynamic-plugin-sdk-utils';
import { K8sModel, useAccessReview, useK8sWatchResource } from '@openshift-console/dynamic-plugin-sdk';
import { K8sModel, useAccessReview, useK8sWatchResource, k8sPatch } from '@openshift-console/dynamic-plugin-sdk';
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import '@testing-library/jest-dom';
Expand All @@ -37,11 +36,11 @@ jest.mock('@i18n/i18nextUtil', () => ({
jest.mock('@openshift-console/dynamic-plugin-sdk', () => ({
useAccessReview: jest.fn(),
useK8sWatchResource: jest.fn(),
k8sPatch: jest.fn(),
}));

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

const mockDeploymentModel = {
Expand Down Expand Up @@ -117,7 +116,7 @@ describe('DeploymentLabelActionModal', () => {
expect(screen.getByText('DEPLOYMENT_ACTION_HELM_CRYOSTAT_SELECTED')).toBeInTheDocument();
});

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

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

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

Expand All @@ -164,7 +163,7 @@ describe('DeploymentLabelActionModal', () => {
}
});

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

const selectElement = screen.getByLabelText('Cryostat Instance Selection');
Expand All @@ -185,8 +184,8 @@ describe('DeploymentLabelActionModal', () => {
const finishButton = screen.queryByRole('button', { name: /finish|submit/i });
if (finishButton) {
await userEvent.click(finishButton);
expect(k8sPatchResource).toHaveBeenCalledTimes(1);
expect(k8sPatchResource).toHaveBeenCalledWith({
expect(k8sPatch).toHaveBeenCalledTimes(1);
expect(k8sPatch).toHaveBeenCalledWith({
model: mockDeploymentModel,
queryOptions: { name: 'test-app', ns: 'test-namespace' },
patches: [
Expand Down Expand Up @@ -259,10 +258,10 @@ describe('DeploymentLabelActionModal', () => {
const finishButton = screen.queryByRole('button', { name: /finish|submit/i });
if (finishButton) {
await userEvent.click(finishButton);
expect(k8sPatchResource).toHaveBeenCalled();
expect(k8sPatch).toHaveBeenCalled();

const callArgs = (k8sPatchResource as jest.Mock).mock.calls[0][0];
const patches = callArgs.patches;
const callArgs = (k8sPatch as jest.Mock).mock.calls[0][0];
const patches = callArgs.data;

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

await waitFor(() => {
expect(k8sPatchResource).toHaveBeenCalled();
expect(k8sPatch).toHaveBeenCalled();
});

const callArgs = (k8sPatchResource as jest.Mock).mock.calls[0][0];
const patches = callArgs.patches;
const callArgs = (k8sPatch as jest.Mock).mock.calls[0][0];
const patches = callArgs.data;

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

const callArgs = (k8sPatchResource as jest.Mock).mock.calls[0][0];
const patches = callArgs.patches;
const callArgs = (k8sPatch as jest.Mock).mock.calls[0][0];
const patches = callArgs.data;

// Verify callback port removal patch is included
expect(patches).toEqual(
Expand Down
5 changes: 1 addition & 4 deletions src/openshift/utils/CryostatPluginUtilsConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { UtilsConfig, WebSocketAppSettings } from '@openshift/dynamic-plugin-sdk-utils';
import { UtilsConfig } from '@openshift-console/dynamic-plugin-sdk/lib/app/configSetup';
import { getCSRFToken } from '@openshift-console/dynamic-plugin-sdk/lib/utils/fetch/console-fetch-utils';
import * as _ from 'lodash';

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

/**
Expand Down
Loading
Loading