Skip to content

Commit 611377c

Browse files
DanilaRubleuskiDanila Rubleuskigreg-in-a-boxkkuliczkowski-boxmergify[bot]
authored
feat(boxai-sidebar): Empty Sidebar for Box AI (#3668)
* feat(boxai-sidebar): PR fixes and Storybook test added * feat(boxai-sidebar): Empty Sidebar for Box AI * feat(boxai-sidebar): BoxAISidebar.tsx deleted * feat(boxai-sidebar): SidebarPanels.test.js test fixed * feat(boxai-sidebar): PR fixes * feat(boxai-sidebar): PR fixes * feat(boxai-sidebar): Storybook test fixes * feat(boxai-sidebar): Fixed UT * chore(i18n): translations * Resolved issue with flow check * feat(boxai-sidebar): flow check fixes * chore(boxai-sidebar): BoxAISidebar.stories.tsx small fix * chore(boxai-sidebar): PR fixes * chore(boxai-sidebar): PR fixes --------- Co-authored-by: Danila Rubleuski <drubleuski@box.com> Co-authored-by: Greg Wong <gregorywong@box.com> Co-authored-by: kkuliczkowski <kkuliczkowski@box.com> Co-authored-by: greg-in-a-box <103291617+greg-in-a-box@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 47ba331 commit 611377c

21 files changed

+316
-14
lines changed

i18n/en-US.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,8 @@ be.shareDialogText = Shared Link:
646646
be.sidebarAccessStats = Access Stats
647647
# Title for the preview activity feed.
648648
be.sidebarActivityTitle = Activity
649+
# Title for the preview Box AI feed.
650+
be.sidebarBoxAITitle = Box AI
649651
# Title for the sidebar content insights.
650652
be.sidebarContentInsights = Content Insights
651653
# Title for the preview details sidebar.

src/constants.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ export const ERROR_CODE_UNKNOWN = 'unknown_error';
319319
export const ORIGIN_CONTENT_PREVIEW: 'content_preview' = 'content_preview';
320320
export const ORIGIN_CONTENT_SIDEBAR: 'content_sidebar' = 'content_sidebar';
321321
export const ORIGIN_ACTIVITY_SIDEBAR: 'activity_sidebar' = 'activity_sidebar';
322+
export const ORIGIN_BOXAI_SIDEBAR: 'boxai_sidebar' = 'boxai_sidebar';
322323
export const ORIGIN_DETAILS_SIDEBAR: 'details_sidebar' = 'details_sidebar';
323324
export const ORIGIN_DOCGEN_SIDEBAR: 'docgen_sidebar' = 'docgen_sidebar';
324325
export const ORIGIN_METADATA_SIDEBAR: 'metadata_sidebar' = 'metadata_sidebar';
@@ -405,6 +406,7 @@ export const SIDEBAR_VIEW_SKILLS: 'skills' = 'skills';
405406
export const SIDEBAR_VIEW_DETAILS: 'details' = 'details';
406407
export const SIDEBAR_VIEW_METADATA: 'metadata' = 'metadata';
407408
export const SIDEBAR_VIEW_METADATA_REDESIGN: 'metadata_redesign' = 'metadata_redesign';
409+
export const SIDEBAR_VIEW_BOXAI: 'boxai' = 'boxai';
408410
export const SIDEBAR_VIEW_ACTIVITY: 'activity' = 'activity';
409411
export const SIDEBAR_VIEW_VERSIONS: 'versions' = 'versions';
410412
export const SIDEBAR_VIEW_DOCGEN: 'docgen' = 'docgen';

src/elements/common/flowTypes.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
ORIGIN_PREVIEW,
88
ORIGIN_CONTENT_PREVIEW,
99
ORIGIN_DETAILS_SIDEBAR,
10+
ORIGIN_BOXAI_SIDEBAR,
1011
ORIGIN_ACTIVITY_SIDEBAR,
1112
ORIGIN_SKILLS_SIDEBAR,
1213
ORIGIN_METADATA_SIDEBAR,
@@ -42,6 +43,7 @@ type ElementOrigin =
4243
| typeof ORIGIN_CONTENT_PREVIEW
4344
| typeof ORIGIN_PREVIEW
4445
| typeof ORIGIN_DETAILS_SIDEBAR
46+
| typeof ORIGIN_BOXAI_SIDEBAR
4547
| typeof ORIGIN_ACTIVITY_SIDEBAR
4648
| typeof ORIGIN_SKILLS_SIDEBAR
4749
| typeof ORIGIN_METADATA_SIDEBAR

src/elements/common/interactionTargets.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// @flow strict
22
export const SIDEBAR_NAV_TARGETS = {
3+
BOXAI: 'sidebarboxai',
34
ACTIVITY: 'sidebaractivity',
45
DETAILS: 'sidebardetails',
56
SIGN: 'sidebarsign',

src/elements/common/messages.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,11 @@ const messages = defineMessages({
452452
description: 'Generic error content for skills editing.',
453453
defaultMessage: 'An error has occurred while updating skills. Please refresh the page and try again.',
454454
},
455+
sidebarBoxAITitle: {
456+
id: 'be.sidebarBoxAITitle',
457+
description: 'Title for the preview Box AI feed.',
458+
defaultMessage: 'Box AI',
459+
},
455460
sidebarActivityTitle: {
456461
id: 'be.sidebarActivityTitle',
457462
description: 'Title for the preview activity feed.',
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Flowtype definitions for BoxAISidebar.tsx
3+
* Generated by Flowgen from a Typescript Definition
4+
* Flowgen v1.21.0
5+
*/
6+
7+
import * as React from "react";
8+
import flow from "lodash/flow";
9+
import { useIntl } from "react-intl";
10+
import SidebarContent from "./SidebarContent";
11+
import { withAPIContext } from "../common/api-context";
12+
import { withErrorBoundary } from "../common/error-boundary";
13+
import { withLogger } from "../common/logger";
14+
import { ORIGIN_BOXAI_SIDEBAR, SIDEBAR_VIEW_BOXAI } from "../../constants";
15+
import { EVENT_JS_READY } from "../common/logger/constants";
16+
import { mark } from "../../utils/performance";
17+
import messages from "../common/messages";
18+
declare var MARK_NAME_JS_READY: string;
19+
export interface BoxAISidebarProps {
20+
onExpandPressed: () => void;
21+
}
22+
declare function BoxAISidebar(): void;
23+
declare export { BoxAISidebar as BoxAISidebarComponent };
24+
declare var BoxAISidebarDefaultExport: typeof withAPIContext;
25+
declare export default typeof BoxAISidebarDefaultExport;
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* @file Redesigned Metadata sidebar component
3+
* @author Box
4+
*/
5+
import * as React from 'react';
6+
import flow from 'lodash/flow';
7+
import { useIntl } from 'react-intl';
8+
9+
import SidebarContent from './SidebarContent';
10+
import { withAPIContext } from '../common/api-context';
11+
import { withErrorBoundary } from '../common/error-boundary';
12+
import { withLogger } from '../common/logger';
13+
import { ORIGIN_BOXAI_SIDEBAR, SIDEBAR_VIEW_BOXAI } from '../../constants';
14+
import { EVENT_JS_READY } from '../common/logger/constants';
15+
import { mark } from '../../utils/performance';
16+
17+
import messages from '../common/messages';
18+
19+
const MARK_NAME_JS_READY: string = `${ORIGIN_BOXAI_SIDEBAR}_${EVENT_JS_READY}`;
20+
21+
mark(MARK_NAME_JS_READY);
22+
23+
export interface BoxAISidebarProps {
24+
onExpandPressed: () => void;
25+
}
26+
27+
function BoxAISidebar() {
28+
const { formatMessage } = useIntl();
29+
30+
return (
31+
<SidebarContent
32+
className={'bcs-BoxAISidebar'}
33+
sidebarView={SIDEBAR_VIEW_BOXAI}
34+
title={formatMessage(messages.sidebarBoxAITitle)}
35+
>
36+
<div className="bcs-BoxAISidebar-content" />
37+
</SidebarContent>
38+
);
39+
}
40+
41+
export { BoxAISidebar as BoxAISidebarComponent };
42+
43+
const BoxAISidebarDefaultExport: typeof withAPIContext = flow([
44+
withLogger(ORIGIN_BOXAI_SIDEBAR),
45+
withErrorBoundary(ORIGIN_BOXAI_SIDEBAR),
46+
withAPIContext,
47+
])(BoxAISidebar);
48+
49+
export default BoxAISidebarDefaultExport;

src/elements/content-sidebar/ContentSidebar.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
import { withLogger } from '../common/logger';
3030

3131
import type { ActivitySidebarProps } from './ActivitySidebar';
32+
import type { BoxAISidebarProps } from './BoxAISidebar';
3233
import type { DetailsSidebarProps } from './DetailsSidebar';
3334
import type { DocGenSidebarProps } from './DocGenSidebar/DocGenSidebar';
3435
import type { MetadataSidebarProps } from './MetadataSidebar';
@@ -50,6 +51,7 @@ type Props = {
5051
activitySidebarProps: ActivitySidebarProps,
5152
additionalTabs?: Array<AdditionalSidebarTab>,
5253
apiHost: string,
54+
boxAISidebarProps: BoxAISidebarProps,
5355
cache?: APICache,
5456
className: string,
5557
clientName: string,
@@ -107,6 +109,7 @@ class ContentSidebar extends React.Component<Props, State> {
107109
static defaultProps = {
108110
activitySidebarProps: {},
109111
apiHost: DEFAULT_HOSTNAME_API,
112+
boxAISidebarProps: {},
110113
className: '',
111114
clientName: CLIENT_NAME_CONTENT_SIDEBAR,
112115
defaultView: '',
@@ -333,6 +336,7 @@ class ContentSidebar extends React.Component<Props, State> {
333336
const {
334337
activitySidebarProps,
335338
additionalTabs,
339+
boxAISidebarProps,
336340
className,
337341
currentUser,
338342
defaultView,
@@ -372,6 +376,7 @@ class ContentSidebar extends React.Component<Props, State> {
372376
<Sidebar
373377
activitySidebarProps={activitySidebarProps}
374378
additionalTabs={additionalTabs}
379+
boxAISidebarProps={boxAISidebarProps}
375380
className={className}
376381
currentUser={currentUser}
377382
detailsSidebarProps={detailsSidebarProps}

src/elements/content-sidebar/Sidebar.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import type { ActivitySidebarProps } from './ActivitySidebar';
2424
import type { DetailsSidebarProps } from './DetailsSidebar';
2525
import type { DocGenSidebarProps } from './DocGenSidebar/DocGenSidebar';
2626
import type { MetadataSidebarProps } from './MetadataSidebar';
27+
import type { BoxAISidebarProps } from './BoxAISidebar';
2728
import type { VersionsSidebarProps } from './versions';
2829
import type { AdditionalSidebarTab } from './flowTypes';
2930
import type { MetadataEditor } from '../../common/types/metadata';
@@ -36,6 +37,7 @@ type Props = {
3637
activitySidebarProps: ActivitySidebarProps,
3738
additionalTabs?: Array<AdditionalSidebarTab>,
3839
api: API,
40+
boxAISidebarProps: BoxAISidebarProps,
3941
className: string,
4042
currentUser?: User,
4143
currentUserError?: Errors,
@@ -247,6 +249,7 @@ class Sidebar extends React.Component<Props, State> {
247249
const {
248250
activitySidebarProps,
249251
additionalTabs,
252+
boxAISidebarProps,
250253
className,
251254
currentUser,
252255
currentUserError,
@@ -268,6 +271,7 @@ class Sidebar extends React.Component<Props, State> {
268271
versionsSidebarProps,
269272
}: Props = this.props;
270273
const isOpen = this.isForcedSet() ? this.isForcedOpen() : !!isDefaultOpen;
274+
const hasBoxAI = SidebarUtils.canHaveBoxAISidebar(this.props);
271275
const hasActivity = SidebarUtils.canHaveActivitySidebar(this.props);
272276
const hasDetails = SidebarUtils.canHaveDetailsSidebar(this.props);
273277
const hasMetadata = SidebarUtils.shouldRenderMetadataSidebar(this.props, metadataEditors);
@@ -292,6 +296,7 @@ class Sidebar extends React.Component<Props, State> {
292296
fileId={fileId}
293297
hasActivity={hasActivity}
294298
hasAdditionalTabs={hasAdditionalTabs}
299+
hasBoxAI={hasBoxAI}
295300
hasDetails={hasDetails}
296301
hasMetadata={hasMetadata}
297302
hasSkills={hasSkills}
@@ -301,6 +306,7 @@ class Sidebar extends React.Component<Props, State> {
301306
)}
302307
<SidebarPanels
303308
activitySidebarProps={activitySidebarProps}
309+
boxAISidebarProps={boxAISidebarProps}
304310
currentUser={currentUser}
305311
currentUserError={currentUserError}
306312
elementId={this.id}
@@ -311,6 +317,7 @@ class Sidebar extends React.Component<Props, State> {
311317
getPreview={getPreview}
312318
getViewer={getViewer}
313319
hasActivity={hasActivity}
320+
hasBoxAI={hasBoxAI}
314321
hasDetails={hasDetails}
315322
hasDocGen={docGenSidebarProps.isDocGenTemplate}
316323
hasMetadata={hasMetadata}

src/elements/content-sidebar/SidebarNav.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import * as React from 'react';
88
import { injectIntl } from 'react-intl';
99
import type { IntlShape } from 'react-intl';
10+
import { BoxAiLogo } from '@box/blueprint-web-assets/icons/Logo';
11+
import { Size5 } from '@box/blueprint-web-assets/tokens/tokens';
1012
import AdditionalTabs from './additional-tabs';
1113
import DocGenIcon from '../../icon/fill/DocGenIcon';
1214
import IconChatRound from '../../icons/general/IconChatRound';
@@ -20,9 +22,10 @@ import SidebarToggle from './SidebarToggle';
2022
import messages from '../common/messages';
2123
import { SIDEBAR_NAV_TARGETS } from '../common/interactionTargets';
2224
import {
23-
SIDEBAR_VIEW_DOCGEN,
2425
SIDEBAR_VIEW_ACTIVITY,
26+
SIDEBAR_VIEW_BOXAI,
2527
SIDEBAR_VIEW_DETAILS,
28+
SIDEBAR_VIEW_DOCGEN,
2629
SIDEBAR_VIEW_METADATA,
2730
SIDEBAR_VIEW_SKILLS,
2831
} from '../../constants';
@@ -36,6 +39,7 @@ type Props = {
3639
fileId: string,
3740
hasActivity: boolean,
3841
hasAdditionalTabs: boolean,
42+
hasBoxAI: boolean,
3943
hasDetails: boolean,
4044
hasDocGen?: boolean,
4145
hasMetadata: boolean,
@@ -51,6 +55,7 @@ const SidebarNav = ({
5155
fileId,
5256
hasActivity,
5357
hasAdditionalTabs,
58+
hasBoxAI,
5459
hasDetails,
5560
hasMetadata,
5661
hasSkills,
@@ -65,6 +70,16 @@ const SidebarNav = ({
6570
<div className="bcs-SidebarNav" aria-label={intl.formatMessage(messages.sidebarNavLabel)}>
6671
<div className="bcs-SidebarNav-tabs">
6772
<SidebarNavTablist elementId={elementId} isOpen={isOpen} onNavigate={onNavigate}>
73+
{hasBoxAI && (
74+
<SidebarNavButton
75+
data-resin-target={SIDEBAR_NAV_TARGETS.BOXAI}
76+
data-testid="sidebarboxai"
77+
sidebarView={SIDEBAR_VIEW_BOXAI}
78+
tooltip={intl.formatMessage(messages.sidebarBoxAITitle)}
79+
>
80+
<BoxAiLogo height={Size5} width={Size5} />
81+
</SidebarNavButton>
82+
)}
6883
{hasActivity && (
6984
<SidebarNavButton
7085
data-resin-target={SIDEBAR_NAV_TARGETS.ACTIVITY}

0 commit comments

Comments
 (0)