ShareDialog

Modal dialog for managing project or folder sharing. Supports per-user role assignment (owner/editor/viewer), user search, "anyone with link" access (owners only), ownership transfer, and optional email notifications.

Constructor

new ShareDialog(entityId, server, typeopt)

Parameters:
NameTypeAttributesDefaultDescription
entityIdstringProject ID or folder path.
serverobjectServer instance (for token + baseUrl + backendUser).
type'project' | 'folder'<optional>
'project'

Classes

ShareDialog

Members

_perms

Resolved permissions: {owners, editors, viewers, any_with_link, public}

Methods

(async) _addUser(user, role, notify)

Grants the user access at the given role and refreshes the UI.
Parameters:
NameTypeDescription
userobjectUser object from search results.
rolestringRole to grant: 'editor' or 'viewer'.
notifybooleanWhether to email the user about the new access.

(async) _authHeaders(extraopt) → {Promise.<object>}

Parameters:
NameTypeAttributesDescription
extraobject<optional>
additional headers to merge in
Returns:
Type: 
Promise.<object>

_buildActionsSection() → {HTMLElement}

Returns:
the actions footer section with the open-presentation button
Type: 
HTMLElement

_buildAddSection() → {HTMLElement}

Returns:
the "add people" search row section
Type: 
HTMLElement

_buildDOM()

Builds and appends the dialog scrim and root DOM elements.
Returns:
the "anyone with link" toggle section
Type: 
HTMLElement

_buildPeopleSection() → {HTMLElement}

Returns:
the people list section
Type: 
HTMLElement

_buildUserRow(user, role) → {HTMLElement}

Builds a single user row with avatar, name, and role controls.
Parameters:
NameTypeDescription
userobjectUser object with id, display_name, and email.
rolestringCurrent role: 'owner', 'editor', or 'viewer'.
Returns:
Type: 
HTMLElement

(async) _changeRole(user, oldRole, newRole)

Changes a user's role and persists the update.
Parameters:
NameTypeDescription
userobjectUser object being updated.
oldRolestringCurrent role before the change.
newRolestringNew role to assign.

_clonePerms() → {object}

Convert internal {owners: [userObj]} shape to {owners: [id]} for the API.
Returns:
permissions payload with ID arrays
Type: 
object

_confirmTransfer(newOwner)

Shows a confirmation modal before transferring ownership.
Parameters:
NameTypeDescription
newOwnerobjectthe user to transfer ownership to

(async) _doTransfer(newOwner)

Executes the ownership transfer and reloads permissions.
Parameters:
NameTypeDescription
newOwnerobjectthe user to become the new owner

_esc(str) → {string}

Parameters:
NameTypeDescription
strstringRaw string to escape.
Returns:
HTML-escaped string
Type: 
string

_hashColor(id) → {string}

Parameters:
NameTypeDescription
idstringUser ID to hash into a color.
Returns:
deterministic HSL color
Type: 
string

_initials(name) → {string}

Parameters:
NameTypeDescription
namestringDisplay name or email to derive initials from.
Returns:
1-2 letter initials
Type: 
string

(async) _load()

Fetches current permissions from the server and triggers a re-render.

_permPath() → {string}

Returns:
API permissions URL for the current entity.
Type: 
string

(async) _putPerms(permissions, notifyopt) → {Promise.<boolean>}

Sends updated permissions to the server.
Parameters:
NameTypeAttributesDefaultDescription
permissionsobjectPermissions payload with owner/editor/viewer ID arrays and link flags.
notifyboolean<optional>
trueWhether to notify affected users by email.
Returns:
Type: 
Promise.<boolean>

(async) _removeUser(user, role)

Removes a user's access and persists the update.
Parameters:
NameTypeDescription
userobjectUser object to remove.
rolestringCurrent role of the user being removed.

_render()

Rebuilds the dialog body from current permissions state.

(async) _runSearch(query, dropdown, input, roleSelect, notifyWrap)

Searches for users matching the query and populates the dropdown.
Parameters:
NameTypeDescription
querystringSearch string typed by the user.
dropdownHTMLElementContainer element for search results.
inputHTMLElementText input to clear after selection.
roleSelectHTMLElementRole selector whose value is applied on selection.
notifyWrapHTMLElementWrapper containing the notify checkbox.

_showStatus(msg, isErroropt)

Displays a transient status message at the bottom of the dialog.
Parameters:
NameTypeAttributesDefaultDescription
msgstringMessage text to display.
isErrorboolean<optional>
falseIf true, renders in error color.

close()

Removes the dialog and scrim from the DOM.

getSharedUsers() → {Array}

Returns:
all users with any level of access
Type: 
Array