UNPKG

@mikezimm/fps-library-v2

Version:

Library of reusable typescript/javascript functions, interfaces and constants

50 lines 3.37 kB
import * as React from 'react'; import { Icon } from '@fluentui/react/lib/Icon'; /** * Standalone renderer for permissions/sharing icon cell. * Meant to mirror the internal `_renderPerms` method in `reactListView.tsx`. * * @param fieldName - 'HasUniqueRoleAssignments' | 'ItemSharingInfo' * @param item - item data * @param props - component props (used for webUrl, listId, listTitle, bannerProps) * @param onShowPanel - callback to open details panel: accepts an `IAnySourceItemAny` */ export function renderPermsStandalone(fieldName, item, props, onShowPanel) { var _a, _b; const itemIcon = item[`ItemSharingInfo.ID`] ? 'Share' : item.HasUniqueRoleAssignments === true ? 'Shield' : ''; const fontSize = itemIcon ? 'large' : 'default'; const managePermissions = (_b = (_a = props === null || props === void 0 ? void 0 : props.bannerProps) === null || _a === void 0 ? void 0 : _a.FPSUser) === null || _b === void 0 ? void 0 : _b.managePermissions; const cursor = managePermissions && item.HasUniqueRoleAssignments ? 'pointer' : ''; if (!cursor) { return React.createElement("div", { id: 'ButtonID' + item.Id, style: { fontSize: fontSize, fontWeight: 'bolder', width: '25px', textAlign: 'center', cursor: cursor } }, React.createElement(Icon, { iconName: itemIcon })); } if (fieldName === 'ItemSharingInfo') { return React.createElement("div", { id: 'ButtonID' + item.Id, onClick: (e) => onShowPanel('Sharing', [item], e), style: { fontSize: fontSize, fontWeight: 'bolder', width: '25px', textAlign: 'center', cursor: cursor } }, React.createElement(Icon, { iconName: itemIcon })); } const title = item[`ItemSharingInfo.ID`] ? 'Item was shared' : item.HasUniqueRoleAssignments === true ? 'Item has unique permissions' : ''; return React.createElement("div", { title: title, id: 'ButtonID' + item.Id, onClick: (e) => onShowPanel('Perms', [item], e), style: { fontSize: fontSize, fontWeight: 'bolder', width: '25px', textAlign: 'center', cursor: cursor } }, React.createElement(Icon, { iconName: itemIcon })); } /** * Standalone renderer for attachments icon cell. * Mirrors the `_renderAttach` method in `reactListView.tsx`. * * @param item - item data * @param props - component props (used to check `includeDetails`) * @param onShowPanel - callback to open details panel when attachments clicked */ export function renderAttachStandalone(item, props, onShowPanel) { const hasAttach = item.Attachments ? true : false; const cursor = hasAttach ? 'pointer' : ''; const iconName = hasAttach ? 'Attach' : ''; if (props.includeDetails) { return React.createElement("div", { id: 'ButtonID' + item.Id, style: { fontSize: 'larger', fontWeight: 'bolder', width: '25px', textAlign: 'center', cursor: cursor } }, React.createElement(Icon, { iconName: iconName })); } // When includeDetails is false, clicking should open the panel (same as previous behavior) return React.createElement("div", { id: 'ButtonID' + item.Id, onClick: (e) => onShowPanel('Attach', [item], e), style: { fontSize: 'larger', fontWeight: 'bolder', width: '25px', textAlign: 'center', cursor: cursor } }, React.createElement(Icon, { iconName: iconName })); } //# sourceMappingURL=specialRenders.js.map