Skip to content

Commit a12a0aa

Browse files
committed
Upgrade packages to match those used by web console for 4.22
Also fixes some type errors resulting from the package upgrdes
1 parent e5f50e2 commit a12a0aa

10 files changed

Lines changed: 317 additions & 1290 deletions

package-lock.json

Lines changed: 286 additions & 1249 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,23 @@
2121
"test-headless": "npx cypress run --browser chrome"
2222
},
2323
"dependencies": {
24-
"@openshift-console/dynamic-plugin-sdk": "4.19.1",
25-
"@openshift-console/dynamic-plugin-sdk-webpack": "4.19.0",
24+
"@openshift-console/dynamic-plugin-sdk": "4.22.0-prerelease.2",
25+
"@openshift-console/dynamic-plugin-sdk-webpack": "4.22.0-prerelease.2",
2626
"@patternfly/chatbot": "6.6.0-prerelease.6",
2727
"@patternfly/react-code-editor": "6.4.1",
2828
"@patternfly/react-core": "6.4.1",
2929
"@patternfly/react-icons": "6.4.0",
3030
"copy-webpack-plugin": "^14.0.0",
3131
"css-loader": "^7.1.4",
32+
"i18next": "^26.0.4",
3233
"js-yaml": "^4.1.1",
3334
"lodash": "^4.18.1",
34-
"react": "17.0.2",
35-
"react-dom": "17.0.2",
36-
"react-i18next": "11.18.6",
35+
"react": "18.3.1",
36+
"react-dom": "18.3.1",
37+
"react-i18next": "16.5.8",
3738
"react-modal": "^3.16.3",
38-
"react-redux": "7.2.9",
39-
"react-router-dom-v5-compat": "^6.30.3",
39+
"react-redux": "9.2.0",
40+
"react-router": "7.13.1",
4041
"style-loader": "^4.0.0",
4142
"ts-loader": "^9.5.7",
4243
"ts-node": "^10.9.2",
@@ -47,7 +48,7 @@
4748
"devDependencies": {
4849
"@cypress/grep": "^6.0.0",
4950
"@types/node": "^22.19.15",
50-
"@types/react": "^17.0.91",
51+
"@types/react": "^18.3.27",
5152
"@typescript-eslint/eslint-plugin": "^8.58.0",
5253
"@typescript-eslint/parser": "^8.58.0",
5354
"cypress": "^15.13.0",
@@ -66,9 +67,7 @@
6667
"webpack-dev-server": "^5.2.3"
6768
},
6869
"overrides": {
69-
"monaco-editor": "0.55.1",
70-
"react": "17.0.2",
71-
"react-dom": "17.0.2"
70+
"monaco-editor": "0.55.1"
7271
},
7372
"consolePlugin": {
7473
"name": "lightspeed-console-plugin",

src/components/GeneralPage.tsx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ const ChatHistoryEntry = React.memo(({ conversationID, entryIndex }: ChatHistory
272272
);
273273

274274
return (
275-
// @ts-expect-error: TS2786
276275
<Message
277276
actions={actions}
278277
avatar={isDarkTheme ? aiAvatarDark : aiAvatar}
@@ -387,7 +386,6 @@ const ChatHistoryEntry = React.memo(({ conversationID, entryIndex }: ChatHistory
387386

388387
if (entry.who === 'user') {
389388
return (
390-
// @ts-expect-error: TS2786
391389
<Message
392390
avatar={userAvatar}
393391
avatarProps={{ className: 'ols-plugin__avatar', isBordered: true }}
@@ -504,7 +502,7 @@ const GeneralPage: React.FC<GeneralPageProps> = ({
504502

505503
const chatHistoryEndRef = React.useRef<HTMLDivElement | null>(null);
506504

507-
const scrollIntoView = React.useCallback((behavior = 'smooth') => {
505+
const scrollIntoView = React.useCallback((behavior: ScrollBehavior = 'smooth') => {
508506
defer(() => {
509507
chatHistoryEndRef?.current?.scrollIntoView({ behavior });
510508
});
@@ -555,23 +553,18 @@ const GeneralPage: React.FC<GeneralPageProps> = ({
555553
}, [chatHistory, setCopied, setNotCopied]);
556554

557555
return (
558-
// @ts-expect-error: TS2786
559556
<Chatbot
560557
ariaLabel={ariaLabel}
561558
className={className}
562559
data-test="ols-plugin__popover"
563560
displayMode={onCollapse ? ChatbotDisplayMode.fullscreen : ChatbotDisplayMode.default}
564561
>
565-
{/* @ts-expect-error: TS2786 */}
566562
<ChatbotHeader>
567-
{/* @ts-expect-error: TS2786 */}
568563
<ChatbotHeaderMain>
569-
{/* @ts-expect-error: TS2786 */}
570564
<ChatbotHeaderTitle className="ols-plugin__header-title">
571565
<Title headingLevel="h1">{t('Red Hat OpenShift Lightspeed')}</Title>
572566
</ChatbotHeaderTitle>
573567
</ChatbotHeaderMain>
574-
{/* @ts-expect-error: TS2786 */}
575568
<ChatbotHeaderActions className="ols-plugin__header-actions">
576569
{chatHistory.size > 0 && (
577570
<>
@@ -629,9 +622,7 @@ const GeneralPage: React.FC<GeneralPageProps> = ({
629622
</ChatbotHeaderActions>
630623
</ChatbotHeader>
631624

632-
{/* @ts-expect-error: TS2786 */}
633625
<ChatbotContent aria-label={t('OpenShift Lightspeed chat history')}>
634-
{/* @ts-expect-error: TS2786 */}
635626
<MessageBox>
636627
<div className="ols-plugin__welcome-logo"></div>
637628
<Title className="ols-plugin__welcome-subheading" headingLevel="h5">
@@ -658,10 +649,8 @@ const GeneralPage: React.FC<GeneralPageProps> = ({
658649
</ChatbotContent>
659650

660651
{authStatus !== AuthStatus.NotAuthenticated && authStatus !== AuthStatus.NotAuthorized && (
661-
// @ts-expect-error: TS2786
662652
<ChatbotFooter>
663653
<Prompt scrollIntoView={scrollIntoView} />
664-
{/* @ts-expect-error: TS2786 */}
665654
<ChatbotFootnote label={t('Always review AI generated content prior to use.')} />
666655
<div className="ols-plugin__footnote">
667656
{t('For questions or feedback about OpenShift Lightspeed,')}{' '}

src/components/ImportAction.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as _ from 'lodash';
22
import * as React from 'react';
33
import { useTranslation } from 'react-i18next';
44
import { useDispatch } from 'react-redux';
5-
import { useLocation, useNavigate } from 'react-router-dom-v5-compat';
5+
import { useLocation, useNavigate } from 'react-router';
66
import { useActiveNamespace } from '@openshift-console/dynamic-plugin-sdk';
77
import { Button, ButtonVariant, Tooltip } from '@patternfly/react-core';
88
import { PlusCircleIcon } from '@patternfly/react-icons';

src/components/Prompt.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,6 @@ const Prompt: React.FC<PromptProps> = ({ scrollIntoView }) => {
757757

758758
return (
759759
<div>
760-
{/* @ts-expect-error: TS2786 */}
761760
<MessageBar
762761
additionalActions={
763762
isTroubleshooting ? (

src/components/ResponseToolModal.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,15 @@ const ToolModal: React.FC = () => {
9090
)}
9191
<p>
9292
{argsFormatted ? (
93-
<Trans>
93+
<Trans values={{ name, argsFormatted }}>
9494
The following output was generated when running{' '}
95-
<span className="ols-plugin__code-inline">{{ name }}</span> with arguments{' '}
96-
<span className="ols-plugin__code-inline">{{ argsFormatted }}</span>.
95+
<span className="ols-plugin__code-inline">{'{{name}}'}</span> with arguments{' '}
96+
<span className="ols-plugin__code-inline">{'{{argsFormatted}}'}</span>.
9797
</Trans>
9898
) : (
99-
<Trans>
99+
<Trans values={{ name }}>
100100
The following output was generated when running{' '}
101-
<span className="ols-plugin__code-inline">{{ name }}</span> with no arguments.
101+
<span className="ols-plugin__code-inline">{'{{name}}'}</span> with no arguments.
102102
</Trans>
103103
)}
104104
</p>

src/error.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TFunction } from 'react-i18next';
1+
import { TFunction } from 'i18next';
22

33
export type ErrorType = {
44
message?: string;

src/hooks/useLocationContext.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { useLocation } from 'react-router-dom-v5-compat';
2+
import { useLocation } from 'react-router';
33
import { useK8sModels } from '@openshift-console/dynamic-plugin-sdk';
44

55
export const useLocationContext = () => {
@@ -10,10 +10,17 @@ export const useLocationContext = () => {
1010
const location = useLocation();
1111
const path = location?.pathname;
1212

13-
const [models, inFlight] = useK8sModels();
13+
const [k8sModels, inFlight] = useK8sModels();
14+
15+
// Use a ref to avoid putting an unstable reference in the useEffect dependency array
16+
const modelsRef = React.useRef(k8sModels);
17+
React.useEffect(() => {
18+
modelsRef.current = k8sModels;
19+
});
1420

1521
React.useEffect(() => {
1622
if (path) {
23+
const models = modelsRef.current;
1724
const ns = `[a-z0-9-]+`;
1825
const resourceName = '[a-z0-9-.]+';
1926

@@ -150,7 +157,7 @@ export const useLocationContext = () => {
150157
setName(undefined);
151158
setNamespace(undefined);
152159
}
153-
}, [inFlight, location.search, models, path]);
160+
}, [inFlight, location.search, path]);
154161

155162
return [kind, name, namespace];
156163
};

src/hooks/useToolUIMapping.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import * as React from 'react';
22
import { useResolvedExtensions } from '@openshift-console/dynamic-plugin-sdk';
3-
import type {
4-
CodeRef,
5-
Extension,
6-
ExtensionDeclaration,
7-
} from '@openshift-console/dynamic-plugin-sdk/lib/types';
3+
import type { CodeRef, Extension } from '@openshift-console/dynamic-plugin-sdk/lib/types';
84
import type { OlsToolUIComponent } from '../types';
95

106
type ToolUIExtensionProperties = {
@@ -14,7 +10,7 @@ type ToolUIExtensionProperties = {
1410
component: CodeRef<OlsToolUIComponent>;
1511
};
1612

17-
type ToolUIExtension = ExtensionDeclaration<'ols.tool-ui', ToolUIExtensionProperties>;
13+
type ToolUIExtension = Extension<'ols.tool-ui', ToolUIExtensionProperties>;
1814

1915
const isToolUIExtension = (e: Extension): e is ToolUIExtension => e.type === 'ols.tool-ui';
2016

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"module": "esnext",
55
"moduleResolution": "node",
66
"target": "es2020",
7-
"jsx": "react",
7+
"jsx": "react-jsx",
88
"allowJs": true,
99
"strict": true,
1010
"noImplicitAny": false,

0 commit comments

Comments
 (0)