This is an automated email from the ASF dual-hosted git repository. mintsweet pushed a commit to branch feat-6446 in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit 4cd995f9c6ea383d7672955a571ccd4b7a8e7d70 Author: mintsweet <[email protected]> AuthorDate: Mon Nov 20 16:52:55 2023 +1300 feat(config-ui): simplify the display of the github scope config --- config-ui/src/plugins/register/github/styled.ts | 63 --- .../src/plugins/register/github/transformation.tsx | 464 ++++++++++++--------- 2 files changed, 262 insertions(+), 265 deletions(-) diff --git a/config-ui/src/plugins/register/github/styled.ts b/config-ui/src/plugins/register/github/styled.ts deleted file mode 100644 index 107a79d6f..000000000 --- a/config-ui/src/plugins/register/github/styled.ts +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -import styled from 'styled-components'; - -export const Transformation = styled.div` - .issue-tracking { - .issue-type { - .title { - margin-bottom: 8px; - } - - .list { - padding-left: 40px; - } - } - } - - .bp5-form-group { - display: flex; - align-items: center; - - .bp5-label { - flex: 0 0 140px; - } - - .bp5-form-content { - flex: auto; - } - } -`; - -export const CICD = styled.div` - h3 { - margin-top: 16px; - } - - .text, - .sub-text { - display: flex; - align-items: baseline; - margin-bottom: 8px; - } - - .sub-text { - padding-left: 28px; - } -`; diff --git a/config-ui/src/plugins/register/github/transformation.tsx b/config-ui/src/plugins/register/github/transformation.tsx index e010f5b3f..f82dce8ee 100644 --- a/config-ui/src/plugins/register/github/transformation.tsx +++ b/config-ui/src/plugins/register/github/transformation.tsx @@ -17,13 +17,18 @@ */ import { useState, useEffect } from 'react'; -import { FormGroup, InputGroup, TextArea, Tag, Checkbox, Icon, Intent, Colors } from '@blueprintjs/core'; +import { + QuestionCircleOutlined, + CheckCircleOutlined, + CloseCircleOutlined, + CaretRightOutlined, +} from '@ant-design/icons'; +import type { CheckboxChangeEvent } from 'antd/lib/checkbox'; +import { theme, Form, Collapse as AntdCollapse, Input, Tooltip, Tag, Checkbox } from 'antd'; -import { ExternalLink, HelpTooltip, Divider } from '@/components'; +import { ExternalLink } from '@/components'; import { DOC_URL } from '@/release'; -import * as S from './styled'; - interface Props { entities: string[]; transformation: any; @@ -46,7 +51,7 @@ export const GitHubTransformation = ({ entities, transformation, setTransformati setHasError(useCustom && !transformation.deploymentPattern); }, [useCustom, transformation]); - const handleChangeUseCustom = (e: React.FormEvent<HTMLInputElement>) => { + const handleChangeUseCustom = (e: CheckboxChangeEvent) => { const checked = (e.target as HTMLInputElement).checked; if (!checked) { @@ -60,258 +65,314 @@ export const GitHubTransformation = ({ entities, transformation, setTransformati setUseCustom(checked); }; + const { token } = theme.useToken(); + + const panelStyle: React.CSSProperties = { + marginBottom: 24, + background: token.colorFillAlter, + borderRadius: token.borderRadiusLG, + border: 'none', + }; + return ( - <S.Transformation> - {entities.includes('TICKET') && ( - <div className="issue-tracking"> - <h2>Issue Tracking</h2> + <Form labelCol={{ span: 4 }} wrapperCol={{ span: 16 }}> + <AntdCollapse + bordered={false} + defaultActiveKey={['TICKET', 'CICD']} + expandIcon={({ isActive }) => <CaretRightOutlined rotate={isActive ? 90 : 0} rev="" />} + style={{ background: token.colorBgContainer }} + size="large" + items={renderCollapseItems({ + entities, + panelStyle, + transformation, + onChangeTransformation: setTransformation, + useCustom, + onChangeUseCustom: handleChangeUseCustom, + })} + /> + </Form> + ); +}; + +const renderCollapseItems = ({ + entities, + panelStyle, + transformation, + onChangeTransformation, + useCustom, + onChangeUseCustom, +}: { + entities: string[]; + panelStyle: React.CSSProperties; + transformation: any; + onChangeTransformation: any; + useCustom: boolean; + onChangeUseCustom: any; +}) => + [ + { + key: 'TICKET', + label: 'Issue Tracking', + style: panelStyle, + children: ( + <> <p> Tell DevLake what your issue labels mean to view metrics such as{' '} <ExternalLink link={DOC_URL.METRICS.BUG_AGE}>Bug Age</ExternalLink>,{' '} <ExternalLink link={DOC_URL.METRICS.MTTR}>DORA - Median Time to Restore Service</ExternalLink>, etc. </p> - <div className="issue-type"> - <div className="title"> - <span>Issue Type</span> - <HelpTooltip content="DevLake defines three standard types of issues: FEATURE, BUG and INCIDENT. Set your issues to these three types with issue labels that match the RegEx." /> - </div> - <div className="list"> - <FormGroup inline label="Requirement"> - <InputGroup - placeholder="(feat|feature|proposal|requirement)" - value={transformation.issueTypeRequirement ?? ''} - onChange={(e) => - setTransformation({ - ...transformation, - issueTypeRequirement: e.target.value, - }) - } - /> - </FormGroup> - <FormGroup inline label="Bug"> - <InputGroup - placeholder="(bug|broken)" - value={transformation.issueTypeBug ?? ''} - onChange={(e) => - setTransformation({ - ...transformation, - issueTypeBug: e.target.value, - }) - } - /> - </FormGroup> - <FormGroup - inline - label={ - <span> - Incident - <Tag minimal intent={Intent.PRIMARY} style={{ marginLeft: 4 }}> - DORA - </Tag> - </span> - } - > - <InputGroup - placeholder="(incident|failure)" - value={transformation.issueTypeIncident ?? ''} - onChange={(e) => - setTransformation({ - ...transformation, - issueTypeIncident: e.target.value, - }) - } - /> - </FormGroup> - </div> - </div> - <FormGroup - inline + <p> + DevLake defines three standard types of issues: FEATURE, BUG and INCIDENT. Set your issues to these three + types with issue labels that match the RegEx. + </p> + <Form.Item label="Requirement"> + <Input + placeholder="(feat|feature|proposal|requirement)" + value={transformation.issueTypeRequirement ?? ''} + onChange={(e) => + onChangeTransformation({ + ...transformation, + issueTypeRequirement: e.target.value, + }) + } + /> + </Form.Item> + <Form.Item label="Bug"> + <Input + placeholder="(bug|broken)" + value={transformation.issueTypeBug ?? ''} + onChange={(e) => + onChangeTransformation({ + ...transformation, + issueTypeBug: e.target.value, + }) + } + /> + </Form.Item> + <Form.Item + label={ + <> + <span>Incident</span> + <Tag style={{ marginLeft: 4 }} color="blue"> + DORA + </Tag> + </> + } + > + <Input + placeholder="(incident|failure)" + value={transformation.issueTypeIncident ?? ''} + onChange={(e) => + onChangeTransformation({ + ...transformation, + issueTypeIncident: e.target.value, + }) + } + /> + </Form.Item> + <Form.Item label={ <> - <span>Issue Priority</span> - <HelpTooltip content="Labels that match the RegEx will be set as the priority of an issue." /> + <span style={{ marginRight: 4 }}>Issue Priority</span> + <Tooltip title="Labels that match the RegEx will be set as the priority of an issue."> + <QuestionCircleOutlined rev="" /> + </Tooltip> </> } > - <InputGroup + <Input placeholder="(highest|high|medium|low|p0|p1|p2|p3)" value={transformation.issuePriority ?? ''} onChange={(e) => - setTransformation({ + onChangeTransformation({ ...transformation, issuePriority: e.target.value, }) } /> - </FormGroup> - <FormGroup - inline + </Form.Item> + <Form.Item label={ <> - <span>Issue Component</span> - <HelpTooltip content="Labels that match the RegEx will be set as the component of an issue." /> + <span style={{ marginRight: 4 }}>Issue Component</span> + <Tooltip title="Labels that match the RegEx will be set as the component of an issue."> + <QuestionCircleOutlined rev="" /> + </Tooltip> </> } > - <InputGroup + <Input placeholder="component(.*)" value={transformation.issueComponent ?? ''} onChange={(e) => - setTransformation({ + onChangeTransformation({ ...transformation, issueComponent: e.target.value, }) } /> - </FormGroup> - <FormGroup - inline + </Form.Item> + <Form.Item label={ <> - <span>Issue Severity</span> - <HelpTooltip content="Labels that match the RegEx will be set as the serverity of an issue." /> + <span style={{ marginRight: 4 }}>Issue Severity</span> + <Tooltip title="Labels that match the RegEx will be set as the serverity of an issue."> + <QuestionCircleOutlined rev="" /> + </Tooltip> </> } > - <InputGroup + <Input placeholder="severity(.*)" value={transformation.issueSeverity ?? ''} onChange={(e) => - setTransformation({ + onChangeTransformation({ ...transformation, issueSeverity: e.target.value, }) } /> - </FormGroup> - <Divider /> - </div> - )} - {entities.includes('CICD') && ( + </Form.Item> + </> + ), + }, + { + key: 'CICD', + label: 'CI/CD', + style: panelStyle, + children: ( <> - <S.CICD> - <h2>CI/CD</h2> - <h3> - <span>Deployment</span> - <Tag minimal intent={Intent.PRIMARY} style={{ marginLeft: 8 }}> - DORA - </Tag> - </h3> - <p style={{ marginBottom: 16 }}> - Use Regular Expression to define Deployments in DevLake in order to measure DORA metrics.{' '} - <ExternalLink link={DOC_URL.PLUGIN.GITHUB.TRANSFORMATION}>Learn more</ExternalLink> - </p> - <div className="text"> - <Checkbox disabled checked /> - <span>Convert a GitHub Deployment to a DevLake Deployment </span> - </div> - <div className="sub-text"> - <span>If its environment name matches</span> - <InputGroup - style={{ width: 180, margin: '0 8px' }} - placeholder="(?i)prod(.*)" - value={transformation.envNamePattern} - onChange={(e) => - setTransformation({ - ...transformation, - envNamePattern: e.target.value, - }) - } - /> - <span>, this deployment is a ‘Production Deployment’</span> - </div> - <div className="text"> - <Checkbox checked={useCustom} onChange={handleChangeUseCustom} /> - <span>Convert a GitHub workflow run as a DevLake Deployment when: </span> - </div> - <div className="sub-text"> - <span> - The name of the <strong>GitHub workflow run</strong> or <strong> one of its jobs</strong> matches - </span> - <InputGroup - style={{ width: 180, margin: '0 8px' }} - placeholder="(deploy|push-image)" - value={transformation.deploymentPattern ?? ''} - onChange={(e) => - setTransformation({ - ...transformation, - deploymentPattern: e.target.value, - productionPattern: !e.target.value ? '' : transformation.productionPattern, - }) - } - /> - <i style={{ color: '#E34040' }}>*</i> - <HelpTooltip content="GitHub Workflow Runs: https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow" /> - </div> - <div className="sub-text"> - <span>If the name or its branch’s name also matches</span> - <InputGroup - style={{ width: 180, margin: '0 8px' }} - placeholder="prod(.*)" - value={transformation.productionPattern ?? ''} - onChange={(e) => - setTransformation({ - ...transformation, - productionPattern: e.target.value, - }) - } - /> - <span>, this deployment is a ‘Production Deployment’</span> - <HelpTooltip content="If you leave this field empty, all Deployments will be tagged as in the Production environment. " /> - </div> - </S.CICD> - <Divider /> + <h3 style={{ marginBottom: 16 }}> + <span>Deployment</span> + <Tag style={{ marginLeft: 4 }} color="blue"> + DORA + </Tag> + </h3> + <p style={{ marginBottom: 16 }}> + Use Regular Expression to define Deployments in DevLake in order to measure DORA metrics.{' '} + <ExternalLink link={DOC_URL.PLUGIN.GITHUB.TRANSFORMATION}>Learn more</ExternalLink> + </p> + <Checkbox disabled checked> + Convert a GitHub Deployment to a DevLake Deployment + </Checkbox> + <div style={{ margin: '8px 0', paddingLeft: 28 }}> + <span>If its environment name matches</span> + <Input + style={{ width: 180, margin: '0 8px' }} + placeholder="(?i)prod(.*)" + value={transformation.envNamePattern} + onChange={(e) => + onChangeTransformation({ + ...transformation, + envNamePattern: e.target.value, + }) + } + /> + <span>, this deployment is a ‘Production Deployment’</span> + </div> + <Checkbox checked={useCustom} onChange={onChangeUseCustom}> + Convert a GitHub workflow run as a DevLake Deployment when: + </Checkbox> + <div style={{ margin: '8px 0', paddingLeft: 28 }}> + <span> + The name of the <strong>GitHub workflow run</strong> or <strong> one of its jobs</strong> matches + </span> + <Input + style={{ width: 180, margin: '0 8px' }} + placeholder="(deploy|push-image)" + value={transformation.deploymentPattern ?? ''} + onChange={(e) => + onChangeTransformation({ + ...transformation, + deploymentPattern: e.target.value, + productionPattern: !e.target.value ? '' : transformation.productionPattern, + }) + } + /> + <i style={{ marginRight: 4, color: '#E34040' }}>*</i> + <Tooltip title="GitHub Workflow Runs: https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow"> + <QuestionCircleOutlined rev="" /> + </Tooltip> + </div> + <div style={{ margin: '8px 0', paddingLeft: 28 }}> + <span>If the name or its branch’s name also matches</span> + <Input + style={{ width: 180, margin: '0 8px' }} + placeholder="prod(.*)" + value={transformation.productionPattern ?? ''} + onChange={(e) => + onChangeTransformation({ + ...transformation, + productionPattern: e.target.value, + }) + } + /> + <span>, this deployment is a ‘Production Deployment’</span> + <Tooltip title="If you leave this field empty, all Deployments will be tagged as in the Production environment. "> + <QuestionCircleOutlined rev="" /> + </Tooltip> + </div> </> - )} - {entities.includes('CODEREVIEW') && ( - <div> - <h2>Code Review</h2> + ), + }, + { + key: 'CODEREVIEW', + label: 'Code Review', + style: panelStyle, + children: ( + <> <p> If you use labels to identify types and components of pull requests, use the following RegExes to extract them into corresponding columns.{' '} <ExternalLink link={DOC_URL.DATA_MODELS.DEVLAKE_DOMAIN_LAYER_SCHEMA.PULL_REQUEST}>Learn More</ExternalLink> </p> - <FormGroup - inline + <Form.Item label={ <> - <span>PR Type</span> - <HelpTooltip content="Labels that match the RegEx will be set as the type of a pull request." /> + <span style={{ marginRight: 4 }}>PR Type</span> + <Tooltip title="Labels that match the RegEx will be set as the type of a pull request."> + <QuestionCircleOutlined rev="" /> + </Tooltip> </> } > - <InputGroup + <Input placeholder="type(.*)$" value={transformation.prType ?? ''} - onChange={(e) => setTransformation({ ...transformation, prType: e.target.value })} + onChange={(e) => onChangeTransformation({ ...transformation, prType: e.target.value })} /> - </FormGroup> - <FormGroup - inline + </Form.Item> + <Form.Item label={ <> - <span>PR Component</span> - <HelpTooltip content="Labels that match the RegEx will be set as the component of a pull request." /> + <span style={{ marginRight: 4 }}>PR Component</span> + <Tooltip title="Labels that match the RegEx will be set as the component of a pull request."> + <QuestionCircleOutlined rev="" /> + </Tooltip> </> } > - <InputGroup + <Input placeholder="component(.*)$" value={transformation.prComponent ?? ''} onChange={(e) => - setTransformation({ + onChangeTransformation({ ...transformation, prComponent: e.target.value, }) } /> - </FormGroup> - <Divider /> - </div> - )} - {entities.includes('CROSS') && ( - <div> - <h2>Cross-domain</h2> + </Form.Item> + </> + ), + }, + { + key: 'CROSS', + label: 'Cross-domain', + style: panelStyle, + children: ( + <> <p> Connect entities across domains to measure metrics such as{' '} <ExternalLink link={DOC_URL.METRICS.BUG_COUNT_PER_1K_LINES_OF_CODE}> @@ -319,46 +380,45 @@ export const GitHubTransformation = ({ entities, transformation, setTransformati </ExternalLink> . </p> - <FormGroup - inline + <Form.Item + labelCol={{ span: 6 }} label={ <div className="label"> - <span>Connect PRs and Issues</span> - <HelpTooltip - content={ + <span style={{ marginRight: 4 }}>Connect PRs and Issues</span> + <Tooltip + title={ <> <div> - <Icon icon="tick-circle" size={12} color={Colors.GREEN4} style={{ marginRight: '4px' }} /> + <CheckCircleOutlined rev="" style={{ marginRight: 4, color: '#4DB764' }} /> Example 1: PR #321 body contains "<strong>Closes #1234</strong>" (PR #321 and issue #1234 will be mapped by the following RegEx) </div> <div> - <Icon icon="delete" size={12} color={Colors.RED4} style={{ marginRight: '4px' }} /> + <CloseCircleOutlined rev="" style={{ marginRight: 4, color: '#E34040' }} /> Example 2: PR #321 body contains "<strong>Related to #1234</strong>" (PR #321 and issue #1234 will NOT be mapped by the following RegEx) </div> </> } - /> + > + <QuestionCircleOutlined rev="" /> + </Tooltip> </div> } > - <TextArea + <Input.TextArea value={transformation.prBodyClosePattern ?? ''} placeholder="(?mi)(fix|close|resolve|fixes|closes|resolves|fixed|closed|resolved)[s]*.*(((and )?(#|https://github.com/%s/%s/issues/)d+[ ]*)+)" onChange={(e) => - setTransformation({ + onChangeTransformation({ ...transformation, prBodyClosePattern: e.target.value, }) } - fill rows={2} /> - </FormGroup> - <Divider /> - </div> - )} - </S.Transformation> - ); -}; + </Form.Item> + </> + ), + }, + ].filter((it) => entities.includes(it.key));
