Skip to content

Commit 729b20f

Browse files
authored
fix(content-sidebar): fix typescript errors in boxai (#3974)
1 parent 8cf5e9f commit 729b20f

File tree

7 files changed

+10
-21
lines changed

7 files changed

+10
-21
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,11 @@
306306
"peerDependencies": {
307307
"@box/blueprint-web": "^7.36.3",
308308
"@box/blueprint-web-assets": "^4.33.0",
309-
"@box/box-ai-agent-selector": "^0.22.0",
310-
"@box/box-ai-content-answers": "^0.86.0",
309+
"@box/box-ai-agent-selector": "^0.26.4",
310+
"@box/box-ai-content-answers": "^0.95.0",
311311
"@box/cldr-data": ">=34.2.0",
312312
"@box/item-icon": "^0.9.58",
313-
"@box/metadata-editor": "^0.92.2",
313+
"@box/metadata-editor": "^0.92.3",
314314
"@box/react-virtualized": "9.22.3-rc-box.9",
315315
"@hapi/address": "^2.1.4",
316316
"axios": "^0.25.0",

src/elements/common/content-answers/ContentAnswersModal.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { useState, useCallback } from 'react';
22
import { useIntl } from 'react-intl';
33
import getProp from 'lodash/get';
4+
import noop from 'lodash/noop';
45
import { AxiosResponse } from 'axios';
56

67
import {
@@ -11,15 +12,15 @@ import {
1112
SuggestedQuestionType,
1213
} from '@box/box-ai-content-answers';
1314

15+
import { withAPIContext } from '../api-context';
1416
import { DOCUMENT_SUGGESTED_QUESTIONS, SPREADSHEET_FILE_EXTENSIONS } from './constants';
15-
import withCurrentUser from '../current-user';
1617

17-
// @ts-ignore: no ts definition
18-
import { BoxItem, User } from '../../../common/types/core';
1918
// @ts-ignore: no ts definition
2019
import APIFactory from '../../../api';
2120
// @ts-ignore: no ts definition
2221
import { ElementsXhrError } from '../../common/types/api';
22+
// @ts-ignore: no ts definition
23+
import { BoxItem } from '../../../common/types/core';
2324

2425
import messages from './messages';
2526

@@ -35,7 +36,6 @@ export interface ExternalProps {
3536

3637
export interface ContentAnswersModalProps extends ExternalProps {
3738
api: APIFactory;
38-
currentUser?: User;
3939
file: BoxItem;
4040
isOpen: boolean;
4141
}
@@ -182,7 +182,7 @@ const ContentAnswersModal = ({
182182
open={isOpen}
183183
questions={questions}
184184
retryQuestion={handleRetry}
185-
setAnswerFeedback={undefined}
185+
setAnswerFeedback={noop}
186186
submitQuestion={handleAsk}
187187
suggestedQuestions={suggestedQuestions || localizedQuestions}
188188
warningNotice={spreadsheetNotice}
@@ -191,4 +191,4 @@ const ContentAnswersModal = ({
191191
);
192192
};
193193

194-
export default withCurrentUser(ContentAnswersModal);
194+
export default withAPIContext(ContentAnswersModal);

src/elements/content-sidebar/BoxAISidebar.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import * as React from 'react';
66
import { useIntl } from 'react-intl';
77
import { type ItemType } from '@box/box-ai-content-answers';
8-
import { AgentsProvider , RecordActionType } from '@box/box-ai-agent-selector';
8+
import { AgentsProvider, RecordActionType } from '@box/box-ai-agent-selector';
99
import BoxAISidebarContent from './BoxAISidebarContent';
1010
import { BoxAISidebarContext } from './context/BoxAISidebarContext';
1111
import { SPREADSHEET_FILE_EXTENSIONS } from '../common/content-answers/constants';
@@ -53,7 +53,6 @@ export interface BoxAISidebarProps {
5353
localizedQuestions: Array<{ id: string; label: string; prompt: string }>;
5454
recordAction: (params: RecordActionType) => void;
5555
setCacheValue: BoxAISidebarCacheSetter;
56-
userInfo: { name: string; avatarURL: string };
5756
}
5857

5958
const BoxAISidebar = (props: BoxAISidebarProps) => {
@@ -72,7 +71,6 @@ const BoxAISidebar = (props: BoxAISidebarProps) => {
7271
localizedQuestions,
7372
recordAction,
7473
setCacheValue,
75-
userInfo,
7674
...rest
7775
} = props;
7876
const { questions } = cache;
@@ -89,7 +87,6 @@ const BoxAISidebar = (props: BoxAISidebarProps) => {
8987
itemSize,
9088
setCacheValue,
9189
recordAction,
92-
userInfo,
9390
}),
9491
[
9592
cache,
@@ -102,7 +99,6 @@ const BoxAISidebar = (props: BoxAISidebarProps) => {
10299
itemSize,
103100
setCacheValue,
104101
recordAction,
105-
userInfo,
106102
],
107103
);
108104

src/elements/content-sidebar/BoxAISidebarContent.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ function BoxAISidebarContent(props: ApiWrapperProps) {
6363
itemSize,
6464
recordAction,
6565
setCacheValue,
66-
userInfo,
6766
} = React.useContext(BoxAISidebarContext);
6867
const { agents, requestState, selectedAgent } = useAgents();
6968
const { questions: cacheQuestions } = cache;
@@ -176,7 +175,6 @@ function BoxAISidebarContent(props: ApiWrapperProps) {
176175
questions={questions}
177176
stopQuestion={stopQuestion}
178177
submitQuestion={sendQuestion}
179-
userInfo={userInfo}
180178
variant="sidebar"
181179
recordAction={recordAction}
182180
{...rest}
@@ -205,7 +203,6 @@ function BoxAISidebarContent(props: ApiWrapperProps) {
205203
stopPropagationOnEsc
206204
stopQuestion={stopQuestion}
207205
submitQuestion={sendQuestion}
208-
userInfo={userInfo}
209206
variant="collapsible"
210207
{...rest}
211208
shouldRenderProviders={false}

src/elements/content-sidebar/SidebarPanels.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,6 @@ class SidebarPanels extends React.Component<Props, State> {
278278
hasSidebarInitialized={isInitialized}
279279
ref={this.boxAISidebar}
280280
startMarkName={MARK_NAME_JS_LOADING_BOXAI}
281-
userInfo={{ name: currentUser?.name, avatarURL: currentUser?.avatar_url }}
282281
cache={this.boxAiSidebarCache}
283282
setCacheValue={this.setBoxAiSidebarCacheValue}
284283
{...boxAISidebarProps}

src/elements/content-sidebar/__tests__/BoxAISidebar.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ describe('elements/content-sidebar/BoxAISidebar', () => {
105105
isResetChatEnabled: true,
106106
isStopResponseEnabled: true,
107107
isStreamingEnabled: true,
108-
userInfo: { name: 'Test', avatarUrl: undefined },
109108
recordAction: jest.fn(),
110109
setCacheValue: jest.fn(),
111110
} as unknown as BoxAISidebarProps;

src/elements/content-sidebar/context/BoxAISidebarContext.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export interface BoxAISidebarContextValues {
2525
itemSize?: string;
2626
recordAction: (params: BoxAISidebarRecordActionType) => void;
2727
setCacheValue: BoxAISidebarCacheSetter;
28-
userInfo: { name: string; avatarURL: string };
2928
}
3029

3130
export const BoxAISidebarContext = React.createContext<BoxAISidebarContextValues>({
@@ -38,5 +37,4 @@ export const BoxAISidebarContext = React.createContext<BoxAISidebarContextValues
3837
items: [],
3938
recordAction: noop,
4039
setCacheValue: noop,
41-
userInfo: { name: '', avatarURL: '' },
4240
});

0 commit comments

Comments
 (0)