feat: bug fix pack

pull/107/head 2.2.1
huoyong.msb 5 years ago
parent 2ffe59f992
commit 9efef03b92

@ -1,11 +1,7 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { PropTypes, connect, _ } from '../../family' import { PropTypes, connect, _ } from '../../family'
import InterfaceEditorToolbar from './InterfaceEditorToolbar' import InterfaceEditorToolbar from './InterfaceEditorToolbar'
import InterfaceSummary, { import InterfaceSummary from './InterfaceSummary'
BODY_OPTION,
REQUEST_PARAMS_TYPE,
rptFromStr2Num,
} from './InterfaceSummary'
import PropertyList from './PropertyList' import PropertyList from './PropertyList'
import MoveInterfaceForm from './MoveInterfaceForm' import MoveInterfaceForm from './MoveInterfaceForm'
import { fetchRepository } from '../../actions/repository' import { fetchRepository } from '../../actions/repository'
@ -57,8 +53,7 @@ class InterfaceEditor extends Component<InterfaceEditorProps, InterfaceEditorSta
this.state = { this.state = {
...InterfaceEditor.mapPropsToState(props), ...InterfaceEditor.mapPropsToState(props),
summaryState: { summaryState: {
bodyOption: BODY_OPTION.FORM_DATA, bodyOption: props.bodyOption,
requestParamsType: REQUEST_PARAMS_TYPE.QUERY_PARAMS,
}, },
moveInterfaceDialogOpen: false, moveInterfaceDialogOpen: false,
} }
@ -117,7 +112,7 @@ class InterfaceEditor extends Component<InterfaceEditorProps, InterfaceEditorSta
render() { render() {
const { auth, repository, mod } = this.props const { auth, repository, mod } = this.props
const { editable, itf } = this.state const { editable, itf } = this.state
const { id, locker } = this.state.itf const { id, locker, bodyOption } = this.state.itf
if (!id) { if (!id) {
return null return null
} }
@ -154,8 +149,8 @@ class InterfaceEditor extends Component<InterfaceEditorProps, InterfaceEditorSta
repository={repository} repository={repository}
mod={mod} mod={mod}
interfaceId={itf.id} interfaceId={itf.id}
bodyOption={this.state.summaryState.bodyOption} bodyOption={bodyOption}
requestParamsType={this.state.summaryState.requestParamsType} posFilter={this.state.summaryState.posFilter}
handleChangeProperty={this.handleChangeProperty} handleChangeProperty={this.handleChangeProperty}
handleDeleteMemoryProperty={this.handleDeleteMemoryProperty} handleDeleteMemoryProperty={this.handleDeleteMemoryProperty}
/> />
@ -191,8 +186,6 @@ class InterfaceEditor extends Component<InterfaceEditorProps, InterfaceEditorSta
this.handleAddMemoryProperties([property], cb) this.handleAddMemoryProperties([property], cb)
} }
handleAddMemoryProperties = (properties: any, cb: any) => { handleAddMemoryProperties = (properties: any, cb: any) => {
const requestParamsType = this.state.summaryState.requestParamsType
const rpt = rptFromStr2Num(requestParamsType)
properties.forEach((item: any) => { properties.forEach((item: any) => {
if (item.memory === undefined) { if (item.memory === undefined) {
@ -201,7 +194,6 @@ class InterfaceEditor extends Component<InterfaceEditorProps, InterfaceEditorSta
if (item.id === undefined) { if (item.id === undefined) {
item.id = _.uniqueId('memory-') item.id = _.uniqueId('memory-')
} }
item.pos = rpt
}) })
const nextState = { properties: [...this.state.properties, ...properties] } const nextState = { properties: [...this.state.properties, ...properties] }
this.setState(nextState, () => { this.setState(nextState, () => {
@ -227,9 +219,7 @@ class InterfaceEditor extends Component<InterfaceEditorProps, InterfaceEditorSta
} }
this.setState({ properties }, () => { this.setState({ properties }, () => {
if (cb) { cb && cb()
cb()
}
}) })
} }
} }

@ -9,29 +9,34 @@ import { CopyToClipboard } from '../utils/'
import { getRelativeUrl } from '../../utils/URLUtils' import { getRelativeUrl } from '../../utils/URLUtils'
import './InterfaceSummary.css' import './InterfaceSummary.css'
import { showMessage, MSG_TYPE } from 'actions/common' import { showMessage, MSG_TYPE } from 'actions/common'
import { TextField, Select, InputLabel, Input, MenuItem } from '@material-ui/core' import { TextField, Select, InputLabel, Input, MenuItem, FormControl, RadioGroup, FormControlLabel, Radio } from '@material-ui/core'
import Markdown from 'markdown-to-jsx' import Markdown from 'markdown-to-jsx'
export const BODY_OPTION = { export enum BODY_OPTION {
FORM_DATA: 'FORM_DATA', FORM_DATA = 'FORM_DATA',
FORM_URLENCODED: 'FORM_URLENCODED', FORM_URLENCODED = 'FORM_URLENCODED',
RAW: 'RAW', RAW = 'RAW',
BINARY: 'BINARY', BINARY = 'BINARY',
} }
export const REQUEST_PARAMS_TYPE = {
HEADERS: 'HEADERS', export const BODY_OPTION_LIST = [
QUERY_PARAMS: 'QUERY_PARAMS', { label: 'form-data', value: BODY_OPTION.FORM_DATA },
BODY_PARAMS: 'BODY_PARAMS', { label: 'x-www-form-urlencoded', value: BODY_OPTION.FORM_URLENCODED },
} { label: 'raw', value: BODY_OPTION.RAW },
export function rptFromStr2Num(rpt: any) { { label: 'binary', value: BODY_OPTION.BINARY },
let pos = 2 ]
if (rpt === 'HEADERS') {
pos = 1 /**
} else if (rpt === 'BODY_PARAMS') { *
pos = 3 */
} export enum POS_TYPE {
return pos QUERY = 2,
HEADER = 1,
BODY = 3,
PRE_REQUEST_SCRIPT = 4,
TEST = 5
} }
function url2name(itf: any) { function url2name(itf: any) {
// copy from http://gitlab.alibaba-inc.com/thx/magix-cli/blob/master/platform/rap.js#L306 // copy from http://gitlab.alibaba-inc.com/thx/magix-cli/blob/master/platform/rap.js#L306
const method = itf.method.toLowerCase() const method = itf.method.toLowerCase()
@ -87,11 +92,11 @@ type InterfaceSummaryProps = {
[x: string]: any; [x: string]: any;
} }
type InterfaceSummaryState = { type InterfaceSummaryState = {
bodyOption?: any; bodyOption?: any
requestParamsType?: any; method?: any
method?: any; status?: any
status?: any; posFilter: POS_TYPE
[x: string]: any; [x: string]: any
} }
class InterfaceSummary extends Component< class InterfaceSummary extends Component<
InterfaceSummaryProps, InterfaceSummaryProps,
@ -103,38 +108,26 @@ class InterfaceSummary extends Component<
constructor(props: any) { constructor(props: any) {
super(props) super(props)
this.state = { this.state = {
bodyOption: BODY_OPTION.FORM_DATA, bodyOption: props?.itf?.bodyOption ?? BODY_OPTION.FORM_DATA,
requestParamsType: posFilter: props?.itf?.method === 'POST' ? POS_TYPE.BODY : POS_TYPE.QUERY,
props.itf.method === 'POST'
? REQUEST_PARAMS_TYPE.BODY_PARAMS
: REQUEST_PARAMS_TYPE.QUERY_PARAMS,
} }
this.changeMethod = this.changeMethod.bind(this) this.changeMethod = this.changeMethod.bind(this)
this.changeHandler = this.changeHandler.bind(this) this.changeHandler = this.changeHandler.bind(this)
this.switchBodyOption = this.switchBodyOption.bind(this) this.switchBodyOption = this.switchBodyOption.bind(this)
this.switchRequestParamsType = this.switchRequestParamsType.bind(this) this.switchPos = this.switchPos.bind(this)
this.copyModelName = this.copyModelName.bind(this) this.copyModelName = this.copyModelName.bind(this)
this.state.requestParamsType === REQUEST_PARAMS_TYPE.BODY_PARAMS && props.stateChangeHandler(this.state)
props.stateChangeHandler(this.state)
} }
switchBodyOption(val: any) { switchBodyOption(val: BODY_OPTION) {
return () => { this.setState({ bodyOption: val },
this.setState( () => {
{ this.props.stateChangeHandler(this.state)
bodyOption: val, }
}, )
() => {
this.props.stateChangeHandler(this.state)
}
)
}
} }
switchRequestParamsType(val: any) { switchPos(val: POS_TYPE) {
return () => { return () => {
this.setState( this.setState( { posFilter: val },
{
requestParamsType: val,
},
() => { () => {
this.props.stateChangeHandler(this.state) this.props.stateChangeHandler(this.state)
} }
@ -178,7 +171,7 @@ class InterfaceSummary extends Component<
editable, editable,
handleChangeInterface, handleChangeInterface,
} = this.props } = this.props
const { requestParamsType } = this.state const { posFilter } = this.state
const keyMap = { const keyMap = {
COPY_MODEL_NAME: ['ctrl+alt+c'], COPY_MODEL_NAME: ['ctrl+alt+c'],
} }
@ -186,6 +179,7 @@ class InterfaceSummary extends Component<
const handlers = { const handlers = {
COPY_MODEL_NAME: this.copyModelName, COPY_MODEL_NAME: this.copyModelName,
} }
if (!itf.id) { if (!itf.id) {
return null return null
} }
@ -326,42 +320,27 @@ class InterfaceSummary extends Component<
{ {
editable && ( editable && (
<ul className="nav nav-tabs" role="tablist"> <ul className="nav nav-tabs" role="tablist">
<li <li className="nav-item" onClick={this.switchPos(POS_TYPE.HEADER)} >
className="nav-item"
onClick={this.switchRequestParamsType(REQUEST_PARAMS_TYPE.HEADERS)}
>
<button <button
className={`nav-link ${ className={`nav-link ${posFilter === POS_TYPE.HEADER ? 'active' : ''}`}
requestParamsType === REQUEST_PARAMS_TYPE.HEADERS ? 'active' : ''
}`}
role="tab" role="tab"
data-toggle="tab" data-toggle="tab"
> >
headers Headers
</button> </button>
</li> </li>
<li <li className="nav-item" onClick={this.switchPos(POS_TYPE.QUERY)} >
className="nav-item"
onClick={this.switchRequestParamsType(REQUEST_PARAMS_TYPE.QUERY_PARAMS)}
>
<button <button
className={`nav-link ${ className={`nav-link ${posFilter === POS_TYPE.QUERY ? 'active' : ''}`}
requestParamsType === REQUEST_PARAMS_TYPE.QUERY_PARAMS ? 'active' : ''
}`}
role="tab" role="tab"
data-toggle="tab" data-toggle="tab"
> >
Query Params Query Params
</button> </button>
</li> </li>
<li <li className="nav-item" onClick={this.switchPos(POS_TYPE.BODY)} >
className="nav-item"
onClick={this.switchRequestParamsType(REQUEST_PARAMS_TYPE.BODY_PARAMS)}
>
<button <button
className={`nav-link ${ className={`nav-link ${posFilter === POS_TYPE.BODY ? 'active' : ''}`}
requestParamsType === REQUEST_PARAMS_TYPE.BODY_PARAMS ? 'active' : ''
}`}
role="tab" role="tab"
data-toggle="tab" data-toggle="tab"
> >
@ -372,60 +351,18 @@ class InterfaceSummary extends Component<
) )
} }
{ {
editable && requestParamsType === REQUEST_PARAMS_TYPE.BODY_PARAMS ? ( editable && posFilter === POS_TYPE.BODY ? (
<div className="body-options"> <FormControl component="fieldset">
<div className="form-check" onClick={this.switchBodyOption(BODY_OPTION.FORM_DATA)}> <RadioGroup
<input aria-label="body type"
className="form-check-input" name="body-type"
type="radio" value={this.state.bodyOption}
name="inlineRadioOptions" onChange={e => this.switchBodyOption(e.target.value as BODY_OPTION)}
id="inlineRadio1" row={true}
value="option1"
/>
<label className="form-check-label" htmlFor="inlineRadio1">
form-data
</label>
</div>
<div
className="form-check"
onClick={this.switchBodyOption(BODY_OPTION.FORM_URLENCODED)}
> >
<input {BODY_OPTION_LIST.map(x => <FormControlLabel key={x.value} value={x.value} control={<Radio />} label={x.label} />)}
className="form-check-input" </RadioGroup>
type="radio" </FormControl>
name="inlineRadioOptions"
id="inlineRadio2"
value="option2"
/>
<label className="form-check-label" htmlFor="inlineRadio2">
x-www-form-urlencoded
</label>
</div>
<div className="form-check" onClick={this.switchBodyOption(BODY_OPTION.RAW)}>
<input
className="form-check-input"
type="radio"
name="inlineRadioOptions"
id="inlineRadio3"
value="option3"
/>
<label className="form-check-label" htmlFor="inlineRadio3">
raw
</label>
</div>
<div className="form-check" onClick={this.switchBodyOption(BODY_OPTION.BINARY)}>
<input
className="form-check-input"
type="radio"
name="inlineRadioOptions"
id="inlineRadio4"
value="option4"
/>
<label className="form-check-label" htmlFor="inlineRadio4">
binary
</label>
</div>
</div>
) : null ) : null
} }
</div > </div >

@ -12,40 +12,40 @@ import PropertyForm from './PropertyForm'
import Importer from './Importer' import Importer from './Importer'
import Previewer from './InterfacePreviewer' import Previewer from './InterfacePreviewer'
import { GoPlus, GoTrashcan, GoQuestion, GoChevronDown, GoChevronRight } from 'react-icons/go' import { GoPlus, GoTrashcan, GoQuestion, GoChevronDown, GoChevronRight } from 'react-icons/go'
import { rptFromStr2Num } from './InterfaceSummary'
import './PropertyList.css' import './PropertyList.css'
import { ButtonGroup, Button, Checkbox } from '@material-ui/core' import { ButtonGroup, Button, Checkbox, Chip } from '@material-ui/core'
import classNames from 'classnames' import classNames from 'classnames'
import _ from 'lodash' import _ from 'lodash'
import Mock from 'mockjs' import Mock from 'mockjs'
import JSON5 from 'json5' import JSON5 from 'json5'
import { elementInViewport } from 'utils/ElementInViewport' import { elementInViewport } from 'utils/ElementInViewport'
import { POS_TYPE, BODY_OPTION } from './InterfaceSummary'
const mockProperty = const mockProperty =
process.env.NODE_ENV === 'development' process.env.NODE_ENV === 'development'
? () => ? () =>
Mock.mock({ Mock.mock({
'scope|1': ['request', 'response'], 'scope|1': ['request', 'response'],
name: '@WORD(6)', name: '@WORD(6)',
'type|1': ['String', 'Number', 'Boolean'], 'type|1': ['String', 'Number', 'Boolean'],
'value|1': ['@INT', '@FLOAT', '@TITLE', '@NAME'], 'value|1': ['@INT', '@FLOAT', '@TITLE', '@NAME'],
description: '@CSENTENCE', description: '@CSENTENCE',
parentId: -1,
interfaceId: '@NATURAL',
moduleId: '@NATURAL',
repositoryId: '@NATURAL',
})
: () => ({
scope: 'response',
name: '',
type: 'String',
value: '',
description: '',
parentId: -1, parentId: -1,
interfaceId: undefined, interfaceId: '@NATURAL',
moduleId: undefined, moduleId: '@NATURAL',
repositoryId: undefined, repositoryId: '@NATURAL',
}) })
: () => ({
scope: 'response',
name: '',
type: 'String',
value: '',
description: '',
parentId: -1,
interfaceId: undefined,
moduleId: undefined,
repositoryId: undefined,
})
export const RequestPropertyListPreviewer = (props: any) => ( export const RequestPropertyListPreviewer = (props: any) => (
<Previewer {...props} /> <Previewer {...props} />
@ -206,6 +206,7 @@ class SortableTreeTableRow extends Component<SortableTreeTableRowProps, Sortable
handleChangeProperty, handleChangeProperty,
handleChangePropertyField, handleChangePropertyField,
handleSortProperties, handleSortProperties,
bodyOption,
} = this.props } = this.props
return ( return (
isExpanding && ( isExpanding && (
@ -229,27 +230,27 @@ class SortableTreeTableRow extends Component<SortableTreeTableRowProps, Sortable
> >
<div className="td operations nowrap"> <div className="td operations nowrap">
{(item.type === 'Object' || item.type === 'Array') && {(item.type === 'Object' || item.type === 'Array') &&
item.children && item.children &&
item.children.length ? ( item.children.length ? (
<Link <Link
to="" to=""
onClick={e => { onClick={e => {
e.preventDefault() e.preventDefault()
this.setState(prev => ({ this.setState(prev => ({
...prev, ...prev,
childrenExpandingIdList: childrenIsExpanding childrenExpandingIdList: childrenIsExpanding
? prev.childrenExpandingIdList.filter(id => id !== item.id) ? prev.childrenExpandingIdList.filter(id => id !== item.id)
: [...prev.childrenExpandingIdList, item.id], : [...prev.childrenExpandingIdList, item.id],
})) }))
}} }}
> >
{childrenIsExpanding ? ( {childrenIsExpanding ? (
<GoChevronDown className="fontsize-14 color-6" /> <GoChevronDown className="fontsize-14 color-6" />
) : ( ) : (
<GoChevronRight className="fontsize-14 color-6" /> <GoChevronRight className="fontsize-14 color-6" />
)} )}
</Link> </Link>
) : null} ) : null}
{editable && ( {editable && (
<> <>
{item.type === 'Object' || item.type === 'Array' ? ( {item.type === 'Object' || item.type === 'Array' ? (
@ -280,7 +281,9 @@ class SortableTreeTableRow extends Component<SortableTreeTableRowProps, Sortable
{!editable ? ( {!editable ? (
<> <>
<CopyToClipboard text={item.name} type="right"> <CopyToClipboard text={item.name} type="right">
<span className="name-wrapper nowrap">{item.name}</span> <span className="name-wrapper nowrap">
{item.name}{item.pos === POS_TYPE.BODY ? <BodyParamLabel type={bodyOption} /> : null}
</span>
</CopyToClipboard> </CopyToClipboard>
{item.scope === 'request' && item.depth === 0 ? ( {item.scope === 'request' && item.depth === 0 ? (
<div style={{ margin: '1px 0 0 3px' }}> <div style={{ margin: '1px 0 0 3px' }}>
@ -289,21 +292,21 @@ class SortableTreeTableRow extends Component<SortableTreeTableRowProps, Sortable
) : null} ) : null}
</> </>
) : ( ) : (
<input <input
ref={(input: HTMLInputElement) => { ref={(input: HTMLInputElement) => {
if (item.id === highlightId) { if (item.id === highlightId) {
this.focusNameInput = input this.focusNameInput = input
}
}}
value={item.name}
onChange={e =>
handleChangePropertyField(item.id, 'name', e.target.value)
} }
}} className="form-control editable"
value={item.name} spellCheck={false}
onChange={e => placeholder=""
handleChangePropertyField(item.id, 'name', e.target.value) />
} )}
className="form-control editable"
spellCheck={false}
placeholder=""
/>
)}
</div> </div>
<div className={`td payload required type depth-${item.depth} nowrap`}> <div className={`td payload required type depth-${item.depth} nowrap`}>
<Checkbox <Checkbox
@ -325,43 +328,43 @@ class SortableTreeTableRow extends Component<SortableTreeTableRowProps, Sortable
<span className="nowrap">{item.type}</span> <span className="nowrap">{item.type}</span>
</CopyToClipboard> </CopyToClipboard>
) : ( ) : (
<select <select
value={item.type} value={item.type}
onChange={e => { onChange={e => {
const type = e.target.value const type = e.target.value
if (isNoValueType(type)) { if (isNoValueType(type)) {
handleChangeProperty(item.id, { handleChangeProperty(item.id, {
value: '', value: '',
type, type,
}) })
} else { } else {
handleChangeProperty(item.id, { type }) handleChangeProperty(item.id, { type })
} }
}} }}
className="form-control editable" className="form-control editable"
> >
{TYPES.map(type => ( {TYPES.map(type => (
<option key={type} value={type}> <option key={type} value={type}>
{type} {type}
</option> </option>
))} ))}
</select> </select>
)} )}
</div> </div>
<div className="td payload rule nowrap"> <div className="td payload rule nowrap">
{!editable ? ( {!editable ? (
<span className="nowrap">{item.rule}</span> <span className="nowrap">{item.rule}</span>
) : ( ) : (
<input <input
value={item.rule || ''} value={item.rule || ''}
onChange={e => onChange={e =>
handleChangePropertyField(item.id, 'rule', e.target.value) handleChangePropertyField(item.id, 'rule', e.target.value)
} }
className="form-control editable" className="form-control editable"
spellCheck={false} spellCheck={false}
placeholder="" placeholder=""
/> />
)} )}
</div> </div>
<div className="td payload value"> <div className="td payload value">
{!editable ? ( {!editable ? (
@ -369,18 +372,18 @@ class SortableTreeTableRow extends Component<SortableTreeTableRowProps, Sortable
<span className="value-container">{getFormattedValue(item)}</span> <span className="value-container">{getFormattedValue(item)}</span>
</CopyToClipboard> </CopyToClipboard>
) : ( ) : (
<SmartTextarea <SmartTextarea
value={item.value || ''} value={item.value || ''}
onChange={(e: any) => onChange={(e: any) =>
handleChangePropertyField(item.id, 'value', e.target.value) handleChangePropertyField(item.id, 'value', e.target.value)
} }
disabled={isNoValueType(item.type) && !item.value} disabled={isNoValueType(item.type) && !item.value}
rows="1" rows="1"
className="form-control editable" className="form-control editable"
spellCheck={false} spellCheck={false}
placeholder="" placeholder=""
/> />
)} )}
</div> </div>
<div className="td payload desc"> <div className="td payload desc">
{!editable ? ( {!editable ? (
@ -388,17 +391,17 @@ class SortableTreeTableRow extends Component<SortableTreeTableRowProps, Sortable
<span>{item.description}</span> <span>{item.description}</span>
</CopyToClipboard> </CopyToClipboard>
) : ( ) : (
<SmartTextarea <SmartTextarea
value={item.description || ''} value={item.description || ''}
onChange={(e: any) => onChange={(e: any) =>
handleChangePropertyField(item.id, 'description', e.target.value) handleChangePropertyField(item.id, 'description', e.target.value)
} }
rows="1" rows="1"
className="form-control editable" className="form-control editable"
spellCheck={false} spellCheck={false}
placeholder="" placeholder=""
/> />
)} )}
</div> </div>
</div> </div>
{item.children && item.children.length ? ( {item.children && item.children.length ? (
@ -412,6 +415,7 @@ class SortableTreeTableRow extends Component<SortableTreeTableRowProps, Sortable
handleChangePropertyField={handleChangePropertyField} handleChangePropertyField={handleChangePropertyField}
handleSortProperties={handleSortProperties} handleSortProperties={handleSortProperties}
property={item} property={item}
bodyOption={bodyOption}
isExpanding={childrenIsExpanding} isExpanding={childrenIsExpanding}
/> />
) : null} ) : null}
@ -424,6 +428,12 @@ class SortableTreeTableRow extends Component<SortableTreeTableRowProps, Sortable
) )
} }
} }
function BodyParamLabel({ type }: { type: BODY_OPTION }) {
return (
<Chip label={type} className="ml1" size="small" />
)
}
class SortableTreeTable extends Component<any, any> { class SortableTreeTable extends Component<any, any> {
render() { render() {
const { const {
@ -436,6 +446,7 @@ class SortableTreeTable extends Component<any, any> {
handleChangeProperty, handleChangeProperty,
handleChangePropertyField, handleChangePropertyField,
handleSortProperties, handleSortProperties,
bodyOption,
} = this.props } = this.props
return ( return (
<div className={`SortableTreeTable ${editable ? 'editable' : ''}`}> <div className={`SortableTreeTable ${editable ? 'editable' : ''}`}>
@ -451,6 +462,7 @@ class SortableTreeTable extends Component<any, any> {
interfaceId={interfaceId} interfaceId={interfaceId}
property={root} property={root}
isExpanding={true} isExpanding={true}
bodyOption={bodyOption}
/> />
</div> </div>
) )
@ -471,7 +483,7 @@ class PropertyList extends PureComponent<any, any> {
editable: PropTypes.bool.isRequired, editable: PropTypes.bool.isRequired,
/** optional */ /** optional */
bodyOption: PropTypes.string, bodyOption: PropTypes.string,
requestParamsType: PropTypes.string, posFilter: PropTypes.number,
} }
static contextTypes = { static contextTypes = {
handleAddMemoryProperty: PropTypes.func.isRequired, handleAddMemoryProperty: PropTypes.func.isRequired,
@ -495,17 +507,18 @@ class PropertyList extends PureComponent<any, any> {
repository = {}, repository = {},
mod = {}, mod = {},
interfaceId, interfaceId,
bodyOption,
posFilter,
} = this.props } = this.props
if (!interfaceId) { if (!interfaceId) {
return null return null
} }
const { editable, requestParamsType } = this.props // itf.locker && (itf.locker.id === auth.id) const { editable } = this.props // itf.locker && (itf.locker.id === auth.id)
let scopedProperties = properties let scopedProperties = properties
.map((property: any) => ({ ...property })) .map((property: any) => ({ ...property }))
.filter((property: any) => property.scope === scope) .filter((property: any) => property.scope === scope)
const pos = rptFromStr2Num(requestParamsType)
if (scope === 'request' && editable) { if (scope === 'request' && editable) {
scopedProperties = scopedProperties.filter((s: any) => s.pos === pos) scopedProperties = scopedProperties.filter((s: any) => s.pos === posFilter)
} }
return ( return (
@ -534,6 +547,7 @@ class PropertyList extends PureComponent<any, any> {
<div className="body"> <div className="body">
<SortableTreeTable <SortableTreeTable
root={Tree.arrayToTree(scopedProperties)} root={Tree.arrayToTree(scopedProperties)}
bodyOption={bodyOption}
editable={editable} editable={editable}
highlightId={this.state.highlightId} highlightId={this.state.highlightId}
interfaceId={interfaceId} interfaceId={interfaceId}

@ -9,7 +9,6 @@ import {
connectRouter, connectRouter,
LOCATION_CHANGE, LOCATION_CHANGE,
} from 'connected-react-router' } from 'connected-react-router'
import loggerMiddleware from './loggerMiddleware'
import createSagaMiddleware from 'redux-saga' import createSagaMiddleware from 'redux-saga'
import URI from 'urijs' import URI from 'urijs'
@ -110,7 +109,7 @@ const Family: {
})) || })) ||
compose compose
const middlewares = logger const middlewares = logger
? [loggerMiddleware, routerMiddleware, apiMiddleware, sagaMiddleware] ? [routerMiddleware, apiMiddleware, sagaMiddleware] // 真的不需要这个logger d- o-b|||
: [routerMiddleware, apiMiddleware, sagaMiddleware] : [routerMiddleware, apiMiddleware, sagaMiddleware]
const store = createStore<any, any, any, any>( const store = createStore<any, any, any, any>(
combineReducers({ ..._reducers, router: connectRouter(history) }), combineReducers({ ..._reducers, router: connectRouter(history) }),

@ -262,7 +262,6 @@ const relatives = {
} }
}, },
*[DO_UPDATE_USER_SETTING](action: DoUpdateUserSettingAction) { *[DO_UPDATE_USER_SETTING](action: DoUpdateUserSettingAction) {
console.log('什么鬼啊')
const { key, value, cb } = action.payload const { key, value, cb } = action.payload
yield put(updateUserSetting(key, value) as AnyAction) yield put(updateUserSetting(key, value) as AnyAction)
const opAction = yield take(UPDATE_USER_SETTING_SUCCESS) const opAction = yield take(UPDATE_USER_SETTING_SUCCESS)

Loading…
Cancel
Save