From 910aee056a4d350a8e5c3e62c5f7b88a45e07648 Mon Sep 17 00:00:00 2001 From: mintsweet <0x1304570@gmail.com> Date: Thu, 23 May 2024 21:44:36 +1200 Subject: [PATCH] feat: assiocate pull request with issue --- config-ui/src/components/block/index.tsx | 2 +- .../routes/project/detail/settings-panel.tsx | 49 ++++++++++++++++--- config-ui/src/types/project.ts | 2 +- 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/config-ui/src/components/block/index.tsx b/config-ui/src/components/block/index.tsx index 068c6493513..2df5368798f 100644 --- a/config-ui/src/components/block/index.tsx +++ b/config-ui/src/components/block/index.tsx @@ -42,7 +42,7 @@ interface Props { title?: React.ReactNode; description?: React.ReactNode; required?: boolean; - children: React.ReactNode; + children?: React.ReactNode; } export const Block = ({ style, title, description, required, children }: Props) => { diff --git a/config-ui/src/routes/project/detail/settings-panel.tsx b/config-ui/src/routes/project/detail/settings-panel.tsx index 535c824ec5f..0cd2f006ee8 100644 --- a/config-ui/src/routes/project/detail/settings-panel.tsx +++ b/config-ui/src/routes/project/detail/settings-panel.tsx @@ -22,7 +22,7 @@ import { WarningOutlined } from '@ant-design/icons'; import { Flex, Space, Card, Modal, Input, Checkbox, Button, message } from 'antd'; import API from '@/api'; -import { Block } from '@/components'; +import { Block, HelpTooltip } from '@/components'; import { PATHS } from '@/config'; import { IProject } from '@/types'; import { operator } from '@/utils'; @@ -39,6 +39,8 @@ interface Props { export const SettingsPanel = ({ project, onRefresh }: Props) => { const [name, setName] = useState(''); const [enableDora, setEnableDora] = useState(false); + const [associatePrWithIssues, setAssociatePrWithIssues] = useState(false); + const [regexPrIssue, setRegexPrIssue] = useState(''); const [operating, setOperating] = useState(false); const [open, setOpen] = useState(false); @@ -65,9 +67,16 @@ export const SettingsPanel = ({ project, onRefresh }: Props) => { metrics: [ { pluginName: 'dora', - pluginOption: '', + pluginOption: {}, enable: enableDora, }, + { + pluginName: 'linker', + pluginOption: { + prToIssueRegexp: regexPrIssue, + }, + enable: associatePrWithIssues, + }, ], }), { @@ -107,10 +116,38 @@ export const SettingsPanel = ({ project, onRefresh }: Props) => { setName(e.target.value)} /> - - setEnableDora(e.target.checked)}> - Enable DORA Metrics - + setEnableDora(e.target.checked)}> + Enable DORA Metrics + + } + description="DORA metrics are four widely-adopted metrics for measuring software delivery performance." + /> + setAssociatePrWithIssues(e.target.checked)}> + Associate pull requests with issues + + } + description={ + + Parse the issue key with the regex from the title and description of the pull requests in this project. + + The default regex will parse the issue key from the table.pull_requests where the description + contains "fix/close/.../resolved {'{'}issue_key{'}'}". The relationship between pull requests and + issues will be stored in the table.pull_request_issues + + } + /> + + } + > + {associatePrWithIssues && ( + setRegexPrIssue(e.target.value)} /> + )}