[UI] Lock action (#11981)

- Toggle part lock directly from existing icon
This commit is contained in:
Oliver 2026-05-22 10:21:23 +10:00 committed by GitHub
parent 9908870a81
commit 8b9ea43b5b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 3 deletions

View File

@ -23,6 +23,7 @@ import {
IconListDetails,
IconListTree,
IconLock,
IconLockOpen,
IconPackages,
IconSearch,
IconShoppingCart,
@ -1132,9 +1133,20 @@ export default function PartDetail() {
<PageDetail
title={`${t`Part`}: ${part.full_name}`}
icon={
part?.locked ? (
<IconLock aria-label='part-lock-icon' />
) : undefined
<ActionIcon
aria-label='part-lock-icon'
variant='transparent'
disabled={!user.hasChangeRole(UserRoles.part)}
onClick={() => {
api
.patch(apiUrl(ApiEndpoints.part_list, part.pk), {
locked: !part.locked
})
.then(refreshInstance);
}}
>
{part?.locked ? <IconLock /> : <IconLockOpen />}
</ActionIcon>
}
subtitle={part.description}
imageUrl={part.image}