From 84b70aa7b3458b92a06705f0b1e55303b5e107fc Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Tue, 27 Sep 2022 18:11:13 +0000 Subject: [PATCH] UI: If MR is applied, don't do the canApply check and display "RESOLVED" --- src/Vervis/Handler/Cloth.hs | 7 +++++-- templates/cloth/one.hamlet | 33 ++++++++++++++++++--------------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/Vervis/Handler/Cloth.hs b/src/Vervis/Handler/Cloth.hs index 621168a..4bede0f 100644 --- a/src/Vervis/Handler/Cloth.hs +++ b/src/Vervis/Handler/Cloth.hs @@ -317,8 +317,11 @@ getClothR loomHash clothHash = do let patchIDs = NE.map entityKey patches diffs = NE.map (patchContent . entityVal) $ NE.reverse patches (repoID, _, _, maybeBranch) = targetRepo - errorOrCanApply <- runExceptT $ canApplyPatches repoID maybeBranch diffs - return (bundleID, patchIDs, errorOrCanApply) + maybeErrorOrCanApply <- + case ticketStatus ticket of + TSClosed -> pure Nothing + _ -> Just <$> runExceptT (canApplyPatches repoID maybeBranch diffs) + return (bundleID, patchIDs, maybeErrorOrCanApply) hashMessageKey <- handlerToWidget getEncodeKeyHashid let desc :: Widget desc = toWidget $ markupHTML $ ticketDescription ticket diff --git a/templates/cloth/one.hamlet b/templates/cloth/one.hamlet index bfb088e..65f368c 100644 --- a/templates/cloth/one.hamlet +++ b/templates/cloth/one.hamlet @@ -54,7 +54,7 @@ $with (_repoID, repoHash, name, maybeBranch) <- targetRepo #{branch} -$maybe (bundleID, patchIDs, errorOrCanApply) <- mbundle' +$maybe (bundleID, patchIDs, maybeErrorOrCanApply) <- mbundle'
Bundle @@ -66,20 +66,23 @@ $maybe (bundleID, patchIDs, errorOrCanApply) <- mbundle' #{keyHashidText $ hashPatch patchID}
- Status: - $case errorOrCanApply - $of Left e - - [Error! #{e}] - ^{applyButton "Try applying anyway"} - $of Right False - - [Apply check failed! Possibly conflicts exist] - ^{applyButton "Try applying anyway"} - $of Right True - - [Can apply!] - ^{applyButton "Apply"} + Status: # + $maybe errorOrCanApply <- maybeErrorOrCanApply + $case errorOrCanApply + $of Left e + + [Error! #{e}] + ^{applyButton "Try applying anyway"} + $of Right False + + [Apply check failed! Possibly conflicts exist] + ^{applyButton "Try applying anyway"} + $of Right True + + [Can apply!] + ^{applyButton "Apply"} + $nothing + RESOLVED