Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dedicated): add iplb delete option for us #14243

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
</oui-guide-menu-item>
</oui-guide-menu>
</div>
<div data-ovh-alert="InfoErrors"></div>
<oui-header-tabs>
<oui-header-tabs-item
data-state="iplb.detail.home"
Expand Down
13 changes: 12 additions & 1 deletion packages/manager/modules/iplb/src/home/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ import IpLoadBalancerHomeService from './iplb-home.service';
import IpLoadBalancerHomeStatusService from './iplb-home-status.service';
import IpLoadBalancerUpdateQuotaCtrl from './updateQuota/iplb-update-quota.controller';
import IplbBulletChartComponent from './bullet-chart.component';

import IpLoadBalancerTerminateCtrl from '../modal/terminate/terminate.controller';
import IplbHeaderTemplate from '../header/iplb-dashboard-header.html';
import IplbHomeTemplate from './iplb-home.html';

import './bullet-chart.less';
import './status-card.less';
import './home.less';

import { LB_DELETE_FEATURE } from './iplb-home.constants';

const moduleName = 'ovhManagerIplbHome';

angular
Expand All @@ -41,6 +43,14 @@ angular
},
resolve: {
breadcrumb: () => null,
isDeleteOptionsAvailable: /* @ngInject */ (ovhFeatureFlipping) => {
return ovhFeatureFlipping
.checkFeatureAvailability([LB_DELETE_FEATURE])
.then((featureAvailability) =>
featureAvailability.isFeatureAvailable(LB_DELETE_FEATURE),
)
.catch(() => false);
},
},
});
},
Expand All @@ -53,6 +63,7 @@ angular
.controller('IpLoadBalancerHomeCtrl', IpLoadBalancerHomeCtrl)
.service('IpLoadBalancerHomeStatusService', IpLoadBalancerHomeStatusService)
.controller('IpLoadBalancerUpdateQuotaCtrl', IpLoadBalancerUpdateQuotaCtrl)
.controller('IpLoadBalancerTerminateCtrl', IpLoadBalancerTerminateCtrl)
.directive('iplbBulletChart', IplbBulletChartComponent)
.run(/* @ngTranslationsInject:json ./translations */);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const MESSAGE_DISPLAY_DATE = '2023-04-01';

export const LB_TEMPORARY_WARNING_BANNER_FEATURE =
'ip-load-balancer:lb-temporary-warning-banner';
export const LB_DELETE_FEATURE = 'ip-load-balancer:delete';

export const LB_SUBSCRIPTION_CONTACT_SECTION =
'ip-load-balancer:lb-contact-section';
Expand All @@ -33,5 +34,6 @@ export default {
INFO_LINK,
MESSAGE_DISPLAY_DATE,
LB_TEMPORARY_WARNING_BANNER_FEATURE,
LB_DELETE_FEATURE,
LB_SUBSCRIPTION_CONTACT_SECTION,
};
21 changes: 21 additions & 0 deletions packages/manager/modules/iplb/src/home/iplb-home.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import map from 'lodash/map';
import 'moment';

