Skip to content

Commit

Permalink
feat(pci.instances): add Windows Gen 3 license price (#14543)
Browse files Browse the repository at this point in the history
ref: TAPC-1803, TAPC-1802

Signed-off-by: Yann Lojewski <[email protected]>
Co-authored-by: CDS Translator Agent <[email protected]>
  • Loading branch information
2 people authored and anooparveti committed Jan 7, 2025
1 parent 6657dc2 commit 0a153a3
Show file tree
Hide file tree
Showing 19 changed files with 194 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ export default {
hourlyPriceInformation: '<',
onChange: '&',
},
transclude: {
hourlyPrice: '?pciProjectFlavorBillingHourlyPrice',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
data-translate-values="{ price: $ctrl.formatPrice($ctrl.prices.hourly) }"
>
</span>
<span data-ng-transclude="hourlyPrice"></span>
</p>
<div data-ng-if="$ctrl.addons.length > 0">
<p data-ng-if="$ctrl.defaultGateway">
Expand Down Expand Up @@ -65,6 +66,7 @@
data-translate-values="{ price: $ctrl.formatPrice($ctrl.hourlyPriceInformation) }"
>
</span>
<span data-ng-transclude="hourlyPrice"></span>
</p>
</oui-select-picker-section>
</oui-select-picker>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class FlavorGroup {
flavors,
(flavor) => image.includes(flavor.osType) && !flavor.isFlex(),
),
['regions', 'id', 'osType', 'planCodes'],
['regions', 'id', 'osType'],
),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default {
onTabChange: '&',
serviceName: '@',
region: '<?',
getPriceText: '&',
},
transclude: true,
};
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@
data-match="name"
data-values="images"
>
<oui-select-picker-section
data-ng-if="$ctrl.getPriceText({ distribution, images })"
>
<span
data-ng-bind="$ctrl.getPriceText({ distribution, images })"
></span>
</oui-select-picker-section>
</oui-select-picker>
</div>
<oui-checkbox
Expand All @@ -52,6 +59,13 @@
data-match="name"
data-values="images"
>
<oui-select-picker-section
data-ng-if="$ctrl.getPriceText({ distribution, images })"
>
<span
data-ng-bind="$ctrl.getPriceText({ distribution, images })"
></span>
</oui-select-picker-section>
</oui-select-picker>
</div>
<div
Expand Down Expand Up @@ -168,6 +182,13 @@
data-picture="{{$ctrl.IMAGE_ASSETS.os[$ctrl.distribution]}}"
data-match="name"
>
<oui-select-picker-section
data-ng-if="$ctrl.getPriceText({ distribution: $ctrl.distribution, images: [$ctrl.image] })"
>
<span
data-ng-bind="$ctrl.getPriceText({ distribution: $ctrl.distribution, images: [$ctrl.image] })"
></span>
</oui-select-picker-section>
</oui-select-picker>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export default {
projectActivationPageHref: '<',
goToDiscoveryProjectActivationPage: '&',
getUAppUrl: '<',
windowsGen3: '<',
catalog: '<',
},
controller,
template,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ import {
LOCAL_PRIVATE_NETWORK_MODE,
} from './add.constants';

import { INSTANCE_PRICING_LINKS } from '../instances.constants';
import {
INSTANCE_PRICING_LINKS,
WINDOWS_GEN_3_ADDON_PLANCODE,
} from '../instances.constants';
import { useURLModel } from '../../project.utils';

export default class PciInstancesAddController {
Expand Down Expand Up @@ -1708,4 +1711,83 @@ export default class PciInstancesAddController {
`${modelValue ? '' : 'de'}activate_private_network_compatible_lz`,
]);
}

shouldShowWindowsGen3Data(
distribution = this.model?.image?.distribution,
images = [this.model?.image],
) {
const {
windowsGen3: { isFeatureAvailable },
model: { flavorGroup },
} = this;

if (!distribution || !images.length || !flavorGroup) {
return false;
}

const isWindowsDistribution = Boolean(distribution.match(/^windows/i));
const hasWindowsServerImages =
isWindowsDistribution &&
images.some(({ name }) => name.match(/20(16|19|22)/));
const isLicensedFlavor = Boolean(
this.catalog.addons
.find(({ planCode }) => planCode === flavorGroup?.planCodes.hourly)
?.addonFamilies.some(({ addons }) =>
addons.includes(WINDOWS_GEN_3_ADDON_PLANCODE),
),
);
const is1AZRegion = !this.isLocalZone();

return (
isFeatureAvailable &&
isWindowsDistribution &&
hasWindowsServerImages &&
isLicensedFlavor &&
is1AZRegion
);
}

