Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(boxai-sidebar): Add logic to render sidebar from function #4011

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/elements/content-sidebar/BoxAISidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface BoxAISidebarProps {
itemSize?: string;
localizedQuestions: Array<{ id: string; label: string; prompt: string }>;
recordAction: (params: RecordActionType) => void;
renderBoxAISidebar?: (elementId: string) => React.ReactNode;
setCacheValue: BoxAISidebarCacheSetter;
shouldPreinitSession?: boolean;
setHasQuestions: (hasQuestions: boolean) => void;
Expand All @@ -72,6 +73,7 @@ const BoxAISidebar = (props: BoxAISidebarProps) => {
itemSize,
localizedQuestions,
recordAction,
renderBoxAISidebar,
setCacheValue,
shouldPreinitSession = true,
setHasQuestions,
Expand Down Expand Up @@ -114,6 +116,10 @@ const BoxAISidebar = (props: BoxAISidebarProps) => {
}
}, [questions.length, setHasQuestions]);

if (renderBoxAISidebar) {
return <>{renderBoxAISidebar(elementId)}</>;
}

let questionsWithoutInProgress = questions;
if (questions.length > 0 && !questions[questions.length - 1].isCompleted) {
// pass only fully completed questions to not show loading indicator of question where we canceled API request
Expand Down
3 changes: 3 additions & 0 deletions src/elements/content-sidebar/ContentSidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ type Props = {
onPanelChange?: (name: string, isInitialState: boolean) => void,
onVersionChange?: Function,
onVersionHistoryClick?: Function,
renderBoxAISidebar?: Function,
requestInterceptor?: Function,
responseInterceptor?: Function,
sharedLink?: string,
Expand Down Expand Up @@ -368,6 +369,7 @@ class ContentSidebar extends React.Component<Props, State> {
onPanelChange,
onVersionChange,
onVersionHistoryClick,
renderBoxAISidebar,
signSidebarProps,
theme,
versionsSidebarProps,
Expand Down Expand Up @@ -410,6 +412,7 @@ class ContentSidebar extends React.Component<Props, State> {
onOpenChange={onOpenChange}
onPanelChange={onPanelChange}
onVersionChange={onVersionChange}
renderBoxAISidebar={renderBoxAISidebar}
onVersionHistoryClick={onVersionHistoryClick}
signSidebarProps={signSidebarProps}
theme={theme}
Expand Down
3 changes: 3 additions & 0 deletions src/elements/content-sidebar/SidebarPanels.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ type Props = {
onPanelChange?: (name: string, isInitialState?: boolean) => void,
onVersionChange?: Function,
onVersionHistoryClick?: Function,
renderBoxAISidebar?: Function,
versionsSidebarProps: VersionsSidebarProps,
};

Expand Down Expand Up @@ -234,6 +235,7 @@ class SidebarPanels extends React.Component<Props, State> {
onAnnotationSelect,
onVersionChange,
onVersionHistoryClick,
renderBoxAISidebar,
versionsSidebarProps,
}: Props = this.props;

Expand Down Expand Up @@ -280,6 +282,7 @@ class SidebarPanels extends React.Component<Props, State> {
startMarkName={MARK_NAME_JS_LOADING_BOXAI}
cache={this.boxAiSidebarCache}
setCacheValue={this.setBoxAiSidebarCacheValue}
renderBoxAISidebar={renderBoxAISidebar}
{...boxAISidebarProps}
/>
);
Expand Down