import IplbHomeUpdateQuotaTemplate from './updateQuota/iplb-update-quota.html';
import IpLoadBalancerTerminateTemplate from '../modal/terminate/terminate.html';
import {
INFO_LINK,
MESSAGE_DISPLAY_DATE,
Expand Down Expand Up @@ -40,6 +41,7 @@ export default class IpLoadBalancerHomeCtrl {
ovhManagerRegionService,
CucVrackService,
ovhFeatureFlipping,
isDeleteOptionsAvailable,
) {
this.$http = $http;
this.$state = $state;
Expand All @@ -63,6 +65,7 @@ export default class IpLoadBalancerHomeCtrl {
this.ovhManagerRegionService = ovhManagerRegionService;
this.VrackService = CucVrackService;
this.ovhFeatureFlipping = ovhFeatureFlipping;
this.isDeleteOptionsAvailable = isDeleteOptionsAvailable;

this.serviceName = this.$stateParams.serviceName;

Expand Down Expand Up @@ -247,6 +250,24 @@ export default class IpLoadBalancerHomeCtrl {
text: this.$translate.instant('iplb_edit'),
isAvailable: () => false,
},
deleteService: {
callback: () =>
this.CucControllerHelper.modal.showModal({
mhelhali-soufien marked this conversation as resolved.
Show resolved Hide resolved
modalConfig: {
template: IpLoadBalancerTerminateTemplate,
controller: 'IpLoadBalancerTerminateCtrl',
controllerAs: '$ctrl',
resolve: {
service: () => this,
},
},
}),
text: this.$translate.instant('iplb_delete'),
isAvailable: () =>
this.isDeleteOptionsAvailable &&
!this.subscription.loading &&
!this.subscription.hasErrors,
},
manageAutorenew: {
text: this.$translate.instant('iplb_manage'),
href: this.coreURLBuilder.buildURL('dedicated', '#/billing/autoRenew', {
Expand Down
9 changes: 9 additions & 0 deletions packages/manager/modules/iplb/src/home/iplb-home.html
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,15 @@
data-ng-bind="::$ctrl.actions.manageAutorenew.text"
></span>
</oui-action-menu-item>

<oui-action-menu-item
aria-label="{{::$ctrl.actions.deleteService.text}}"
data-ng-if="$ctrl.actions.deleteService.isAvailable()"
data-on-click="$ctrl.actions.deleteService.callback()"
><span
data-ng-bind="::$ctrl.actions.deleteService.text"
></span>
</oui-action-menu-item>
</oui-action-menu>
</oui-tile-definition>
<oui-tile-definition
Expand Down
3 changes: 2 additions & 1 deletion packages/manager/modules/iplb/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import 'oclazyload';
import '@ovh-ux/ui-kit/dist/css/oui.css';

import onboarding from './onboarding';
import listing from './listing';

const moduleName = 'ovhManagerIplbLazyLoading';

angular
.module(moduleName, ['ui.router', 'oc.lazyLoad', onboarding])
.module(moduleName, ['ui.router', 'oc.lazyLoad', onboarding, listing])
.config(
/* @ngInject */ ($stateProvider, $urlRouterProvider) => {
$stateProvider
Expand Down
20 changes: 8 additions & 12 deletions packages/manager/modules/iplb/src/iplb.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,15 @@ import ngTranslateAsyncLoader from '@ovh-ux/ng-translate-async-loader';
import { ListLayoutHelper } from '@ovh-ux/manager-ng-layout-helpers';
import ngOvhFeatureFlipping from '@ovh-ux/ng-ovh-feature-flipping';

import routing from './iplb.routing';
mhelhali-soufien marked this conversation as resolved.
Show resolved Hide resolved

const moduleName = 'ovhManagerIpLoadBalancer';

angular
.module(moduleName, [
ngOvhFeatureFlipping,
ngTranslateAsyncLoader,
'oui',
'pascalprecht.translate',
'ovhManagerFilters',
ListLayoutHelper.moduleName,
])
.config(routing);
angular.module(moduleName, [
ngOvhFeatureFlipping,
ngTranslateAsyncLoader,
'oui',
'pascalprecht.translate',
'ovhManagerFilters',
ListLayoutHelper.moduleName,
]);

export default moduleName;
19 changes: 19 additions & 0 deletions packages/manager/modules/iplb/src/listing/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import angular from 'angular';
import '@uirouter/angularjs';
import '@ovh-ux/ui-kit';
import '@ovh-ux/manager-core';

import IpLoadBalancerTerminateCtrl from '../modal/terminate/terminate.controller';
import iplbListing from './listing.component';
import route from './listing.route';

const moduleName = 'iplbListing';

angular
.module(moduleName, ['oui', 'ui.router', 'ovhManagerCore'])
.controller('IpLoadBalancerTerminateCtrl', IpLoadBalancerTerminateCtrl)
.component('iplbListing', iplbListing)
.config(route)
.run(/* @ngTranslationsInject:json ./translations */);

export default moduleName;
25 changes: 25 additions & 0 deletions packages/manager/modules/iplb/src/listing/listing.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ListLayoutHelper } from '@ovh-ux/manager-ng-layout-helpers';
import controller from './listing.controller';
import template from './listing.html';

export default {
bindings: {
...ListLayoutHelper.componentBindings,
header: '<',
staticResources: '<?',
id: '@',
description: '<',
loadResource: '<?',
columns: '<',
customizableColumns: '<?',
defaultFilterColumn: '<',
getServiceNameLink: '<?',
options: '<?',
formatters: '<?',
topbarOptions: '<?',
customizeColumnsMap: '<?',
isDeleteOptionsAvailable: '<',
},
template,
controller,
};
29 changes: 29 additions & 0 deletions packages/manager/modules/iplb/src/listing/listing.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { ListLayoutHelper } from '@ovh-ux/manager-ng-layout-helpers';
import template from '../modal/terminate/terminate.html';

export default class iplbListingCtrl extends ListLayoutHelper.ListLayoutCtrl {
/* @ngInject */
constructor($state, $q, ouiDatagridService, CucControllerHelper) {
super($q, ouiDatagridService);
this.$state = $state;
this.ouiDatagridService = ouiDatagridService;
this.CucControllerHelper = CucControllerHelper;
}

gotoService({ serviceName }) {
this.$state.go('iplb.detail.home', { serviceName });
}

deleteIplb(service) {
this.CucControllerHelper.modal.showModal({
mhelhali-soufien marked this conversation as resolved.
Show resolved Hide resolved
modalConfig: {
template,
controller: 'IpLoadBalancerTerminateCtrl',
controllerAs: '$ctrl',
resolve: {
service: () => service,
},
},
});
}
}
34 changes: 34 additions & 0 deletions packages/manager/modules/iplb/src/listing/listing.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<div class="iplb">
<oui-header class="mb-2" data-heading="{{:: $ctrl.header }}"></oui-header>
</div>
<div data-ovh-alert="InfoErrors"></div>
<oui-datagrid
id="{{ $ctrl.datagridId }}"
rows-loader="$ctrl.loadPage()"
row-loader="$ctrl.loadResource($row)"
columns="$ctrl.columns"
customizable="true"
criteria="$ctrl.criteria"
on-columns-parameters-change="$ctrl.onColumnChange(id, columns)"
on-page-change="$ctrl.onPageChange($pagination)"
on-criteria-change="$ctrl.onCriteriaChange($criteria)"
page-size="{{ $ctrl.paginationSize }}"
page="{{ $ctrl.paginationNumber }}"
on-sort-change="$ctrl.onSortChange($sort)"
data-navi-id="{{ $ctrl.dataNaviId }}"
>
<oui-datagrid-topbar data-ng-if="$ctrl.topbarOptions">
<topbar-cta data-options="$ctrl.topbarOptions"> </topbar-cta>
</oui-datagrid-topbar>
<oui-action-menu data-compact data-placement="end">
<oui-action-menu-item data-on-click="$ctrl.gotoService($row)">
<span data-translate="iplb_listing_action_detail"></span>
</oui-action-menu-item>
<oui-action-menu-item
data-on-click="$ctrl.deleteIplb($row)"
data-ng-if="$ctrl.isDeleteOptionsAvailable"
>
<span data-translate="iplb_listing_action_delete"></span>
</oui-action-menu-item>
</oui-action-menu>
</oui-datagrid>
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { ListLayoutHelper } from '@ovh-ux/manager-ng-layout-helpers';
import { LB_DELETE_FEATURE } from '../home/iplb-home.constants';

export default /* @ngInject */ ($stateProvider) => {
$stateProvider.state('iplb.index', {
url: `?${ListLayoutHelper.urlQueryParams}`,
views: {
iplbContainer: {
component: 'managerListLayout',
component: 'iplbListing',
},
},
params: ListLayoutHelper.stateParams,
Expand All @@ -14,13 +15,21 @@ export default /* @ngInject */ ($stateProvider) => {
apiPath: () => '/ipLoadbalancing',
dataModel: () => 'ipLoadbalancing.Ip',
defaultFilterColumn: () => 'serviceName',
header: /* @ngInject */ ($translate) => $translate.instant('iplb_title'),
customizableColumns: () => true,
getServiceNameLink: /* @ngInject */ ($state) => ({ serviceName }) =>
$state.href('iplb.detail', {
serviceName,
}),
breadcrumb: () => null,
hideBreadcrumb: () => true,
isDeleteOptionsAvailable: /* @ngInject */ (ovhFeatureFlipping) => {
return ovhFeatureFlipping
.checkFeatureAvailability([LB_DELETE_FEATURE])
.then((featureAvailability) =>
featureAvailability.isFeatureAvailable(LB_DELETE_FEATURE),
)
.catch(() => false);
},
header: /* @ngInject */ ($translate) => $translate.instant('iplb_title'),
},
redirectTo: (transition) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we removing this redirection for empty case ?

transition
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"iplb_listing_action_delete": "Supprimer mon service",
"iplb_listing_action_detail": "Voir les details de mon service",
"iplb_terminate_service": "Supprimer mon service",
"iplb_terminate_service_warning": "Veuillez confirmer la suppression de votre service",
"iplb_terminate_service_success": "Votre demande de suppression de votre service a été prise en compte. Un e-mail contenant la procédure vous a été envoyé.",
"iplb_terminate_service_error": "Une erreur est survenue lors de la demande de suppression de votre service. {{error}}",
"iplb_terminate_service_confirm_input": "Entrez \"TERMINATE\" dans le champ ci-dessous pour confirmer",
"iplb_terminate_service_terminate_valid": "Valider",
"iplb_terminate_service_terminate_cancel": "Annuler"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const TERMINATE_PATTERN = /^TERMINATE$/;

export default {
TERMINATE_PATTERN,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { TERMINATE_PATTERN } from './constants';

export default class IpLoadBalancerTerminateCtrl {
/* @ngInject */
constructor(
$http,
$translate,
$uibModalInstance,
service,
CucControllerHelper,
Alerter,
) {
this.$uibModalInstance = $uibModalInstance;
this.service = service;
this.CucControllerHelper = CucControllerHelper;
this.TERMINATE_PATTERN = TERMINATE_PATTERN;
this.$translate = $translate;
this.$http = $http;
this.Alerter = Alerter;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$onInit() {
this.isDeleting = false;
}

dismiss() {
this.$uibModalInstance.dismiss();
}

terminate() {
this.$http
.post(`/ipLoadbalancing/${this.service.serviceName}/terminate`)
.then(() => {
this.Alerter.success(
this.$translate.instant('iplb_terminate_service_success'),
'InfoErrors',
);
})
.catch((err) => {
this.Alerter.error(
this.$translate.instant('iplb_terminate_service_error', {
t0: err.data ? err.data.message : err.message,
}),
'InfoErrors',
);
});
this.$uibModalInstance.close();
}

close() {
this.$uibModalInstance.close();
}
}
Loading
Loading