@mikezimm/fps-library-v2
Version:
Library of reusable typescript/javascript functions, interfaces and constants
72 lines (71 loc) • 3.48 kB
JavaScript
/**
* CodeAnalizerComment: Updated 2 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;'
*/
/**
* COPIED FROM PIVOT TILES ON 2023-12-09
*/
import * as React from 'react';
/**
* Name changed TO: createItemSharingTable From: createDetailsShareTable
* This builds up the DETAILS COLUMN on PivotTiles Shared Details tab.
* Also can be brought into SINGLE ITEM PROPERTY PANE
*
* Timestamp SharedBy SharedWith
*
* All the firstShareDate and lastShareDate stuff was removed because linting found it didn't
* actually do anything. That is why it is smaller than ECStorage version
*
* @param item
* @returns
*/
export function createItemSharingTable(item, includeTH = false) {
if (!item.ItemSharingInfo || !item.ItemSharingInfo.SharedEvents)
return React.createElement("h4", null, "No sharing history found");
// let firstShareDateMS = 3618105359201;
// let lastShareDateMS = 0;
// let firstShareDate = null;
// let lastShareDate = null;
const sharedByPeopleArray = []; // Does not seem to be used
const thisFileShares = [];
let prevTime = ``;
let prevBy = ``;
item.ItemSharingInfo.SharedEvents.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]; }
// if ( share.TimeMS > lastShareDateMS ) { lastShareDate = share.SharedTime; lastShareDateMS = share.TimeMS ; }
// if ( share.TimeMS < firstShareDateMS ) { firstShareDate = share.SharedTime; firstShareDateMS = share.TimeMS ; }
sharedByPeopleArray.push(share.sharedWith); // Does not seem to be used
const thisTime = `${share.SharedTime.toLocaleString()}`;
const thisBy = `${share.sharedByShort}`;
thisFileShares.push(React.createElement("tr", null,
React.createElement("td", null,
" ",
thisTime === prevTime ? '...' : thisTime,
" "),
React.createElement("td", null,
" ",
thisBy === prevBy ? '...' : thisBy,
" "),
React.createElement("td", null,
" ",
share.sharedWithShort,
" ")));
prevTime = `${share.SharedTime.toLocaleString()}`;
prevBy = `${share.sharedByShort}`;
});
// let shareTimeFrame = firstShareDate === null ? null : firstShareDate.toLocaleString();
// if ( lastShareDate !== null && firstShareDateMS !== lastShareDateMS ) { shareTimeFrame += ' - ' + lastShareDate.toLocaleString() ; }
const shareTable = thisFileShares.length === 0 ? null : React.createElement("table", { className: 'fps-gen-table' },
includeTH === true ?
React.createElement("tr", null,
React.createElement("th", null, "Date"),
React.createElement("th", null, "Shared By"),
React.createElement("th", null, "Shared With"))
: undefined,
thisFileShares);
return shareTable;
}
//# sourceMappingURL=createItemSharingTable.js.map