forked from OHIF/Viewers
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddSegmentationRow.tsx
More file actions
56 lines (50 loc) · 1.7 KB
/
AddSegmentationRow.tsx
File metadata and controls
56 lines (50 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import React from 'react';
import { Icons } from '../Icons';
import { useTranslation } from 'react-i18next';
import { useSegmentationTableContext } from './contexts';
export const AddSegmentationRow: React.FC<{ children?: React.ReactNode }> = ({
children = null,
}) => {
const { t } = useTranslation('SegmentationPanel');
const {
onSegmentationAdd,
data,
disableEditing,
mode,
disabled,
segmentationRepresentationTypes,
} = useSegmentationTableContext('AddSegmentationRow');
// Check if we have at least one segmentation of the representation type for the panel this component is contained in.
const hasRepresentationType =
(!segmentationRepresentationTypes && data.length > 0) ||
data.some(info => segmentationRepresentationTypes?.includes(info.representation?.type));
if (hasRepresentationType && mode === 'collapsed') {
return null;
}
if (disableEditing) {
return null;
}
return (
<div
data-cy="addSegmentation"
className={`group ${disabled ? 'pointer-events-none cursor-not-allowed opacity-70' : ''}`}
onClick={() =>
!disabled &&
onSegmentationAdd({
segmentationId: '',
segmentationRepresentationType: segmentationRepresentationTypes?.[0],
})
}
>
{children}
<div className="text-primary group-hover:bg-secondary-dark flex items-center rounded-[4px] pl-1 group-hover:cursor-pointer">
<div className="grid h-[28px] w-[28px] place-items-center">
{disabled ? <Icons.Info /> : <Icons.Add />}
</div>
<span className="text-[13px]">
{t(disabled ? 'Segmentation not supported' : 'Add segmentation')}
</span>
</div>
</div>
);
};