Skip to content

Commit 026800b

Browse files
authored
Replace old access route with new access route. (#3472)
* Replace old access route with new access route. * Replace old access route with new access route. * Replace old access route with new access route. * Replace old access route with new access route. * Replace old access route with new access route.
1 parent 241429a commit 026800b

File tree

19 files changed

+615
-534
lines changed

19 files changed

+615
-534
lines changed

src/frontend/src/lib/components/views/AccessMethods.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
AuthnMethodData,
1111
OpenIdCredential,
1212
} from "$lib/generated/internet_identity_types";
13-
import RemovePasskey from "../../../routes/(new-styling)/manage/(authenticated)/access-new/components/RemovePasskey.svelte";
14-
import RenamePasskey from "../../../routes/(new-styling)/manage/(authenticated)/access-new/components/RenamePasskey.svelte";
15-
import RemoveOpenIdCredential from "../../../routes/(new-styling)/manage/(authenticated)/access-new/components/RemoveOpenIdCredential.svelte";
13+
import RemovePasskey from "../../../routes/(new-styling)/manage/(authenticated)/access/components/RemovePasskey.svelte";
14+
import RenamePasskey from "../../../routes/(new-styling)/manage/(authenticated)/access/components/RenamePasskey.svelte";
15+
import RemoveOpenIdCredential from "../../../routes/(new-styling)/manage/(authenticated)/access/components/RemoveOpenIdCredential.svelte";
1616
import { nonNullish } from "@dfinity/utils";
1717
import { handleError } from "$lib/components/utils/error";
1818
import {

src/frontend/src/lib/components/views/AccessMethodsPanel.svelte

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
<script lang="ts">
22
import Panel from "$lib/components/ui/Panel.svelte";
3-
import identityInfo from "$lib/stores/identity-info.state.svelte";
43
import { ChevronRightIcon } from "@lucide/svelte";
54
import Button from "$lib/components/ui/Button.svelte";
5+
6+
interface Props {
7+
totalAccessMethods: number;
8+
}
9+
10+
const { totalAccessMethods }: Props = $props();
611
</script>
712

813
<Panel>
@@ -24,7 +29,7 @@
2429
</h5>
2530
<div class="flex items-center">
2631
<h5 class="text-text-primary text-sm font-semibold nth-[2]:hidden">
27-
{identityInfo.totalAccessMethods}
32+
{totalAccessMethods}
2833
</h5>
2934
</div>
3035
<div class="flex items-center justify-center">

src/frontend/src/lib/components/views/IdentityInfoPanel.svelte

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
<script lang="ts">
22
import Panel from "$lib/components/ui/Panel.svelte";
3-
import identityInfo from "$lib/stores/identity-info.state.svelte";
43
import Tooltip from "$lib/components/ui/Tooltip.svelte";
54
import { InfoIcon } from "@lucide/svelte";
6-
import PlaceHolder from "$lib/components/ui/PlaceHolder.svelte";
7-
import { fade } from "svelte/transition";
5+
6+
interface Props {
7+
name: string;
8+
}
9+
10+
const { name }: Props = $props();
811
</script>
912

1013
<Panel>
@@ -25,16 +28,9 @@
2528
Identity Name
2629
</h5>
2730
<div class="flex items-center">
28-
{#if identityInfo.name}
29-
<h5
30-
class="text-text-primary text-sm font-semibold nth-[2]:hidden"
31-
transition:fade={{ delay: 30 }}
32-
>
33-
{identityInfo.name}
34-
</h5>
35-
{:else}
36-
<PlaceHolder class="mr-8 h-4 w-full !rounded-sm" />
37-
{/if}
31+
<h5 class="text-text-primary text-sm font-semibold nth-[2]:hidden">
32+
{name}
33+
</h5>
3834
</div>
3935
<div class="flex items-center justify-center">
4036
<Tooltip

src/frontend/src/routes/(new-styling)/manage/(authenticated)/+layout.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { get } from "svelte/store";
44
import { authenticationStore } from "$lib/stores/authentication.store";
55
import { lastUsedIdentitiesStore } from "$lib/stores/last-used-identities.store";
66
import { isNullish } from "@dfinity/utils";
7-
import identityInfoState from "$lib/stores/identity-info.state.svelte";
7+
import { throwCanisterError } from "$lib/utils/utils";
88

9-
export const load: LayoutLoad = ({ url }) => {
9+
export const load: LayoutLoad = async ({ url }) => {
1010
// Go back to / if not authenticated with currently selected identity
1111
const authentication = get(authenticationStore);
1212
const selectedIdentity = get(lastUsedIdentitiesStore).selected;
@@ -25,5 +25,9 @@ export const load: LayoutLoad = ({ url }) => {
2525
throw redirect(307, location);
2626
}
2727

28-
void identityInfoState.fetch();
28+
const identityInfo = await authentication.actor
29+
.identity_info(selectedIdentity.identityNumber)
30+
.then(throwCanisterError);
31+
32+
return { identityInfo, identityNumber: selectedIdentity.identityNumber };
2933
};

src/frontend/src/routes/(new-styling)/manage/(authenticated)/+page.svelte

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,19 @@
1212
import { handleError } from "$lib/components/utils/error";
1313
import { toaster } from "$lib/components/utils/toaster";
1414
import AccessMethodsPanel from "$lib/components/views/AccessMethodsPanel.svelte";
15+
import { toAccessMethods } from "./access/utils";
1516
1617
const { data }: PageProps = $props();
1718
1819
let pendingRegistrationId = $state(data.pendingRegistrationId);
1920
21+
const name = $derived(
22+
data.identityInfo.name[0] ?? String(data.identityNumber),
23+
);
24+
const totalAccessMethods = $derived(
25+
toAccessMethods(data.identityInfo).length,
26+
);
27+
2028
const handleConfirm = () => {
2129
toaster.success({
2230
title: "Passkey has been registered from another device.",
@@ -35,14 +43,7 @@
3543
<div>
3644
<div class="mh-9 mb-3">
3745
<h1 class="text-text-primary text-3xl font-medium">
38-
Welcome,
39-
{#if !identityInfo.name}
40-
<PlaceHolder class="mt-0.5 inline-block h-6 w-40 md:w-64" />
41-
{:else}
42-
<span transition:fade={{ delay: 30 }}>
43-
{identityInfo.name}!
44-
</span>
45-
{/if}
46+
Welcome, {name}!
4647
</h1>
4748
</div>
4849
<h2 class="text-text-tertiary mb-12 text-base">
@@ -51,10 +52,10 @@
5152

5253
<div class="flex flex-col gap-6 lg:flex-row">
5354
<div class="flex-1">
54-
<IdentityInfoPanel />
55+
<IdentityInfoPanel {name} />
5556
</div>
5657
<div class="flex-1">
57-
<AccessMethodsPanel />
58+
<AccessMethodsPanel {totalAccessMethods} />
5859
</div>
5960
</div>
6061
</div>

src/frontend/src/routes/(new-styling)/manage/(authenticated)/access-new/+layout.ts

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)