Skip to content

Commit

Permalink
feat(nutanix): add uninstall node nutanix popin
Browse files Browse the repository at this point in the history
ref: MANAGER-15717

Signed-off-by: Thibault Barske <[email protected]>
  • Loading branch information
tibs245 committed Dec 13, 2024
1 parent db4c1f4 commit 53fe1b3
Show file tree
Hide file tree
Showing 11 changed files with 265 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import template from './template.html';
import controller from './controller';

export default {
bindings: {
goBack: '<',
handleSuccess: '<',
nodeId: '<',
uninstallNode: '<',
userSubsidiary: '<',
},
template,
controller,
};
Original file line number Diff line number Diff line change
@@ -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,
};
Original file line number Diff line number Diff line change
@@ -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;
});
}
}
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<oui-modal
data-on-dismiss="$ctrl.goBack()"
data-primary-action="$ctrl.onSubmit()"
data-primary-label="{{:: 'nutanix_dashboard_uninstall_node_confirm' | translate }}"
data-loading="$ctrl.isLoading"
data-primary-disabled="$ctrl.confirmUninstallForm.$invalid"
data-secondary-action="$ctrl.goBack()"
data-secondary-label="{{:: 'nutanix_dashboard_uninstall_node_cancel' | translate }}"
data-heading="{{:: 'nutanix_dashboard_uninstall_node_title' | translate }}"
>
<form name="$ctrl.confirmUninstallForm" novalidate>
<oui-message data-type="warning" class="mb-2">
<div
data-translate="nutanix_dashboard_uninstall_node_description"
></div>
<a
class="oui-link_icon"
data-ng-href="{{$ctrl.uninstallGuidelink}}"
>
<span
data-translate="nutanix_dashboard_uninstall_node_uninstall_guidelink"
></span>
<span
class="oui-icon oui-icon-arrow-right"
aria-hidden="true"
></span>
</a>
</oui-message>
<p
data-translate="nutanix_dashboard_uninstall_node_confirmation"
data-translate-values="{ serviceName: $ctrl.nodeId}"
></p>
<oui-field
data-label="{{:: 'nutanix_dasboard_uninstall_node_input_label' | translate:{ magicword: $ctrl.UNINSTALL_PATTERN} }}"
>
<input
type="text"
class="oui-input"
name="uninstallInput"
data-ng-model="$ctrl.uninstallConfirmation"
data-ng-pattern="$ctrl.UNINSTALL_PATTERN"
required
/>
</oui-field>
</form>
</oui-modal>
Original file line number Diff line number Diff line change
@@ -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 :"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -23,6 +24,7 @@ angular
addNodes,
poweronNode,
poweroffNode,
uninstallNode,
])
.config(routing)
.component('nutanixAllNodes', component)
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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,
},
});
};
4 changes: 4 additions & 0 deletions packages/manager/modules/nutanix/src/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
}
}

0 comments on commit 53fe1b3

Please sign in to comment.