UNPKG

@mikezimm/fps-library-v2

Version:

Library of reusable typescript/javascript functions, interfaces and constants

76 lines (74 loc) 3.58 kB
/** * CodeAnalizerComment: Updated 3 imports on 2024-09-22 14:49:52 * Update:: import { ISharingEvent } to '@mikezimm/fps-core-v7/lib/components/atoms/SharedItems/IItemWithSharingInfo;' * Update:: import { IItemWithSharingInfo } to '@mikezimm/fps-core-v7/lib/components/atoms/SharedItems/IItemWithSharingInfo;' * Update:: import { openLinkInNewTabUsingDatahref } to '@mikezimm/fps-core-v7/lib/components/atoms/SharedItems/openLinkInNewTabUsingDatahref;' */ /** * CodeAnalizerComment: Updated 1 imports on 2024-09-21 23:07:24 * Update:: import { sortObjectArrayByNumberKey } to '@mikezimm/fps-core-v7/lib/logic/Arrays/sorting/numbers;' */ /** * COPIED FROM PIVOT TILES ON 2023-12-09 */ import * as React from 'react'; import { Link } from '@fluentui/react/lib/Link'; import { sortObjectArrayByNumberKey } from '@mikezimm/fps-core-v7/lib/logic/Arrays/sorting/numbers'; import { openLinkInNewTabUsingDatahref } from '@mikezimm/fps-core-v7/lib/components/atoms/SharedItems/openLinkInNewTabUsingDatahref'; /** * This builds up the Shared History tab-page in Pivot Tiles library permissions * Provides Table of all individual sharing events on library in chronological order * createChronoSortedSharingEvents Was previously called: buildSharingRows, buildChronoSortedSharingEvents * * TIME Type Link SharedBy SharedWith * * @param sharedItems * @param width */ export function createChronoSortedSharingEvents(sharedItems, width) { let sharedItemDetails = []; const sharedElements = []; //This gets all the individual shares currently under a list item, and puts them into a separate array so all shares can be resorted by timestamp and not by item. sharedItems.map(item => { item.ItemSharingInfo.SharedEvents.map(share => { sharedItemDetails.push(share); }); }); //This sorts all the individual details by share timestamp sharedItemDetails = sortObjectArrayByNumberKey(sharedItemDetails, 'desc', 'TimeMS'); //This builds the elements based on the sorting sharedItemDetails.map(share => { const sharedByName = share.sharedBy.split('@')[0]; const sharedByDomain = sharedByName[1].split('.')[0] + '...'; if (share.sharedWith.indexOf(sharedByDomain) > 0) { share.sharedWith = share.sharedBy.split('@')[0]; } let shortFileName = share.FileLeafRef && share.FileLeafRef.length > 0 ? share.FileLeafRef.substr(0, 15) : ''; if (shortFileName.length < share.FileLeafRef.length) { shortFileName += '...'; } sharedElements.push(React.createElement("tr", null, React.createElement("td", null, " ", share.SharedTime.toLocaleString(), " "), React.createElement("td", null, " ", share.FileSystemObjectType === 0 ? 'File' : 'Folder', " "), React.createElement("td", { title: share.FileLeafRef }, " ", React.createElement(Link, { onClick: openLinkInNewTabUsingDatahref, "data-href": share.FileRef }, shortFileName), " "), React.createElement("td", null, " ", sharedByName, " "), React.createElement("td", null, " ", share.sharedWith, " "))); }); return sharedElements; } //# sourceMappingURL=createChronoSortedSharingEvents.js.map