diff --git a/packages/manager/modules/nutanix/src/dashboard/component/uninstall-modal/component.js b/packages/manager/modules/nutanix/src/dashboard/component/uninstall-modal/component.js new file mode 100644 index 000000000000..20a5a244bc20 --- /dev/null +++ b/packages/manager/modules/nutanix/src/dashboard/component/uninstall-modal/component.js @@ -0,0 +1,14 @@ +import template from './template.html'; +import controller from './controller'; + +export default { + bindings: { + goBack: '<', + handleSuccess: '<', + nodeId: '<', + uninstallNode: '<', + userSubsidiary: '<', + }, + template, + controller, +}; diff --git a/packages/manager/modules/nutanix/src/dashboard/component/uninstall-modal/constants.js b/packages/manager/modules/nutanix/src/dashboard/component/uninstall-modal/constants.js new file mode 100644 index 000000000000..5f31caf3cd13 --- /dev/null +++ b/packages/manager/modules/nutanix/src/dashboard/component/uninstall-modal/constants.js @@ -0,0 +1,52 @@ +export const UNINSTALL_PATTERN = 'UNINSTALL'; + +export const UNINSTALL_GUIDE_LINKS = { + FR: + 'https://help.ovhcloud.com/csm/fr-documentation-hosted-private-cloud-nutanix-on-ovhcloud?id=kb_browse_cat&kb_id=62e4cfed55d574502d4c6e78b7421953&kb_category=7e50f429985469141e115d75fb840c3f', + DE: + 'https://help.ovhcloud.com/csm/de-documentation-hosted-private-cloud-nutanix-on-ovhcloud?id=kb_browse_cat&kb_id=62e4cfed55d574502d4c6e78b7421953&kb_category=7e50f429985469141e115d75fb840c3f', + SP: + 'https://help.ovhcloud.com/csm/es-es-documentation-hosted-private-cloud-nutanix-on-ovhcloud?id=kb_browse_cat&kb_id=62e4cfed55d574502d4c6e78b7421953&kb_category=7e50f429985469141e115d75fb840c3f', + IE: + 'https://help.ovhcloud.com/csm/en-ie-documentation-hosted-private-cloud-nutanix-on-ovhcloud?id=kb_browse_cat&kb_id=62e4cfed55d574502d4c6e78b7421953&kb_category=7e50f429985469141e115d75fb840c3f', + IT: + 'https://help.ovhcloud.com/csm/it-documentation-hosted-private-cloud-nutanix-on-ovhcloud?id=kb_browse_cat&kb_id=62e4cfed55d574502d4c6e78b7421953&kb_category=7e50f429985469141e115d75fb840c3f', + EL: + 'https://help.ovhcloud.com/csm/en-nl-documentation-hosted-private-cloud?id=kb_browse_cat&kb_id=62e4cfed55d574502d4c6e78b7421953', + PL: + 'https://help.ovhcloud.com/csm/pl-documentation-hosted-private-cloud?id=kb_browse_cat&kb_id=62e4cfed55d574502d4c6e78b7421953', + PT: + 'https://help.ovhcloud.com/csm/pt-documentation-hosted-private-cloud?id=kb_browse_cat&kb_id=62e4cfed55d574502d4c6e78b7421953', + GB: + 'https://help.ovhcloud.com/csm/en-gb-documentation-hosted-private-cloud?id=kb_browse_cat&kb_id=62e4cfed55d574502d4c6e78b7421953', + CA: + 'https://help.ovhcloud.com/csm/en-ca-documentation-hosted-private-cloud?id=kb_browse_cat&kb_id=62e4cfed55d574502d4c6e78b7421953', + QC: + 'https://help.ovhcloud.com/csm/fr-ca-documentation-hosted-private-cloud?id=kb_browse_cat&kb_id=62e4cfed55d574502d4c6e78b7421953', + USA: 'https://us.ovhcloud.com/support/', + ES: + 'https://help.ovhcloud.com/csm/es-documentation-hosted-private-cloud?id=kb_browse_cat&kb_id=62e4cfed55d574502d4c6e78b7421953', + MA: + 'https://help.ovhcloud.com/csm/fr-ma-documentation-hosted-private-cloud?id=kb_browse_cat&kb_id=62e4cfed55d574502d4c6e78b7421953', + SN: + 'https://help.ovhcloud.com/csm/fr-sn-documentation-hosted-private-cloud?id=kb_browse_cat&kb_id=62e4cfed55d574502d4c6e78b7421953', + TN: + 'https://help.ovhcloud.com/csm/fr-tn-documentation-hosted-private-cloud?id=kb_browse_cat&kb_id=62e4cfed55d574502d4c6e78b7421953', + AU: + 'https://help.ovhcloud.com/csm/en-au-documentation-hosted-private-cloud?id=kb_browse_cat&kb_id=62e4cfed55d574502d4c6e78b7421953', + IN: + 'https://help.ovhcloud.com/csm/en-in-documentation-hosted-private-cloud?id=kb_browse_cat&kb_id=62e4cfed55d574502d4c6e78b7421953', + SG: + 'https://help.ovhcloud.com/csm/en-sg-documentation-hosted-private-cloud?id=kb_browse_cat&kb_id=62e4cfed55d574502d4c6e78b7421953', + ASIA: + 'https://help.ovhcloud.com/csm/asia-documentation-hosted-private-cloud?id=kb_browse_cat&kb_id=62e4cfed55d574502d4c6e78b7421953', + EN: + 'https://help.ovhcloud.com/csm/world-documentation-hosted-private-cloud?id=kb_browse_cat&kb_id=62e4cfed55d574502d4c6e78b7421953', + WE: + 'https://help.ovhcloud.com/csm/en-ie-documentation-hosted-private-cloud?id=kb_browse_cat&kb_id=62e4cfed55d574502d4c6e78b7421953', +}; + +export default { + UNINSTALL_PATTERN, + UNINSTALL_GUIDE_LINKS, +}; diff --git a/packages/manager/modules/nutanix/src/dashboard/component/uninstall-modal/controller.js b/packages/manager/modules/nutanix/src/dashboard/component/uninstall-modal/controller.js new file mode 100644 index 000000000000..e30429c9fe67 --- /dev/null +++ b/packages/manager/modules/nutanix/src/dashboard/component/uninstall-modal/controller.js @@ -0,0 +1,38 @@ +import { UNINSTALL_GUIDE_LINKS, UNINSTALL_PATTERN } from './constants'; + +export default class { + /* @ngInject */ + constructor($translate) { + this.$translate = $translate; + this.UNINSTALL_PATTERN = UNINSTALL_PATTERN; + this.isLoading = false; + } + + get uninstallGuidelink() { + return ( + UNINSTALL_GUIDE_LINKS[this.userSubsidiary] ?? UNINSTALL_GUIDE_LINKS.EN + ); + } + + onSubmit() { + this.isLoading = true; + this.uninstallNode() + .then(() => { + this.handleSuccess( + `${this.$translate.instant( + 'nutanix_dashboard_uninstall_node_success_banner', + )}`, + ); + }) + .catch((error) => { + this.handleError( + `${this.$translate.instant( + 'nutanix_dashboard_uninstall_node_error_banner', + )} ${error.message}`, + ); + }) + .finally(() => { + this.isLoading = false; + }); + } +} diff --git a/packages/manager/modules/nutanix/src/dashboard/component/uninstall-modal/module.js b/packages/manager/modules/nutanix/src/dashboard/component/uninstall-modal/module.js new file mode 100644 index 000000000000..efb7399ee794 --- /dev/null +++ b/packages/manager/modules/nutanix/src/dashboard/component/uninstall-modal/module.js @@ -0,0 +1,21 @@ +import angular from 'angular'; +import '@ovh-ux/manager-core'; +import '@uirouter/angularjs'; +import 'angular-translate'; +import '@ovh-ux/ui-kit'; + +import component from './component'; + +const moduleName = 'ovhManagerNutanixUninstallNutanixNodeModal'; + +angular + .module(moduleName, [ + 'oui', + 'ovhManagerCore', + 'pascalprecht.translate', + 'ui.router', + ]) + .component('uninstallNutanixNodeModal', component) + .run(/* @ngTranslationsInject:json ./translations */); + +export default moduleName; diff --git a/packages/manager/modules/nutanix/src/dashboard/component/uninstall-modal/template.html b/packages/manager/modules/nutanix/src/dashboard/component/uninstall-modal/template.html new file mode 100644 index 000000000000..f4d5507fa32f --- /dev/null +++ b/packages/manager/modules/nutanix/src/dashboard/component/uninstall-modal/template.html @@ -0,0 +1,46 @@ + +
+ +
+ + + + +
+

