Skip to content

Commit

Permalink
Merge pull request #156 from developmentseed/enhance/restrict-add-cla…
Browse files Browse the repository at this point in the history
…ss-button-to-the-base-model

Restrict Add Class button to the base model checkpoint
  • Loading branch information
vgeorge authored Apr 3, 2024
2 parents 4f8c849 + 3c16f04 commit 7ab0d52
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ import EditClass from './add-class.js';

function RetrainTab({ className }) {
const actorRef = ProjectMachineContext.useActorRef();

const currentCheckpoint = ProjectMachineContext.useSelector(
selectors.currentCheckpoint
);
const canAddClass = currentCheckpoint?.parent === null;

const retrainClasses = ProjectMachineContext.useSelector(
selectors.retrainClasses
);
Expand Down Expand Up @@ -170,17 +176,22 @@ function RetrainTab({ className }) {
as={DropdownTrigger}
variation='primary-plain'
useIcon='plus--small'
title='Open dropdown'
className='add__class'
size='medium'
{...props}
visuallyDisabled={!canAddClass}
info={
canAddClass
? 'Add a new class'
: 'New classes can only be added to the base model'
}
>
Add Class
</AddClassButton>
)}
className='add-class__dropdown'
>
<EditClass />
{canAddClass && <EditClass />}
</Dropdown>
</ClassList>
</>
Expand Down

0 comments on commit 7ab0d52

Please sign in to comment.