Skip to content

Commit f3eb12e

Browse files
authored
Update upgrade modal footer to contain two links. (#3601)
Update upgrade modal footer to contain two links. # Changes - Rename `Help` link to `FAQ & Support`. - Replace `Forgot your identity number?` question with `Lookup identity` link. - Pass parent window origin into iframe so it can be used for the lookup link. - Use either the above passed in origin, the current origin (if not id.ai) or fallback to `identity.ic0.app`. # Tests Manually verified on beta the links work as expected.
1 parent 50173ec commit f3eb12e

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

src/frontend/src/lib/components/wizards/migration/views/EnterIdentityNumber.svelte

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<script lang="ts">
22
import MigrationIllustration from "$lib/components/illustrations/MigrationIllustration.svelte";
3-
import Button from "$lib/components/ui/Button.svelte";
43
import Input from "$lib/components/ui/Input.svelte";
54
import ProgressRing from "$lib/components/ui/ProgressRing.svelte";
65
import { UPGRADE_SUPPORT_URL } from "$lib/config";
@@ -9,6 +8,7 @@
98
import Tooltip from "$lib/components/ui/Tooltip.svelte";
109
import { t } from "$lib/stores/locale.store";
1110
import { Trans } from "$lib/components/locale";
11+
import { getPrimaryOrigin, parentIFrameOrigin } from "$lib/globals";
1212
1313
interface Props {
1414
onSubmit: (
@@ -17,6 +17,14 @@
1717
) => Promise<void | "cancelled" | "wrongDomain">;
1818
}
1919
20+
const primaryOrigin = getPrimaryOrigin();
21+
const selfServiceOrigin =
22+
parentIFrameOrigin !== undefined
23+
? parentIFrameOrigin
24+
: window.location.origin !== primaryOrigin
25+
? window.location.origin
26+
: "https://identity.ic0.app";
27+
2028
let { onSubmit }: Props = $props();
2129
2230
let identityNumber = $state<string>("");
@@ -100,16 +108,21 @@
100108
</Tooltip>
101109
<div class="border-border-tertiary my-5 border-t"></div>
102110
<div class="flex flex-row items-center justify-between gap-4">
103-
<p class="text-text-secondary text-sm">
104-
{$t`Forgot your identity number?`}
105-
</p>
111+
<a
112+
href={`${selfServiceOrigin}/self-service`}
113+
target="_blank"
114+
rel="noopener noreferrer"
115+
class="text-text-primary text-sm font-semibold outline-0 hover:underline focus-visible:underline"
116+
>
117+
{$t`Lookup identity`}
118+
</a>
106119
<a
107120
href={UPGRADE_SUPPORT_URL}
108121
target="_blank"
109122
rel="noopener noreferrer"
110123
class="text-text-primary text-sm font-semibold outline-0 hover:underline focus-visible:underline"
111124
>
112-
{$t`Help`}
125+
{$t`FAQ & Support`}
113126
</a>
114127
</div>
115128
</form>

src/frontend/src/lib/globals.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ export let canisterConfig: InternetIdentityInit;
1919
export let agentOptions: HttpAgentOptions;
2020
export let anonymousAgent: HttpAgent;
2121
export let anonymousActor: ActorSubclass<_SERVICE>;
22+
export let parentIFrameOrigin: string | undefined;
23+
24+
// Search param passed by parent window to indicate its origin to child window
25+
export const IFRAME_PARENT_PARAM = "parent_origin";
2226

2327
export const initGlobals = () => {
2428
canisterId = Principal.fromText(readCanisterId());
@@ -36,6 +40,12 @@ export const initGlobals = () => {
3640
agent: anonymousAgent,
3741
canisterId,
3842
});
43+
// Set when `IFRAME_PARENT_PARAM` search param contains a valid related origin
44+
parentIFrameOrigin = canisterConfig.related_origins[0]?.find(
45+
(origin) =>
46+
origin ===
47+
new URL(window.location.href).searchParams.get(IFRAME_PARENT_PARAM),
48+
);
3949
};
4050

4151
// Get primary origin (either https://id.ai or https://beta.id.ai) when deployed on beta or prod

src/frontend/src/routes/(new-styling)/(cross-origin)/+layout.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts">
22
import type { LayoutProps } from "./$types";
3-
import { getPrimaryOrigin } from "$lib/globals";
3+
import { getPrimaryOrigin, IFRAME_PARENT_PARAM } from "$lib/globals";
44
import { forwardMessage, isForwardedMessage } from "./utils";
55
66
const { children, data }: LayoutProps = $props();
@@ -24,6 +24,7 @@
2424
const url = new URL(window.location.href);
2525
url.hostname = new URL(primaryOrigin).hostname;
2626
url.searchParams.set("feature_flag_guided_upgrade", "true");
27+
url.searchParams.set(IFRAME_PARENT_PARAM, window.location.origin);
2728
return url.href;
2829
});
2930

0 commit comments

Comments
 (0)