Skip to content
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion dynamic-demo-plugin/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"module": "esnext",
"moduleResolution": "node",
"target": "es2021",
"jsx": "react",
"jsx": "react-jsx",
"allowJs": true,
"experimentalDecorators": true,
"noUnusedLocals": true,
Expand Down
1 change: 1 addition & 0 deletions frontend/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ module.exports = {
'prefer-const': ['error', { destructuring: 'all' }],
'prefer-template': 2,
radix: 2,
'react/react-in-jsx-scope': 'off', // React 17 doesn't require this anymore
'react/jsx-fragments': 'error',
'react/jsx-no-duplicate-props': 2,
'react/jsx-uses-react': 'error',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { mount } from 'enzyme';
import { Provider } from 'react-redux';
import { BrowserRouter } from 'react-router-dom-v5-compat';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { mount } from 'enzyme';
import { Provider } from 'react-redux';
import { BrowserRouter } from 'react-router-dom-v5-compat';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { mount } from 'enzyme';
import { Provider } from 'react-redux';
import { BrowserRouter } from 'react-router-dom-v5-compat';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { mount } from 'enzyme';
import { Provider } from 'react-redux';
import { BrowserRouter } from 'react-router-dom-v5-compat';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { mount } from 'enzyme';
import { Provider } from 'react-redux';
import { BrowserRouter } from 'react-router-dom-v5-compat';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { mount } from 'enzyme';
import { Provider } from 'react-redux';
import { BrowserRouter } from 'react-router-dom-v5-compat';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { mount } from 'enzyme';
import { Provider } from 'react-redux';
import { BrowserRouter } from 'react-router-dom-v5-compat';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { mount } from 'enzyme';
import { Provider } from 'react-redux';
import { BrowserRouter } from 'react-router-dom-v5-compat';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { mount } from 'enzyme';
import { Provider } from 'react-redux';
import { BrowserRouter } from 'react-router-dom-v5-compat';
Expand Down
1 change: 0 additions & 1 deletion frontend/__tests__/components/command-line-tools.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { mount } from 'enzyme';
import { Provider } from 'react-redux';
import store from '@console/internal/redux';
Expand Down
1 change: 0 additions & 1 deletion frontend/__tests__/components/container.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
ContainerDetailsList,
} from '../../public/components/container';
import { mount, ReactWrapper, shallow } from 'enzyme';
import * as React from 'react';
import store from '@console/internal/redux';
import { Provider } from 'react-redux';
import * as ReactRouter from 'react-router-dom-v5-compat';
Expand Down
1 change: 0 additions & 1 deletion frontend/__tests__/components/create-yaml.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { shallow, ShallowWrapper } from 'enzyme';
import { safeLoad, safeDump } from 'js-yaml';
import * as useExtensionsModule from '@console/plugin-sdk/src/api/useExtensions';
Expand Down
1 change: 0 additions & 1 deletion frontend/__tests__/components/environment.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { shallow } from 'enzyme';

import { t } from '../../__mocks__/i18next';
Expand Down
1 change: 0 additions & 1 deletion frontend/__tests__/components/factory/details.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { Provider } from 'react-redux';
import * as Router from 'react-router-dom-v5-compat';
import { mount, ReactWrapper } from 'enzyme';
Expand Down
1 change: 0 additions & 1 deletion frontend/__tests__/components/graphs/area.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { shallow } from 'enzyme';
import { Chart, ChartArea, ChartAxis } from '@patternfly/react-charts/victory';

Expand Down
1 change: 0 additions & 1 deletion frontend/__tests__/components/graphs/bar.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { shallow } from 'enzyme';
import { ChartBar } from '@patternfly/react-charts/victory';

Expand Down
1 change: 0 additions & 1 deletion frontend/__tests__/components/graphs/gauge.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { shallow } from 'enzyme';
import { ChartDonutThreshold, ChartDonutUtilization } from '@patternfly/react-charts/victory';

Expand Down
1 change: 0 additions & 1 deletion frontend/__tests__/components/graphs/graph-empty.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { shallow } from 'enzyme';

