Skip to content
Snippets Groups Projects
Commit e2a9c3af authored by Piotr Gawron's avatar Piotr Gawron
Browse files

show comments in the left tab

parent 59ff89e8
No related branches found
No related tags found
2 merge requests!223reset the pin numbers before search results are fetch (so the results will be...,!201Resolve "[MIN-114] Browse comments on the map"
...@@ -2,6 +2,7 @@ import { ZERO } from '@/constants/common'; ...@@ -2,6 +2,7 @@ import { ZERO } from '@/constants/common';
import { import {
currentDrawerBioEntityRelatedSubmapSelector, currentDrawerBioEntityRelatedSubmapSelector,
currentDrawerBioEntitySelector, currentDrawerBioEntitySelector,
currentDrawerCommentsSelector,
} from '@/redux/bioEntity/bioEntity.selectors'; } from '@/redux/bioEntity/bioEntity.selectors';
import { import {
getChemicalsForBioEntityDrawerTarget, getChemicalsForBioEntityDrawerTarget,
...@@ -11,6 +12,7 @@ import { useAppDispatch } from '@/redux/hooks/useAppDispatch'; ...@@ -11,6 +12,7 @@ import { useAppDispatch } from '@/redux/hooks/useAppDispatch';
import { useAppSelector } from '@/redux/hooks/useAppSelector'; import { useAppSelector } from '@/redux/hooks/useAppSelector';
import { DrawerHeading } from '@/shared/DrawerHeading'; import { DrawerHeading } from '@/shared/DrawerHeading';
import { ElementSearchResultType } from '@/types/models'; import { ElementSearchResultType } from '@/types/models';
import { CommentItem } from '@/components/Map/Drawer/BioEntityDrawer/Comments/CommentItem.component';
import { CollapsibleSection } from '../ExportDrawer/CollapsibleSection'; import { CollapsibleSection } from '../ExportDrawer/CollapsibleSection';
import { AnnotationItem } from './AnnotationItem'; import { AnnotationItem } from './AnnotationItem';
import { AssociatedSubmap } from './AssociatedSubmap'; import { AssociatedSubmap } from './AssociatedSubmap';
...@@ -23,6 +25,7 @@ const TARGET_PREFIX: ElementSearchResultType = `ALIAS`; ...@@ -23,6 +25,7 @@ const TARGET_PREFIX: ElementSearchResultType = `ALIAS`;
export const BioEntityDrawer = (): React.ReactNode => { export const BioEntityDrawer = (): React.ReactNode => {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const bioEntityData = useAppSelector(currentDrawerBioEntitySelector); const bioEntityData = useAppSelector(currentDrawerBioEntitySelector);
const commentsData = useAppSelector(currentDrawerCommentsSelector);
const relatedSubmap = useAppSelector(currentDrawerBioEntityRelatedSubmapSelector); const relatedSubmap = useAppSelector(currentDrawerBioEntityRelatedSubmapSelector);
const currentTargetId = bioEntityData?.id ? `${TARGET_PREFIX}:${bioEntityData.id}` : ''; const currentTargetId = bioEntityData?.id ? `${TARGET_PREFIX}:${bioEntityData.id}` : '';
...@@ -38,6 +41,7 @@ export const BioEntityDrawer = (): React.ReactNode => { ...@@ -38,6 +41,7 @@ export const BioEntityDrawer = (): React.ReactNode => {
} }
const isReferenceAvailable = bioEntityData.references.length > ZERO; const isReferenceAvailable = bioEntityData.references.length > ZERO;
const isCommentAvailable = commentsData.length > ZERO;
return ( return (
<div className="h-calc-drawer" data-testid="bioentity-drawer"> <div className="h-calc-drawer" data-testid="bioentity-drawer">
...@@ -86,6 +90,9 @@ export const BioEntityDrawer = (): React.ReactNode => { ...@@ -86,6 +90,9 @@ export const BioEntityDrawer = (): React.ReactNode => {
isShowGroupedOverlays={Boolean(relatedSubmap)} isShowGroupedOverlays={Boolean(relatedSubmap)}
isShowOverlayBioEntityName={Boolean(relatedSubmap)} isShowOverlayBioEntityName={Boolean(relatedSubmap)}
/> />
{isCommentAvailable && <div> Comments</div>}
{isCommentAvailable &&
commentsData.map(comment => <CommentItem key={comment.id} comment={comment} />)}
</div> </div>
</div> </div>
); );
......
import { Icon } from '@/shared/Icon';
import { Comment } from '@/types/models';
import React from 'react';
interface CommentItemProps {
comment: Comment;
}
export const CommentItem = (commentItemProps: CommentItemProps): JSX.Element => {
const { comment } = commentItemProps;
const { owner, content } = comment;
return (
<div className="flex justify-between">
<div> {owner}</div>
<div> {content} </div>
<Icon name="arrow" className="h-6 w-6 fill-font-500" />
</div>
);
};
...@@ -3,9 +3,12 @@ import { ONE, SIZE_OF_EMPTY_ARRAY, ZERO } from '@/constants/common'; ...@@ -3,9 +3,12 @@ import { ONE, SIZE_OF_EMPTY_ARRAY, ZERO } from '@/constants/common';
import { BioEntityWithPinType } from '@/types/bioEntity'; import { BioEntityWithPinType } from '@/types/bioEntity';
import { ElementIdTabObj } from '@/types/elements'; import { ElementIdTabObj } from '@/types/elements';
import { MultiSearchData } from '@/types/fetchDataState'; import { MultiSearchData } from '@/types/fetchDataState';
import { BioEntity, BioEntityContent, MapModel } from '@/types/models'; import { BioEntity, BioEntityContent, Comment, MapModel } from '@/types/models';
import { createSelector } from '@reduxjs/toolkit'; import { createSelector } from '@reduxjs/toolkit';
import { commentElementSelector } from '@/redux/comment/comment.selectors'; import {
allCommentsSelectorOfCurrentMap,
commentElementSelector,
} from '@/redux/comment/comment.selectors';
import { import {
allChemicalsBioEntitesOfAllMapsSelector, allChemicalsBioEntitesOfAllMapsSelector,
allChemicalsBioEntitesOfCurrentMapSelector, allChemicalsBioEntitesOfCurrentMapSelector,
...@@ -260,10 +263,6 @@ export const currentDrawerBioEntitySelector = createSelector( ...@@ -260,10 +263,6 @@ export const currentDrawerBioEntitySelector = createSelector(
commentElementSelector, commentElementSelector,
currentSearchedBioEntityId, currentSearchedBioEntityId,
(bioEntities, commentElement, currentBioEntityId): BioEntity | undefined => { (bioEntities, commentElement, currentBioEntityId): BioEntity | undefined => {
// eslint-disable-next-line no-console
console.log(currentBioEntityId);
// eslint-disable-next-line no-console
console.log(commentElement);
if (commentElement && commentElement.id === currentBioEntityId) { if (commentElement && commentElement.id === currentBioEntityId) {
return commentElement; return commentElement;
} }
...@@ -311,3 +310,16 @@ export const allVisibleBioEntitiesIdsSelector = createSelector( ...@@ -311,3 +310,16 @@ export const allVisibleBioEntitiesIdsSelector = createSelector(
return [...elements, ...submapConnections].map(e => e.id); return [...elements, ...submapConnections].map(e => e.id);
}, },
); );
export const currentDrawerCommentsSelector = createSelector(
currentDrawerBioEntitySelector,
allCommentsSelectorOfCurrentMap,
(element, comments): Comment[] => {
if (element) {
return comments.filter(
comment => comment.modelId === element.model && Number(comment.elementId) === element.id,
);
}
return [];
},
);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment