Skip to content

Commit 554ce1e

Browse files
📝 Add docstrings to handle-error-case-for-init-data
Docstrings generation was requested by @reneshen0328. * #4350 (comment) The following files were modified: * `src/elements/content-sharing/ContentSharing.js` * `src/elements/content-sharing/ContentSharingV2.tsx`
1 parent 094e633 commit 554ce1e

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

src/elements/content-sharing/ContentSharing.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,25 @@ const createAPI = (apiHost, itemID, itemType, token) =>
7373
version: CLIENT_VERSION,
7474
});
7575

76+
/**
77+
* Top-level React component that initializes the sharing API and renders the content-sharing UI,
78+
* either the feature-flagged ContentSharingV2 wrapped with localization and providers or the legacy SharingModal with an optional custom launch button.
79+
*
80+
* @param {string} [apiHost] - Hostname for the API; defaults to the library's default API hostname.
81+
* @param {React.ReactNode} [children] - Optional children passed into the ContentSharingV2 variant.
82+
* @param {Object} [config] - Configuration object passed to the legacy SharingModal.
83+
* @param {React.ReactElement} [customButton] - Optional custom launch button; when provided it is cloned and wired to open the sharing UI.
84+
* @param {boolean} [displayInModal] - When true, instructs the legacy sharing UI to render inside a modal.
85+
* @param {Object} [features] - Feature-flag map; used to enable the `contentSharingV2` variant.
86+
* @param {boolean} [hasProviders] - When true, wraps ContentSharingV2 with provider context; controls whether Providers is applied.
87+
* @param {string} itemID - Identifier of the item being shared.
88+
* @param {string} itemType - Type of the item being shared.
89+
* @param {string} [language] - Locale code used by the Internationalize wrapper.
90+
* @param {Object} [messages] - Localization messages passed to Internationalize.
91+
* @param {string} [token] - Authorization token used to construct the API client.
92+
* @param {string} [uuid] - Unique identifier used to reset component visibility when it changes.
93+
* @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.
94+
*/
7695
function ContentSharing({
7796
apiHost = DEFAULT_HOSTNAME_API,
7897
children,
@@ -152,4 +171,4 @@ function ContentSharing({
152171
}
153172

154173
export { ContentSharing as ContentSharingComponent };
155-
export default withBlueprintModernization(ContentSharing);
174+
export default withBlueprintModernization(ContentSharing);

src/elements/content-sharing/ContentSharingV2.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ export interface ContentSharingV2Props {
2929
itemType: ItemType;
3030
}
3131

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

230-
export default withBlueprintModernization(ContentSharingV2);
240+
export default withBlueprintModernization(ContentSharingV2);

0 commit comments

Comments
 (0)