2018-10-15 14:42:47 +05:30
|
|
|
import createFlash from '~/flash';
|
|
|
|
import { __ } from '~/locale';
|
|
|
|
import setupToggleButtons from '~/toggle_buttons';
|
|
|
|
import gcpSignupOffer from '~/clusters/components/gcp_signup_offer';
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
import ClustersService from './services/clusters_service';
|
|
|
|
|
|
|
|
export default () => {
|
|
|
|
const clusterList = document.querySelector('.js-clusters-list');
|
2018-10-15 14:42:47 +05:30
|
|
|
|
|
|
|
gcpSignupOffer();
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
// The empty state won't have a clusterList
|
|
|
|
if (clusterList) {
|
2018-10-15 14:42:47 +05:30
|
|
|
setupToggleButtons(document.querySelector('.js-clusters-list'), (value, toggle) =>
|
|
|
|
ClustersService.updateCluster(toggle.dataset.endpoint, { cluster: { enabled: value } }).catch(
|
|
|
|
err => {
|
|
|
|
createFlash(__('Something went wrong on our end.'));
|
|
|
|
throw err;
|
|
|
|
},
|
|
|
|
),
|
2018-03-17 18:26:18 +05:30
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|