Skip to content

Commit

Permalink
pushing new changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mbogo-mit committed Nov 16, 2023
1 parent 1f045df commit fa32db2
Show file tree
Hide file tree
Showing 16 changed files with 196 additions and 63 deletions.
2 changes: 1 addition & 1 deletion src/components/Admin/User/AdminUserList/AdminUserList.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const AdminUserList = (props) => {
SortIcon={SortIcon}
style={{ flex: 13 }}
>
Role
Type
</SortableHeader>
<SortableHeader
field="affiliation"
Expand Down
2 changes: 1 addition & 1 deletion src/components/Admin/User/AdminUserTable/AdminUserTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const AdminUserTable = ({
<td>{user.affiliation}</td>
</tr>
<tr>
<th>Type</th>
<th>Role</th>
<td><AdminRoleBadge role={user.role || 'user'} /></td>
</tr>
<tr>
Expand Down
1 change: 1 addition & 0 deletions src/components/AnnotationCard/AnnotationCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ function AnnotationCard({
channelAnnos[side] = [{ ...annotationData, permissions: { ...newPermissions } }];
const ids = FilterAnnotations(channelAnnos, {
annotatedBy: documentFilters.filters.annotatedBy.map((opt) => opt.email),
byGroup: (documentFilters.filters.byGroup || []).map((opt) => opt.id),
byTags: documentFilters.filters.byTags.map((opt) => opt.name),
permissions: documentFilters.filters.permissions,
});
Expand Down
2 changes: 2 additions & 0 deletions src/components/CreateEditDocument/CreateEditDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ const CreateEditDocument = ({

const resourceTypeAdditionalMetadata = resourceTypeMetadataObj(rt);
const newDocument = {
version: 4,
uploadContentType: htmlValue ? contentType : 'text/slate-html',
fileObj,
title: title === '' ? (fileName || 'Untitled') : title,
Expand Down Expand Up @@ -417,6 +418,7 @@ const CreateEditDocument = ({
const patchUrl = `/api/document/${document.id}`;
const resourceTypeAdditionalMetadata = resourceTypeMetadataObj(rt);
const newDocument = {
version: document.version,
title: title === '' ? 'Untitled' : title,
groups: orderOfGroupsShared.core.concat(orderOfGroupsShared.contributions),
slug: document.slug,
Expand Down
5 changes: 2 additions & 3 deletions src/components/DashboardChannels/AnnotationTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function AnnotationTile({
activityDate,
draggable,
tags,
maxNumberOfAnnotationTags = 3,
maxNumberOfAnnotationTags = 1,
onClick = () => {},
onDelete,
openInAnnotationStudio,
Expand All @@ -40,8 +40,7 @@ export default function AnnotationTile({
if (tags.length > maxNumberOfAnnotationTags) {
tileBadges = [
<TileBadge key="tag1" color="grey" text={tags[0]} />,
<TileBadge key="tag2" color="grey" text={tags[1]} marginLeft={5} />,
<TileBadge key="moreTags" color="grey" text={`+${tags.length - 2} more`} marginLeft={5} />,
<TileBadge key="moreTags" color="grey" text={`+${tags.length - 1}`} marginLeft={5} />,
];
} else {
tileBadges = tags.map((t, i) => <TileBadge key={t} color="grey" text={t} marginLeft={i > 0 ? 5 : 0} />);
Expand Down
44 changes: 28 additions & 16 deletions src/components/DashboardChannels/AnnotationsChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,33 +232,38 @@ export default function AnnotationsChannel({
byDateCreated: <CalendarEventFill size={14} style={{ marginRight: 4 }} />,
};

const byWithGroupId = (anno) => byGroupFilterMatch(anno?.creator?.withGroupId ? [anno?.creator?.withGroupId] : [], [selectedGroupId]);

const buttons = [
{
text: 'Mine',
textWidth: 40,
count: annotations[slug]?.countByPermissions === undefined
? 0
: annotations[slug]?.countByPermissions.mine,
count: (annotations[slug]?.mine || [])?.filter(byWithGroupId).length || 0,
// count: annotations[slug]?.countByPermissions === undefined
// ? 0
// : annotations[slug]?.countByPermissions.mine,
selected: selectedPermissions === 'mine',
onClick: () => { setSelectedPermissions('mine'); },
icon: <PersonFill size="1.2em" />,
},
{
text: 'Shared with group(s)',
textWidth: 145,
count: annotations[slug]?.countByPermissions === undefined
? 0
: annotations[slug]?.countByPermissions.shared,
count: (annotations[slug]?.shared || [])?.filter(byWithGroupId).length || 0,
// count: annotations[slug]?.countByPermissions === undefined
// ? 0
// : annotations[slug]?.countByPermissions.shared,
selected: selectedPermissions === 'shared',
onClick: () => { setSelectedPermissions('shared'); },
icon: <PeopleFill size="1.2em" />,
},
{
text: 'Shared with me',
textWidth: 115,
count: annotations[slug]?.countByPermissions === undefined
? 0
: annotations[slug]?.countByPermissions['shared-with-me'],
count: (annotations[slug] && (annotations[slug]['shared-with-me'] || [])?.filter(byWithGroupId).length) || 0,
// count: annotations[slug]?.countByPermissions === undefined
// ? 0
// : annotations[slug]?.countByPermissions['shared-with-me'],
selected: selectedPermissions === 'shared-with-me',
onClick: () => { setSelectedPermissions('shared-with-me'); },
icon: <PersonPlusFill size="1.2em" />,
Expand Down Expand Up @@ -305,18 +310,23 @@ export default function AnnotationsChannel({
};

const filterAnnotations = (f) => {
const annotationMatchesFilters = (a) => (
const annotationMatchesFilters = (a) => {

return (
byPermissionsIdeaSpaceFilterMatch({
user: session.user,
annotation: a,
filterPermissions: f.byPermissions,
})
&& byGroupFilterMatch(a.target.document.groups, f.byGroup)
&& (mode === 'as'
? byGroupFilterMatch(a.creator.withGroupId ? [a.creator.withGroupId] : [], [selectedGroupId])
: byGroupFilterMatch(a.target.document.groups, f.byGroup)
)
&& byDocumentFilterMatch(a.target.document.id, f.byDocument)
&& annotatedByFilterMatch(a.creator.id, f.annotatedBy)
&& byTagFilterMatch(a.body.tags, f.byTag)
&& byDateCreatedFilterMatch(a.created, f.byDateCreated)
);
)};

const filteredAnnos = [];
if (appliedFilters.byGroup.length === 0) {
Expand Down Expand Up @@ -1284,25 +1294,27 @@ export default function AnnotationsChannel({
annotationTiles = <EmptyListMessage text="No document selected" />;
} else if (annotations[slug] === undefined) {
annotationTiles = <EmptyListMessage />;
} else if (annotations[slug][selectedPermissions].length === 0) {
} else if (annotations[slug][selectedPermissions].filter(byWithGroupId).length === 0) {
annotationTiles = <EmptyListMessage />;
} else {
rawAnnotationTiles = annotations[slug][selectedPermissions];

const byGroupRawAnnotationTiles = rawAnnotationTiles.filter(byWithGroupId)

if (selectedPermissions === 'mine') {
annotationTiles = rawAnnotationTiles.map((anno) => toAnnotationsTile(anno, {
annotationTiles = byGroupRawAnnotationTiles.map((anno) => toAnnotationsTile(anno, {
maxNumberOfTags: maxNumberOfAnnotationTags,
shareableLink: `${origin}/documents/${anno.target.document.slug}?mine=true&aid=${anno._id}`,
setAlerts,
}));
} else if (selectedPermissions === 'shared') {
annotationTiles = rawAnnotationTiles.map((anno) => toAnnotationsTile(anno, {
annotationTiles = byGroupRawAnnotationTiles.map((anno) => toAnnotationsTile(anno, {
maxNumberOfTags: maxNumberOfAnnotationTags,
shareableLink: `${origin}/documents/${anno.target.document.slug}?mine=false&aid=${anno._id}`,
setAlerts,
}));
} else if (selectedPermissions === 'shared-with-me') {
annotationTiles = rawAnnotationTiles.map((anno) => toAnnotationsTile(anno, {
annotationTiles = byGroupRawAnnotationTiles.map((anno) => toAnnotationsTile(anno, {
maxNumberOfTags: maxNumberOfAnnotationTags,
shareableLink: `${origin}/documents/${anno.target.document.slug}?mine=false&&sharedWithMe=true&aid=${anno._id}`,
setAlerts,
Expand Down
3 changes: 1 addition & 2 deletions src/components/DashboardChannels/DocumentTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export default function DocumentTile({
const g = groups.slice();

if (g.length > 0) {
console.log('groups: ', groups)
const indexOfSelectedGroup = groups.findIndex((grp) => grp?._id === selectedGroupId);
const selectedGroup = g.splice(indexOfSelectedGroup, 1)[0];
tileBadges = [
Expand Down Expand Up @@ -82,7 +81,7 @@ export default function DocumentTile({
</Popover>
)}
color="grey"
text={`+${g.length} more`}
text={`+${g.length}`}
marginLeft={5}
/>);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/components/DashboardChannels/DocumentsChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default function DocumentsChannel({
documentPermissions,
setDocumentPermissions,
groupMembers,
maxNumberOfDocumentGroups = 3,
maxNumberOfDocumentGroups = 1,
dashboardState,
retry,
setRetry,
Expand Down
2 changes: 2 additions & 0 deletions src/components/Document/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export default function Document({
displayAnnotationsInChannels,
setAlerts,
setShowCannotAnnotateDocumentToast,
defaultGroupFilteringId,
}) {
const myRef = useRef();
const documentZoomRef = useRef(documentZoom);
Expand Down Expand Up @@ -291,6 +292,7 @@ export default function Document({
id: user.id,
name: user.name,
email: user.email,
withGroupId: defaultGroupFilteringId,
},
permissions: {
groups: [],
Expand Down
Loading

0 comments on commit fa32db2

Please sign in to comment.