Skip to content
Draft
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
14 changes: 12 additions & 2 deletions src/elements/content-sidebar/SidebarNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,21 @@ const SidebarNav = ({
onPanelChange = noop,
}: Props) => {
const { enabled: hasBoxSign } = useFeatureConfig('boxSign');
const { disabledTooltip: boxAIDisabledTooltip, showOnlyNavButton: showOnlyBoxAINavButton } =
useFeatureConfig('boxai.sidebar');
const {
disabledTooltip: boxAIDisabledTooltip,
showOnlyNavButton: showOnlyBoxAINavButton,
useBoxAISidebarPrompt = () => ({}),
} = useFeatureConfig('boxai.sidebar');

const { focusBoxAISidebarPrompt = noop } = useBoxAISidebarPrompt();

const handleSidebarNavButtonClick = (sidebarview: string) => {
onPanelChange(sidebarview, false);

// If the Box AI sidebar is enabled, focus the Box AI sidebar prompt
if (sidebarview === SIDEBAR_VIEW_BOXAI) {
focusBoxAISidebarPrompt();
}
};

return (
Expand Down
25 changes: 25 additions & 0 deletions src/elements/content-sidebar/__tests__/SidebarNav.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,31 @@ describe('elements/content-sidebar/SidebarNav', () => {
});
});

test('should call focusBoxAISidebarPrompt when clicked on Box AI Tab', async () => {
const mockFocusBoxAISidebarPrompt = jest.fn();
const mockUseBoxAISidebarPrompt = () => ({ focusBoxAISidebarPrompt: mockFocusBoxAISidebarPrompt });

render(
getSidebarNav({
features: {
boxai: {
sidebar: {
showOnlyNavButton: false,
useBoxAISidebarPrompt: mockUseBoxAISidebarPrompt,
},
},
},
props: { hasBoxAI: true },
}),
);

const button = screen.getByTestId('sidebarboxai');

await userEvent.click(button);

expect(mockFocusBoxAISidebarPrompt).toHaveBeenCalled();
});

test('should have multiple tabs', () => {
const props = {
hasActivity: true,
Expand Down