@@ -18,13 +18,13 @@ import bind from 'autobind-decorator'
18
18
import { connect } from 'react-redux'
19
19
import { push } from 'connected-react-router'
20
20
21
- import Spinner from '../../../components/spinner'
22
21
import Breadcrumb from '../../../components/breadcrumbs/breadcrumb'
23
22
import { withBreadcrumb } from '../../../components/breadcrumbs/context'
24
23
import sharedMessages from '../../../lib/shared-messages'
25
24
import Message from '../../../lib/components/message'
26
25
import IntlHelmet from '../../../lib/components/intl-helmet'
27
26
import CollaboratorForm from '../../components/collaborator-form'
27
+ import withRequest from '../../../lib/components/with-request'
28
28
29
29
import {
30
30
selectSelectedGatewayId ,
@@ -56,6 +56,10 @@ import api from '../../api'
56
56
getGatewaysRightsList : ( ) => dispatchProps . getGatewaysRightsList ( stateProps . gtwId ) ,
57
57
redirectToList : ( ) => dispatchProps . redirectToList ( stateProps . gtwId ) ,
58
58
} ) )
59
+ @withRequest (
60
+ ( { getGatewaysRightsList } ) => getGatewaysRightsList ( ) ,
61
+ ( { fetching, rights } ) => fetching || ! Boolean ( rights . length )
62
+ )
59
63
@withBreadcrumb ( 'gtws.single.collaborators.add' , function ( props ) {
60
64
const gtwId = props . gtwId
61
65
return (
@@ -73,20 +77,6 @@ export default class GatewayCollaboratorAdd extends React.Component {
73
77
error : '' ,
74
78
}
75
79
76
- componentDidMount ( ) {
77
- const { getGatewaysRightsList } = this . props
78
-
79
- getGatewaysRightsList ( )
80
- }
81
-
82
- componentDidUpdate ( prevProps ) {
83
- const { error } = this . props
84
-
85
- if ( Boolean ( error ) && prevProps . error !== error ) {
86
- throw error
87
- }
88
- }
89
-
90
80
handleSubmit ( collaborator ) {
91
81
const { gtwId } = this . props
92
82
@@ -96,15 +86,10 @@ export default class GatewayCollaboratorAdd extends React.Component {
96
86
render ( ) {
97
87
const {
98
88
rights,
99
- fetching,
100
89
redirectToList,
101
90
universalRights,
102
91
} = this . props
103
92
104
- if ( fetching && ! rights . length ) {
105
- return < Spinner center />
106
- }
107
-
108
93
return (
109
94
< Container >
110
95
< Row >
0 commit comments