Skip to content

Commit

Permalink
feat(boxai-sidebar): SidebarPanels.test.js test fixed and feature fla…
Browse files Browse the repository at this point in the history
…g check added
  • Loading branch information
DanilaRubleuski committed Sep 24, 2024
1 parent 4e22d57 commit 5948f9b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions i18n/en-US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,8 @@ be.shareDialogText = Shared Link:
be.sidebarAccessStats = Access Stats
# Title for the preview activity feed.
be.sidebarActivityTitle = Activity
# Title for the preview Box AI feed.
be.sidebarBoxAITitle = Box AI
# Title for the sidebar content insights.
be.sidebarContentInsights = Content Insights
# Title for the preview details sidebar.
Expand Down
3 changes: 1 addition & 2 deletions src/elements/content-sidebar/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import type { ActivitySidebarProps } from './ActivitySidebar';
import type { DetailsSidebarProps } from './DetailsSidebar';
import type { DocGenSidebarProps } from './DocGenSidebar/DocGenSidebar';
import type { MetadataSidebarProps } from './MetadataSidebar';
import type { BoxAISidebarProps } from './BoxAISidebarProps';
import type { BoxAISidebarProps } from './BoxAISidebar';
import type { VersionsSidebarProps } from './versions';
import type { AdditionalSidebarTab } from './flowTypes';
import type { MetadataEditor } from '../../common/types/metadata';
Expand All @@ -47,7 +47,6 @@ type Props = {
fileId: string,
getPreview: Function,
getViewer: Function,
hasBoxAI: boolean,
hasActivityFeed: boolean,
hasAdditionalTabs: boolean,
hasMetadata: boolean,
Expand Down
4 changes: 3 additions & 1 deletion src/elements/content-sidebar/SidebarUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
import type { MetadataSidebarProps } from './MetadataSidebar';
import type { MetadataEditor } from '../../common/types/metadata';
import type { BoxItem } from '../../common/types/core';
import { isFeatureEnabled } from '../common/feature-checking';

class SidebarUtils {
/**
Expand Down Expand Up @@ -57,7 +58,7 @@ class SidebarUtils {
* @return {Boolean} true if we should render
*/
static canHaveBoxAISidebar(props: ContentSidebarProps): boolean {
return !!props.hasBoxAI;
return isFeatureEnabled(props.features, 'boxai.sidebar.enabled');
}

/**
Expand Down Expand Up @@ -123,6 +124,7 @@ class SidebarUtils {
*/
static shouldRenderMetadataSidebar(props: ContentSidebarProps, editors?: Array<MetadataEditor>): boolean {
const { metadataSidebarProps = {} }: ContentSidebarProps = props;
// eslint-disable-next-line no-shadow
const { isFeatureEnabled = true }: MetadataSidebarProps = metadataSidebarProps;

return (
Expand Down
4 changes: 2 additions & 2 deletions src/elements/content-sidebar/__tests__/SidebarPanels.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ describe('elements/content-sidebar/SidebarPanels', () => {
${'/metadata'} | ${'MetadataSidebar'}
${'/skills'} | ${'SkillsSidebar'}
${'/boxai'} | ${'BoxAISidebar'}
${'/nonsense'} | ${'SkillsSidebar'}
${'/'} | ${'SkillsSidebar'}
${'/nonsense'} | ${'BoxAISidebar'}
${'/'} | ${'BoxAISidebar'}
`('should render $sidebar given the path $path', ({ path, sidebar }) => {
const wrapper = getWrapper({ path });
expect(wrapper.exists(sidebar)).toBe(true);
Expand Down

0 comments on commit 5948f9b

Please sign in to comment.