| ... | @@ -111,15 +111,25 @@ export default class Clusters { |
... | @@ -111,15 +111,25 @@ export default class Clusters { |
|
|
this.initApplications(clusterType);
|
|
this.initApplications(clusterType);
|
|
|
this.initEnvironments();
|
|
this.initEnvironments();
|
|
|
|
|
|
|
|
if (clusterEnvironmentsPath) {
|
|
if (clusterEnvironmentsPath && this.environments) {
|
|
|
this.fetchEnvironments();
|
|
this.store.toggleFetchEnvironments(true);
|
|
|
|
|
|
|
|
this.initPolling(
|
|
|
|
'fetchClusterEnvironments',
|
|
|
|
data => this.handleClusterEnvironmentsSuccess(data),
|
|
|
|
() => this.handleEnvironmentsPollError(),
|
|
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
this.updateContainer(null, this.store.state.status, this.store.state.statusReason);
|
|
this.updateContainer(null, this.store.state.status, this.store.state.statusReason);
|
|
|
|
|
|
|
|
this.addListeners();
|
|
this.addListeners();
|
|
|
if (statusPath && !this.environments) {
|
|
if (statusPath && !this.environments) {
|
|
|
this.initPolling();
|
|
this.initPolling(
|
|
|
|
'fetchClusterStatus',
|
|
|
|
data => this.handleClusterStatusSuccess(data),
|
|
|
|
() => this.handlePollError(),
|
|
|
|
);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
| ... | @@ -179,16 +189,9 @@ export default class Clusters { |
... | @@ -179,16 +189,9 @@ export default class Clusters { |
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
fetchEnvironments() {
|
|
handleClusterEnvironmentsSuccess(data) {
|
|
|
this.store.toggleFetchEnvironments(true);
|
|
this.store.toggleFetchEnvironments(false);
|
|
|
|
|
this.store.updateEnvironments(data.data);
|
|
|
this.service
|
|
|
|
|
.fetchClusterEnvironments()
|
|
|
|
|
.then(data => {
|
|
|
|
|
this.store.toggleFetchEnvironments(false);
|
|
|
|
|
this.store.updateEnvironments(data.data);
|
|
|
|
|
})
|
|
|
|
|
.catch(() => Clusters.handleError());
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static initDismissableCallout() {
|
|
static initDismissableCallout() {
|
| ... | @@ -224,21 +227,16 @@ export default class Clusters { |
... | @@ -224,21 +227,16 @@ export default class Clusters { |
|
|
eventHub.$off('uninstallApplication');
|
|
eventHub.$off('uninstallApplication');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
initPolling() {
|
|
initPolling(method, successCallback, errorCallback) {
|
|
|
this.poll = new Poll({
|
|
this.poll = new Poll({
|
|
|
resource: this.service,
|
|
resource: this.service,
|
|
|
method: 'fetchData',
|
|
method,
|
|
|
successCallback: data => this.handleSuccess(data),
|
|
successCallback,
|
|
|
errorCallback: () => Clusters.handleError(),
|
|
errorCallback,
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
if (!Visibility.hidden()) {
|
|
if (!Visibility.hidden()) {
|
|
|
this.poll.makeRequest();
|
|
this.poll.makeRequest();
|
|
|
} else {
|
|
|
|
|
this.service
|
|
|
|
|
.fetchData()
|
|
|
|
|
.then(data => this.handleSuccess(data))
|
|
|
|
|
.catch(() => Clusters.handleError());
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Visibility.change(() => {
|
|
Visibility.change(() => {
|
| ... | @@ -250,11 +248,21 @@ export default class Clusters { |
... | @@ -250,11 +248,21 @@ export default class Clusters { |
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
handlePollError() {
|
|
|
|
this.constructor.handleError();
|
|
|
|
}
|
|
|
|
|
|
|
|
handleEnvironmentsPollError() {
|
|
|
|
this.store.toggleFetchEnvironments(false);
|
|
|
|
|
|
|
|
this.handlePollError();
|
|
|
|
}
|
|
|
|
|
|
|
static handleError() {
|
|
static handleError() {
|
|
|
Flash(s__('ClusterIntegration|Something went wrong on our end.'));
|
|
Flash(s__('ClusterIntegration|Something went wrong on our end.'));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
handleSuccess(data) {
|
|
handleClusterStatusSuccess(data) {
|
|
|
const prevStatus = this.store.state.status;
|
|
const prevStatus = this.store.state.status;
|
|
|
const prevApplicationMap = Object.assign({}, this.store.state.applications);
|
|
const prevApplicationMap = Object.assign({}, this.store.state.applications);
|
|
|
|
|
|
| ... | |
... | |
| ... | | ... | |