diff --git a/web/src/components/BranchProtection/BranchProtectionForm/BranchProtectionForm.module.scss b/web/src/components/BranchProtection/BranchProtectionForm/BranchProtectionForm.module.scss index 03e2f3e55..80fcb6921 100644 --- a/web/src/components/BranchProtection/BranchProtectionForm/BranchProtectionForm.module.scss +++ b/web/src/components/BranchProtection/BranchProtectionForm/BranchProtectionForm.module.scss @@ -71,6 +71,16 @@ width: 100% !important; } +.codeClose { + cursor: pointer !important; + padding: 2px !important; + &:hover { + background: var(--grey-100) !important; + box-shadow: var(--elevation-2) !important; + padding: 2px !important; + } +} + .targetContainer { :global(.bp3-form-group) { margin-bottom: unset !important; diff --git a/web/src/components/BranchProtection/BranchProtectionForm/BranchProtectionForm.module.scss.d.ts b/web/src/components/BranchProtection/BranchProtectionForm/BranchProtectionForm.module.scss.d.ts index 6e6afed1d..bc5f21614 100644 --- a/web/src/components/BranchProtection/BranchProtectionForm/BranchProtectionForm.module.scss.d.ts +++ b/web/src/components/BranchProtection/BranchProtectionForm/BranchProtectionForm.module.scss.d.ts @@ -21,6 +21,7 @@ export declare const bypassContainer: string export declare const checkboxLabel: string export declare const checkboxText: string export declare const checkContainer: string +export declare const codeClose: string export declare const dividerContainer: string export declare const generalContainer: string export declare const greyButton: string diff --git a/web/src/components/BranchProtection/BranchProtectionForm/BranchProtectionForm.tsx b/web/src/components/BranchProtection/BranchProtectionForm/BranchProtectionForm.tsx index d4ba5fe16..9c901d014 100644 --- a/web/src/components/BranchProtection/BranchProtectionForm/BranchProtectionForm.tsx +++ b/web/src/components/BranchProtection/BranchProtectionForm/BranchProtectionForm.tsx @@ -15,6 +15,7 @@ */ import React, { useMemo, useState } from 'react' import cx from 'classnames' +import * as yup from 'yup' import { Button, ButtonVariation, @@ -36,7 +37,7 @@ import { useHistory } from 'react-router-dom' import { useGet, useMutate } from 'restful-react' import { BranchTargetType, SettingsTab, branchTargetOptions } from 'utils/GitUtils' import { useStrings } from 'framework/strings' -import { getErrorMessage, rulesFormInitialPayload } from 'utils/Utils' +import { REGEX_VALID_REPO_NAME, getErrorMessage, rulesFormInitialPayload } from 'utils/Utils' import type { TypesRepository, OpenapiRule, @@ -192,6 +193,10 @@ const BranchProtectionForm = (props: { formName="branchProtectionRulesNewEditForm" initialValues={initialValues} enableReinitialize + validationSchema={yup.object().shape({ + name: yup.string().trim().required().matches(REGEX_VALID_REPO_NAME, getString('validation.nameLogic')), + minReviewers: yup.number().typeError(getString('enterANumber')) + })} onSubmit={async formData => { const stratArray = [ formData.squashMerge && 'squash', @@ -243,6 +248,9 @@ const BranchProtectionForm = (props: { } } } + if (!formData.limitMergeStrategies) { + delete (payload?.definition as ProtectionBranch)?.pullreq?.merge?.strategies_allowed + } if (!formData.requireMinReviewers) { delete (payload?.definition as ProtectionBranch)?.pullreq?.approvals?.require_minimum_count } @@ -393,6 +401,7 @@ const BranchProtectionForm = (props: { ) formik.setFieldValue('targetList', filteredData) }} + className={css.codeClose} /> ) @@ -408,6 +417,8 @@ const BranchProtectionForm = (props: { items={filteredUserOptions} onQueryChange={setSearchTerm} className={css.widthContainer} + value={{ label: '', value: '' }} + placeholder={getString('selectUsers')} onChange={item => { const id = item.value?.toString().split(' ')[0] const displayName = item.label @@ -432,7 +443,10 @@ const BranchProtectionForm = (props: {