UNPKG

@mikezimm/fps-library-v2

Version:

Library of reusable typescript/javascript functions, interfaces and constants

81 lines (80 loc) 4.01 kB
/** * CodeAnalizerComment: Updated 2 imports on 2024-09-22 14:49:52 * Update:: import { IItemSharingInfo } to '@mikezimm/fps-core-v7/lib/components/atoms/SharedItems/IItemWithSharingInfo;' * Update:: import { IItemWithSharingInfo } to '@mikezimm/fps-core-v7/lib/components/atoms/SharedItems/IItemWithSharingInfo;' */ /** * 2023-12-07 * COPIED FROM ECSTORAGE v0.1.1: src\webparts\exStorage\components\Sharing */ import * as React from 'react'; require('@mikezimm/fps-styles/dist/Sharing.css'); /** USE THIS IN THE ITEM PANE * This just creates the 3 column table for each file/item showing When, who shared, with whome. * Can be consumed as a cell in a larger table of all shared files or just for a specific file. * @param item * @param headings * @param cleanCells - this will remove Date and Shared By if both of those are the same as the previous row. * @param tableStyle */ export function createDetailsShareTable(item, headings, cleanCells, tableStyle) { let hasSharing = item.ItemSharingInfo && item.ItemSharingInfo.SharedEvents ? true : false; if (hasSharing === false) { return null; } let firstShareDateMS = 3618105359201; let lastShareDateMS = 0; let firstShareDate = null; let lastShareDate = null; let sharedByPeopleArray = []; // sharedByPeopleArray does not seem to be used here. let thisFileShares = []; let ItemSharingInfo = item.ItemSharingInfo; if (ItemSharingInfo && ItemSharingInfo.SharedEvents) { ItemSharingInfo.SharedEvents.map((event, index) => { let lastEvent = index > 0 ? ItemSharingInfo.SharedEvents[index - 1] : null; let isSameAsLast = index > 0 && event.sharedBy === lastEvent.sharedBy && event.TimeMS === lastEvent.TimeMS ? true : false; let sharedByName = event.sharedBy.split('@')[0]; let sharedByDomain = sharedByName[1].split('.')[0] + '...'; if (event.sharedWith.indexOf(sharedByDomain) > 0) { event.sharedWith = event.sharedBy.split('@')[0]; } if (event.TimeMS > lastShareDateMS) { lastShareDate = `${event.SharedTime}`; lastShareDateMS = event.TimeMS; } if (event.TimeMS < firstShareDateMS) { firstShareDate = `${event.SharedTime}`; firstShareDateMS = event.TimeMS; } sharedByPeopleArray.push(event.sharedWith); // sharedByPeopleArray does not seem to be used here. thisFileShares.push(React.createElement("tr", null, React.createElement("td", null, " ", isSameAsLast === true ? '...' : event.SharedTime.toLocaleString(), " "), React.createElement("td", null, " ", isSameAsLast === true ? '...' : sharedByName, " "), React.createElement("td", null, " ", event.sharedWith, " "))); }); } let shareTimeFrame = firstShareDate !== null ? firstShareDate.toLocaleString() : null; if (lastShareDate !== null && firstShareDateMS !== lastShareDateMS) { shareTimeFrame += ' - ' + lastShareDate.toLocaleString(); } let cellClass = tableStyle === 'pad30' ? 'padAllCellsLeft' : null; let tableWidth = tableStyle === '100%Wide' ? '100%' : null; let headingRow = headings !== true ? null : React.createElement("tr", null, React.createElement("th", null, "Date"), React.createElement("th", null, "Shared By"), React.createElement("th", null, "Shared With")); let shareTable = thisFileShares.length === 0 ? null : React.createElement("table", { className: cellClass, style: { width: tableWidth } }, headingRow, thisFileShares); return shareTable; } //# sourceMappingURL=SharingElements2.js.map