Skip to content

Commit

Permalink
Merge branch 'main' into feature/i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
yidafu committed Mar 21, 2023
2 parents 12f7605 + 7d76c6e commit 7ad1d1b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ import { TAB } from '@src/polaris/service/detail/types'
import CreateDuck from './CreateDuck'

import { LimitMethodType, LimitMethodTypeOptions } from '@src/polaris/administration/accessLimiting/types'
import { FaultDetectHttpMethodOptions, FaultDetectProtocol, FaultDetectProtocolOptions } from '../types'
import {
BlockHttpBodyMethod,
FaultDetectHttpMethodOptions,
FaultDetectProtocol,
FaultDetectProtocolOptions,
} from '../types'
import { BreakerType } from '../../types'

const addArrayFieldValue = (field, defaultValue) => {
Expand Down Expand Up @@ -289,16 +294,18 @@ export default purify(function CustomRoutePage(props: DuckCmpProps<CreateDuck>)
></Button>
)}
</FormItem>
<FormField field={body} label={'Body'}>
<TeaInput.TextArea
value={body.getValue()}
onChange={v => {
body.setValue(v)
}}
size={'m'}
rows={4}
/>
</FormField>
{!BlockHttpBodyMethod.includes(method.getValue()) && (
<FormField field={body} label={'Body'}>
<TeaInput.TextArea
value={body.getValue()}
onChange={v => {
body.setValue(v)
}}
size={'m'}
rows={4}
/>
</FormField>
)}
</>
)}
{protocol.getValue() === FaultDetectProtocol.TCP && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { delay } from 'redux-saga'
import router from '@src/polaris/common/util/router'
import { TAB } from '@src/polaris/service/detail/types'
import { createFaultDetect, DescribeFaultDetects, modifyFaultDetect } from '../model'
import { FaultDetectProtocol, FaultDetectRule } from '../types'
import { BlockHttpBodyMethod, FaultDetectProtocol, FaultDetectRule } from '../types'
import { BreakerType } from '../../types'

interface ComposedId {
Expand Down Expand Up @@ -118,10 +118,14 @@ export default class CircuitBreakerCreatePageDuck extends DetailPage {
const values = ducks.form.selectors.values(yield select())
const { id, namespace, service } = yield select(selectors.composedId)
let result
const cloneValues = JSON.parse(JSON.stringify(values))
if (BlockHttpBodyMethod.includes(values.httpConfig.method as any)) {
delete cloneValues.httpConfig.body
}
if (id) {
delete values['@type']
delete values.ctime
delete values.mtime
delete cloneValues['@type']
delete cloneValues.ctime
delete cloneValues.mtime
result = yield modifyFaultDetect([values])
} else {
result = yield createFaultDetect([values])
Expand Down
5 changes: 5 additions & 0 deletions web/src/polaris/administration/breaker/faultDetect/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,8 @@ export const FaultDetectHttpMethodOptions = Object.keys(FaultDetectHttpMethod).m
text: item,
value: item,
}))
export const BlockHttpBodyMethod = [
FaultDetectHttpMethod.GET,
FaultDetectHttpMethod.DELETE,
FaultDetectHttpMethod.HEAD,
] as string[]

0 comments on commit 7ad1d1b

Please sign in to comment.