Skip to content
Closed
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
21 changes: 20 additions & 1 deletion src/elements/content-sharing/ContentSharing.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,25 @@ const createAPI = (apiHost, itemID, itemType, token) =>
version: CLIENT_VERSION,
});

/**
* Top-level React component that initializes the sharing API and renders the content-sharing UI,
* either the feature-flagged ContentSharingV2 wrapped with localization and providers or the legacy SharingModal with an optional custom launch button.
*
* @param {string} [apiHost] - Hostname for the API; defaults to the library's default API hostname.
* @param {React.ReactNode} [children] - Optional children passed into the ContentSharingV2 variant.
* @param {Object} [config] - Configuration object passed to the legacy SharingModal.
* @param {React.ReactElement} [customButton] - Optional custom launch button; when provided it is cloned and wired to open the sharing UI.
* @param {boolean} [displayInModal] - When true, instructs the legacy sharing UI to render inside a modal.
* @param {Object} [features] - Feature-flag map; used to enable the `contentSharingV2` variant.
* @param {boolean} [hasProviders] - When true, wraps ContentSharingV2 with provider context; controls whether Providers is applied.
* @param {string} itemID - Identifier of the item being shared.
* @param {string} itemType - Type of the item being shared.
* @param {string} [language] - Locale code used by the Internationalize wrapper.
* @param {Object} [messages] - Localization messages passed to Internationalize.
* @param {string} [token] - Authorization token used to construct the API client.
* @param {string} [uuid] - Unique identifier used to reset component visibility when it changes.
* @returns {JSX.Element|null} The rendered content-sharing UI (either ContentSharingV2 wrapped with Internationalize and Providers, or the legacy SharingModal and optional launch button), or null while the API is unavailable.
*/
function ContentSharing({
apiHost = DEFAULT_HOSTNAME_API,
children,
Expand Down Expand Up @@ -152,4 +171,4 @@ function ContentSharing({
}

export { ContentSharing as ContentSharingComponent };
export default withBlueprintModernization(ContentSharing);
export default withBlueprintModernization(ContentSharing);
12 changes: 11 additions & 1 deletion src/elements/content-sharing/ContentSharingV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ export interface ContentSharingV2Props {
itemType: ItemType;
}

/**
* Orchestrates fetching item, user, collaborator, and avatar data and renders a UnifiedShareModal when the item is loaded.
*
* This component manages internal state for the item, shared link, collaborators, avatars, roles, and current user,
* resets state when the provided `api` changes, and displays a single error notification on initial data-retrieval failures.
*
* @param itemId - The Box file or folder ID to load and share
* @param itemType - Either `"file"` or `"folder"`, indicating the type of `itemId`
* @returns The rendered UnifiedShareModal element when item data is available, otherwise `null`
*/
function ContentSharingV2({ api, children, itemId, itemType }: ContentSharingV2Props) {
const [avatarUrlMap, setAvatarUrlMap] = React.useState<AvatarURLMap | null>(null);
const [item, setItem] = React.useState<Item | null>(null);
Expand Down Expand Up @@ -227,4 +237,4 @@ function ContentSharingV2({ api, children, itemId, itemType }: ContentSharingV2P
);
}

export default withBlueprintModernization(ContentSharingV2);
export default withBlueprintModernization(ContentSharingV2);
Loading