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(content-sidebar): Option to render Box AI nav button disabled #3831

Conversation

kkuliczkowski-box
Copy link
Contributor

Description

Added option to display disabled tab nav item (button) without the corresponding sidebar.

This is used for Box AI Sidebar when the file is not compatible with AI features or there are permissions issues. In that case we want to not render Box AI Sidebar, however we still want to display the tab nav button with a proper tooltip.

This is controlled with boxai.sidebar feature.

Screenshots

image

@kkuliczkowski-box kkuliczkowski-box requested review from a team as code owners January 8, 2025 14:30
marcoartaviaq
marcoartaviaq previously approved these changes Jan 8, 2025
Comment on lines 90 to 94
tooltip={
(showOnlyBoxAINavButton && boxAIDisabledTooltip) ||
intl.formatMessage(messages.sidebarBoxAITitle)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can boxAIDisabledTooltip be falsy? if not, can we just use a tenary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, boxAIDisabledTooltip will be null if there is no tooltip to display.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the tooltip only available when showOnlyBoxAINavButton is true ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is the current assumption. I've simplified it to ternary expression.
showOnlyBoxAINavButton ? boxAIDisabledTooltip : intl.formatMessage(messages.sidebarBoxAITitle)

src/elements/content-sidebar/__tests__/SidebarNav.test.js Outdated Show resolved Hide resolved
@@ -87,6 +98,57 @@ describe('elements/content-sidebar/SidebarNav', () => {
expect(wrapper.find(IconChatRound)).toHaveLength(0);
});

describe('should render box ai tab with correct disabled state and tooltip', () => {
const defaultTooltip = messages.sidebarBoxAITitle.defaultMessage;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should hardcode the expected message instead of referencing the base message so that in case that someone accidentally changes the message itself, this test should break

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that we intentionally use imported messages, so that the tests will not fail when the text changes. The goal of this test is to check if the tooltip is visible either with a given message or the default message, no matter what the default message actually is. I've seen numerous examples of such pattern in tests in BUIE and internal repos. Also there are currently no tests checking the tooltip message against a hardcoded string for any tab tooltip. Maybe we should create separate tests checking those? WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we want the test to fail if the text has changed because its an intentional change, so it would be required to update the tests too. having to update the tests is verification for an intentional text change. there have been occasions where additional messages were changed by accident and they persisted all the way up to parent applications before it was caught.

currently, majority of the occurrences in buie are from older tests, all the new tests are hardcoding the strings for assertions. any tests that is currently using messages within a test to assert will be changed to hardcoded strings that correspond to the message defaultMessage, when we reach them during the enyzme to rtl migrations

for clarity, this is an example of what talking about in case what im asking is unclear

screen.getByText('Add Metadata to your file to support business operations, workflows, and more!'),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The request was clear to me, thank you for additional explanation. I've updated tests to use hardcoded string in order to follow the current convention of not using message variables in tests.

src/elements/common/nav-button/__tests__/NavButton.test.js Outdated Show resolved Hide resolved
Comment on lines 90 to 94
tooltip={
(showOnlyBoxAINavButton && boxAIDisabledTooltip) ||
intl.formatMessage(messages.sidebarBoxAITitle)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the tooltip only available when showOnlyBoxAINavButton is true ?

@@ -87,6 +98,57 @@ describe('elements/content-sidebar/SidebarNav', () => {
expect(wrapper.find(IconChatRound)).toHaveLength(0);
});

describe('should render box ai tab with correct disabled state and tooltip', () => {
const defaultTooltip = messages.sidebarBoxAITitle.defaultMessage;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we want the test to fail if the text has changed because its an intentional change, so it would be required to update the tests too. having to update the tests is verification for an intentional text change. there have been occasions where additional messages were changed by accident and they persisted all the way up to parent applications before it was caught.

currently, majority of the occurrences in buie are from older tests, all the new tests are hardcoding the strings for assertions. any tests that is currently using messages within a test to assert will be changed to hardcoded strings that correspond to the message defaultMessage, when we reach them during the enyzme to rtl migrations

for clarity, this is an example of what talking about in case what im asking is unclear

screen.getByText('Add Metadata to your file to support business operations, workflows, and more!'),

@kkuliczkowski-box kkuliczkowski-box force-pushed the content-sidebar/option-to-render-boxi-nav-button-disabled branch from ce0a7c4 to 3b10e73 Compare January 10, 2025 10:23
@kkuliczkowski-box kkuliczkowski-box force-pushed the content-sidebar/option-to-render-boxi-nav-button-disabled branch from 3b10e73 to 97083af Compare January 10, 2025 17:24
@marcoartaviaq marcoartaviaq self-requested a review January 10, 2025 17:27
@mergify mergify bot merged commit 2ba1a10 into box:master Jan 10, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants