@@ -31,12 +31,15 @@ import replicaLargeImage from './images/replica-large.svg'
3131
3232import projectStore from '../../../stores/ProjectStore'
3333import replicaStore from '../../../stores/ReplicaStore'
34+ import scheduleStore from '../../../stores/ScheduleStore'
3435import endpointStore from '../../../stores/EndpointStore'
3536import notificationStore from '../../../stores/NotificationStore'
3637import configLoader from '../../../utils/Config'
3738
3839const Wrapper = styled . div ``
3940
41+ const SCHEDULE_POLL_TIMEOUT = 10000
42+
4043const BulkActions = [
4144 { label : 'Execute' , value : 'execute' } ,
4245 { label : 'Delete' , value : 'delete' } ,
@@ -57,6 +60,8 @@ class ReplicasPage extends React.Component<{ history: any }, State> {
5760
5861 pollTimeout : TimeoutID
5962 stopPolling : boolean
63+ schedulePolling : boolean
64+ schedulePollTimeout : TimeoutID
6065
6166 componentDidMount ( ) {
6267 document . title = 'Coriolis Replicas'
@@ -70,6 +75,7 @@ class ReplicasPage extends React.Component<{ history: any }, State> {
7075
7176 componentWillUnmount ( ) {
7277 clearTimeout ( this . pollTimeout )
78+ clearTimeout ( this . schedulePollTimeout )
7379 this . stopPolling = true
7480 }
7581
@@ -164,10 +170,25 @@ class ReplicasPage extends React.Component<{ history: any }, State> {
164170 }
165171
166172 Promise . all ( [ replicaStore . getReplicas ( ) , endpointStore . getEndpoints ( ) ] ) . then ( ( ) => {
173+ if ( ! this . schedulePolling ) {
174+ this . pollSchedule ( )
175+ }
167176 this . pollTimeout = setTimeout ( ( ) => { this . pollData ( ) } , configLoader . config . requestPollTimeout )
168177 } )
169178 }
170179
180+ pollSchedule ( ) {
181+ if ( this . state . modalIsOpen || this . stopPolling || replicaStore . replicas . length === 0 ) {
182+ return
183+ }
184+ this . schedulePolling = true
185+ scheduleStore . getSchedulesBulk ( replicaStore . replicas . map ( r => r . id ) ) . then ( ( ) => {
186+ this . schedulePollTimeout = setTimeout ( ( ) => {
187+ this . pollSchedule ( )
188+ } , SCHEDULE_POLL_TIMEOUT )
189+ } )
190+ }
191+
171192 searchText ( item : MainItem , text : ?string ) {
172193 let result = false
173194 if ( item . instances [ 0 ] . toLowerCase ( ) . indexOf ( text || '' ) > - 1 ) {
@@ -196,6 +217,14 @@ class ReplicasPage extends React.Component<{ history: any }, State> {
196217 return true
197218 }
198219
220+ isReplicaScheduled ( replicaId : string ) : boolean {
221+ let bulkScheduleItem = scheduleStore . bulkSchedules . find ( b => b . replicaId === replicaId )
222+ if ( ! bulkScheduleItem ) {
223+ return false
224+ }
225+ return Boolean ( bulkScheduleItem . schedules . find ( s => s . enabled ) )
226+ }
227+
199228 render ( ) {
200229 return (
201230 < Wrapper >
@@ -216,6 +245,7 @@ class ReplicasPage extends React.Component<{ history: any }, State> {
216245 ( < MainListItem
217246 { ...options }
218247 image = { replicaItemImage }
248+ showScheduleIcon = { this . isReplicaScheduled ( options . item . id ) }
219249 endpointType = { id => {
220250 let endpoint = this . getEndpoint ( id )
221251 if ( endpoint ) {
0 commit comments