11import React from 'react' ;
22import PropTypes from 'prop-types' ;
3- import { NavLink } from 'react-router-dom' ;
43import CatalogForm from '../../../../react2/src/components/catalog/CatalogForm' ;
54import CatalogApi from '../../api/catalogApi' ;
65import { Breadcrumb , Spin , notification , Modal } from 'antd' ;
@@ -24,8 +23,23 @@ export class ManageCatalogPage extends React.Component {
2423 } ;
2524 }
2625
27- componentWillMount ( ) {
28- CatalogApi . getCatalogInfo ( this . props . match . params . name )
26+ componentDidMount ( ) {
27+ const id = this . props . match . params . id ;
28+ const name = this . props . match . params . name ;
29+
30+ this . fetchCatalogData ( name , id ) ;
31+ }
32+
33+ componentWillReceiveProps ( nextProps ) {
34+ const nextId = nextProps . match . params . id ;
35+ if ( nextId === this . props . match . params . id ) return ;
36+
37+ const name = this . props . match . params . name ;
38+ this . fetchCatalogData ( name , nextId ) ;
39+ }
40+
41+ fetchCatalogData = ( name , id ) => {
42+ CatalogApi . getCatalogInfo ( name )
2943 . then ( ( response ) => {
3044 this . setState ( { catalog : response . data } ) ;
3145
@@ -37,9 +51,6 @@ export class ManageCatalogPage extends React.Component {
3751 }
3852 } ) ;
3953
40- const id = this . props . match . params . id ;
41- const name = this . props . match . params . name ;
42-
4354 if ( id ) {
4455 return CatalogApi . getFormObjectById ( name , id ) ;
4556 }
@@ -58,7 +69,7 @@ export class ManageCatalogPage extends React.Component {
5869 message : 'An error has occurred: ' + summary
5970 } ) ;
6071 } ) ;
61- }
72+ } ;
6273
6374 loadCollection = ( catalogClass ) => {
6475 return CatalogApi . getCatalogExtendWithClass ( catalogClass )
@@ -80,10 +91,8 @@ export class ManageCatalogPage extends React.Component {
8091 let errors = { } ;
8192
8293 /*
83- if (this.state.form.title.length < 5) {
84- errors.title = 'Title must be at least 5 characters.';
85- formIsValid = false;
86- }*/
94+ Put validation logic here
95+ */
8796
8897 this . setState ( { errors } ) ;
8998 return formIsValid ;
0 commit comments