diff --git a/packages/manager/modules/billing-components/src/components/cancellation-form/billing-confirmTerminate.service.js b/packages/manager/modules/billing-components/src/components/cancellation-form/billing-confirmTerminate.service.js index 364301571359..8c0ccb692623 100644 --- a/packages/manager/modules/billing-components/src/components/cancellation-form/billing-confirmTerminate.service.js +++ b/packages/manager/modules/billing-components/src/components/cancellation-form/billing-confirmTerminate.service.js @@ -55,6 +55,10 @@ export default class BillingTerminate { return this.$http.post(`/services/${serviceId}/terminate`); } + serviceTerminationForVrack(serviceId) { + return this.$http.post(`/vrack/${serviceId}/terminate`); + } + getTerminationForm(serviceId) { return this.OvhApiServices.Form() .v6() diff --git a/packages/manager/modules/billing-components/src/components/services-actions/services-actions.component.js b/packages/manager/modules/billing-components/src/components/services-actions/services-actions.component.js index 89f0133ee76b..8a22b4b07350 100644 --- a/packages/manager/modules/billing-components/src/components/services-actions/services-actions.component.js +++ b/packages/manager/modules/billing-components/src/components/services-actions/services-actions.component.js @@ -4,6 +4,7 @@ import template from './services-actions.html'; export default { bindings: { billingManagementAvailability: '<', + deleteVrackAvailability: '<', service: '<', trackingPrefix: '@?', trackingPage: '@?', diff --git a/packages/manager/modules/billing-components/src/components/services-actions/services-actions.controller.js b/packages/manager/modules/billing-components/src/components/services-actions/services-actions.controller.js index 86586639b505..880526b74eaf 100644 --- a/packages/manager/modules/billing-components/src/components/services-actions/services-actions.controller.js +++ b/packages/manager/modules/billing-components/src/components/services-actions/services-actions.controller.js @@ -26,7 +26,6 @@ export default class ServicesActionsCtrl { } $onInit() { - this.user = this.coreConfig.getUser(); this.BillingLinksService.generateAutorenewLinks(this.service, { billingManagementAvailability: this.billingManagementAvailability, @@ -59,9 +58,12 @@ export default class ServicesActionsCtrl { } canResiliate() { + if (this.service.serviceType === this.SERVICE_TYPE.VRACK) { + return this.deleteVrackAvailability && !!this.resiliateLink; + } + return ![ SERVICE_TYPE.PACK_XDSL, - SERVICE_TYPE.VRACK, SERVICE_TYPE.VMWARE_CLOUD_DIRECTOR_ORGANIZATION, ].includes(this.service.serviceType); } diff --git a/packages/manager/modules/billing-components/src/components/utils/billing.links.service.js b/packages/manager/modules/billing-components/src/components/utils/billing.links.service.js index df3a85a51dc4..32b70236fc35 100644 --- a/packages/manager/modules/billing-components/src/components/utils/billing.links.service.js +++ b/packages/manager/modules/billing-components/src/components/utils/billing.links.service.js @@ -101,6 +101,11 @@ export default class BillingLinksService { ? resiliationByEndRuleLink : `${autorenewLink}/delete-all-dom?serviceId=${service.serviceId}&serviceType=${service.serviceType}`; break; + case SERVICE_TYPE.VRACK: + if (service.status !== 'suspended') { + links.resiliateLink = `${autorenewLink}/terminate-vrack?service=${service.serviceId}${serviceTypeParam}`; + } + break; case SERVICE_TYPE.OKMS: case SERVICE_TYPE.VRACK_SERVICES: case SERVICE_TYPE.LICENSE_HYCU: diff --git a/packages/manager/modules/billing/src/autoRenew/actions/terminate-vrack/component.js b/packages/manager/modules/billing/src/autoRenew/actions/terminate-vrack/component.js new file mode 100644 index 000000000000..dabe2a119f69 --- /dev/null +++ b/packages/manager/modules/billing/src/autoRenew/actions/terminate-vrack/component.js @@ -0,0 +1,14 @@ +import template from './template.html'; +import controller from './controller'; + +export default { + bindings: { + goBack: '<', + service: '<', + serviceType: '<', + isEmpty: '<', + }, + controller, + template, + name: 'billingAutorenewTerminateVrack', +}; diff --git a/packages/manager/modules/billing/src/autoRenew/actions/terminate-vrack/constants.js b/packages/manager/modules/billing/src/autoRenew/actions/terminate-vrack/constants.js new file mode 100644 index 000000000000..203add1344d7 --- /dev/null +++ b/packages/manager/modules/billing/src/autoRenew/actions/terminate-vrack/constants.js @@ -0,0 +1,5 @@ +export const TERMINATE_PATTERN = /^TERMINATE$/; + +export default { + TERMINATE_PATTERN, +}; diff --git a/packages/manager/modules/billing/src/autoRenew/actions/terminate-vrack/controller.js b/packages/manager/modules/billing/src/autoRenew/actions/terminate-vrack/controller.js new file mode 100644 index 000000000000..c8e2d14f4a6a --- /dev/null +++ b/packages/manager/modules/billing/src/autoRenew/actions/terminate-vrack/controller.js @@ -0,0 +1,34 @@ +import { TERMINATE_PATTERN } from './constants'; + +export default class TerminateVrackController { + /* @ngInject */ + constructor($translate, BillingTerminate) { + this.TERMINATE_PATTERN = TERMINATE_PATTERN; + this.$translate = $translate; + this.BillingTerminate = BillingTerminate; + } + + terminate() { + this.BillingTerminate.serviceTerminationForVrack(this.service) + .then(() => this.onSuccess()) + .catch((error) => this.onError({ error })); + } + + onSuccess() { + this.goBack( + this.$translate.instant( + `autorenew_agora_terminate_service_success_VRACK`, + ), + 'success', + ); + } + + onError(error) { + this.goBack( + this.$translate.instant(`autorenew_agora_terminate_service_error_VRACK`, { + error: error?.data?.message, + }), + 'danger', + ); + } +} diff --git a/packages/manager/modules/billing/src/autoRenew/actions/terminate-vrack/index.js b/packages/manager/modules/billing/src/autoRenew/actions/terminate-vrack/index.js new file mode 100644 index 000000000000..d04d0f812cc1 --- /dev/null +++ b/packages/manager/modules/billing/src/autoRenew/actions/terminate-vrack/index.js @@ -0,0 +1,25 @@ +import angular from 'angular'; +import angularTranslate from 'angular-translate'; +import ngAtInternet from '@ovh-ux/ng-at-internet'; +import ngTranslateAsyncLoader from '@ovh-ux/ng-translate-async-loader'; +import '@ovh-ux/ui-kit'; +import uiRouter from '@uirouter/angularjs'; + +import component from './component'; +import routing from './routing'; + +const moduleName = 'ovhManagerBillingAutorenewTerminateVrack'; + +angular + .module(moduleName, [ + angularTranslate, + ngAtInternet, + ngTranslateAsyncLoader, + 'oui', + uiRouter, + ]) + .config(routing) + .component(component.name, component) + .run(/* @ngTranslationsInject:json ./translations */); + +export default moduleName; diff --git a/packages/manager/modules/billing/src/autoRenew/actions/terminate-vrack/routing.js b/packages/manager/modules/billing/src/autoRenew/actions/terminate-vrack/routing.js new file mode 100644 index 000000000000..7da55d0aff4c --- /dev/null +++ b/packages/manager/modules/billing/src/autoRenew/actions/terminate-vrack/routing.js @@ -0,0 +1,35 @@ +export default /* @ngInject */ ($stateProvider) => { + $stateProvider.state('app.account.billing.autorenew.terminateVrack', { + url: '/terminate-vrack?service&serviceType', + views: { + modal: { + component: 'billingAutorenewTerminateVrack', + }, + }, + layout: 'modal', + resolve: { + goBack: /* @ngInject */ (goToAutorenew) => goToAutorenew, + service: /* @ngInject */ ($transition$) => $transition$.params().service, + serviceType: /* @ngInject */ ($transition$) => + $transition$.params().serviceType, + isEmpty: /* @ngInject */ (OvhApiVrack, service) => + OvhApiVrack.Aapi() + .services({ serviceName: service }) + .$promise.then((allServicesParam) => { + const services = Object.entries(allServicesParam).filter( + ([, value]) => { + return Array.isArray(value) && value.length; + }, + ); + return !services.length; + }) + .catch(() => { + return false; + }), + breadcrumb: () => null, + }, + atInternet: { + ignore: true, + }, + }); +}; diff --git a/packages/manager/modules/billing/src/autoRenew/actions/terminate-vrack/template.html b/packages/manager/modules/billing/src/autoRenew/actions/terminate-vrack/template.html new file mode 100644 index 000000000000..ec65d14fcc52 --- /dev/null +++ b/packages/manager/modules/billing/src/autoRenew/actions/terminate-vrack/template.html @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + diff --git a/packages/manager/modules/billing/src/autoRenew/actions/terminate-vrack/translations/Messages_fr_FR.json b/packages/manager/modules/billing/src/autoRenew/actions/terminate-vrack/translations/Messages_fr_FR.json new file mode 100644 index 000000000000..07714c8520d5 --- /dev/null +++ b/packages/manager/modules/billing/src/autoRenew/actions/terminate-vrack/translations/Messages_fr_FR.json @@ -0,0 +1,9 @@ +{ + "autorenew_agora_terminate_vrack_blocked_title": "Supprimer mon Vrack", + "autorenew_agora_terminate_vrack_blocked_description": "Afin de supprimer votre Vrack vous devez au préalable deconnecter tous les services qui y sont ratachés", + "autorenew_agora_terminate_vrack_blocked_close": "Fermer", + "autorenew_agora_terminate_service_VRACK": "Supprimer Vrack", + "autorenew_agora_terminate_service_warning_VRACK": "Veuillez confirmer la suppression de Vrack", + "autorenew_agora_terminate_service_success_VRACK": "Votre demande de suppression de votre Vrack a été prise en compte. Un e-mail contenant la procédure vous a été envoyé.", + "autorenew_agora_terminate_service_error_VRACK": "Une erreur est survenue lors de la demande de suppression de votre Vrack. {{error}}" +} diff --git a/packages/manager/modules/billing/src/autoRenew/autorenew.component.js b/packages/manager/modules/billing/src/autoRenew/autorenew.component.js index b19e0bd6e6dd..5658eee2263c 100644 --- a/packages/manager/modules/billing/src/autoRenew/autorenew.component.js +++ b/packages/manager/modules/billing/src/autoRenew/autorenew.component.js @@ -19,6 +19,7 @@ export default { hasAutoRenew: '<', homeLink: '<', isAutorenewManagementAvailable: '<', + canDeleteVrack: '<', isAutorenew2016DeploymentBannerAvailable: '<', isEnterpriseCustomer: '<', nicBilling: '<', diff --git a/packages/manager/modules/billing/src/autoRenew/autorenew.html b/packages/manager/modules/billing/src/autoRenew/autorenew.html index bcd8b6868ebc..0b3e7528869f 100644 --- a/packages/manager/modules/billing/src/autoRenew/autorenew.html +++ b/packages/manager/modules/billing/src/autoRenew/autorenew.html @@ -244,6 +244,7 @@ tracking-page="{{ $ctrl.trackingPage }}" user="$ctrl.currentUser" billing-management-availability="$ctrl.isAutorenewManagementAvailable" + delete-vrack-availability="$ctrl.canDeleteVrack" > diff --git a/packages/manager/modules/billing/src/autoRenew/autorenew.module.js b/packages/manager/modules/billing/src/autoRenew/autorenew.module.js index 20a7e9b9688a..4608d16eb06f 100644 --- a/packages/manager/modules/billing/src/autoRenew/autorenew.module.js +++ b/packages/manager/modules/billing/src/autoRenew/autorenew.module.js @@ -31,6 +31,7 @@ import terminateHostingWeb from './actions/terminateHostingWeb/hosting-web.modul import terminatePrivateDatabase from './actions/terminatePrivateDatabase/private-database.module'; import terminateWebCoach from './actions/terminate-webcoach/terminate-webcoach.module'; import terminateAllDOm from './actions/terminate-all-dom/module'; +import terminateVrack from './actions/terminate-vrack'; import update from './actions/update/update.module'; import warnNicBilling from './actions/warnNicBilling/warnNicBilling.module'; import warnPendingDebt from './actions/warnPendingDebt/pending-debt.module'; @@ -72,6 +73,7 @@ angular terminatePrivateDatabase, terminateWebCoach, terminateAllDOm, + terminateVrack, uiRouter, update, warnNicBilling, diff --git a/packages/manager/modules/billing/src/autoRenew/autorenew.routing.js b/packages/manager/modules/billing/src/autoRenew/autorenew.routing.js index 5a58546718ac..67a6b14c92a9 100644 --- a/packages/manager/modules/billing/src/autoRenew/autorenew.routing.js +++ b/packages/manager/modules/billing/src/autoRenew/autorenew.routing.js @@ -95,6 +95,7 @@ export default /* @ngInject */ ($stateProvider, coreConfigProvider) => { }, featureAvailability: /* @ngInject */ (ovhFeatureFlipping) => ovhFeatureFlipping.checkFeatureAvailability([ + 'vrack:delete', 'billing:management', 'billing:autorenew2016Deployment', ]), @@ -107,6 +108,8 @@ export default /* @ngInject */ ($stateProvider, coreConfigProvider) => { featureAvailability?.isFeatureAvailable( 'billing:autorenew2016Deployment', ) || false, + canDeleteVrack: /* @ngInject */ (featureAvailability) => + featureAvailability?.isFeatureAvailable('vrack:delete') || false, hideBreadcrumb: /* @ngInject */ () => true, trackingPrefix: () => 'dedicated::account::billing::autorenew', }, diff --git a/packages/manager/modules/new-billing/src/autoRenew/actions/terminate-vrack/component.js b/packages/manager/modules/new-billing/src/autoRenew/actions/terminate-vrack/component.js new file mode 100644 index 000000000000..dabe2a119f69 --- /dev/null +++ b/packages/manager/modules/new-billing/src/autoRenew/actions/terminate-vrack/component.js @@ -0,0 +1,14 @@ +import template from './template.html'; +import controller from './controller'; + +export default { + bindings: { + goBack: '<', + service: '<', + serviceType: '<', + isEmpty: '<', + }, + controller, + template, + name: 'billingAutorenewTerminateVrack', +}; diff --git a/packages/manager/modules/new-billing/src/autoRenew/actions/terminate-vrack/constants.js b/packages/manager/modules/new-billing/src/autoRenew/actions/terminate-vrack/constants.js new file mode 100644 index 000000000000..203add1344d7 --- /dev/null +++ b/packages/manager/modules/new-billing/src/autoRenew/actions/terminate-vrack/constants.js @@ -0,0 +1,5 @@ +export const TERMINATE_PATTERN = /^TERMINATE$/; + +export default { + TERMINATE_PATTERN, +}; diff --git a/packages/manager/modules/new-billing/src/autoRenew/actions/terminate-vrack/controller.js b/packages/manager/modules/new-billing/src/autoRenew/actions/terminate-vrack/controller.js new file mode 100644 index 000000000000..c8e2d14f4a6a --- /dev/null +++ b/packages/manager/modules/new-billing/src/autoRenew/actions/terminate-vrack/controller.js @@ -0,0 +1,34 @@ +import { TERMINATE_PATTERN } from './constants'; + +export default class TerminateVrackController { + /* @ngInject */ + constructor($translate, BillingTerminate) { + this.TERMINATE_PATTERN = TERMINATE_PATTERN; + this.$translate = $translate; + this.BillingTerminate = BillingTerminate; + } + + terminate() { + this.BillingTerminate.serviceTerminationForVrack(this.service) + .then(() => this.onSuccess()) + .catch((error) => this.onError({ error })); + } + + onSuccess() { + this.goBack( + this.$translate.instant( + `autorenew_agora_terminate_service_success_VRACK`, + ), + 'success', + ); + } + + onError(error) { + this.goBack( + this.$translate.instant(`autorenew_agora_terminate_service_error_VRACK`, { + error: error?.data?.message, + }), + 'danger', + ); + } +} diff --git a/packages/manager/modules/new-billing/src/autoRenew/actions/terminate-vrack/index.js b/packages/manager/modules/new-billing/src/autoRenew/actions/terminate-vrack/index.js new file mode 100644 index 000000000000..d04d0f812cc1 --- /dev/null +++ b/packages/manager/modules/new-billing/src/autoRenew/actions/terminate-vrack/index.js @@ -0,0 +1,25 @@ +import angular from 'angular'; +import angularTranslate from 'angular-translate'; +import ngAtInternet from '@ovh-ux/ng-at-internet'; +import ngTranslateAsyncLoader from '@ovh-ux/ng-translate-async-loader'; +import '@ovh-ux/ui-kit'; +import uiRouter from '@uirouter/angularjs'; + +import component from './component'; +import routing from './routing'; + +const moduleName = 'ovhManagerBillingAutorenewTerminateVrack'; + +angular + .module(moduleName, [ + angularTranslate, + ngAtInternet, + ngTranslateAsyncLoader, + 'oui', + uiRouter, + ]) + .config(routing) + .component(component.name, component) + .run(/* @ngTranslationsInject:json ./translations */); + +export default moduleName; diff --git a/packages/manager/modules/new-billing/src/autoRenew/actions/terminate-vrack/routing.js b/packages/manager/modules/new-billing/src/autoRenew/actions/terminate-vrack/routing.js new file mode 100644 index 000000000000..d686c7d02488 --- /dev/null +++ b/packages/manager/modules/new-billing/src/autoRenew/actions/terminate-vrack/routing.js @@ -0,0 +1,36 @@ +export default /* @ngInject */ ($stateProvider) => { + $stateProvider.state('billing.autorenew.terminateVrack', { + url: '/terminate-vrack?service&serviceType', + views: { + modal: { + component: 'billingAutorenewTerminateVrack', + }, + }, + layout: 'modal', + resolve: { + goBack: /* @ngInject */ (goToAutorenew) => goToAutorenew, + service: /* @ngInject */ ($transition$) => $transition$.params().service, + serviceType: /* @ngInject */ ($transition$) => + $transition$.params().serviceType, + isEmpty: /* @ngInject */ (OvhApiVrack, service) => + OvhApiVrack.Aapi() + .services({ serviceName: service }) + .$promise.then((allServicesParam) => { + console.log('>>>>>>', allServicesParam); + const services = Object.entries(allServicesParam).filter( + ([, value]) => { + return Array.isArray(value) && value.length; + }, + ); + return !services.length; + }) + .catch(() => { + return false; + }), + breadcrumb: () => null, + }, + atInternet: { + ignore: true, + }, + }); +}; diff --git a/packages/manager/modules/new-billing/src/autoRenew/actions/terminate-vrack/template.html b/packages/manager/modules/new-billing/src/autoRenew/actions/terminate-vrack/template.html new file mode 100644 index 000000000000..ec65d14fcc52 --- /dev/null +++ b/packages/manager/modules/new-billing/src/autoRenew/actions/terminate-vrack/template.html @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + diff --git a/packages/manager/modules/new-billing/src/autoRenew/actions/terminate-vrack/translations/Messages_fr_FR.json b/packages/manager/modules/new-billing/src/autoRenew/actions/terminate-vrack/translations/Messages_fr_FR.json new file mode 100644 index 000000000000..07714c8520d5 --- /dev/null +++ b/packages/manager/modules/new-billing/src/autoRenew/actions/terminate-vrack/translations/Messages_fr_FR.json @@ -0,0 +1,9 @@ +{ + "autorenew_agora_terminate_vrack_blocked_title": "Supprimer mon Vrack", + "autorenew_agora_terminate_vrack_blocked_description": "Afin de supprimer votre Vrack vous devez au préalable deconnecter tous les services qui y sont ratachés", + "autorenew_agora_terminate_vrack_blocked_close": "Fermer", + "autorenew_agora_terminate_service_VRACK": "Supprimer Vrack", + "autorenew_agora_terminate_service_warning_VRACK": "Veuillez confirmer la suppression de Vrack", + "autorenew_agora_terminate_service_success_VRACK": "Votre demande de suppression de votre Vrack a été prise en compte. Un e-mail contenant la procédure vous a été envoyé.", + "autorenew_agora_terminate_service_error_VRACK": "Une erreur est survenue lors de la demande de suppression de votre Vrack. {{error}}" +} diff --git a/packages/manager/modules/new-billing/src/autoRenew/autorenew.component.js b/packages/manager/modules/new-billing/src/autoRenew/autorenew.component.js index b19e0bd6e6dd..e61c87df5466 100644 --- a/packages/manager/modules/new-billing/src/autoRenew/autorenew.component.js +++ b/packages/manager/modules/new-billing/src/autoRenew/autorenew.component.js @@ -18,6 +18,7 @@ export default { goToAutorenew: '<', hasAutoRenew: '<', homeLink: '<', + canDeleteVrack: '<', isAutorenewManagementAvailable: '<', isAutorenew2016DeploymentBannerAvailable: '<', isEnterpriseCustomer: '<', diff --git a/packages/manager/modules/new-billing/src/autoRenew/autorenew.html b/packages/manager/modules/new-billing/src/autoRenew/autorenew.html index bcd8b6868ebc..0b3e7528869f 100644 --- a/packages/manager/modules/new-billing/src/autoRenew/autorenew.html +++ b/packages/manager/modules/new-billing/src/autoRenew/autorenew.html @@ -244,6 +244,7 @@ tracking-page="{{ $ctrl.trackingPage }}" user="$ctrl.currentUser" billing-management-availability="$ctrl.isAutorenewManagementAvailable" + delete-vrack-availability="$ctrl.canDeleteVrack" > diff --git a/packages/manager/modules/new-billing/src/autoRenew/autorenew.module.js b/packages/manager/modules/new-billing/src/autoRenew/autorenew.module.js index 20a7e9b9688a..8019ef353a75 100644 --- a/packages/manager/modules/new-billing/src/autoRenew/autorenew.module.js +++ b/packages/manager/modules/new-billing/src/autoRenew/autorenew.module.js @@ -32,6 +32,7 @@ import terminatePrivateDatabase from './actions/terminatePrivateDatabase/private import terminateWebCoach from './actions/terminate-webcoach/terminate-webcoach.module'; import terminateAllDOm from './actions/terminate-all-dom/module'; import update from './actions/update/update.module'; +import terminateVrack from './actions/terminate-vrack'; import warnNicBilling from './actions/warnNicBilling/warnNicBilling.module'; import warnPendingDebt from './actions/warnPendingDebt/pending-debt.module'; @@ -73,6 +74,7 @@ angular terminateWebCoach, terminateAllDOm, uiRouter, + terminateVrack, update, warnNicBilling, warnPendingDebt, diff --git a/packages/manager/modules/new-billing/src/autoRenew/autorenew.routing.js b/packages/manager/modules/new-billing/src/autoRenew/autorenew.routing.js index 99e22e2379c4..a01b1fbaf94e 100644 --- a/packages/manager/modules/new-billing/src/autoRenew/autorenew.routing.js +++ b/packages/manager/modules/new-billing/src/autoRenew/autorenew.routing.js @@ -91,6 +91,7 @@ export default /* @ngInject */ ($stateProvider, coreConfigProvider) => { }, featureAvailability: /* @ngInject */ (ovhFeatureFlipping) => ovhFeatureFlipping.checkFeatureAvailability([ + 'vrack:delete', 'billing:management', 'billing:autorenew2016Deployment', ]), @@ -103,6 +104,8 @@ export default /* @ngInject */ ($stateProvider, coreConfigProvider) => { featureAvailability?.isFeatureAvailable( 'billing:autorenew2016Deployment', ) || false, + canDeleteVrack: /* @ngInject */ (featureAvailability) => + featureAvailability?.isFeatureAvailable('vrack:delete') || false, hideBreadcrumb: /* @ngInject */ () => true, trackingPrefix: () => 'dedicated::account::billing::autorenew', },