MCPcopy Create free account
hub / github.com/error311/FileRise / pickGroupGrantsForSource

Function pickGroupGrantsForSource

public/js/adminFolderAccess.js:823–849  ·  view source on GitHub ↗
(group, sourceId)

Source from the content-addressed store, hash-verified

821}
822
823function pickGroupGrantsForSource(group, sourceId) {
824 if (!group || typeof group !== 'object') return {};
825 const sid = normalizeSourceId(sourceId);
826 const bySource = (group.grantsBySource && typeof group.grantsBySource === 'object' && !Array.isArray(group.grantsBySource))
827 ? group.grantsBySource
828 : null;
829 if (bySource) {
830 if (sid && Object.prototype.hasOwnProperty.call(bySource, sid)) {
831 const candidate = bySource[sid];
832 return (candidate && typeof candidate === 'object' && !Array.isArray(candidate)) ? candidate : {};
833 }
834 if (!sid && Object.prototype.hasOwnProperty.call(bySource, 'local')) {
835 const candidate = bySource.local;
836 return (candidate && typeof candidate === 'object' && !Array.isArray(candidate)) ? candidate : {};
837 }
838 if (isLocalSourceId(sid)) {
839 const legacy = group.grants;
840 return (legacy && typeof legacy === 'object' && !Array.isArray(legacy)) ? legacy : {};
841 }
842 return {};
843 }
844 if (isLocalSourceId(sid)) {
845 const legacy = group.grants;
846 return (legacy && typeof legacy === 'object' && !Array.isArray(legacy)) ? legacy : {};
847 }
848 return {};
849}
850
851function setGroupGrantsForSource(group, sourceId, grants) {
852 if (!group || typeof group !== 'object') return;

Callers 3

ensureLoadedFunction · 0.85
renderGroupAclFunction · 0.85

Calls 2

isLocalSourceIdFunction · 0.85
normalizeSourceIdFunction · 0.70

Tested by

no test coverage detected