From e2dc8bf84a980f3f713fc78d9485f1407b88218a Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 5 Nov 2024 13:02:50 +0000 Subject: [PATCH 1/2] PUI panel tab updates Hide build order tabs for cancelled or complete orders --- src/frontend/src/pages/build/BuildDetail.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/frontend/src/pages/build/BuildDetail.tsx b/src/frontend/src/pages/build/BuildDetail.tsx index 75d1826bac05..f7c0e0c1aeaa 100644 --- a/src/frontend/src/pages/build/BuildDetail.tsx +++ b/src/frontend/src/pages/build/BuildDetail.tsx @@ -64,6 +64,8 @@ export default function BuildDetail() { const user = useUserState(); + const buildStatus = useStatusCodes({ modelType: ModelType.build }); + const { instance: build, refreshInstance, @@ -269,8 +271,10 @@ export default function BuildDetail() { ) : ( - ) - // TODO: Hide if build is complete + ), + hidden: + build.status == buildStatus.COMPLETE || + build.status == buildStatus.CANCELLED }, { name: 'complete-outputs', @@ -291,6 +295,9 @@ export default function BuildDetail() { name: 'allocated-stock', label: t`Allocated Stock`, icon: , + hidden: + build.status == buildStatus.COMPLETE || + build.status == buildStatus.CANCELLED, content: build.pk ? ( ) : ( @@ -355,7 +362,7 @@ export default function BuildDetail() { model_id: build.pk }) ]; - }, [build, id, user]); + }, [build, id, user, buildStatus]); const buildOrderFields = useBuildOrderFields({ create: false }); @@ -379,8 +386,6 @@ export default function BuildDetail() { modelType: ModelType.build }); - const buildStatus = useStatusCodes({ modelType: ModelType.build }); - const cancelOrder = useCreateApiFormModal({ url: apiUrl(ApiEndpoints.build_order_cancel, build.pk), title: t`Cancel Build Order`, From 5651c9c2c1d3c6accd528a1e322d5c0df0494950 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 5 Nov 2024 13:06:58 +0000 Subject: [PATCH 2/2] Fix a // TODO entry --- src/frontend/src/tables/settings/CustomUnitsTable.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/frontend/src/tables/settings/CustomUnitsTable.tsx b/src/frontend/src/tables/settings/CustomUnitsTable.tsx index a26fc2152d30..4da699989eee 100644 --- a/src/frontend/src/tables/settings/CustomUnitsTable.tsx +++ b/src/frontend/src/tables/settings/CustomUnitsTable.tsx @@ -95,15 +95,15 @@ export default function CustomUnitsTable() { let actions = []; actions.push( - // TODO: Adjust actions based on user permissions newUnit.open()} + hidden={!user.isStaff() || !user.hasChangeRole(UserRoles.admin)} /> ); return actions; - }, []); + }, [user]); return ( <>