Merge pull request #341 from makeplane/chore/delete_state_options

chore: cannot have empty state group
This commit is contained in:
Aaryan Khandelwal 2023-03-01 10:48:40 +05:30 committed by GitHub
commit 2c0b27d838
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 12 deletions

View File

@ -181,20 +181,29 @@ export const SingleState: React.FC<Props> = ({
</button> </button>
)} )}
<button
type="button"
className={`${state.default ? "cursor-not-allowed" : ""} grid place-items-center`}
onClick={handleDeleteState}
disabled={state.default}
>
<Tooltip tooltipContent="Cannot delete the default state." disabled={!state.default}>
<TrashIcon className="h-4 w-4 text-red-400" />
</Tooltip>
</button>
<button type="button" className="grid place-items-center" onClick={handleEditState}> <button type="button" className="grid place-items-center" onClick={handleEditState}>
<PencilSquareIcon className="h-4 w-4 text-gray-400" /> <PencilSquareIcon className="h-4 w-4 text-gray-400" />
</button> </button>
<button
type="button"
className={`${
state.default || groupLength === 1 ? "cursor-not-allowed" : ""
} grid place-items-center`}
onClick={handleDeleteState}
disabled={state.default || groupLength === 1}
>
{state.default ? (
<Tooltip tooltipContent="Cannot delete the default state.">
<TrashIcon className="h-4 w-4 text-red-400" />
</Tooltip>
) : groupLength === 1 ? (
<Tooltip tooltipContent="Cannot have an empty group.">
<TrashIcon className="h-4 w-4 text-red-400" />
</Tooltip>
) : (
<TrashIcon className="h-4 w-4 text-red-400" />
)}
</button>
</div> </div>
</div> </div>
); );

View File

@ -38,7 +38,7 @@ export const Tooltip: React.FC<Props> = ({
disabled={disabled} disabled={disabled}
content={ content={
<div <div
className={`flex flex-col justify-center items-start gap-1 max-w-[600px] text-xs rounded-md bg-white p-2 shadow-md capitalize text-left ${className}`} className={`flex flex-col justify-center items-start gap-1 max-w-[600px] text-xs rounded-md bg-white p-2 shadow-md text-left ${className}`}
> >
{tooltipHeading ? ( {tooltipHeading ? (
<> <>