+ + + +
+
diff --git a/packages/manager/modules/nutanix/src/dashboard/component/uninstall-modal/translations/Messages_fr_FR.json b/packages/manager/modules/nutanix/src/dashboard/component/uninstall-modal/translations/Messages_fr_FR.json new file mode 100644 index 000000000000..2e450f24619c --- /dev/null +++ b/packages/manager/modules/nutanix/src/dashboard/component/uninstall-modal/translations/Messages_fr_FR.json @@ -0,0 +1,11 @@ +{ + "nutanix_dashboard_uninstall_node_title": "Eteindre le noeud", + "nutanix_dashboard_uninstall_node_description": "L'extinction d'un noeud Nutanix peut avoir un impact sur votre cluster, vérifiez les pré-requis sur le portail de Nutanix pour réaliser cette action", + "nutanix_dashboard_uninstall_node_uninstall_guidelink": "Accéder au portail", + "nutanix_dashboard_uninstall_node_confirmation": "Voulez-vous vraiment éteindre votre noeud {{serviceName}} ?", + "nutanix_dashboard_uninstall_node_confirm": "Détâcher", + "nutanix_dashboard_uninstall_node_cancel": "Annuler", + "nutanix_dasboard_uninstall_node_input_label": "Entrez \"{{magicword}}\" pour configurer votre choix", + "nutanix_dashboard_uninstall_node_success_banner": "Votre demande de désinstallation a été prise en compte. Cette opération peut prendre jusqu'à 10 minutes", + "nutanix_dashboard_uninstall_node_error_banner": "Votre demande de désinstallation n'a pas été prise en compte :" +} diff --git a/packages/manager/modules/nutanix/src/dashboard/nodes/list/module.js b/packages/manager/modules/nutanix/src/dashboard/nodes/list/module.js index cb481f902e7e..105ec6de713c 100644 --- a/packages/manager/modules/nutanix/src/dashboard/nodes/list/module.js +++ b/packages/manager/modules/nutanix/src/dashboard/nodes/list/module.js @@ -10,6 +10,7 @@ import datacenterName from '../../component/datacenter-name/module'; import addNodes from './add-nodes'; import poweronNode from './poweron-node'; import poweroffNode from './poweroff-node'; +import uninstallNode from './uninstall-node'; const moduleName = 'ovhManagerNutanixAllNodes'; @@ -23,6 +24,7 @@ angular addNodes, poweronNode, poweroffNode, + uninstallNode, ]) .config(routing) .component('nutanixAllNodes', component) diff --git a/packages/manager/modules/nutanix/src/dashboard/nodes/list/uninstall-node/index.js b/packages/manager/modules/nutanix/src/dashboard/nodes/list/uninstall-node/index.js new file mode 100644 index 000000000000..de895293083b --- /dev/null +++ b/packages/manager/modules/nutanix/src/dashboard/nodes/list/uninstall-node/index.js @@ -0,0 +1,22 @@ +import angular from 'angular'; + +import '@uirouter/angularjs'; +import 'oclazyload'; + +const moduleName = 'ovhManagerNutanixNodeUninstallLazyLoading'; + +angular.module(moduleName, ['ui.router', 'oc.lazyLoad']).config( + /* @ngInject */ ($stateProvider) => { + $stateProvider.state('nutanix.dashboard.nodes.all.uninstall-node.**', { + url: '/uninstall/:node', + lazyLoad: ($transition$) => { + const $ocLazyLoad = $transition$.injector().get('$ocLazyLoad'); + return import('./uninstall-node.module').then((mod) => + $ocLazyLoad.inject(mod.default || mod), + ); + }, + }); + }, +); + +export default moduleName; diff --git a/packages/manager/modules/nutanix/src/dashboard/nodes/list/uninstall-node/uninstall-node.module.js b/packages/manager/modules/nutanix/src/dashboard/nodes/list/uninstall-node/uninstall-node.module.js new file mode 100644 index 000000000000..8425e161132e --- /dev/null +++ b/packages/manager/modules/nutanix/src/dashboard/nodes/list/uninstall-node/uninstall-node.module.js @@ -0,0 +1,24 @@ +import atInternet from '@ovh-ux/ng-at-internet'; +import angular from 'angular'; +import uninstallModal from '../../../component/uninstall-modal/module'; + +import '@ovh-ux/ng-translate-async-loader'; +import '@uirouter/angularjs'; +import 'angular-translate'; +import '@ovh-ux/ui-kit'; + +import routing from './uninstall-node.routing'; + +const moduleName = 'ovhManagerNutanixNodePowerOff'; + +angular + .module(moduleName, [ + atInternet, + 'oui', + 'pascalprecht.translate', + 'ui.router', + uninstallModal, + ]) + .config(routing); + +export default moduleName; diff --git a/packages/manager/modules/nutanix/src/dashboard/nodes/list/uninstall-node/uninstall-node.routing.js b/packages/manager/modules/nutanix/src/dashboard/nodes/list/uninstall-node/uninstall-node.routing.js new file mode 100644 index 000000000000..ac854c05453e --- /dev/null +++ b/packages/manager/modules/nutanix/src/dashboard/nodes/list/uninstall-node/uninstall-node.routing.js @@ -0,0 +1,31 @@ +export default /* @ngInject */ ($stateProvider) => { + $stateProvider.state('nutanix.dashboard.nodes.all.uninstall', { + url: '/uninstall/:node', + views: { + modal: { + component: 'uninstallNutanixNodeModal', + }, + }, + layout: 'modal', + resolve: { + nodeId: /* @ngInject */ ($transition$) => $transition$.params().node, + goBack: /* @ngInject */ ($state) => () => + $state.go('nutanix.dashboard.nodes.all'), + handleSuccess: /* @ngInject */ (Alerter, goBack) => (message) => { + Alerter.success(message, 'nutanix_dashboard_alert'); + goBack(); + }, + handleError: /* @ngInject */ (Alerter, goBack) => (message) => { + Alerter.error(message, 'nutanix_dashboard_alert'); + goBack(); + }, + uninstallNode: /* ngInject */ ( + NutanixService, + serviceName, + nodeId, + ) => () => NutanixService.uninstallClusterNode(serviceName, nodeId), + userSubsidiary: /* ngInject */ (coreConfig) => + coreConfig.getUser().ovhSubsidiary, + }, + }); +}; diff --git a/packages/manager/modules/nutanix/src/service.js b/packages/manager/modules/nutanix/src/service.js index 54f1f1f1489c..8cea1e5aa289 100644 --- a/packages/manager/modules/nutanix/src/service.js +++ b/packages/manager/modules/nutanix/src/service.js @@ -337,4 +337,8 @@ export default class NutanixService { rebootClusterNode(nodeId) { return this.$http.post(`/dedicated/server/${nodeId}/reboot`); } + + uninstallClusterNode(clusterId, nodeId) { + return this.$http.post(`/nutanix/${clusterId}/nodes/${nodeId}/terminate`); + } }