From 61a3f6bf23d1d42e09942309ddbeabfc87f11dcc Mon Sep 17 00:00:00 2001 From: Anton Strogonoff Date: Thu, 19 Mar 2020 11:55:19 +0900 Subject: [PATCH] feat: Make past drill plan revisions read-only --- src/renderer/plans/edit-drill-plan.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/renderer/plans/edit-drill-plan.tsx b/src/renderer/plans/edit-drill-plan.tsx index d4f89ba..c306ae2 100644 --- a/src/renderer/plans/edit-drill-plan.tsx +++ b/src/renderer/plans/edit-drill-plan.tsx @@ -47,6 +47,9 @@ export const EditDrillPlan: React.FC = function ({ planID }) const [sanitizedPlanRevision, updateSanitizedPlanRevision] = useState(undefined); + // TODO: Get max ID instead. + // Could theoretically fail, mixes up index in array and revision ID: + const isLatestRevision = selectedRevisionID === revisions.length; const canAmendRevision = selectedRevisionID === revisions.length && selectedRevisionID > 0; @@ -248,6 +251,7 @@ export const EditDrillPlan: React.FC = function ({ planID }) onClick={commitInProgress ? undefined : () => commitChanges()} active={commitInProgress} disabled={ + !isLatestRevision || sanitizedPlanRevision === undefined || bcPlan.isUpdating || !revision || @@ -263,10 +267,10 @@ export const EditDrillPlan: React.FC = function ({ planID }) );