Skip to content

Commit e20c430

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 fd2ff54 commit e20c430

10 files changed

Lines changed: 322 additions & 1295 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
@@ -22,22 +22,23 @@
2222
"test:unit": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' node -r ts-node/register --test 'unit-tests/**/*.test.ts'"
2323
},
2424
"dependencies": {
25-
"@openshift-console/dynamic-plugin-sdk": "4.19.1",
26-
"@openshift-console/dynamic-plugin-sdk-webpack": "4.19.0",
25+
"@openshift-console/dynamic-plugin-sdk": "4.22.0-prerelease.2",
26+
"@openshift-console/dynamic-plugin-sdk-webpack": "4.22.0-prerelease.2",
2727
"@patternfly/chatbot": "6.6.0-prerelease.6",
2828
"@patternfly/react-code-editor": "6.4.1",
2929
"@patternfly/react-core": "6.4.1",
3030
"@patternfly/react-icons": "6.4.0",
3131
"copy-webpack-plugin": "^14.0.0",
3232
"css-loader": "^7.1.4",
33+
"i18next": "^26.0.4",
3334
"js-yaml": "^4.1.1",
3435
"lodash": "^4.18.1",
35-
"react": "17.0.2",
36-
"react-dom": "17.0.2",
37-
"react-i18next": "11.18.6",
36+
"react": "18.3.1",
37+
"react-dom": "18.3.1",
38+
"react-i18next": "16.5.8",
3839
"react-modal": "^3.16.3",
39-
"react-redux": "7.2.9",
40-
"react-router-dom-v5-compat": "^6.30.3",
40+
"react-redux": "9.2.0",
41+
"react-router": "7.13.1",
4142
"style-loader": "^4.0.0",
4243
"ts-loader": "^9.5.7",
4344
"ts-node": "^10.9.2",
@@ -48,7 +49,7 @@
4849
"devDependencies": {
4950
"@cypress/grep": "^6.0.0",
5051
"@types/node": "^22.19.15",
51-
"@types/react": "^17.0.91",
52+
"@types/react": "^18.3.27",
5253
"@typescript-eslint/eslint-plugin": "^8.58.0",
5354
"@typescript-eslint/parser": "^8.58.0",
5455
"cypress": "^15.13.0",
@@ -67,9 +68,7 @@
6768
"webpack-dev-server": "^5.2.3"
6869
},
6970
"overrides": {
70-
"monaco-editor": "0.55.1",
71-
"react": "17.0.2",
72-
"react-dom": "17.0.2"
71+
"monaco-editor": "0.55.1"
7372
},
7473
"consolePlugin": {
7574
"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: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,27 +96,27 @@ const ToolModal: React.FC = () => {
9696
<p>
9797
{isDenied ? (
9898
argsFormatted ? (
99-
<Trans>
100-
The tool <span className="ols-plugin__code-inline">{{ name }}</span> was requested
101-
with arguments <span className="ols-plugin__code-inline">{{ argsFormatted }}</span>{' '}
99+
<Trans values={{ name, argsFormatted }}>
100+
The tool <span className="ols-plugin__code-inline">{'{{name}}'}</span> was requested
101+
with arguments <span className="ols-plugin__code-inline">{'{{argsFormatted}}'}</span>{' '}
102102
but was rejected.
103103
</Trans>
104104
) : (
105-
<Trans>
106-
The tool <span className="ols-plugin__code-inline">{{ name }}</span> was requested
105+
<Trans values={{ name }}>
106+
The tool <span className="ols-plugin__code-inline">{'{{name}}'}</span> was requested
107107
with no arguments but was rejected.
108108
</Trans>
109109
)
110110
) : argsFormatted ? (
111-
<Trans>
111+
<Trans values={{ name, argsFormatted }}>
112112
The following output was generated when running{' '}
113-
<span className="ols-plugin__code-inline">{{ name }}</span> with arguments{' '}
114-
<span className="ols-plugin__code-inline">{{ argsFormatted }}</span>.
113+
<span className="ols-plugin__code-inline">{'{{name}}'}</span> with arguments{' '}
114+
<span className="ols-plugin__code-inline">{'{{argsFormatted}}'}</span>.
115115
</Trans>
116116
) : (
117-
<Trans>
117+
<Trans values={{ name }}>
118118
The following output was generated when running{' '}
119-
<span className="ols-plugin__code-inline">{{ name }}</span> with no arguments.
119+
<span className="ols-plugin__code-inline">{'{{name}}'}</span> with no arguments.
120120
</Trans>
121121
)}
122122
</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)