Skip to content

Commit 5e6fa5a

Browse files
Merge remote-tracking branch 'origin/main'
2 parents 37ef917 + 88b1fa7 commit 5e6fa5a

20 files changed

+333
-233
lines changed

src/frontend/src/lib/api/mission-control.api.ts

+3-13
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import type { Controller, SetController } from '$declarations/mission_control/mission_control.did';
1+
import type { Controller } from '$declarations/mission_control/mission_control.did';
22
import { getMissionControl } from '$lib/services/mission-control.services';
3+
import type { SetControllerParams } from '$lib/types/controlers';
34
import { getMissionControlActor } from '$lib/utils/actor.utils';
4-
import { toNullable } from '$lib/utils/did.utils';
5-
import { nonNullish } from '$lib/utils/utils';
5+
import { toSetController } from '$lib/utils/controllers.utils';
66
import type { Identity } from '@dfinity/agent';
77
import { Principal } from '@dfinity/principal';
88

@@ -43,16 +43,6 @@ export const initMissionControl = async ({
4343
}
4444
});
4545

46-
export type SetControllerParams = {
47-
controllerId: string;
48-
profile: string | null | undefined;
49-
};
50-
51-
const toSetController = (profile: string | null | undefined): SetController => ({
52-
metadata: nonNullish(profile) && profile !== '' ? [['profile', profile]] : [],
53-
expires_at: toNullable<bigint>(undefined)
54-
});
55-
5646
export const setSatellitesController = async ({
5747
missionControlId,
5848
satelliteIds,

src/frontend/src/lib/components/canister/Controllers.svelte

-171
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<script lang="ts">
2+
import { Principal } from '@dfinity/principal';
3+
import { isNullish } from '$lib/utils/utils';
4+
import { toasts } from '$lib/stores/toasts.store';
5+
import { i18n } from '$lib/stores/i18n.store';
6+
import { missionControlStore } from '$lib/stores/mission-control.store';
7+
import { busy, isBusy } from '$lib/stores/busy.store';
8+
import Popover from '$lib/components/ui/Popover.svelte';
9+
import type { Controller } from '$declarations/satellite/satellite.did';
10+
import Value from '$lib/components/ui/Value.svelte';
11+
12+
export let visible = false;
13+
export let selectedController: [Principal, Controller] | undefined;
14+
export let remove: (params: {
15+
missionControlId: Principal;
16+
controller: Principal;
17+
}) => Promise<void>;
18+
export let load: () => Promise<void>;
19+
20+
const deleteController = async () => {
21+
if (isNullish(selectedController)) {
22+
toasts.error({
23+
text: $i18n.errors.controllers_no_selection
24+
});
25+
return;
26+
}
27+
28+
if (isNullish($missionControlStore)) {
29+
toasts.error({
30+
text: $i18n.errors.no_mission_control
31+
});
32+
return;
33+
}
34+
35+
busy.start();
36+
37+
try {
38+
await remove({
39+
missionControlId: $missionControlStore,
40+
controller: selectedController[0]
41+
});
42+
} catch (err: unknown) {
43+
toasts.error({
44+
text: $i18n.errors.controllers_delete,
45+
detail: err
46+
});
47+
}
48+
49+
close();
50+
51+
await load();
52+
53+
busy.stop();
54+
};
55+
56+
const close = () => {
57+
selectedController = undefined;
58+
visible = false;
59+
};
60+
</script>
61+
62+
<Popover bind:visible center={true}>
63+
<div class="content">
64+
<h3>{$i18n.controllers.delete_question}</h3>
65+
66+
<Value>
67+
<svelte:fragment slot="label">{$i18n.controllers.controller_id}</svelte:fragment>
68+
<p>{selectedController?.[0].toText() ?? ''}</p>
69+
</Value>
70+
71+
<button type="button" on:click|stopPropagation={close} disabled={$isBusy}>
72+
{$i18n.core.no}
73+
</button>
74+
75+
<button type="button" on:click|stopPropagation={deleteController} disabled={$isBusy}>
76+
{$i18n.core.yes}
77+
</button>
78+
</div>
79+
</Popover>
80+
81+
<style lang="scss">
82+
.content {
83+
padding: var(--padding-2x);
84+
}
85+
86+
h3 {
87+
margin-bottom: var(--padding-2x);
88+
}
89+
</style>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<script lang="ts">
2+
import { i18n } from '$lib/stores/i18n.store';
3+
import Popover from '$lib/components/ui/Popover.svelte';
4+
5+
export let visible = false;
6+
7+
const close = () => (visible = false);
8+
</script>
9+
10+
<Popover bind:visible center={true}>
11+
<div class="content">
12+
<p>{$i18n.controllers.no_delete}</p>
13+
14+
<p>{$i18n.controllers.more_delete}</p>
15+
16+
<button type="button" on:click|stopPropagation={close}>
17+
{$i18n.core.ok}
18+
</button>
19+
</div>
20+
</Popover>
21+
22+
<style lang="scss">
23+
.content {
24+
padding: var(--padding-2x);
25+
}
26+
</style>

0 commit comments

Comments
 (0)