import React from 'react';
import { Select, Icon, Dropdown } from '../../components';
import PropTypes from 'prop-types';
function SegmentationDropDownRow({
segmentations = [],
activeSegmentation,
onActiveSegmentationChange,
disableEditing,
onToggleSegmentationVisibility,
onSegmentationEdit,
onSegmentationDownload,
onSegmentationDownloadRTSS,
storeSegmentation,
onSegmentationDelete,
onSegmentationAdd,
}) {
const handleChange = option => {
onActiveSegmentationChange(option.value); // Notify the parent
};
const selectOptions = segmentations.map(s => ({
value: s.id,
label: s.label,
}));
if (!activeSegmentation) {
return null;
}
return (
{
e.stopPropagation();
}}
>
{
onSegmentationAdd();
},
},
]
: []),
...(!disableEditing
? [
{
title: 'Rename',
onClick: () => {
onSegmentationEdit(activeSegmentation.id);
},
},
]
: []),
{
title: 'Delete',
onClick: () => {
onSegmentationDelete(activeSegmentation.id);
},
},
...(!disableEditing
? [
{
title: 'Export DICOM SEG',
onClick: () => {
storeSegmentation(activeSegmentation.id);
},
},
]
: []),
...[
{
title: 'Download DICOM SEG',
onClick: () => {
onSegmentationDownload(activeSegmentation.id);
},
},
{
title: 'Download DICOM RTSTRUCT',
onClick: () => {
onSegmentationDownloadRTSS(activeSegmentation.id);
},
},
],
]}
>
{selectOptions?.length && (
);
}
SegmentationDropDownRow.propTypes = {
segmentations: PropTypes.arrayOf(
PropTypes.shape({
id: PropTypes.string.isRequired,
label: PropTypes.string.isRequired,
})
).isRequired,
activeSegmentation: PropTypes.shape({
id: PropTypes.string.isRequired,
isVisible: PropTypes.bool.isRequired,
}),
onActiveSegmentationChange: PropTypes.func.isRequired,
disableEditing: PropTypes.bool,
onToggleSegmentationVisibility: PropTypes.func,
onSegmentationEdit: PropTypes.func,
onSegmentationDownload: PropTypes.func,
onSegmentationDownloadRTSS: PropTypes.func,
storeSegmentation: PropTypes.func,
onSegmentationDelete: PropTypes.func,
onSegmentationAdd: PropTypes.func,
};
SegmentationDropDownRow.defaultProps = {
segmentations: [],
disableEditing: false,
};
export default SegmentationDropDownRow;