From 0a5957e361525a541b8b680d8ebd0f293ef50705 Mon Sep 17 00:00:00 2001 From: Walter Galvao Date: Sun, 22 Sep 2024 03:50:49 -0300 Subject: [PATCH] chore: address review --- .../form-pr-size-labeler-settings.tsx | 8 +-- .../settings/pr-size-labeler/page.tsx | 54 +++++++++---------- .../settings/pr-size-labeler/types.ts | 40 +++++++------- .../settings/pr-title-check/page.tsx | 17 +++--- .../automations/settings/use-automation.tsx | 4 ++ .../app/settings/integrations/slack/page.tsx | 15 ------ 6 files changed, 64 insertions(+), 74 deletions(-) diff --git a/apps/web/src/app/automations/settings/pr-size-labeler/components/form-pr-size-labeler-settings/form-pr-size-labeler-settings.tsx b/apps/web/src/app/automations/settings/pr-size-labeler/components/form-pr-size-labeler-settings/form-pr-size-labeler-settings.tsx index e16b783..1ad7ecf 100644 --- a/apps/web/src/app/automations/settings/pr-size-labeler/components/form-pr-size-labeler-settings/form-pr-size-labeler-settings.tsx +++ b/apps/web/src/app/automations/settings/pr-size-labeler/components/form-pr-size-labeler-settings/form-pr-size-labeler-settings.tsx @@ -28,8 +28,8 @@ export const FormPrSizeLabelerSettings = ({ {form.values.enabled && ( - Object.keys(form.values.settings) as Array< - keyof typeof form.values.settings + Object.keys(form.values.settings.labels) as Array< + keyof typeof form.values.settings.labels > ).map((size) => ( diff --git a/apps/web/src/app/automations/settings/pr-size-labeler/page.tsx b/apps/web/src/app/automations/settings/pr-size-labeler/page.tsx index 9c3293b..f811028 100644 --- a/apps/web/src/app/automations/settings/pr-size-labeler/page.tsx +++ b/apps/web/src/app/automations/settings/pr-size-labeler/page.tsx @@ -10,10 +10,8 @@ import { useForm, zodResolver } from "@mantine/form"; import { useEffect, useMemo, FormEventHandler } from "react"; import { useDrawerPage } from "../../../../providers/drawer-page.provider"; import { FormPrSizeLabeler } from "./types"; -import { useNavigate } from "react-router-dom"; export const AutomationPrSizeLabelerPage = () => { - const navigate = useNavigate(); const { automation, automationSettings, query, mutation, mutate } = useAutomationSettings(AutomationType.PR_SIZE_LABELER); @@ -26,29 +24,35 @@ export const AutomationPrSizeLabelerPage = () => { }); useEffect(() => { - const settings = automationSettings?.settings as any; + const settings = automationSettings?.settings as + | FormPrSizeLabeler["settings"] + | undefined + | null; + form.setValues({ enabled: automationSettings?.enabled || false, settings: { - tiny: { - label: settings?.labels?.tiny?.label || "tiny", - color: settings?.labels?.tiny?.color || "#69db7c", - }, - small: { - label: settings?.labels?.small?.label || "small", - color: settings?.labels?.small?.color || "#69db7c", - }, - medium: { - label: settings?.labels?.medium?.label || "medium", - color: settings?.labels?.medium?.color || "#a6a7ab", - }, - large: { - label: settings?.labels?.large?.label || "large", - color: settings?.labels?.large?.color || "#ff8787", - }, - huge: { - label: settings?.labels?.huge?.label || "huge", - color: settings?.labels?.huge?.color || "#ff8787", + labels: { + tiny: { + label: settings?.labels?.tiny?.label || "tiny", + color: settings?.labels?.tiny?.color || "#69db7c", + }, + small: { + label: settings?.labels?.small?.label || "small", + color: settings?.labels?.small?.color || "#69db7c", + }, + medium: { + label: settings?.labels?.medium?.label || "medium", + color: settings?.labels?.medium?.color || "#a6a7ab", + }, + large: { + label: settings?.labels?.large?.label || "large", + color: settings?.labels?.large?.color || "#ff8787", + }, + huge: { + label: settings?.labels?.huge?.label || "huge", + color: settings?.labels?.huge?.color || "#ff8787", + }, }, }, }); @@ -67,8 +71,6 @@ export const AutomationPrSizeLabelerPage = () => { settings: form.values.settings, enabled: form.values.enabled, }); - - navigate("/automations"); }; return ( @@ -86,9 +88,7 @@ export const AutomationPrSizeLabelerPage = () => { } - toolbar={ - <>{automation.docsUrl && } - } + toolbar={automation.docsUrl && } actions={ - - } actions={ <> {integration && !integration?.isEnabled && integration.installUrl && (