From 1f8686f0fc8c17beb32fd8e6446f8009d9f96dfb Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Thu, 26 Oct 2023 01:17:43 +0100 Subject: [PATCH] feat: label fat fingerer added warning for double labels --- src/handlers/pricing/action.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/handlers/pricing/action.ts b/src/handlers/pricing/action.ts index 7e9673c6f..640b19eb6 100644 --- a/src/handlers/pricing/action.ts +++ b/src/handlers/pricing/action.ts @@ -2,6 +2,7 @@ import { getBotConfig, getBotContext, getLogger } from "../../bindings"; import { GLOBAL_STRINGS } from "../../configs"; import { addCommentToIssue, addLabelToIssue, clearAllPriceLabelsOnIssue, createLabel, getLabel, calculateWeight, getAllLabeledEvents } from "../../helpers"; import { Payload, UserType } from "../../types"; +import { ErrorDiff } from "../../utils/helpers"; import { handleLabelsAccess } from "../access"; import { getTargetPriceLabel } from "../shared"; @@ -12,6 +13,18 @@ export const pricingLabelLogic = async (): Promise => { const payload = context.payload as Payload; if (!payload.issue) return; const labels = payload.issue.labels; + + const doubleTimePrefix = labels.filter((label) => label.name.toString().startsWith("Time:")).length > 1; + const doublePriorityPrefix = labels.filter((label) => label.name.toString().startsWith("Priority:")).length > 1; + const doublePrefix = doubleTimePrefix || doublePriorityPrefix; + + if (doublePrefix) { + await addCommentToIssue( + ErrorDiff("Be careful not to add two labels of the same catergory or issue pricing will default to the lowest value."), + payload.issue.number + ); + } + const labelNames = labels.map((i) => i.name); logger.info(`Checking if the issue is a parent issue.`); if (payload.issue.body && isParentIssue(payload.issue.body)) {