2017-10-24 00:56:39 -04:00
|
|
|
import Visibility from 'visibilityjs';
|
|
|
|
import Vue from 'vue';
|
2019-04-25 10:50:57 -04:00
|
|
|
import { GlToast } from '@gitlab/ui';
|
2019-12-09 07:07:58 -05:00
|
|
|
import AccessorUtilities from '~/lib/utils/accessor';
|
2018-12-06 08:41:20 -05:00
|
|
|
import PersistentUserCallout from '../persistent_user_callout';
|
2017-10-24 00:56:39 -04:00
|
|
|
import { s__, sprintf } from '../locale';
|
|
|
|
import Flash from '../flash';
|
|
|
|
import Poll from '../lib/utils/poll';
|
|
|
|
import initSettingsPanels from '../settings_panels';
|
|
|
|
import eventHub from './event_hub';
|
2020-03-27 14:07:48 -04:00
|
|
|
import {
|
|
|
|
APPLICATION_STATUS,
|
|
|
|
INGRESS,
|
|
|
|
INGRESS_DOMAIN_SUFFIX,
|
|
|
|
CROSSPLANE,
|
|
|
|
KNATIVE,
|
2020-04-29 14:09:56 -04:00
|
|
|
FLUENTD,
|
2020-03-27 14:07:48 -04:00
|
|
|
} from './constants';
|
2017-10-24 00:56:39 -04:00
|
|
|
import ClustersService from './services/clusters_service';
|
|
|
|
import ClustersStore from './stores/clusters_store';
|
2018-11-04 16:35:24 -05:00
|
|
|
import Applications from './components/applications.vue';
|
2019-12-17 04:07:48 -05:00
|
|
|
import RemoveClusterConfirmation from './components/remove_cluster_confirmation.vue';
|
2018-01-24 16:54:33 -05:00
|
|
|
import setupToggleButtons from '../toggle_buttons';
|
2019-11-04 04:06:21 -05:00
|
|
|
import initProjectSelectDropdown from '~/project_select';
|
2020-03-27 14:07:48 -04:00
|
|
|
import initServerlessSurveyBanner from '~/serverless/survey_banner';
|
2017-10-24 00:56:39 -04:00
|
|
|
|
2019-09-04 13:03:05 -04:00
|
|
|
const Environments = () => import('ee_component/clusters/components/environments.vue');
|
|
|
|
|
2019-04-25 10:50:57 -04:00
|
|
|
Vue.use(GlToast);
|
|
|
|
|
2017-10-24 00:56:39 -04:00
|
|
|
/**
|
|
|
|
* Cluster page has 2 separate parts:
|
|
|
|
* Toggle button and applications section
|
|
|
|
*
|
|
|
|
* - Polling status while creating or scheduled
|
|
|
|
* - Update status area with the response result
|
|
|
|
*/
|
|
|
|
|
|
|
|
export default class Clusters {
|
|
|
|
constructor() {
|
|
|
|
const {
|
|
|
|
statusPath,
|
|
|
|
installHelmPath,
|
|
|
|
installIngressPath,
|
2018-11-02 23:38:21 -04:00
|
|
|
installCertManagerPath,
|
2017-11-06 11:07:19 -05:00
|
|
|
installRunnerPath,
|
2018-05-16 05:01:13 -04:00
|
|
|
installJupyterPath,
|
2018-10-25 01:38:44 -04:00
|
|
|
installKnativePath,
|
2019-02-19 04:24:37 -05:00
|
|
|
updateKnativePath,
|
2019-10-22 11:06:06 -04:00
|
|
|
installElasticStackPath,
|
2019-11-17 22:06:28 -05:00
|
|
|
installCrossplanePath,
|
2017-12-22 12:23:43 -05:00
|
|
|
installPrometheusPath,
|
2020-04-21 11:21:10 -04:00
|
|
|
installFluentdPath,
|
2018-01-30 18:21:59 -05:00
|
|
|
managePrometheusPath,
|
2019-09-13 09:26:31 -04:00
|
|
|
clusterEnvironmentsPath,
|
2018-12-13 10:39:44 -05:00
|
|
|
hasRbac,
|
2019-09-22 20:06:29 -04:00
|
|
|
providerType,
|
|
|
|
preInstalledKnative,
|
2018-11-04 16:36:22 -05:00
|
|
|
clusterType,
|
2017-10-24 00:56:39 -04:00
|
|
|
clusterStatus,
|
|
|
|
clusterStatusReason,
|
|
|
|
helpPath,
|
2018-02-06 09:59:15 -05:00
|
|
|
ingressHelpPath,
|
2018-02-20 07:44:20 -05:00
|
|
|
ingressDnsHelpPath,
|
2020-01-07 07:07:55 -05:00
|
|
|
ingressModSecurityHelpPath,
|
2019-09-04 13:03:05 -04:00
|
|
|
environmentsHelpPath,
|
|
|
|
clustersHelpPath,
|
|
|
|
deployBoardsHelpPath,
|
2019-09-22 20:06:29 -04:00
|
|
|
cloudRunHelpPath,
|
2019-05-27 04:23:17 -04:00
|
|
|
clusterId,
|
2017-10-24 00:56:39 -04:00
|
|
|
} = document.querySelector('.js-edit-cluster-form').dataset;
|
|
|
|
|
2019-05-27 04:23:17 -04:00
|
|
|
this.clusterId = clusterId;
|
2019-08-02 16:08:53 -04:00
|
|
|
this.clusterNewlyCreatedKey = `cluster_${this.clusterId}_newly_created`;
|
|
|
|
this.clusterBannerDismissedKey = `cluster_${this.clusterId}_banner_dismissed`;
|
|
|
|
|
2017-10-24 00:56:39 -04:00
|
|
|
this.store = new ClustersStore();
|
2019-09-04 13:03:05 -04:00
|
|
|
this.store.setHelpPaths(
|
|
|
|
helpPath,
|
|
|
|
ingressHelpPath,
|
|
|
|
ingressDnsHelpPath,
|
2020-01-07 07:07:55 -05:00
|
|
|
ingressModSecurityHelpPath,
|
2019-09-04 13:03:05 -04:00
|
|
|
environmentsHelpPath,
|
|
|
|
clustersHelpPath,
|
|
|
|
deployBoardsHelpPath,
|
2019-09-22 20:06:29 -04:00
|
|
|
cloudRunHelpPath,
|
2019-09-04 13:03:05 -04:00
|
|
|
);
|
2018-01-30 18:21:59 -05:00
|
|
|
this.store.setManagePrometheusPath(managePrometheusPath);
|
2017-10-24 00:56:39 -04:00
|
|
|
this.store.updateStatus(clusterStatus);
|
|
|
|
this.store.updateStatusReason(clusterStatusReason);
|
2019-09-22 20:06:29 -04:00
|
|
|
this.store.updateProviderType(providerType);
|
|
|
|
this.store.updatePreInstalledKnative(preInstalledKnative);
|
2018-12-13 10:39:44 -05:00
|
|
|
this.store.updateRbac(hasRbac);
|
2017-10-24 00:56:39 -04:00
|
|
|
this.service = new ClustersService({
|
|
|
|
endpoint: statusPath,
|
|
|
|
installHelmEndpoint: installHelmPath,
|
2017-11-06 05:03:25 -05:00
|
|
|
installIngressEndpoint: installIngressPath,
|
2018-11-02 23:38:21 -04:00
|
|
|
installCertManagerEndpoint: installCertManagerPath,
|
2019-11-17 22:06:28 -05:00
|
|
|
installCrossplaneEndpoint: installCrossplanePath,
|
2017-11-06 11:07:19 -05:00
|
|
|
installRunnerEndpoint: installRunnerPath,
|
2017-12-22 12:23:43 -05:00
|
|
|
installPrometheusEndpoint: installPrometheusPath,
|
2018-05-16 05:01:13 -04:00
|
|
|
installJupyterEndpoint: installJupyterPath,
|
2018-10-25 01:38:44 -04:00
|
|
|
installKnativeEndpoint: installKnativePath,
|
2019-02-19 04:24:37 -05:00
|
|
|
updateKnativeEndpoint: updateKnativePath,
|
2019-10-22 11:06:06 -04:00
|
|
|
installElasticStackEndpoint: installElasticStackPath,
|
2019-09-13 09:26:31 -04:00
|
|
|
clusterEnvironmentsEndpoint: clusterEnvironmentsPath,
|
2020-04-21 11:21:10 -04:00
|
|
|
installFluentdEndpoint: installFluentdPath,
|
2017-10-24 00:56:39 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
this.installApplication = this.installApplication.bind(this);
|
|
|
|
|
|
|
|
this.errorContainer = document.querySelector('.js-cluster-error');
|
|
|
|
this.successContainer = document.querySelector('.js-cluster-success');
|
|
|
|
this.creatingContainer = document.querySelector('.js-cluster-creating');
|
2019-05-27 04:23:17 -04:00
|
|
|
this.unreachableContainer = document.querySelector('.js-cluster-api-unreachable');
|
|
|
|
this.authenticationFailureContainer = document.querySelector(
|
|
|
|
'.js-cluster-authentication-failure',
|
|
|
|
);
|
2017-10-24 00:56:39 -04:00
|
|
|
this.errorReasonContainer = this.errorContainer.querySelector('.js-error-reason');
|
|
|
|
this.successApplicationContainer = document.querySelector('.js-cluster-application-notice');
|
2017-11-09 06:47:08 -05:00
|
|
|
this.tokenField = document.querySelector('.js-cluster-token');
|
2019-03-18 15:53:51 -04:00
|
|
|
this.ingressDomainHelpText = document.querySelector('.js-ingress-domain-help-text');
|
2019-08-02 16:08:53 -04:00
|
|
|
this.ingressDomainSnippet =
|
|
|
|
this.ingressDomainHelpText &&
|
|
|
|
this.ingressDomainHelpText.querySelector('.js-ingress-domain-snippet');
|
2017-10-24 00:56:39 -04:00
|
|
|
|
2019-11-04 04:06:21 -05:00
|
|
|
initProjectSelectDropdown();
|
2018-12-06 08:41:20 -05:00
|
|
|
Clusters.initDismissableCallout();
|
2017-10-24 00:56:39 -04:00
|
|
|
initSettingsPanels();
|
2019-11-04 04:06:21 -05:00
|
|
|
|
2019-08-02 16:08:53 -04:00
|
|
|
const toggleButtonsContainer = document.querySelector('.js-cluster-enable-toggle-area');
|
|
|
|
if (toggleButtonsContainer) {
|
|
|
|
setupToggleButtons(toggleButtonsContainer);
|
|
|
|
}
|
2018-11-04 16:36:22 -05:00
|
|
|
this.initApplications(clusterType);
|
2019-09-04 13:03:05 -04:00
|
|
|
this.initEnvironments();
|
2017-10-24 00:56:39 -04:00
|
|
|
|
2019-09-18 10:02:45 -04:00
|
|
|
if (clusterEnvironmentsPath && this.environments) {
|
|
|
|
this.store.toggleFetchEnvironments(true);
|
|
|
|
|
|
|
|
this.initPolling(
|
|
|
|
'fetchClusterEnvironments',
|
|
|
|
data => this.handleClusterEnvironmentsSuccess(data),
|
|
|
|
() => this.handleEnvironmentsPollError(),
|
|
|
|
);
|
2019-09-13 09:26:31 -04:00
|
|
|
}
|
|
|
|
|
2019-08-02 16:08:53 -04:00
|
|
|
this.updateContainer(null, this.store.state.status, this.store.state.statusReason);
|
2017-10-24 00:56:39 -04:00
|
|
|
|
|
|
|
this.addListeners();
|
2019-09-04 13:03:05 -04:00
|
|
|
if (statusPath && !this.environments) {
|
2019-09-18 10:02:45 -04:00
|
|
|
this.initPolling(
|
|
|
|
'fetchClusterStatus',
|
|
|
|
data => this.handleClusterStatusSuccess(data),
|
|
|
|
() => this.handlePollError(),
|
|
|
|
);
|
2017-10-24 00:56:39 -04:00
|
|
|
}
|
2019-12-17 04:07:48 -05:00
|
|
|
|
|
|
|
this.initRemoveClusterActions();
|
2017-10-24 00:56:39 -04:00
|
|
|
}
|
|
|
|
|
2018-11-04 16:36:22 -05:00
|
|
|
initApplications(type) {
|
2018-06-16 17:50:13 -04:00
|
|
|
const { store } = this;
|
2017-10-24 00:56:39 -04:00
|
|
|
const el = document.querySelector('#js-cluster-applications');
|
|
|
|
|
|
|
|
this.applications = new Vue({
|
|
|
|
el,
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
state: store.state,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
render(createElement) {
|
2018-11-04 16:35:24 -05:00
|
|
|
return createElement(Applications, {
|
2017-10-24 00:56:39 -04:00
|
|
|
props: {
|
2018-11-04 16:36:22 -05:00
|
|
|
type,
|
2017-10-24 00:56:39 -04:00
|
|
|
applications: this.state.applications,
|
|
|
|
helpPath: this.state.helpPath,
|
2018-02-06 09:59:15 -05:00
|
|
|
ingressHelpPath: this.state.ingressHelpPath,
|
2018-01-30 18:21:59 -05:00
|
|
|
managePrometheusPath: this.state.managePrometheusPath,
|
2018-02-20 07:44:20 -05:00
|
|
|
ingressDnsHelpPath: this.state.ingressDnsHelpPath,
|
2020-01-07 07:07:55 -05:00
|
|
|
ingressModSecurityHelpPath: this.state.ingressModSecurityHelpPath,
|
2019-09-22 20:06:29 -04:00
|
|
|
cloudRunHelpPath: this.state.cloudRunHelpPath,
|
|
|
|
providerType: this.state.providerType,
|
|
|
|
preInstalledKnative: this.state.preInstalledKnative,
|
2018-12-13 10:39:44 -05:00
|
|
|
rbac: this.state.rbac,
|
2017-10-24 00:56:39 -04:00
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-09-04 13:03:05 -04:00
|
|
|
initEnvironments() {
|
|
|
|
const { store } = this;
|
|
|
|
const el = document.querySelector('#js-cluster-environments');
|
|
|
|
|
|
|
|
if (!el) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.environments = new Vue({
|
|
|
|
el,
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
state: store.state,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
render(createElement) {
|
|
|
|
return createElement(Environments, {
|
|
|
|
props: {
|
2019-09-13 09:26:31 -04:00
|
|
|
isFetching: this.state.fetchingEnvironments,
|
2019-09-04 13:03:05 -04:00
|
|
|
environments: this.state.environments,
|
|
|
|
environmentsHelpPath: this.state.environmentsHelpPath,
|
|
|
|
clustersHelpPath: this.state.clustersHelpPath,
|
|
|
|
deployBoardsHelpPath: this.state.deployBoardsHelpPath,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-12-17 04:07:48 -05:00
|
|
|
initRemoveClusterActions() {
|
|
|
|
const el = document.querySelector('#js-cluster-remove-actions');
|
|
|
|
if (el && el.dataset) {
|
|
|
|
const { clusterName, clusterPath } = el.dataset;
|
|
|
|
|
|
|
|
this.removeClusterAction = new Vue({
|
|
|
|
el,
|
|
|
|
render(createElement) {
|
|
|
|
return createElement(RemoveClusterConfirmation, {
|
|
|
|
props: {
|
|
|
|
clusterName,
|
|
|
|
clusterPath,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-18 10:02:45 -04:00
|
|
|
handleClusterEnvironmentsSuccess(data) {
|
|
|
|
this.store.toggleFetchEnvironments(false);
|
|
|
|
this.store.updateEnvironments(data.data);
|
2019-09-13 09:26:31 -04:00
|
|
|
}
|
|
|
|
|
2018-12-06 08:41:20 -05:00
|
|
|
static initDismissableCallout() {
|
|
|
|
const callout = document.querySelector('.js-cluster-security-warning');
|
2019-02-21 01:05:09 -05:00
|
|
|
PersistentUserCallout.factory(callout);
|
2018-12-06 08:41:20 -05:00
|
|
|
}
|
|
|
|
|
2019-05-27 04:23:17 -04:00
|
|
|
addBannerCloseHandler(el, status) {
|
|
|
|
el.querySelector('.js-close-banner').addEventListener('click', () => {
|
|
|
|
el.classList.add('hidden');
|
|
|
|
this.setBannerDismissedState(status, true);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-10-24 00:56:39 -04:00
|
|
|
addListeners() {
|
|
|
|
eventHub.$on('installApplication', this.installApplication);
|
2019-06-06 10:15:39 -04:00
|
|
|
eventHub.$on('updateApplication', data => this.updateApplication(data));
|
2019-02-19 04:24:37 -05:00
|
|
|
eventHub.$on('saveKnativeDomain', data => this.saveKnativeDomain(data));
|
2020-04-03 20:09:37 -04:00
|
|
|
eventHub.$on('setKnativeDomain', data => this.setKnativeDomain(data));
|
2019-05-02 10:17:03 -04:00
|
|
|
eventHub.$on('uninstallApplication', data => this.uninstallApplication(data));
|
2019-11-17 22:06:28 -05:00
|
|
|
eventHub.$on('setCrossplaneProviderStack', data => this.setCrossplaneProviderStack(data));
|
2020-02-19 07:09:13 -05:00
|
|
|
eventHub.$on('setIngressModSecurityEnabled', data => this.setIngressModSecurityEnabled(data));
|
2020-03-19 05:09:27 -04:00
|
|
|
eventHub.$on('setIngressModSecurityMode', data => this.setIngressModSecurityMode(data));
|
|
|
|
eventHub.$on('resetIngressModSecurityChanges', id => this.resetIngressModSecurityChanges(id));
|
2020-04-21 11:21:10 -04:00
|
|
|
eventHub.$on('setFluentdSettings', data => this.setFluentdSettings(data));
|
2019-05-27 04:23:17 -04:00
|
|
|
// Add event listener to all the banner close buttons
|
|
|
|
this.addBannerCloseHandler(this.unreachableContainer, 'unreachable');
|
|
|
|
this.addBannerCloseHandler(this.authenticationFailureContainer, 'authentication_failure');
|
2017-10-24 00:56:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
removeListeners() {
|
|
|
|
eventHub.$off('installApplication', this.installApplication);
|
2019-06-06 10:15:39 -04:00
|
|
|
eventHub.$off('updateApplication', this.updateApplication);
|
2019-02-19 04:24:37 -05:00
|
|
|
eventHub.$off('saveKnativeDomain');
|
2020-04-03 20:09:37 -04:00
|
|
|
eventHub.$off('setKnativeDomain');
|
2019-11-17 22:06:28 -05:00
|
|
|
eventHub.$off('setCrossplaneProviderStack');
|
2019-05-02 10:17:03 -04:00
|
|
|
eventHub.$off('uninstallApplication');
|
2020-02-19 07:09:13 -05:00
|
|
|
eventHub.$off('setIngressModSecurityEnabled');
|
2020-03-19 05:09:27 -04:00
|
|
|
eventHub.$off('setIngressModSecurityMode');
|
|
|
|
eventHub.$off('resetIngressModSecurityChanges');
|
2020-04-21 11:21:10 -04:00
|
|
|
eventHub.$off('setFluentdSettings');
|
2017-10-24 00:56:39 -04:00
|
|
|
}
|
|
|
|
|
2019-09-18 10:02:45 -04:00
|
|
|
initPolling(method, successCallback, errorCallback) {
|
2017-10-24 00:56:39 -04:00
|
|
|
this.poll = new Poll({
|
|
|
|
resource: this.service,
|
2019-09-18 10:02:45 -04:00
|
|
|
method,
|
|
|
|
successCallback,
|
|
|
|
errorCallback,
|
2017-10-24 00:56:39 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
if (!Visibility.hidden()) {
|
|
|
|
this.poll.makeRequest();
|
|
|
|
}
|
|
|
|
|
|
|
|
Visibility.change(() => {
|
|
|
|
if (!Visibility.hidden() && !this.destroyed) {
|
|
|
|
this.poll.restart();
|
|
|
|
} else {
|
|
|
|
this.poll.stop();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-09-18 10:02:45 -04:00
|
|
|
handlePollError() {
|
|
|
|
this.constructor.handleError();
|
|
|
|
}
|
|
|
|
|
|
|
|
handleEnvironmentsPollError() {
|
|
|
|
this.store.toggleFetchEnvironments(false);
|
|
|
|
|
|
|
|
this.handlePollError();
|
|
|
|
}
|
|
|
|
|
2017-10-24 00:56:39 -04:00
|
|
|
static handleError() {
|
|
|
|
Flash(s__('ClusterIntegration|Something went wrong on our end.'));
|
|
|
|
}
|
|
|
|
|
2019-09-18 10:02:45 -04:00
|
|
|
handleClusterStatusSuccess(data) {
|
2017-11-06 09:48:44 -05:00
|
|
|
const prevStatus = this.store.state.status;
|
2020-05-07 17:09:26 -04:00
|
|
|
const prevApplicationMap = { ...this.store.state.applications };
|
2017-11-06 11:07:19 -05:00
|
|
|
|
2017-10-24 00:56:39 -04:00
|
|
|
this.store.updateStateFromServer(data.data);
|
2017-11-06 11:07:19 -05:00
|
|
|
|
2017-10-24 00:56:39 -04:00
|
|
|
this.checkForNewInstalls(prevApplicationMap, this.store.state.applications);
|
2017-11-06 11:07:19 -05:00
|
|
|
this.updateContainer(prevStatus, this.store.state.status, this.store.state.statusReason);
|
2020-03-12 11:09:39 -04:00
|
|
|
|
|
|
|
if (this.ingressDomainHelpText) {
|
|
|
|
this.toggleIngressDomainHelpText(
|
|
|
|
prevApplicationMap[INGRESS],
|
|
|
|
this.store.state.applications[INGRESS],
|
|
|
|
);
|
|
|
|
}
|
2020-03-27 14:07:48 -04:00
|
|
|
|
|
|
|
if (this.store.state.applications[KNATIVE]?.status === APPLICATION_STATUS.INSTALLED) {
|
|
|
|
initServerlessSurveyBanner();
|
|
|
|
}
|
2017-10-24 00:56:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
hideAll() {
|
|
|
|
this.errorContainer.classList.add('hidden');
|
|
|
|
this.successContainer.classList.add('hidden');
|
|
|
|
this.creatingContainer.classList.add('hidden');
|
2019-05-27 04:23:17 -04:00
|
|
|
this.unreachableContainer.classList.add('hidden');
|
|
|
|
this.authenticationFailureContainer.classList.add('hidden');
|
2017-10-24 00:56:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
checkForNewInstalls(prevApplicationMap, newApplicationMap) {
|
|
|
|
const appTitles = Object.keys(newApplicationMap)
|
2018-09-06 16:41:12 -04:00
|
|
|
.filter(
|
|
|
|
appId =>
|
|
|
|
newApplicationMap[appId].status === APPLICATION_STATUS.INSTALLED &&
|
|
|
|
prevApplicationMap[appId].status !== APPLICATION_STATUS.INSTALLED &&
|
|
|
|
prevApplicationMap[appId].status !== null,
|
|
|
|
)
|
2017-10-24 00:56:39 -04:00
|
|
|
.map(appId => newApplicationMap[appId].title);
|
|
|
|
|
|
|
|
if (appTitles.length > 0) {
|
2018-09-06 16:41:12 -04:00
|
|
|
const text = sprintf(
|
|
|
|
s__('ClusterIntegration|%{appList} was successfully installed on your Kubernetes cluster'),
|
|
|
|
{
|
|
|
|
appList: appTitles.join(', '),
|
|
|
|
},
|
|
|
|
);
|
2017-11-07 07:28:02 -05:00
|
|
|
Flash(text, 'notice', this.successApplicationContainer);
|
2017-10-24 00:56:39 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-27 04:23:17 -04:00
|
|
|
setBannerDismissedState(status, isDismissed) {
|
|
|
|
if (AccessorUtilities.isLocalStorageAccessSafe()) {
|
2019-08-02 16:08:53 -04:00
|
|
|
window.localStorage.setItem(this.clusterBannerDismissedKey, `${status}_${isDismissed}`);
|
2019-05-27 04:23:17 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
isBannerDismissed(status) {
|
|
|
|
let bannerState;
|
|
|
|
if (AccessorUtilities.isLocalStorageAccessSafe()) {
|
2019-08-02 16:08:53 -04:00
|
|
|
bannerState = window.localStorage.getItem(this.clusterBannerDismissedKey);
|
2019-05-27 04:23:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return bannerState === `${status}_true`;
|
|
|
|
}
|
|
|
|
|
2019-08-02 16:08:53 -04:00
|
|
|
setClusterNewlyCreated(state) {
|
|
|
|
if (AccessorUtilities.isLocalStorageAccessSafe()) {
|
|
|
|
window.localStorage.setItem(this.clusterNewlyCreatedKey, Boolean(state));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
isClusterNewlyCreated() {
|
|
|
|
// once this is true, it will always be true for a given page load
|
|
|
|
if (!this.isNewlyCreated) {
|
|
|
|
let newlyCreated;
|
|
|
|
if (AccessorUtilities.isLocalStorageAccessSafe()) {
|
|
|
|
newlyCreated = window.localStorage.getItem(this.clusterNewlyCreatedKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.isNewlyCreated = newlyCreated === 'true';
|
|
|
|
}
|
|
|
|
return this.isNewlyCreated;
|
|
|
|
}
|
2017-11-06 11:07:19 -05:00
|
|
|
|
2019-08-02 16:08:53 -04:00
|
|
|
updateContainer(prevStatus, status, error) {
|
|
|
|
if (status !== 'created' && this.isBannerDismissed(status)) {
|
2019-05-27 04:23:17 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.setBannerDismissedState(status, false);
|
|
|
|
|
2019-08-02 16:08:53 -04:00
|
|
|
if (prevStatus !== status) {
|
|
|
|
this.hideAll();
|
|
|
|
|
2017-11-06 11:07:19 -05:00
|
|
|
switch (status) {
|
|
|
|
case 'created':
|
2019-08-02 16:08:53 -04:00
|
|
|
if (this.isClusterNewlyCreated()) {
|
|
|
|
this.setClusterNewlyCreated(false);
|
|
|
|
this.successContainer.classList.remove('hidden');
|
|
|
|
} else if (prevStatus) {
|
|
|
|
this.setClusterNewlyCreated(true);
|
|
|
|
window.location.reload();
|
|
|
|
}
|
2017-11-06 11:07:19 -05:00
|
|
|
break;
|
|
|
|
case 'errored':
|
|
|
|
this.errorContainer.classList.remove('hidden');
|
|
|
|
this.errorReasonContainer.textContent = error;
|
|
|
|
break;
|
2019-05-27 04:23:17 -04:00
|
|
|
case 'unreachable':
|
|
|
|
this.unreachableContainer.classList.remove('hidden');
|
|
|
|
break;
|
|
|
|
case 'authentication_failure':
|
|
|
|
this.authenticationFailureContainer.classList.remove('hidden');
|
|
|
|
break;
|
2017-11-06 11:07:19 -05:00
|
|
|
case 'scheduled':
|
|
|
|
case 'creating':
|
|
|
|
this.creatingContainer.classList.remove('hidden');
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
}
|
2017-10-24 00:56:39 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-02 10:17:03 -04:00
|
|
|
installApplication({ id: appId, params }) {
|
2019-11-17 22:06:28 -05:00
|
|
|
return Clusters.validateInstallation(appId, params)
|
|
|
|
.then(() => {
|
|
|
|
this.store.updateAppProperty(appId, 'requestReason', null);
|
|
|
|
this.store.updateAppProperty(appId, 'statusReason', null);
|
|
|
|
this.store.installApplication(appId);
|
|
|
|
|
|
|
|
// eslint-disable-next-line promise/no-nesting
|
|
|
|
this.service.installApplication(appId, params).catch(() => {
|
|
|
|
this.store.notifyInstallFailure(appId);
|
|
|
|
this.store.updateAppProperty(
|
|
|
|
appId,
|
|
|
|
'requestReason',
|
|
|
|
s__('ClusterIntegration|Request to begin installing failed'),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
})
|
|
|
|
.catch(error => this.store.updateAppProperty(appId, 'validationError', error));
|
|
|
|
}
|
2019-02-01 05:44:49 -05:00
|
|
|
|
2019-11-17 22:06:28 -05:00
|
|
|
static validateInstallation(appId, params) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
if (appId === CROSSPLANE && !params.stack) {
|
|
|
|
reject(s__('ClusterIntegration|Select a stack to install Crossplane.'));
|
|
|
|
return;
|
|
|
|
}
|
2019-04-26 04:15:44 -04:00
|
|
|
|
2020-05-28 17:08:22 -04:00
|
|
|
if (appId === KNATIVE && !params.hostname && !params.pages_domain_id) {
|
|
|
|
reject(s__('ClusterIntegration|You must specify a domain before you can install Knative.'));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-11-17 22:06:28 -05:00
|
|
|
resolve();
|
2019-02-01 05:44:49 -05:00
|
|
|
});
|
2017-10-24 00:56:39 -04:00
|
|
|
}
|
|
|
|
|
2019-05-02 10:17:03 -04:00
|
|
|
uninstallApplication({ id: appId }) {
|
|
|
|
this.store.updateAppProperty(appId, 'requestReason', null);
|
|
|
|
this.store.updateAppProperty(appId, 'statusReason', null);
|
|
|
|
|
|
|
|
this.store.uninstallApplication(appId);
|
|
|
|
|
|
|
|
return this.service.uninstallApplication(appId).catch(() => {
|
|
|
|
this.store.notifyUninstallFailure(appId);
|
|
|
|
this.store.updateAppProperty(
|
|
|
|
appId,
|
|
|
|
'requestReason',
|
|
|
|
s__('ClusterIntegration|Request to begin uninstalling failed'),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:15:39 -04:00
|
|
|
updateApplication({ id: appId, params }) {
|
2019-04-26 04:15:44 -04:00
|
|
|
this.store.updateApplication(appId);
|
2019-06-06 10:15:39 -04:00
|
|
|
this.service.installApplication(appId, params).catch(() => {
|
2019-04-26 04:15:44 -04:00
|
|
|
this.store.notifyUpdateFailure(appId);
|
|
|
|
});
|
2019-02-07 16:40:55 -05:00
|
|
|
}
|
|
|
|
|
2020-04-29 14:09:56 -04:00
|
|
|
setFluentdSettings(settings = {}) {
|
|
|
|
Object.entries(settings).forEach(([key, value]) => {
|
|
|
|
this.store.updateAppProperty(FLUENTD, key, value);
|
|
|
|
});
|
2020-04-21 11:21:10 -04:00
|
|
|
}
|
|
|
|
|
2019-04-26 10:20:04 -04:00
|
|
|
toggleIngressDomainHelpText({ externalIp }, { externalIp: newExternalIp }) {
|
|
|
|
if (externalIp !== newExternalIp) {
|
|
|
|
this.ingressDomainHelpText.classList.toggle('hide', !newExternalIp);
|
|
|
|
this.ingressDomainSnippet.textContent = `${newExternalIp}${INGRESS_DOMAIN_SUFFIX}`;
|
2019-03-18 15:53:51 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-19 04:24:37 -05:00
|
|
|
saveKnativeDomain(data) {
|
|
|
|
const appId = data.id;
|
2019-05-29 14:56:35 -04:00
|
|
|
this.store.updateApplication(appId);
|
|
|
|
this.service.updateApplication(appId, data.params).catch(() => {
|
|
|
|
this.store.notifyUpdateFailure(appId);
|
|
|
|
});
|
2019-02-19 04:24:37 -05:00
|
|
|
}
|
|
|
|
|
2020-04-03 20:09:37 -04:00
|
|
|
setKnativeDomain({ id: appId, domain, domainId }) {
|
|
|
|
this.store.updateAppProperty(appId, 'isEditingDomain', true);
|
|
|
|
this.store.updateAppProperty(appId, 'hostname', domain);
|
|
|
|
this.store.updateAppProperty(appId, 'pagesDomain', domainId ? { id: domainId, domain } : null);
|
2020-05-28 17:08:22 -04:00
|
|
|
this.store.updateAppProperty(appId, 'validationError', null);
|
2019-02-19 04:24:37 -05:00
|
|
|
}
|
|
|
|
|
2019-11-17 22:06:28 -05:00
|
|
|
setCrossplaneProviderStack(data) {
|
|
|
|
const appId = data.id;
|
|
|
|
this.store.updateAppProperty(appId, 'stack', data.stack.code);
|
|
|
|
this.store.updateAppProperty(appId, 'validationError', null);
|
|
|
|
}
|
|
|
|
|
2020-02-19 07:09:13 -05:00
|
|
|
setIngressModSecurityEnabled({ id, modSecurityEnabled }) {
|
|
|
|
this.store.updateAppProperty(id, 'isEditingModSecurityEnabled', true);
|
|
|
|
this.store.updateAppProperty(id, 'modsecurity_enabled', modSecurityEnabled);
|
|
|
|
}
|
|
|
|
|
2020-03-19 05:09:27 -04:00
|
|
|
setIngressModSecurityMode({ id, modSecurityMode }) {
|
|
|
|
this.store.updateAppProperty(id, 'isEditingModSecurityMode', true);
|
|
|
|
this.store.updateAppProperty(id, 'modsecurity_mode', modSecurityMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
resetIngressModSecurityChanges(id) {
|
2020-03-13 05:09:23 -04:00
|
|
|
this.store.updateAppProperty(id, 'isEditingModSecurityEnabled', false);
|
2020-03-19 05:09:27 -04:00
|
|
|
this.store.updateAppProperty(id, 'isEditingModSecurityMode', false);
|
2020-03-13 05:09:23 -04:00
|
|
|
}
|
|
|
|
|
2017-10-24 00:56:39 -04:00
|
|
|
destroy() {
|
|
|
|
this.destroyed = true;
|
|
|
|
|
|
|
|
this.removeListeners();
|
|
|
|
|
|
|
|
if (this.poll) {
|
|
|
|
this.poll.stop();
|
|
|
|
}
|
|
|
|
|
2019-09-04 13:03:05 -04:00
|
|
|
if (this.environments) {
|
|
|
|
this.environments.$destroy();
|
|
|
|
}
|
|
|
|
|
2017-10-24 00:56:39 -04:00
|
|
|
this.applications.$destroy();
|
|
|
|
}
|
|
|
|
}
|