import { GraphEmpty } from '@console/internal/components/graphs/graph-empty';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { Provider } from 'react-redux';
import { Link, BrowserRouter } from 'react-router-dom-v5-compat';
import { mount, shallow } from 'enzyme';
Expand Down
1 change: 0 additions & 1 deletion frontend/__tests__/components/import-yaml-results.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { shallow, ShallowWrapper } from 'enzyme';
import { Spinner } from '@patternfly/react-core';
import { Tr } from '@patternfly/react-table';
Expand Down
1 change: 0 additions & 1 deletion frontend/__tests__/components/limitrange.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { shallow, ShallowWrapper } from 'enzyme';
import {
LimitRangeDetailsRowProps,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { Provider } from 'react-redux';
import { mount } from 'enzyme';
import { Alert, DataList, DataListCheck } from '@patternfly/react-core';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { shallow, ShallowWrapper } from 'enzyme';
import Spy = jasmine.Spy;

Expand Down
1 change: 0 additions & 1 deletion frontend/__tests__/components/namespace.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { mount, ReactWrapper } from 'enzyme';
import Spy = jasmine.Spy;

Expand Down
1 change: 0 additions & 1 deletion frontend/__tests__/components/pod.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { Provider } from 'react-redux';
import { shallow, ShallowWrapper, mount, ReactWrapper } from 'enzyme';
import store from '@console/internal/redux';
Expand Down
1 change: 0 additions & 1 deletion frontend/__tests__/components/resource-quota.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { shallow, ShallowWrapper } from 'enzyme';
import {
UsageIcon,
Expand Down
1 change: 0 additions & 1 deletion frontend/__tests__/components/route-pages.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { shallow, mount } from 'enzyme';

import { RouteLinkAndCopy, RouteLocation, RouteStatus } from '../../public/components/routes';
Expand Down
1 change: 0 additions & 1 deletion frontend/__tests__/components/routes/create-route.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { shallow, ShallowWrapper } from 'enzyme';
import { Formik } from 'formik';
import { Button } from '@patternfly/react-core';
Expand Down
17 changes: 9 additions & 8 deletions frontend/__tests__/components/safety-first.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { mount, ReactWrapper } from 'enzyme';
import Spy = jasmine.Spy;

import { useSafetyFirst } from '@console/dynamic-plugin-sdk';
import { waitFor } from '@testing-library/react';

type Props = {
loader: () => Promise<any>;
Expand Down Expand Up @@ -76,16 +77,16 @@ describe('useSafetyFirst', () => {
wrapper = wrapper.setProps({ loader });
wrapper.find('button').simulate('click');

// FIXME(alecmerdler): Shouldn't need a `setTimeout` here...
setTimeout(() => {
waitFor(() => {
expect(
consoleErrorSpy.calls
.all()
.map((call) => call.args[0] as string)
.some((text) => text.includes(warning)),
).toBe(false);
done();
}, 500);
});

done();
});

it('will set React state if mounted (using hook)', (done) => {
Expand All @@ -98,16 +99,16 @@ describe('useSafetyFirst', () => {
wrapper = wrapper.setProps({ loader });
wrapper.find('button').simulate('click');

// FIXME(alecmerdler): Shouldn't need a `setTimeout` here...
setTimeout(() => {
waitFor(() => {
expect(wrapper.text()).toEqual('Loaded');
expect(
consoleErrorSpy.calls
.all()
.map((call) => call.args[0] as string)
.some((text) => text.includes(warning)),
).toBe(false);
done();
}, 500);
});

done();
});
});
1 change: 0 additions & 1 deletion frontend/__tests__/components/utils/async.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { mount, ReactWrapper } from 'enzyme';

import { AsyncComponent } from '../../../public/components/utils/async';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { mount, ReactWrapper } from 'enzyme';
import Spy = jasmine.Spy;
import * as fileSaver from 'file-saver';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { shallow } from 'enzyme';
import { NameValueEditor } from '../../../public/components/utils/name-value-editor';

Expand Down
1 change: 0 additions & 1 deletion frontend/__tests__/components/utils/page-heading.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { Link } from 'react-router-dom-v5-compat';
import { shallow, ShallowWrapper } from 'enzyme';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { shallow } from 'enzyme';

import {
Expand Down
4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@
"@types/lodash-es": "4.17.x",
"@types/node": "18.x",
"@types/prop-types": "15.5.6",
"@types/react": "16.8.13",
"@types/react-dom": "16.8.4",
"@types/react": "17.x",
"@types/react-dom": "17.x",
"@types/react-helmet": "5.x",
"@types/react-jsonschema-form": "^1.3.8",
"@types/react-measure": "^2.0.6",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { act, fireEvent, render } from '@testing-library/react';
import { Provider } from 'react-redux';
import store from '@console/internal/redux';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { Button, FormFieldGroupExpandable } from '@patternfly/react-core';
import { mount } from 'enzyme';
import { ButtonBar } from '@console/internal/components/utils';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { Alert, FormFieldGroupExpandable } from '@patternfly/react-core';
import { mount } from 'enzyme';
import { useK8sGet } from '@console/internal/components/utils/k8s-get-hook';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { Button } from '@patternfly/react-core';
import { mount } from 'enzyme';
import { useK8sGet } from '@console/internal/components/utils/k8s-get-hook';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { mount } from 'enzyme';
import { useK8sWatchResource } from '@console/internal/components/utils/k8s-watch-hook';
import { NamespaceModel, PodModel } from '@console/internal/models';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { shallow } from 'enzyme';
import { useLocation } from 'react-router-dom-v5-compat';
import { usePerspectives } from '@console/shared/src';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { mount } from 'enzyme';
import { act } from 'react-dom/test-utils';
import { Perspective } from '@console/dynamic-plugin-sdk';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { cleanup, configure, render, screen } from '@testing-library/react';
import { useK8sWatchResource } from '@console/internal/components/utils/k8s-watch-hook';
import { FinishTourText } from '../GuidedTourText';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { Nav } from '@patternfly/react-core';
import { shallow, mount } from 'enzyme';
import { Provider } from 'react-redux';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { Nav } from '@patternfly/react-core';
import { shallow, mount } from 'enzyme';
import { Provider } from 'react-redux';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import i18next from 'i18next';
import { Trans } from 'react-i18next';
import { confirmModal } from '@console/internal/components/modals';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { useTranslation } from 'react-i18next';
import { DonutChart } from '@console/internal/components/graphs/donut';
import { AppliedClusterResourceQuotaKind } from '@console/internal/module/k8s';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { useTranslation } from 'react-i18next';
import { DonutChart } from '@console/internal/components/graphs/donut';
import { ClusterResourceQuotaKind } from '@console/internal/module/k8s';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { useTranslation } from 'react-i18next';
import { GaugeChart } from '@console/internal/components/graphs/gauge';
import { ResourceQuotaKind } from '@console/internal/module/k8s';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* This test was generated
*/
import * as React from 'react';
import { shallow } from 'enzyme';
import { Tabs } from '../../Tabs';
// any missing imports can usually be resolved by adding them here
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { Tab, Tabs, TabTitleIcon, TabTitleText } from '@patternfly/react-core';
import { render } from 'enzyme';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { shallow } from 'enzyme';
import { Popover, Modal, Spotlight } from '@console/shared';
import TourStepComponent from '../TourStepComponent';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import {
ResolvedExtension,
UserPreferenceFieldType,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { mount, ReactWrapper } from 'enzyme';
import { Provider } from 'react-redux';
import { useProjectOrNamespaceModel } from '@console/internal/components/utils';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { render, screen, configure } from '@testing-library/react';
import { useExtensions } from '@console/plugin-sdk/src';
import PreferredPerspectiveSelect from '../PreferredPerspectiveSelect';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as React from 'react';

export default () => (
<svg
style={{ verticalAlign: '-0.125em' }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as React from 'react';

export const DummyResourceListPage = () => <h1>Example Resource List Page</h1>;
export const DummyResourceDetailsPage = () => <h1>Example Resource Details Page</h1>;
export const DummyHorizontalNavTab = () => <h1>Example Resource Detail View Tab</h1>;
1 change: 0 additions & 1 deletion frontend/packages/console-demo-plugin/src/plugin.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import * as _ from 'lodash';
import { GridPosition } from '@console/dynamic-plugin-sdk';
// TODO(vojtech): internal code needed by plugins should be moved to console-shared package
Expand Down
2 changes: 1 addition & 1 deletion frontend/packages/console-dynamic-plugin-sdk/docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2548,7 +2548,7 @@ The isAllowed boolean value.

### Returns

An array with a pair of state value and it's set function.
An array with a pair of state value and its set function.


---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { shallow, mount } from 'enzyme';
import { Provider } from 'react-redux';
import configureMockStore from 'redux-mock-store';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ import * as React from 'react';
* Hook that ensures a safe asynchronnous setting of the React state in case a given component could be unmounted.
* (https://github.com/facebook/react/issues/14113)
* @param initialState initial state value
* @returns An array with a pair of state value and it's set function.
* @returns An array with a pair of state value and its set function.
*/
export const useSafetyFirst = <S extends any>(
initialState: S | (() => S),
): [S, React.Dispatch<React.SetStateAction<S>>] => {
const mounted = React.useRef(true);
React.useEffect(() => () => (mounted.current = false), []);
React.useEffect(() => {
return () => {
mounted.current = false;
};
}, []);

const [value, setValue] = React.useState(initialState);
const setValueSafe = React.useCallback((newValue: S) => {
Expand Down
Loading