@@ -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 CollaboratorForm from '../../components/collaborator-form'
26
25
import Message from '../../../lib/components/message'
27
26
import IntlHelmet from '../../../lib/components/intl-helmet'
27
+ import withRequest from '../../../lib/components/with-request'
28
28
29
29
import { getApplicationsRightsList } from '../../store/actions/applications'
30
30
import {
@@ -54,6 +54,10 @@ import api from '../../api'
54
54
redirectToList : ( ) => dispatchProps . redirectToList ( stateProps . appId ) ,
55
55
getApplicationsRightsList : ( ) => dispatchProps . getApplicationsRightsList ( stateProps . appId ) ,
56
56
} ) )
57
+ @withRequest (
58
+ ( { getApplicationsRightsList } ) => getApplicationsRightsList ( ) ,
59
+ ( { fetching, rights } ) => fetching || ! Boolean ( rights . length )
60
+ )
57
61
@withBreadcrumb ( 'apps.single.collaborators.add' , function ( props ) {
58
62
const appId = props . appId
59
63
return (
@@ -71,39 +75,19 @@ export default class ApplicationCollaboratorAdd extends React.Component {
71
75
error : '' ,
72
76
}
73
77
74
- componentDidMount ( ) {
75
- const { getApplicationsRightsList } = this . props
76
-
77
- getApplicationsRightsList ( )
78
- }
79
-
80
- componentDidUpdate ( prevProps ) {
81
- const { error } = this . props
82
-
83
- if ( Boolean ( error ) && prevProps . error !== error ) {
84
- throw error
85
- }
86
- }
87
-
88
78
async handleSubmit ( collaborator ) {
89
79
const { appId } = this . props
90
80
91
81
await api . application . collaborators . add ( appId , collaborator )
92
-
93
82
}
94
83
95
84
render ( ) {
96
85
const {
97
86
rights,
98
- fetching,
99
87
universalRights,
100
88
redirectToList,
101
89
} = this . props
102
90
103
- if ( fetching && ! rights . length ) {
104
- return < Spinner center />
105
- }
106
-
107
91
return (
108
92
< Container >
109
93
< Row >
0 commit comments