Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP feat disabling Segmentation edit #223

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import { useTranslation } from 'react-i18next';
export default function PanelSegmentation({
servicesManager,
commandsManager,
appConfig,
}) {
const disableEditing = appConfig?.disableEditing;
const { segmentationService, uiDialogService } = servicesManager.services;

const { t } = useTranslation('PanelSegmentation');
Expand Down Expand Up @@ -203,6 +205,7 @@ export default function PanelSegmentation({
onSegmentationEdit={onSegmentationEdit}
onSegmentClick={onSegmentClick}
onSegmentEdit={onSegmentEdit}
disableEditing={disableEditing}
onSegmentColorClick={onSegmentColorClick}
onSegmentDelete={onSegmentDelete}
onToggleSegmentVisibility={onToggleSegmentVisibility}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ const AddNewSegmentRow = ({
onSegmentAdd,
isVisible,
showAddSegment,
disableEditing,
}) => {
return (
<div>
<div className="flex items-center pl-[29px] bg-black text-primary-active hover:opacity-80 cursor-pointer text-[12px] py-1">
{showAddSegment && (
{showAddSegment && !disableEditing && (
<div className="flex items-center" onClick={() => onSegmentAdd()}>
<Icon name="row-add" className="w-5 h-5" />
<div className="">Add Segment</div>
Expand Down Expand Up @@ -53,6 +54,7 @@ const SegmentGroupHeader = ({
isActive,
segmentCount,
onSegmentationEdit,
disableEditing,
onSegmentationDelete,
}) => {
return (
Expand Down Expand Up @@ -92,34 +94,36 @@ const SegmentGroupHeader = ({
e.stopPropagation();
}}
>
<Dropdown
id="segmentation-dropdown"
showDropdownIcon={false}
list={[
{
title: 'Rename',
onClick: () => {
onSegmentationEdit(id);
{!disableEditing && (
<Dropdown
id="segmentation-dropdown"
showDropdownIcon={false}
list={[
{
title: 'Rename',
onClick: () => {
onSegmentationEdit(id);
},
},
},
{
title: 'Delete',
onClick: () => {
onSegmentationDelete(id);
{
title: 'Delete',
onClick: () => {
onSegmentationDelete(id);
},
},
},
]}
>
<IconButton
id={''}
variant="text"
color="inherit"
size="initial"
className="text-primary-active"
]}
>
<Icon name="panel-group-more" />
</IconButton>
</Dropdown>
<IconButton
id={''}
variant="text"
color="inherit"
size="initial"
className="text-primary-active"
>
<Icon name="panel-group-more" />
</IconButton>
</Dropdown>
)}
</div>
</div>
);
Expand All @@ -134,6 +138,7 @@ const SegmentationGroup = ({
onSegmentClick,
isMinimized,
onSegmentColorClick,
disableEditing,
showAddSegment,
segments,
activeSegmentIndex,
Expand Down Expand Up @@ -162,6 +167,7 @@ const SegmentationGroup = ({
segmentCount={segmentCount}
onSegmentationEdit={onSegmentationEdit}
onSegmentationDelete={onSegmentationDelete}
disableEditing={disableEditing}
/>
{!isMinimized && (
<div className="flex flex-col flex-auto min-h-0">
Expand All @@ -171,7 +177,8 @@ const SegmentationGroup = ({
isVisible={isVisible}
onToggleSegmentationVisibility={onToggleSegmentationVisibility}
id={id}
showAddSegment={showAddSegment}
disableEditing={disableEditing}
showAddSegment={showAddSegment && !disableEditing}
/>
<div className="flex flex-col min-h-0 ohif-scrollbar overflow-y-hidden">
{!!segments.length &&
Expand All @@ -198,6 +205,7 @@ const SegmentationGroup = ({
isLocked={isLocked}
isVisible={isVisible}
onClick={onSegmentClick}
disableEditing={disableEditing}
onEdit={onSegmentEdit}
onDelete={onSegmentDelete}
showSegmentDelete={showSegmentDelete}
Expand Down Expand Up @@ -241,6 +249,7 @@ SegmentationGroup.propTypes = {
onSegmentationConfigChange: PropTypes.func.isRequired,
onSegmentationDelete: PropTypes.func.isRequired,
onSegmentEdit: PropTypes.func.isRequired,
disableEditing: PropTypes.bool,
};

SegmentationGroup.defaultProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const SegmentItem = ({
isVisible,
color,
showSegmentDelete,
disableEditing,
isLocked = false,
onClick,
onEdit,
Expand Down Expand Up @@ -116,17 +117,20 @@ const SegmentItem = ({
)}
{isHovering && (
<div className={classnames('flex items-center')}>
<Icon
name="row-edit"
className={classnames('w-5 h-5', {
'text-white': isLocked,
'text-primary-light': !isLocked,
})}
onClick={e => {
e.stopPropagation();
onEdit(segmentationId, segmentIndex);
}}
/>
{!disableEditing && (
<Icon
name="row-edit"
className={classnames('w-5 h-5', {
'text-white': isLocked,
'text-primary-light': !isLocked,
})}
onClick={e => {
e.stopPropagation();
onEdit(segmentationId, segmentIndex);
}}
/>
)}

{isVisible ? (
<Icon
name="row-hide"
Expand Down Expand Up @@ -224,6 +228,7 @@ SegmentItem.propTypes = {
segmentIndex: PropTypes.number.isRequired,
segmentationId: PropTypes.string.isRequired,
label: PropTypes.string,
disableEditing: PropTypes.bool,
// color as array
color: PropTypes.array,
isActive: PropTypes.bool.isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const SegmentationGroupTable = ({
onSegmentClick,
onSegmentAdd,
segmentationConfig,
disableEditing,
onSegmentDelete,
onSegmentEdit,
onToggleSegmentationVisibility,
Expand Down Expand Up @@ -60,6 +61,7 @@ const SegmentationGroupTable = ({
id={id}
key={id}
label={label}
disableEditing={disableEditing}
isMinimized={isMinimized[id]}
segments={segments}
showAddSegment={showAddSegment}
Expand All @@ -82,7 +84,7 @@ const SegmentationGroupTable = ({
);
})}
</div>
{showAddSegmentation && (
{showAddSegmentation && !disableEditing && (
<div
className="flex items-center cursor-pointer hover:opacity-80 text-primary-active bg-black text-[12px] pl-1 h-[45px]"
onClick={() => onSegmentationAdd()}
Expand All @@ -106,6 +108,7 @@ SegmentationGroupTable.propTypes = {
onToggleVisibility: PropTypes.func.isRequired,
onToggleVisibilityAll: PropTypes.func.isRequired,
segmentationConfig: PropTypes.object,
disableEditing: PropTypes.bool,
};

SegmentationGroupTable.defaultProps = {
Expand Down