getWindowsLicensePrice(multiplier = 1) {
const { coreConfig, windowsGen3 } = this;
const convertedPrice = windowsGen3.price / 10 ** 8;

return new Intl.NumberFormat(coreConfig.getUserLocale().replace('_', '-'), {
style: 'currency',
currency: coreConfig.getUser().currency.code,
maximumFractionDigits: Math.max(
`${convertedPrice}`.split('.').pop().length,
3,
),
}).format(convertedPrice * multiplier);
}

getWindowsLicensePriceText(distribution, images) {
if (!this.shouldShowWindowsGen3Data(distribution, images)) {
return '';
}

const price = this.getWindowsLicensePrice();
const unit = this.$translate.instant(
'pci_projects_project_instances_add_windows_gen3_license_unit_w_core',
);

return `+ ${price} ${unit}`;
}

getWindowsLicenseTotalPriceText() {
const { flavorGroup } = this.model;

if (!flavorGroup || !this.shouldShowWindowsGen3Data()) {
return '';
}

const price = this.getWindowsLicensePrice(
flavorGroup.technicalBlob.cpu.cores,
);
const unit = this.$translate.instant(
'pci_projects_project_instances_add_windows_gen3_license_unit',
);

return `${price} ${unit}`;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ <h1 data-translate="pci_projects_project_instances_add_title"></h1>
data-is-image-compatible="$ctrl.model.isImageCompatible"
data-on-change="$ctrl.onImageSelected(image)"
data-on-tab-change="$ctrl.onImageTabChange(tab)"
data-get-price-text="$ctrl.getWindowsLicensePriceText(distribution, images)"
>
<div class="d-flex justify-content-between">
<span
Expand Down Expand Up @@ -999,7 +1000,7 @@ <h1 data-translate="pci_projects_project_instances_add_title"></h1>
data-ng-if="$ctrl.IsSavingsPlanBannerDisplayed() && !$ctrl.isAddingPrivateNetwork && !$ctrl.isAddingPrivateNetworkError"
>
<p
data-translate="pci_projects_project_instances_add_billing_savings_plan_banner"
data-translate="{{ 'pci_projects_project_instances_add_billing_savings_plan_banner' + ($ctrl.shouldShowWindowsGen3Data() ? '_windows_gen_3' : '') }}"
></p>
<a
class="oui-link oui-link_icon"
Expand Down Expand Up @@ -1094,6 +1095,18 @@ <h1 data-translate="pci_projects_project_instances_add_title"></h1>
data-disabled="false"
data-on-change="$ctrl.onBillingChange(billing)"
>
<pci-project-flavor-billing-hourly-price
data-ng-if="$ctrl.shouldShowWindowsGen3Data()"
>
<span class="d-block">
<strong
data-translate="pci_projects_project_instances_add_windows_gen3_license_total_price_label"
></strong>
<span
data-ng-bind="$ctrl.getWindowsLicenseTotalPriceText()"
></span>
</span>
</pci-project-flavor-billing-hourly-price>
</pci-project-flavor-billing>

<pci-trusted-zone-banner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"pci_projects_project_instances_add_automated_backup_label": "Automatische Sicherung der Instanzen",
"pci_projects_project_instances_add_automated_backup_recommended": "Empfohlen",
"pci_projects_project_instances_add_automated_backup_infos": "Diese Funktion ermöglicht es Ihnen, Ihre Instanz automatisch nach Ihren Vorgaben zu sichern.",
"pci_projects_project_instances_add_billing_title": "Wählen Sie einen Abrechnungszeitraum aus",
"pci_projects_project_instances_add_billing_title": "Abrechnung",
"pci_projects_project_instances_add_billing_coming_soon_message_title": "Monatliche Preise",
"pci_projects_project_instances_add_billing_coming_soon_message_description": "Die monatlichen Preise werden mit der Einführung der Saving Plans in Kürze verfügbar sein.",
"pci_projects_project_instances_add_billing_montly_discount_message": "Verringern Sie den Rechnungsbetrag, indem Sie Ihre Instanz auf die monatliche Abrechnung umstellen.",
Expand Down Expand Up @@ -125,5 +125,9 @@
"pci_projects_project_instances_add_attch_floating_ip_checkbox_label_tooltip": "Diese Option ist nicht verfügbar, wenn mehrere Instanzen konfiguriert werden. Gehen Sie zu „Public IPs“, um Ihren Instanzen eine Floating-IP zuzuweisen.",
"pci_project_instances_instance_add_region_savings_plan_info": "Die Local Zones kommen für Savings Plans nicht infrage.",
"pci_projects_project_instances_add_billing_savings_plan_banner": "Profitieren Sie von günstigen monatlichen Preisen mit den Savings Plans und behalten Sie die Flexibilität der Instanzen auf Stundenbasis bei.",
"pci_projects_project_instances_add_billing_savings_plan_cta": "Ihre Savings Plans konfigurieren"
"pci_projects_project_instances_add_billing_savings_plan_cta": "Ihre Savings Plans konfigurieren",
"pci_projects_project_instances_add_billing_savings_plan_banner_windows_gen_3": "Profitieren Sie von günstigen monatlichen Preisen mit den Savings Plans und behalten Sie die Flexibilität der Instanzen auf Stundenbasis bei. Beachten Sie, dass die Windows-Lizenzkosten nicht in den Savings Plans enthalten sind.",
"pci_projects_project_instances_add_windows_gen3_license_unit": "inkl. MwSt./Stunde",
"pci_projects_project_instances_add_windows_gen3_license_unit_w_core": "inkl. MwSt./vCore/Stunde",
"pci_projects_project_instances_add_windows_gen3_license_total_price_label": "Preis der Lizenz:"
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"pci_projects_project_instances_add_automated_backup_label": "Automatic instance backup",
"pci_projects_project_instances_add_automated_backup_recommended": "Recommended",
"pci_projects_project_instances_add_automated_backup_infos": "You can use this feature to back up your instance automatically, as often as you like.",
"pci_projects_project_instances_add_billing_title": "Select a billing period",
"pci_projects_project_instances_add_billing_title": "Billing",
"pci_projects_project_instances_add_billing_coming_soon_message_title": "Monthly prices",
"pci_projects_project_instances_add_billing_coming_soon_message_description": "With the launch of Saving Plans, we will soon be able to bill you monthly.",
"pci_projects_project_instances_add_billing_montly_discount_message": "Switch to monthly billing for this instance and save more.",
Expand Down Expand Up @@ -125,5 +125,9 @@
"pci_projects_project_instances_add_attch_floating_ip_checkbox_label_tooltip": "Option not available when configuring multiple instances. Please go to Public IPs to link a Floating IP to your instances.",
"pci_project_instances_instance_add_region_savings_plan_info": "Local Zones are not eligible for Savings Plans.",
"pci_projects_project_instances_add_billing_savings_plan_banner": "Take advantage of low monthly rates with Savings Plans — save money without sacrificing the flexibility to use instances whenever you need them.",
"pci_projects_project_instances_add_billing_savings_plan_cta": "Set up your Savings Plan"
"pci_projects_project_instances_add_billing_savings_plan_cta": "Set up your Savings Plan",
"pci_projects_project_instances_add_billing_savings_plan_banner_windows_gen_3": "Take advantage of low monthly rates with Savings Plans—save money without sacrificing the flexibility to use instances whenever you need them. Please note that Windows licensing costs are not included in Savings Plans",
"pci_projects_project_instances_add_windows_gen3_license_unit": "ex. VAT/hour",
"pci_projects_project_instances_add_windows_gen3_license_unit_w_core": "ex. VAT/vCore/hour",
"pci_projects_project_instances_add_windows_gen3_license_total_price_label": "Licence price:"
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"pci_projects_project_instances_add_automated_backup_label": "Backup automatizado de instancias",
"pci_projects_project_instances_add_automated_backup_recommended": "Recomendado",
"pci_projects_project_instances_add_automated_backup_infos": "Esta funcionalidad permite realizar un backup de su instancia de forma automática, con la frecuencia que usted elija.",
"pci_projects_project_instances_add_billing_title": "Seleccione un período de facturación",
"pci_projects_project_instances_add_billing_title": "Facturación",
"pci_projects_project_instances_add_billing_coming_soon_message_title": "Precios mensuales",
"pci_projects_project_instances_add_billing_coming_soon_message_description": "Los precios mensuales estarán disponibles próximamente con la llegada de los Saving Plans.",
"pci_projects_project_instances_add_billing_montly_discount_message": "Ahorre en la factura de su instancia pasando a la tarifa mensual.",
Expand Down Expand Up @@ -125,5 +125,9 @@
"pci_projects_project_instances_add_attch_floating_ip_checkbox_label_tooltip": "Opción no disponible durante la configuración de varias instancias. Acceda a «Public IP» para asociar una Floating IP a sus instancias.",
"pci_project_instances_instance_add_region_savings_plan_info": "Las Local Zones no son compatibles con los Savings Plans.",
"pci_projects_project_instances_add_billing_savings_plan_banner": "Disfrute de tarifas mensuales más económicas gracias a los Savings Plans, manteniendo la flexibilidad de las instancias por horas.",
"pci_projects_project_instances_add_billing_savings_plan_cta": "Configure sus Savings Plans"
"pci_projects_project_instances_add_billing_savings_plan_cta": "Configure sus Savings Plans",
"pci_projects_project_instances_add_billing_savings_plan_banner_windows_gen_3": "Disfrute de tarifas mensuales más económicas gracias a los Savings Plans, manteniendo la flexibilidad de las instancias por horas. Tenga en cuenta que los costes de las licencias Windows no se incluyen en los Savings Plans.",
"pci_projects_project_instances_add_windows_gen3_license_unit": "/hora + IVA",
"pci_projects_project_instances_add_windows_gen3_license_unit_w_core": "/hora + IVA por vCore",
"pci_projects_project_instances_add_windows_gen3_license_total_price_label": "Precio de la licencia:"
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"pci_projects_project_instances_add_automated_backup_recommended": "Recommandé",
"pci_projects_project_instances_add_automated_backup_infos": "Cette fonctionnalité vous permet de sauvegarder votre instance de manière automatique selon l'ordonnancement de votre choix.",

"pci_projects_project_instances_add_billing_title": "Sélectionnez une période de facturation",
"pci_projects_project_instances_add_billing_title": "Facturation",
"pci_projects_project_instances_add_billing_coming_soon_message_title": "Prix mensuels",
"pci_projects_project_instances_add_billing_coming_soon_message_description": "Les tarifications mensuelles seront prochainement disponibles avec l'arrivée des Saving Plans.",
"pci_projects_project_instances_add_billing_montly_discount_message": "Réduisez le montant de votre facture en passant votre instance au forfait mensuel.",
Expand All @@ -88,6 +88,7 @@
"pci_projects_project_instances_add_billing_monthly_label": "Mensuel",
"pci_projects_project_instances_add_billing_hourly_label": "Horaire",
"pci_projects_project_instances_add_billing_savings_plan_banner": "Bénéficiez de tarifs mensuels avantageux grâce aux Savings Plans, tout en gardant la flexibilité des instances à l'heure.",
"pci_projects_project_instances_add_billing_savings_plan_banner_windows_gen_3": "Bénéficiez de tarifs mensuels avantageux grâce aux Savings Plans, tout en gardant la flexibilité des instances à l'heure. Notez que les coûts de licence Windows ne sont pas inclus dans les Savings Plans",
"pci_projects_project_instances_add_billing_savings_plan_cta": "Configurez vos Savings Plans",

"pci_projects_project_instances_add_billing_gateway_info": "Nous avons détecté des composants manquants : <strong>Gateway</strong>",
Expand Down Expand Up @@ -138,5 +139,9 @@
"pci_projects_project_instances_add_attch_floating_ip_banner_localzone_description1_part2": "compatible avec ",
"pci_projects_project_instances_add_attch_floating_ip_banner_localzone_description2": "Pour mettre en place un réseau privé étendu entre plusieurs régions, veuillez sélectionner une région compatible.",
"pci_projects_project_instances_add_attch_floating_ip_banner_localzone_description3": "Modifier la localisation",
"pci_projects_project_instances_add_attch_floating_ip_checkbox_label_tooltip": "Option indisponible lors de la configuration de multiples instances. Nous vous invitons à vous rendre sur Public IPs pour attacher une floating IP à vos instances."
"pci_projects_project_instances_add_attch_floating_ip_checkbox_label_tooltip": "Option indisponible lors de la configuration de multiples instances. Nous vous invitons à vous rendre sur Public IPs pour attacher une floating IP à vos instances.",

"pci_projects_project_instances_add_windows_gen3_license_unit": "HT/heure",
"pci_projects_project_instances_add_windows_gen3_license_unit_w_core": "HT/vCore/heure",
"pci_projects_project_instances_add_windows_gen3_license_total_price_label": "Prix licence :"
}
Loading

0 comments on commit 0a153a3

Please sign in to comment.