From 50e681d15fe43be1a76c24bc229153f51a2fa64f Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Fri, 22 Dec 2023 08:27:50 +0100 Subject: [PATCH] feat: checks custom domains before delete satellite Signed-off-by: David Dal Busco --- src/frontend/src/lib/api/satellites.api.ts | 4 +- .../CanisterDeleteWizard.svelte} | 157 +++++++++--------- .../src/lib/components/hosting/Hosting.svelte | 16 +- .../modals/OrbiterDeleteModal.svelte | 7 +- .../modals/SatelliteDeleteModal.svelte | 40 ++++- .../satellites/SatelliteActions.svelte | 41 ++++- src/frontend/src/lib/i18n/en.json | 1 + src/frontend/src/lib/i18n/zh-cn.json | 1 + .../src/lib/services/hosting.services.ts | 28 +++- src/frontend/src/lib/types/custom-domain.ts | 4 + src/frontend/src/lib/types/i18n.d.ts | 1 + src/frontend/src/lib/types/modal.ts | 12 +- 12 files changed, 199 insertions(+), 113 deletions(-) rename src/frontend/src/lib/components/{modals/CanisterDeleteModal.svelte => canister/CanisterDeleteWizard.svelte} (62%) diff --git a/src/frontend/src/lib/api/satellites.api.ts b/src/frontend/src/lib/api/satellites.api.ts index acb65b8c4f..72518d71a9 100644 --- a/src/frontend/src/lib/api/satellites.api.ts +++ b/src/frontend/src/lib/api/satellites.api.ts @@ -1,6 +1,5 @@ import type { Controller } from '$declarations/mission_control/mission_control.did'; import type { - CustomDomain, DelDoc as DelRule, Doc, ListResults as ListAssets, @@ -11,6 +10,7 @@ import type { } from '$declarations/satellite/satellite.did'; import type { MemoryText, PermissionText } from '$lib/constants/rules.constants'; import { MemoryHeap } from '$lib/constants/rules.constants'; +import type { CustomDomains } from '$lib/types/custom-domain'; import type { OptionIdentity } from '$lib/types/itentity'; import type { ListParams } from '$lib/types/list'; import { getSatelliteActor } from '$lib/utils/actor.juno.utils'; @@ -175,7 +175,7 @@ export const listCustomDomains = async ({ }: { satelliteId: Principal; identity: OptionIdentity; -}): Promise<[string, CustomDomain][]> => { +}): Promise => { const actor = await getSatelliteActor({ satelliteId, identity }); return actor.list_custom_domains(); }; diff --git a/src/frontend/src/lib/components/modals/CanisterDeleteModal.svelte b/src/frontend/src/lib/components/canister/CanisterDeleteWizard.svelte similarity index 62% rename from src/frontend/src/lib/components/modals/CanisterDeleteModal.svelte rename to src/frontend/src/lib/components/canister/CanisterDeleteWizard.svelte index dfd5c8c737..0a476e7e67 100644 --- a/src/frontend/src/lib/components/modals/CanisterDeleteModal.svelte +++ b/src/frontend/src/lib/components/canister/CanisterDeleteWizard.svelte @@ -1,7 +1,6 @@ - - {#if steps === 'in_progress'} - -

{$i18n.canisters.delete_in_progress}

-
- {:else} -
-

- {@html i18nFormat($i18n.canisters.delete_title, [ +{#if steps === 'in_progress'} + +

{$i18n.canisters.delete_in_progress}

+
+{:else} + +

+ {@html i18nFormat($i18n.canisters.delete_title, [ + { + placeholder: '{0}', + value: segment.replace('_', ' ') + } + ])} +

+ +

+ {@html i18nFormat($i18n.canisters.delete_explanation, [ + { + placeholder: '{0}', + value: segment.replace('_', ' ') + }, + { + placeholder: '{1}', + value: segment.replace('_', ' ') + } + ])} +

+ +

+ {@html i18nFormat($i18n.canisters.delete_customization, [ + { + placeholder: '{0}', + value: segment.replace('_', ' ') + }, + { + placeholder: '{1}', + value: formatTCycles(currentCycles) + } + ])} +

+ + + {$i18n.canisters.cycles_to_retain} + + + + +

+ {@html i18nFormat($i18n.canisters.cycles_to_transfer, [ { placeholder: '{0}', - value: segment.replace('_', ' ') + value: formatTCycles(cyclesToDeposit) } - ])} - - -

- {@html i18nFormat($i18n.canisters.delete_explanation, [ - { - placeholder: '{0}', - value: segment.replace('_', ' ') - }, - { - placeholder: '{1}', - value: segment.replace('_', ' ') - } - ])} -

- -

- {@html i18nFormat($i18n.canisters.delete_customization, [ - { - placeholder: '{0}', - value: segment.replace('_', ' ') - }, - { - placeholder: '{1}', - value: formatTCycles(currentCycles) - } - ])} -

- - - {$i18n.canisters.cycles_to_retain} - - - - -

- {@html i18nFormat($i18n.canisters.cycles_to_transfer, [ - { - placeholder: '{0}', - value: formatTCycles(cyclesToDeposit) - } - ])} -

- -

- - {@html i18nFormat($i18n.canisters.delete_info, [ - { - placeholder: '{0}', - value: segment.replace('_', ' ') - } - ])} -

- - - - {/if} -
+ ])} +

+ +

+ + {@html i18nFormat($i18n.canisters.delete_info, [ + { + placeholder: '{0}', + value: segment.replace('_', ' ') + } + ])} +

+ + + +{/if}