|
|
@@ -18,6 +18,8 @@ import {request} from 'graphql-request'
|
|
|
import {getCookie} from "../../../../cookie";
|
|
|
import {idGen} from "../../../../func";
|
|
|
import {graphqlUrl} from "../../../../config";
|
|
|
+import {manageUsers} from "../../../../config";
|
|
|
+import {FormattedMessage} from 'react-intl';
|
|
|
|
|
|
const confirm = Modal.confirm;
|
|
|
const Search = Input.Search;
|
|
|
@@ -40,7 +42,7 @@ class Schema extends Component {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- shouldComponentUpdate(nextProps,nextState) {
|
|
|
+ shouldComponentUpdate(nextProps, nextState) {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@@ -111,11 +113,10 @@ class Schema extends Component {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
request(graphqlUrl, SEARCH_SCHEMA, {id: referenceID}).then(
|
|
|
data => {
|
|
|
- console.log(data);
|
|
|
if (data.schema_by_id !== null) {
|
|
|
- localStorage.setItem('ecommerce', data.caseSchema.find(obj=>obj.schemaName==='ecommerce').schemaData);
|
|
|
- localStorage.setItem('subscribe', data.caseSchema.find(obj=>obj.schemaName==='subscribe').schemaData);
|
|
|
- localStorage.setItem('bills', data.caseSchema.find(obj=>obj.schemaName==='bills').schemaData);
|
|
|
+ localStorage.setItem('ecommerce', data.caseSchema.find(obj => obj.schemaName === 'ecommerce').schemaData);
|
|
|
+ localStorage.setItem('subscribe', data.caseSchema.find(obj => obj.schemaName === 'subscribe').schemaData);
|
|
|
+ localStorage.setItem('bills', data.caseSchema.find(obj => obj.schemaName === 'bills').schemaData);
|
|
|
resolve(data.schema_by_id.schemaData);
|
|
|
}
|
|
|
}
|
|
|
@@ -126,9 +127,9 @@ class Schema extends Component {
|
|
|
};
|
|
|
|
|
|
receiveDataFromTable = (data) => {
|
|
|
- this.setState({
|
|
|
- data
|
|
|
- })
|
|
|
+ this.setState({
|
|
|
+ data
|
|
|
+ })
|
|
|
};
|
|
|
|
|
|
componentWillReceiveProps(next) {
|
|
|
@@ -156,14 +157,12 @@ class Schema extends Component {
|
|
|
return 'error!';
|
|
|
}
|
|
|
|
|
|
- // let schemaName = data.schema_by_id.schemaName;
|
|
|
-
|
|
|
let copy;
|
|
|
- if(this.props.location.state)
|
|
|
+ if (this.props.location.state)
|
|
|
copy = this.props.location.state.copy;
|
|
|
|
|
|
// 找到 copy 一定几率不显示的 问题原因,异步导致的未存先取
|
|
|
- if (data.schema_by_id === null && copy!==true) data = [];
|
|
|
+ if (data.schema_by_id === null && copy !== true) data = [];
|
|
|
else {
|
|
|
let reference = data.schema_by_id ? data.schema_by_id.reference : this.props.location.state.reference;
|
|
|
data = data.schema_by_id ? JSON.parse(data.schema_by_id.schemaData) : [];
|
|
|
@@ -200,9 +199,7 @@ class Schema extends Component {
|
|
|
<div className={'schema'}>
|
|
|
<span className={'schema-name'}>{this.state.schemaName}</span>
|
|
|
{
|
|
|
- trialcase ?
|
|
|
- ''
|
|
|
- :
|
|
|
+ userID.indexOf(manageUsers) > -1 ?
|
|
|
<Icon style={{marginLeft: 15}}
|
|
|
type="edit"
|
|
|
theme="twoTone"
|
|
|
@@ -212,6 +209,19 @@ class Schema extends Component {
|
|
|
}
|
|
|
}
|
|
|
/>
|
|
|
+ :
|
|
|
+ trialcase ?
|
|
|
+ ''
|
|
|
+ :
|
|
|
+ <Icon style={{marginLeft: 15}}
|
|
|
+ type="edit"
|
|
|
+ theme="twoTone"
|
|
|
+ onClick={
|
|
|
+ () => {
|
|
|
+ this.setState({editSchemaName: this.state.schemaName})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ />
|
|
|
}
|
|
|
</div>
|
|
|
}
|
|
|
@@ -219,14 +229,13 @@ class Schema extends Component {
|
|
|
<div className={'schema-table-list-title'}>
|
|
|
<Row>
|
|
|
<Col span={10}><span
|
|
|
- className={'schema-table-title'}>Name</span></Col>
|
|
|
+ className={'schema-table-title'}><FormattedMessage
|
|
|
+ id="Name"/></span></Col>
|
|
|
<Col span={10}><span
|
|
|
- className={'schema-table-title'}>Remark</span></Col>
|
|
|
+ className={'schema-table-title'}><FormattedMessage id="Remark"/></span></Col>
|
|
|
<Col span={2} offset={2}>
|
|
|
{
|
|
|
- trialcase ?
|
|
|
- ''
|
|
|
- :
|
|
|
+ userID.indexOf(manageUsers) > -1 ?
|
|
|
<span
|
|
|
className={'schema-table-title'}
|
|
|
onClick={() => {
|
|
|
@@ -236,6 +245,19 @@ class Schema extends Component {
|
|
|
}}>
|
|
|
<Icon type="plus"/>
|
|
|
</span>
|
|
|
+ :
|
|
|
+ trialcase ?
|
|
|
+ ''
|
|
|
+ :
|
|
|
+ <span
|
|
|
+ className={'schema-table-title'}
|
|
|
+ onClick={() => {
|
|
|
+ this.setState({
|
|
|
+ currentTable: 'add'
|
|
|
+ })
|
|
|
+ }}>
|
|
|
+ <Icon type="plus" style={{color: '#096dd9',cursor: 'pointer'}}/>
|
|
|
+ </span>
|
|
|
}
|
|
|
|
|
|
</Col>
|
|
|
@@ -263,9 +285,7 @@ class Schema extends Component {
|
|
|
|
|
|
<span className={'schema-table-content'}>
|
|
|
{
|
|
|
- trialcase ?
|
|
|
- ''
|
|
|
- :
|
|
|
+ userID.indexOf(manageUsers) > -1 ?
|
|
|
<DeleteTableButton
|
|
|
currentTable={table.name}
|
|
|
schemaData={data}
|
|
|
@@ -277,8 +297,22 @@ class Schema extends Component {
|
|
|
fetchData={this.fetchData}
|
|
|
location={this.props.location}
|
|
|
/>
|
|
|
+ :
|
|
|
+ trialcase ?
|
|
|
+ ''
|
|
|
+ :
|
|
|
+ <DeleteTableButton
|
|
|
+ currentTable={table.name}
|
|
|
+ schemaData={data}
|
|
|
+ schemaID={this.state.schemaID}
|
|
|
+ userID={userID}
|
|
|
+ showTablePagination={this.showTablePagination}
|
|
|
+ page={this.state.page}
|
|
|
+ pageSize={this.state.pageSize}
|
|
|
+ fetchData={this.fetchData}
|
|
|
+ location={this.props.location}
|
|
|
+ />
|
|
|
}
|
|
|
-
|
|
|
</span>
|
|
|
</Col>
|
|
|
</Row>
|
|
|
@@ -303,9 +337,7 @@ class Schema extends Component {
|
|
|
<Col span={2} offset={2}>
|
|
|
<span className={'schema-table-content'}>
|
|
|
{
|
|
|
- trialcase ?
|
|
|
- ''
|
|
|
- :
|
|
|
+ userID.indexOf(manageUsers) > -1 ?
|
|
|
<DeleteTableButton
|
|
|
currentTable={table.name}
|
|
|
schemaData={data}
|
|
|
@@ -317,6 +349,21 @@ class Schema extends Component {
|
|
|
fetchData={this.fetchData}
|
|
|
location={this.props.location}
|
|
|
/>
|
|
|
+ :
|
|
|
+ trialcase ?
|
|
|
+ ''
|
|
|
+ :
|
|
|
+ <DeleteTableButton
|
|
|
+ currentTable={table.name}
|
|
|
+ schemaData={data}
|
|
|
+ schemaID={this.state.schemaID}
|
|
|
+ showTablePagination={this.showTablePagination}
|
|
|
+ page={this.state.page}
|
|
|
+ pageSize={this.state.pageSize}
|
|
|
+ userID={userID}
|
|
|
+ fetchData={this.fetchData}
|
|
|
+ location={this.props.location}
|
|
|
+ />
|
|
|
}
|
|
|
</span>
|
|
|
</Col>
|
|
|
@@ -330,22 +377,51 @@ class Schema extends Component {
|
|
|
<Row>
|
|
|
<Col span={4}>
|
|
|
{
|
|
|
- trialcase ?
|
|
|
- <div className={'delete-schema'}>
|
|
|
- <CopySchemaButton
|
|
|
- userID={userID}
|
|
|
- history={this.props.history}
|
|
|
- schemaName={this.state.schemaName}
|
|
|
- />
|
|
|
- </div>
|
|
|
+ userID.indexOf(manageUsers) > -1 ?
|
|
|
+ trialcase ?
|
|
|
+ <div>
|
|
|
+ <div style={{display: 'inline-block'}}
|
|
|
+ className={'delete-schema'}>
|
|
|
+ <CopySchemaButton
|
|
|
+ userID={userID}
|
|
|
+ history={this.props.history}
|
|
|
+ schemaName={this.state.schemaName}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div style={{display: 'inline-block'}}
|
|
|
+ className={'delete-schema'}>
|
|
|
+ <DeleteSchemaButton
|
|
|
+ userID={userID}
|
|
|
+ schemaName={this.state.schemaName}
|
|
|
+ history={this.props.history}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ :
|
|
|
+ <div className={'delete-schema'}>
|
|
|
+ <DeleteSchemaButton
|
|
|
+ userID={userID}
|
|
|
+ schemaName={this.state.schemaName}
|
|
|
+ history={this.props.history}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
:
|
|
|
- <div className={'delete-schema'}>
|
|
|
- <DeleteSchemaButton
|
|
|
- userID={userID}
|
|
|
- schemaName={this.state.schemaName}
|
|
|
- history={this.props.history}
|
|
|
- />
|
|
|
- </div>
|
|
|
+ trialcase ?
|
|
|
+ <div className={'delete-schema'}>
|
|
|
+ <CopySchemaButton
|
|
|
+ userID={userID}
|
|
|
+ history={this.props.history}
|
|
|
+ schemaName={this.state.schemaName}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ :
|
|
|
+ <div className={'delete-schema'}>
|
|
|
+ <DeleteSchemaButton
|
|
|
+ userID={userID}
|
|
|
+ schemaName={this.state.schemaName}
|
|
|
+ history={this.props.history}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
}
|
|
|
</Col>
|
|
|
<Col span={4} offset={16}>
|
|
|
@@ -387,8 +463,8 @@ class Schema extends Component {
|
|
|
<Table
|
|
|
currentTable={this.state.currentTable}
|
|
|
schemaData={data}
|
|
|
- columns={this.findColumns(data.length !== 0? data : this.state.data)}
|
|
|
- remark={this.findRemark(data.length !== 0? data : this.state.data)}
|
|
|
+ columns={this.findColumns(data.length !== 0 ? data : this.state.data)}
|
|
|
+ remark={this.findRemark(data.length !== 0 ? data : this.state.data)}
|
|
|
schemaID={this.state.schemaID}
|
|
|
schemaName={this.state.schemaName}
|
|
|
userID={userID}
|
|
|
@@ -467,7 +543,7 @@ class CopySchemaButton extends Component {
|
|
|
});
|
|
|
}}
|
|
|
|
|
|
- >copy</Button>
|
|
|
+ ><FormattedMessage id="copy"/></Button>
|
|
|
)
|
|
|
}}
|
|
|
</Mutation>
|
|
|
@@ -529,7 +605,7 @@ class DeleteSchemaButton extends Component {
|
|
|
this.showConfirm(delete_schema, schemaName, userID);
|
|
|
}}
|
|
|
>
|
|
|
- delete
|
|
|
+ <FormattedMessage id="delete"/>
|
|
|
</Button>
|
|
|
)
|
|
|
}}
|
|
|
@@ -591,6 +667,7 @@ class DeleteTableButton extends Component {
|
|
|
|
|
|
return (
|
|
|
<Icon type="delete"
|
|
|
+ theme="twoTone"
|
|
|
onClick={() => {
|
|
|
update_schema({
|
|
|
variables: {
|
|
|
@@ -634,30 +711,34 @@ class ModifySchemaNameInput extends Component {
|
|
|
return <Spin style={{marginLeft: 3}}/>;
|
|
|
return (
|
|
|
<div className={'schema'}>
|
|
|
- <Search
|
|
|
- value={this.props.editSchemaName}
|
|
|
- enterButton="Confirm"
|
|
|
- style={{width: 500}}
|
|
|
- size="large"
|
|
|
- onChange={this.props.changeEditSchemaName}
|
|
|
- onSearch={value => {
|
|
|
- update_schema({
|
|
|
- variables: {
|
|
|
- id: this.props.schemaID,
|
|
|
- schemaName: value,
|
|
|
- updateAt: new Date().getTime()
|
|
|
- }
|
|
|
- });
|
|
|
- this.props.history.push({
|
|
|
- pathname: `/graphql-service/my-create/${value}`,
|
|
|
- state: {
|
|
|
- schemaName: value,
|
|
|
- schemaID: this.props.schemaID,
|
|
|
- }
|
|
|
- });
|
|
|
- this.props.clearEditSchemaName();
|
|
|
- }}
|
|
|
- />
|
|
|
+ <FormattedMessage id="Confirm">
|
|
|
+ {(msg) => (
|
|
|
+ <Search
|
|
|
+ value={this.props.editSchemaName}
|
|
|
+ enterButton={msg}
|
|
|
+ style={{width: 500}}
|
|
|
+ size="large"
|
|
|
+ onChange={this.props.changeEditSchemaName}
|
|
|
+ onSearch={value => {
|
|
|
+ update_schema({
|
|
|
+ variables: {
|
|
|
+ id: this.props.schemaID,
|
|
|
+ schemaName: value,
|
|
|
+ updateAt: new Date().getTime()
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.props.history.push({
|
|
|
+ pathname: `/graphql-service/my-create/${value}`,
|
|
|
+ state: {
|
|
|
+ schemaName: value,
|
|
|
+ schemaID: this.props.schemaID,
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.props.clearEditSchemaName();
|
|
|
+ }}
|
|
|
+ />)}
|
|
|
+ </FormattedMessage>
|
|
|
+
|
|
|
</div>
|
|
|
)
|
|
|
}}
|