src: Migrate remaining files to TypeScript
This migrates remaining JavaScript files to TypeScript and updates imports.
This commit is contained in:
parent
67138ad99a
commit
45a42ce549
16 changed files with 36 additions and 31 deletions
|
|
@ -116,7 +116,7 @@ export const emptyFoobarApi = createApi({
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Declare the new constat `FOOBAR_API` to the API url in `src/constants.js`
|
3. Declare the new constat `FOOBAR_API` to the API url in `src/constants.ts`
|
||||||
|
|
||||||
```
|
```
|
||||||
export const FOOBAR_API = 'api/foobar/v1'
|
export const FOOBAR_API = 'api/foobar/v1'
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ plugins.push(
|
||||||
root: resolve(__dirname, '../'),
|
root: resolve(__dirname, '../'),
|
||||||
useFileHash: false,
|
useFileHash: false,
|
||||||
exposes: {
|
exposes: {
|
||||||
'./RootApp': resolve(__dirname, '../src/AppEntry.js'),
|
'./RootApp': resolve(__dirname, '../src/AppEntry.tsx'),
|
||||||
},
|
},
|
||||||
shared: [{ 'react-router-dom': { singleton: true } }],
|
shared: [{ 'react-router-dom': { singleton: true } }],
|
||||||
exclude: ['react-router-dom'],
|
exclude: ['react-router-dom'],
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ plugins.push(
|
||||||
root: resolve(__dirname, '../'),
|
root: resolve(__dirname, '../'),
|
||||||
useFileHash: false,
|
useFileHash: false,
|
||||||
exposes: {
|
exposes: {
|
||||||
'./RootApp': resolve(__dirname, '../src/AppEntry.js'),
|
'./RootApp': resolve(__dirname, '../src/AppEntry.tsx'),
|
||||||
},
|
},
|
||||||
shared: [{ 'react-router-dom': { singleton: true } }],
|
shared: [{ 'react-router-dom': { singleton: true } }],
|
||||||
exclude: ['react-router-dom'],
|
exclude: ['react-router-dom'],
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ plugins.push(
|
||||||
{
|
{
|
||||||
root: resolve(__dirname, '../'),
|
root: resolve(__dirname, '../'),
|
||||||
exposes: {
|
exposes: {
|
||||||
'./RootApp': resolve(__dirname, '../src/AppEntry.js'),
|
'./RootApp': resolve(__dirname, '../src/AppEntry.tsx'),
|
||||||
},
|
},
|
||||||
shared: [{ 'react-router-dom': { singleton: true } }],
|
shared: [{ 'react-router-dom': { singleton: true } }],
|
||||||
exclude: ['react-router-dom'],
|
exclude: ['react-router-dom'],
|
||||||
|
|
|
||||||
|
|
@ -2,24 +2,22 @@ import React, { useEffect } from 'react';
|
||||||
|
|
||||||
import { useChrome } from '@redhat-cloud-services/frontend-components/useChrome';
|
import { useChrome } from '@redhat-cloud-services/frontend-components/useChrome';
|
||||||
import NotificationsPortal from '@redhat-cloud-services/frontend-components-notifications/NotificationPortal';
|
import NotificationsPortal from '@redhat-cloud-services/frontend-components-notifications/NotificationPortal';
|
||||||
import { useStore } from 'react-redux';
|
|
||||||
import '@patternfly/patternfly/patternfly-addons.css';
|
import '@patternfly/patternfly/patternfly-addons.css';
|
||||||
|
|
||||||
import { Router } from './Router';
|
import { Router } from './Router';
|
||||||
|
|
||||||
const App = (props) => {
|
const App = () => {
|
||||||
const store = useStore();
|
|
||||||
const { hideGlobalFilter, updateDocumentTitle } = useChrome();
|
const { hideGlobalFilter, updateDocumentTitle } = useChrome();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
updateDocumentTitle('Images');
|
updateDocumentTitle('Images');
|
||||||
hideGlobalFilter();
|
hideGlobalFilter(true);
|
||||||
}, [hideGlobalFilter, updateDocumentTitle]);
|
}, [hideGlobalFilter, updateDocumentTitle]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<NotificationsPortal store={store} />
|
<NotificationsPortal />
|
||||||
<Router childProps={props} />
|
<Router />
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
@ -5,8 +5,12 @@ import { Provider } from 'react-redux';
|
||||||
import App from './App';
|
import App from './App';
|
||||||
import { store } from './store';
|
import { store } from './store';
|
||||||
|
|
||||||
if (process.env.NODE_ENV === 'development' && process.env.MSW === true) {
|
if (
|
||||||
|
process.env.NODE_ENV === 'development' &&
|
||||||
|
process.env.MSW?.toString().toLowerCase() === 'true'
|
||||||
|
) {
|
||||||
// process.env.MSW is set in the webpack config using DefinePlugin
|
// process.env.MSW is set in the webpack config using DefinePlugin
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
const { worker } = require('./test/mocks/browser');
|
const { worker } = require('./test/mocks/browser');
|
||||||
worker.start({
|
worker.start({
|
||||||
serviceWorker: {
|
serviceWorker: {
|
||||||
|
|
@ -7,7 +7,7 @@ import { Text } from '@patternfly/react-core';
|
||||||
import nextStepMapper from './imageOutputStepMapper';
|
import nextStepMapper from './imageOutputStepMapper';
|
||||||
import StepTemplate from './stepTemplate';
|
import StepTemplate from './stepTemplate';
|
||||||
|
|
||||||
import { RHEL_9, X86_64 } from '../../../constants.js';
|
import { RHEL_9, X86_64 } from '../../../constants';
|
||||||
import DocumentationButton from '../../sharedComponents/DocumentationButton';
|
import DocumentationButton from '../../sharedComponents/DocumentationButton';
|
||||||
import CustomButtons from '../formComponents/CustomButtons';
|
import CustomButtons from '../formComponents/CustomButtons';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,14 +9,14 @@ import { manageEdgeImagesUrlName } from './Utilities/edge';
|
||||||
import { useExperimentalFlag } from './Utilities/useExperimentalFlag';
|
import { useExperimentalFlag } from './Utilities/useExperimentalFlag';
|
||||||
|
|
||||||
const LandingPage = lazy(() => import('./Components/LandingPage/LandingPage'));
|
const LandingPage = lazy(() => import('./Components/LandingPage/LandingPage'));
|
||||||
const CreateImageWizard = lazy(() =>
|
const CreateImageWizard = lazy(
|
||||||
import('./Components/CreateImageWizard/CreateImageWizard')
|
() => import('./Components/CreateImageWizard/CreateImageWizard')
|
||||||
);
|
);
|
||||||
const ImportImageWizard = lazy(() =>
|
const ImportImageWizard = lazy(
|
||||||
import('./Components/CreateImageWizardV2/ImportImageWizard')
|
() => import('./Components/CreateImageWizardV2/ImportImageWizard')
|
||||||
);
|
);
|
||||||
const CreateImageWizardV2 = lazy(() =>
|
const CreateImageWizardV2 = lazy(
|
||||||
import('./Components/CreateImageWizardV2')
|
() => import('./Components/CreateImageWizardV2')
|
||||||
);
|
);
|
||||||
|
|
||||||
export const Router = () => {
|
export const Router = () => {
|
||||||
9
src/bootstrap.js
vendored
9
src/bootstrap.js
vendored
|
|
@ -1,9 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
|
|
||||||
import { createRoot } from 'react-dom/client';
|
|
||||||
|
|
||||||
import ImageBuilder from './AppEntry';
|
|
||||||
|
|
||||||
const root = createRoot(document.getElementById('root'));
|
|
||||||
|
|
||||||
root.render(<ImageBuilder />);
|
|
||||||
12
src/bootstrap.tsx
Normal file
12
src/bootstrap.tsx
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import { createRoot } from 'react-dom/client';
|
||||||
|
|
||||||
|
import ImageBuilder from './AppEntry';
|
||||||
|
|
||||||
|
const root = document.getElementById('root');
|
||||||
|
|
||||||
|
if (root) {
|
||||||
|
const reactRoot = createRoot(root);
|
||||||
|
reactRoot.render(<ImageBuilder />);
|
||||||
|
}
|
||||||
|
|
@ -18,7 +18,7 @@ import {
|
||||||
PROVISIONING_API,
|
PROVISIONING_API,
|
||||||
RHEL_8,
|
RHEL_8,
|
||||||
RHSM_API,
|
RHSM_API,
|
||||||
} from '../../../constants.js';
|
} from '../../../constants';
|
||||||
import { server } from '../../mocks/server';
|
import { server } from '../../mocks/server';
|
||||||
import {
|
import {
|
||||||
clickBack,
|
clickBack,
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import { enterBlueprintName } from './wizardTestUtils';
|
||||||
|
|
||||||
import CreateImageWizard from '../../../Components/CreateImageWizardV2/CreateImageWizard';
|
import CreateImageWizard from '../../../Components/CreateImageWizardV2/CreateImageWizard';
|
||||||
import ShareImageModal from '../../../Components/ShareImageModal/ShareImageModal';
|
import ShareImageModal from '../../../Components/ShareImageModal/ShareImageModal';
|
||||||
import { PROVISIONING_API, RHSM_API } from '../../../constants.js';
|
import { PROVISIONING_API, RHSM_API } from '../../../constants';
|
||||||
import { server } from '../../mocks/server';
|
import { server } from '../../mocks/server';
|
||||||
import {
|
import {
|
||||||
clickBack,
|
clickBack,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { screen } from '@testing-library/react';
|
import { screen } from '@testing-library/react';
|
||||||
import { rest } from 'msw';
|
import { rest } from 'msw';
|
||||||
|
|
||||||
import { IMAGE_BUILDER_API } from '../../../constants.js';
|
import { IMAGE_BUILDER_API } from '../../../constants';
|
||||||
import { mockComposesEmpty } from '../../fixtures/composes';
|
import { mockComposesEmpty } from '../../fixtures/composes';
|
||||||
import { server } from '../../mocks/server';
|
import { server } from '../../mocks/server';
|
||||||
import { renderWithReduxRouter } from '../../testUtils';
|
import { renderWithReduxRouter } from '../../testUtils';
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "./dist/",
|
"outDir": "./dist/",
|
||||||
"noImplicitAny": true,
|
"noImplicitAny": true,
|
||||||
"module": "es6",
|
"module": "esnext",
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"downlevelIteration": true, // Needed to allow iteration over some objects like Map() while target is es5
|
"downlevelIteration": true, // Needed to allow iteration over some objects like Map() while target is es5
|
||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue