-
Notifications
You must be signed in to change notification settings - Fork 326
feat: add client version to element api calls #4198
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
base: master
Are you sure you want to change the base?
Conversation
WalkthroughThis update standardizes how the client version is defined and propagated throughout the codebase. It introduces a global Changes
Sequence Diagram(s)sequenceDiagram
participant BuildProcess
participant DefinePlugin
participant Global
participant APIConsumer
participant API
BuildProcess->>DefinePlugin: Set __VERSION__ (env-dependent)
DefinePlugin->>Global: Injects __VERSION__
APIConsumer->>Global: Import CLIENT_VERSION = __VERSION__
APIConsumer->>API: Pass { version: CLIENT_VERSION }
API->>API: Use version for requests/config
Estimated code review effort2 (~18 minutes) Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (1)
src/elements/content-picker/ContentPicker.js (1)
221-233
: Sameversion
field concern as noted for ContentSharingEnsure the
API
constructor recognisesversion
; otherwise update the key or the type definition.
🧹 Nitpick comments (1)
scripts/version.sh (1)
7-9
: Consider adding error handling to the set_version function.The
set_version
function looks good but could benefit from error handling to ensure thejq
command succeeds before replacing the original file.set_version() { - jq --arg version "$1" '.version = $version' package.json > package.json.tmp && mv package.json.tmp package.json + if jq --arg version "$1" '.version = $version' package.json > package.json.tmp; then + mv package.json.tmp package.json + else + rm -f package.json.tmp + echo "Error: Failed to update version in package.json" >&2 + exit 1 + fi }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (13)
.storybook/main.ts
(2 hunks)package.json
(2 hunks)scripts/jest/jest-setup.ts
(1 hunks)scripts/version.sh
(1 hunks)src/constants.js
(3 hunks)src/elements/content-explorer/ContentExplorer.tsx
(2 hunks)src/elements/content-open-with/ContentOpenWith.js
(2 hunks)src/elements/content-picker/ContentPicker.js
(2 hunks)src/elements/content-preview/ContentPreview.js
(2 hunks)src/elements/content-sharing/ContentSharing.js
(2 hunks)src/elements/content-sidebar/ContentSidebar.js
(2 hunks)src/elements/content-uploader/ContentUploader.tsx
(2 hunks)src/elements/wrappers/ES6Wrapper.js
(0 hunks)
🧠 Learnings (10)
src/elements/content-sharing/ContentSharing.js (1)
Learnt from: rafalmaksymiuk
PR: #4136
File: src/elements/common/types/SidebarNavigation.ts:16-26
Timestamp: 2025-06-11T16:30:10.431Z
Learning: VersionSidebarView
intentionally uses the versionId
field to stay consistent with current URL parameter naming; a potential rename to fileVersionId
is deferred until React Router is removed.
src/elements/content-preview/ContentPreview.js (1)
Learnt from: rafalmaksymiuk
PR: #4136
File: src/elements/common/types/SidebarNavigation.ts:16-26
Timestamp: 2025-06-11T16:30:10.431Z
Learning: VersionSidebarView
intentionally uses the versionId
field to stay consistent with current URL parameter naming; a potential rename to fileVersionId
is deferred until React Router is removed.
src/elements/content-picker/ContentPicker.js (1)
Learnt from: rafalmaksymiuk
PR: #4136
File: src/elements/common/types/SidebarNavigation.ts:16-26
Timestamp: 2025-06-11T16:30:10.431Z
Learning: VersionSidebarView
intentionally uses the versionId
field to stay consistent with current URL parameter naming; a potential rename to fileVersionId
is deferred until React Router is removed.
src/elements/content-sidebar/ContentSidebar.js (2)
Learnt from: rafalmaksymiuk
PR: #4136
File: src/elements/common/types/SidebarNavigation.ts:16-26
Timestamp: 2025-06-11T16:30:10.431Z
Learning: VersionSidebarView
intentionally uses the versionId
field to stay consistent with current URL parameter naming; a potential rename to fileVersionId
is deferred until React Router is removed.
Learnt from: rafalmaksymiuk
PR: #4144
File: src/elements/content-sidebar/versions/VersionsList.js:24-33
Timestamp: 2025-06-17T13:30:02.172Z
Learning: In the box-ui-elements codebase, Flow components use .flow.js type definition files, not TypeScript .ts files. The InternalSidebarNavigation type is a union type where different variants may have different properties like versionId, and proper type safety is ensured through conditional checks in methods like getSelectedVersionId.
src/elements/content-explorer/ContentExplorer.tsx (1)
Learnt from: rafalmaksymiuk
PR: #4136
File: src/elements/common/types/SidebarNavigation.ts:16-26
Timestamp: 2025-06-11T16:30:10.431Z
Learning: VersionSidebarView
intentionally uses the versionId
field to stay consistent with current URL parameter naming; a potential rename to fileVersionId
is deferred until React Router is removed.
src/elements/content-open-with/ContentOpenWith.js (1)
Learnt from: rafalmaksymiuk
PR: #4136
File: src/elements/common/types/SidebarNavigation.ts:16-26
Timestamp: 2025-06-11T16:30:10.431Z
Learning: VersionSidebarView
intentionally uses the versionId
field to stay consistent with current URL parameter naming; a potential rename to fileVersionId
is deferred until React Router is removed.
src/elements/content-uploader/ContentUploader.tsx (1)
Learnt from: rafalmaksymiuk
PR: #4136
File: src/elements/common/types/SidebarNavigation.ts:16-26
Timestamp: 2025-06-11T16:30:10.431Z
Learning: VersionSidebarView
intentionally uses the versionId
field to stay consistent with current URL parameter naming; a potential rename to fileVersionId
is deferred until React Router is removed.
.storybook/main.ts (2)
Learnt from: tjuanitas
PR: #4126
File: scripts/buildTranslations.js:1-8
Timestamp: 2025-06-17T15:16:46.279Z
Learning: The buildTranslations and buildLanguageBundles functions from @box/frontend package are synchronous functions that already handle errors internally, so additional error handling wrappers and await keywords are not needed.
Learnt from: jpan-box
PR: #4166
File: src/elements/content-sidebar/SidebarNav.js:126-126
Timestamp: 2025-07-11T14:43:02.677Z
Learning: In the box-ui-elements repository, there's a file-type-based pattern for internationalization: TypeScript files (.tsx) predominantly use the modern useIntl hook (41 vs 15 files), while JavaScript files (.js) predominantly use the legacy injectIntl HOC (64 vs 5 files). New TypeScript components should use useIntl, while existing JavaScript components typically continue using injectIntl for consistency.
scripts/jest/jest-setup.ts (1)
Learnt from: jpan-box
PR: #4166
File: src/elements/content-sidebar/SidebarNav.js:126-126
Timestamp: 2025-07-11T14:43:02.677Z
Learning: In the box-ui-elements repository, there's a file-type-based pattern for internationalization: TypeScript files (.tsx) predominantly use the modern useIntl hook (41 vs 15 files), while JavaScript files (.js) predominantly use the legacy injectIntl HOC (64 vs 5 files). New TypeScript components should use useIntl, while existing JavaScript components typically continue using injectIntl for consistency.
package.json (3)
Learnt from: tjuanitas
PR: #4126
File: scripts/buildLocaleBundles.js:39-40
Timestamp: 2025-06-17T15:19:52.028Z
Learning: In scripts/buildLocaleBundles.js, the user intentionally wants to kill ALL running build:prod:dist
processes on error (not just the ones spawned by the script) for comprehensive cleanup. They've confirmed that tracking individual PIDs from execSync is not feasible and their current approach serves their intended purpose.
Learnt from: tjuanitas
PR: #4126
File: scripts/buildTranslations.js:1-8
Timestamp: 2025-06-17T15:16:46.279Z
Learning: The buildTranslations and buildLanguageBundles functions from @box/frontend package are synchronous functions that already handle errors internally, so additional error handling wrappers and await keywords are not needed.
Learnt from: tjuanitas
PR: #4126
File: scripts/webpack.config.js:72-76
Timestamp: 2025-06-17T15:21:36.180Z
Learning: The Box UI Elements project does not run webpack builds on Windows machines, so Windows path separator compatibility is not a concern for their build scripts.
🧬 Code Graph Analysis (8)
src/elements/content-sharing/ContentSharing.js (1)
src/constants.js (2)
CLIENT_VERSION
(230-230)CLIENT_VERSION
(230-230)
src/elements/content-preview/ContentPreview.js (1)
src/constants.js (2)
CLIENT_VERSION
(230-230)CLIENT_VERSION
(230-230)
src/elements/content-picker/ContentPicker.js (1)
src/constants.js (2)
CLIENT_VERSION
(230-230)CLIENT_VERSION
(230-230)
src/elements/content-sidebar/ContentSidebar.js (1)
src/constants.js (2)
CLIENT_VERSION
(230-230)CLIENT_VERSION
(230-230)
src/elements/content-explorer/ContentExplorer.tsx (1)
src/constants.js (2)
CLIENT_VERSION
(230-230)CLIENT_VERSION
(230-230)
src/elements/content-open-with/ContentOpenWith.js (1)
src/constants.js (2)
CLIENT_VERSION
(230-230)CLIENT_VERSION
(230-230)
src/elements/content-uploader/ContentUploader.tsx (1)
src/constants.js (2)
CLIENT_VERSION
(230-230)CLIENT_VERSION
(230-230)
.storybook/main.ts (1)
scripts/webpack.config.js (2)
language
(21-21)version
(15-15)
💤 Files with no reviewable changes (1)
- src/elements/wrappers/ES6Wrapper.js
🧰 Additional context used
🧠 Learnings (10)
src/elements/content-sharing/ContentSharing.js (1)
Learnt from: rafalmaksymiuk
PR: #4136
File: src/elements/common/types/SidebarNavigation.ts:16-26
Timestamp: 2025-06-11T16:30:10.431Z
Learning: VersionSidebarView
intentionally uses the versionId
field to stay consistent with current URL parameter naming; a potential rename to fileVersionId
is deferred until React Router is removed.
src/elements/content-preview/ContentPreview.js (1)
Learnt from: rafalmaksymiuk
PR: #4136
File: src/elements/common/types/SidebarNavigation.ts:16-26
Timestamp: 2025-06-11T16:30:10.431Z
Learning: VersionSidebarView
intentionally uses the versionId
field to stay consistent with current URL parameter naming; a potential rename to fileVersionId
is deferred until React Router is removed.
src/elements/content-picker/ContentPicker.js (1)
Learnt from: rafalmaksymiuk
PR: #4136
File: src/elements/common/types/SidebarNavigation.ts:16-26
Timestamp: 2025-06-11T16:30:10.431Z
Learning: VersionSidebarView
intentionally uses the versionId
field to stay consistent with current URL parameter naming; a potential rename to fileVersionId
is deferred until React Router is removed.
src/elements/content-sidebar/ContentSidebar.js (2)
Learnt from: rafalmaksymiuk
PR: #4136
File: src/elements/common/types/SidebarNavigation.ts:16-26
Timestamp: 2025-06-11T16:30:10.431Z
Learning: VersionSidebarView
intentionally uses the versionId
field to stay consistent with current URL parameter naming; a potential rename to fileVersionId
is deferred until React Router is removed.
Learnt from: rafalmaksymiuk
PR: #4144
File: src/elements/content-sidebar/versions/VersionsList.js:24-33
Timestamp: 2025-06-17T13:30:02.172Z
Learning: In the box-ui-elements codebase, Flow components use .flow.js type definition files, not TypeScript .ts files. The InternalSidebarNavigation type is a union type where different variants may have different properties like versionId, and proper type safety is ensured through conditional checks in methods like getSelectedVersionId.
src/elements/content-explorer/ContentExplorer.tsx (1)
Learnt from: rafalmaksymiuk
PR: #4136
File: src/elements/common/types/SidebarNavigation.ts:16-26
Timestamp: 2025-06-11T16:30:10.431Z
Learning: VersionSidebarView
intentionally uses the versionId
field to stay consistent with current URL parameter naming; a potential rename to fileVersionId
is deferred until React Router is removed.
src/elements/content-open-with/ContentOpenWith.js (1)
Learnt from: rafalmaksymiuk
PR: #4136
File: src/elements/common/types/SidebarNavigation.ts:16-26
Timestamp: 2025-06-11T16:30:10.431Z
Learning: VersionSidebarView
intentionally uses the versionId
field to stay consistent with current URL parameter naming; a potential rename to fileVersionId
is deferred until React Router is removed.
src/elements/content-uploader/ContentUploader.tsx (1)
Learnt from: rafalmaksymiuk
PR: #4136
File: src/elements/common/types/SidebarNavigation.ts:16-26
Timestamp: 2025-06-11T16:30:10.431Z
Learning: VersionSidebarView
intentionally uses the versionId
field to stay consistent with current URL parameter naming; a potential rename to fileVersionId
is deferred until React Router is removed.
.storybook/main.ts (2)
Learnt from: tjuanitas
PR: #4126
File: scripts/buildTranslations.js:1-8
Timestamp: 2025-06-17T15:16:46.279Z
Learning: The buildTranslations and buildLanguageBundles functions from @box/frontend package are synchronous functions that already handle errors internally, so additional error handling wrappers and await keywords are not needed.
Learnt from: jpan-box
PR: #4166
File: src/elements/content-sidebar/SidebarNav.js:126-126
Timestamp: 2025-07-11T14:43:02.677Z
Learning: In the box-ui-elements repository, there's a file-type-based pattern for internationalization: TypeScript files (.tsx) predominantly use the modern useIntl hook (41 vs 15 files), while JavaScript files (.js) predominantly use the legacy injectIntl HOC (64 vs 5 files). New TypeScript components should use useIntl, while existing JavaScript components typically continue using injectIntl for consistency.
scripts/jest/jest-setup.ts (1)
Learnt from: jpan-box
PR: #4166
File: src/elements/content-sidebar/SidebarNav.js:126-126
Timestamp: 2025-07-11T14:43:02.677Z
Learning: In the box-ui-elements repository, there's a file-type-based pattern for internationalization: TypeScript files (.tsx) predominantly use the modern useIntl hook (41 vs 15 files), while JavaScript files (.js) predominantly use the legacy injectIntl HOC (64 vs 5 files). New TypeScript components should use useIntl, while existing JavaScript components typically continue using injectIntl for consistency.
package.json (3)
Learnt from: tjuanitas
PR: #4126
File: scripts/buildLocaleBundles.js:39-40
Timestamp: 2025-06-17T15:19:52.028Z
Learning: In scripts/buildLocaleBundles.js, the user intentionally wants to kill ALL running build:prod:dist
processes on error (not just the ones spawned by the script) for comprehensive cleanup. They've confirmed that tracking individual PIDs from execSync is not feasible and their current approach serves their intended purpose.
Learnt from: tjuanitas
PR: #4126
File: scripts/buildTranslations.js:1-8
Timestamp: 2025-06-17T15:16:46.279Z
Learning: The buildTranslations and buildLanguageBundles functions from @box/frontend package are synchronous functions that already handle errors internally, so additional error handling wrappers and await keywords are not needed.
Learnt from: tjuanitas
PR: #4126
File: scripts/webpack.config.js:72-76
Timestamp: 2025-06-17T15:21:36.180Z
Learning: The Box UI Elements project does not run webpack builds on Windows machines, so Windows path separator compatibility is not a concern for their build scripts.
🧬 Code Graph Analysis (8)
src/elements/content-sharing/ContentSharing.js (1)
src/constants.js (2)
CLIENT_VERSION
(230-230)CLIENT_VERSION
(230-230)
src/elements/content-preview/ContentPreview.js (1)
src/constants.js (2)
CLIENT_VERSION
(230-230)CLIENT_VERSION
(230-230)
src/elements/content-picker/ContentPicker.js (1)
src/constants.js (2)
CLIENT_VERSION
(230-230)CLIENT_VERSION
(230-230)
src/elements/content-sidebar/ContentSidebar.js (1)
src/constants.js (2)
CLIENT_VERSION
(230-230)CLIENT_VERSION
(230-230)
src/elements/content-explorer/ContentExplorer.tsx (1)
src/constants.js (2)
CLIENT_VERSION
(230-230)CLIENT_VERSION
(230-230)
src/elements/content-open-with/ContentOpenWith.js (1)
src/constants.js (2)
CLIENT_VERSION
(230-230)CLIENT_VERSION
(230-230)
src/elements/content-uploader/ContentUploader.tsx (1)
src/constants.js (2)
CLIENT_VERSION
(230-230)CLIENT_VERSION
(230-230)
.storybook/main.ts (1)
scripts/webpack.config.js (2)
language
(21-21)version
(15-15)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: lint_test_build
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Summary
🔇 Additional comments (16)
src/elements/content-sharing/ContentSharing.js (1)
52-59
: Confirm API supports the newversion
option
API
instances are now created with{ version: CLIENT_VERSION }
. Please double-check that:
src/api/index.js
(or the relevant Options type) listsversion
in its constructor signature.- Flow/TS definitions have been updated accordingly, otherwise this will surface as a type error or silently drop the field.
If the option name in
API
is stillclientVersion
, update the key to avoid losing the information.src/elements/content-explorer/ContentExplorer.tsx (1)
257-269
: Type-safety check forversion
in TypeScript
ContentExplorer
passesversion: CLIENT_VERSION
tonew API(...)
. IfAPIOptions
(or equivalent) hasn’t been extended withversion
, TypeScript compilation will fail or require// @ts-ignore
.Please verify that
api/Types.ts
(or similar) includes:export interface ApiOptions { version?: string; // … }src/elements/content-preview/ContentPreview.js (2)
54-54
: LGTM: Clean import additionThe
CLIENT_VERSION
import is properly added to the existing constants import statement following established patterns.
300-300
: LGTM: Correct API constructor enhancementThe
version: CLIENT_VERSION
property is properly added to the API constructor configuration, following the established pattern and achieving the PR objective of adding client version to element API calls.src/elements/content-sidebar/ContentSidebar.js (2)
19-24
: LGTM: Consistent import expansionThe
CLIENT_VERSION
import is cleanly added to the existing constants import statement, maintaining proper formatting and consistency.
171-171
: LGTM: Proper version integrationThe
version: CLIENT_VERSION
property is correctly added to the API constructor configuration, maintaining consistency with other components in this PR.src/constants.js (2)
9-9
: LGTM: Proper Flow global variable declarationThe global
__VERSION__
variable is correctly declared with the appropriate string type annotation, enabling type-safe usage in the CLIENT_VERSION constant.
230-230
: LGTM: Well-placed constant exportThe
CLIENT_VERSION
constant is properly exported and positioned in the Client Information section, providing a clean interface for components to access the application version.src/elements/content-open-with/ContentOpenWith.js (2)
29-29
: LGTM: Consistent import patternThe
CLIENT_VERSION
import follows the same clean pattern established across other components in this PR.
142-142
: LGTM: Consistent API constructor enhancementThe
version: CLIENT_VERSION
property is correctly added to the API constructor configuration, maintaining the consistent implementation pattern across all components in this PR.src/elements/content-uploader/ContentUploader.tsx (1)
35-35
: LGTM! Clean implementation of client version integration.The import of
CLIENT_VERSION
and its inclusion in the base API options follows the established pattern across the codebase. This ensures all API instances created by the ContentUploader will receive consistent version information.Also applies to: 291-291
.storybook/main.ts (1)
8-8
: Well-implemented webpack configuration for version injection.The DefinePlugin setup correctly injects the
__VERSION__
global constant based on the environment. The use ofJSON.stringify()
ensures proper string literal injection, and the environment-based version logic ('demo'
for production,'dev'
otherwise) is appropriate for Storybook context.Also applies to: 12-12, 64-66
package.json (1)
58-58
: Renamed scripts verifiedBoth new script files are present and retain the original functionality:
- scripts/buildLanguages.js exists (old buildTranslations.js/buildLanguageBundles.js removed) and still calls buildTranslations() and buildLanguageBundles() using the same i18n modules.
- scripts/buildLocaleAssets.js exists (old buildLocaleBundles.js removed) and implements locale asset bundling via @box/languages and worker threads.
No further changes needed.
scripts/version.sh (1)
11-18
: Clean command dispatch implementation.The case statement with default "get" behavior provides a clean interface for version management. The logic correctly handles both get and set operations with appropriate argument passing.
scripts/jest/jest-setup.ts (2)
2-2
: Excellent refactoring of global property definitions.The consolidation into
Object.defineProperties
is much cleaner than individual assignments. The__VERSION__
mock as'test'
properly supports the testing environment, and all existing functionality is preserved while improving code organization.Also applies to: 4-23
31-32
: Minor style improvement for comment consistency.The lowercase "deprecated" comments maintain consistency with standard documentation practices.
Summary by CodeRabbit
New Features
Chores
Refactor