Skip to content

Commit 0e32fbe

Browse files
Redirect to CreateAI dialog (#605)
Task (private): https://microbit-global.monday.com/boards/1125389526/pulses/2022067347 - Show redirect to CreateAI dialog to everyone before cookie dialog - Remove "Are you a UK primary school teacher" redirect dialog - Update `maint-nextgen` branch to be `STAGING`
1 parent 7f70430 commit 0e32fbe

File tree

10 files changed

+77
-118
lines changed

10 files changed

+77
-118
lines changed

bin/print-ci-env.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const ref = process.env.GITHUB_REF;
44
let stage;
5-
if (ref === 'refs/heads/main') {
5+
if (ref === 'refs/heads/maint-nextgen') {
66
stage = 'STAGING';
77
} else if (ref.startsWith('refs/tags/v')) {
88
stage = 'PRODUCTION';

src/App.svelte

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@
99
import PageContentView from './views/PageContentView.svelte';
1010
import {
1111
compatibility,
12-
hasSeenAppVersionRedirectDialog,
1312
isCompatibilityWarningDialogOpen,
1413
} from './script/stores/uiStore';
1514
import IncompatiblePlatformView from './views/IncompatiblePlatformView.svelte';
1615
import CompatibilityWarningDialog from './components/CompatibilityWarningDialog.svelte';
17-
import AppVersionRedirectDialog from './components/AppVersionRedirectDialog.svelte';
16+
import CreateAiVersionRedirectDialog from './components/CreateAiVersionRedirectDialog.svelte';
1817
import Router from './router/Router.svelte';
1918
import ControlBar from './components/control-bar/ControlBar.svelte';
2019
import { t } from './i18n';
@@ -33,17 +32,8 @@
3332
connectionDialogState,
3433
} from './script/stores/connectDialogStore';
3534
import { isLoading } from 'svelte-i18n';
36-
import { fetchBrowserInfo } from './script/utils/api';
37-
import { get } from 'svelte/store';
3835
39-
let isPotentiallyNonNextGenUser: boolean = false;
4036
onMount(async () => {
41-
if (!get(hasSeenAppVersionRedirectDialog)) {
42-
const { country } = await fetchBrowserInfo();
43-
const nextGenAvailableCountries = ['GB', 'JE', 'IM', 'GG'];
44-
isPotentiallyNonNextGenUser = !nextGenAvailableCountries.includes(country || '');
45-
}
46-
4737
const { bluetooth, usb } = $compatibility;
4838
// Value must switch from false to true after mount to trigger dialog transition
4939
isCompatibilityWarningDialogOpen.set(!bluetooth && !usb);
@@ -73,12 +63,12 @@
7363
<div class="h-full w-full m-0 relative flex">
7464
<OverlayView />
7565
<!-- Wait for consent dialog to avoid a clash -->
66+
{#if !$isCompatibilityWarningDialogOpen}
67+
<CreateAiVersionRedirectDialog />
68+
{/if}
7669
{#if $consent}
7770
<CompatibilityWarningDialog />
7871
{/if}
79-
{#if $consent && !$isCompatibilityWarningDialogOpen && isPotentiallyNonNextGenUser}
80-
<AppVersionRedirectDialog />
81-
{/if}
8272
<div class="w-full flex flex-col bg-backgrounddark">
8373
<ControlBar>
8474
<div class="flex items-center divide-x h-full">

src/components/AppVersionRedirectDialog.svelte

Lines changed: 0 additions & 52 deletions
This file was deleted.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<!--
2+
(c) 2023, Center for Computational Thinking and Design at Aarhus University and contributors
3+
4+
SPDX-License-Identifier: MIT
5+
-->
6+
7+
<script lang="ts">
8+
import { t } from '../i18n';
9+
import StandardDialog from './dialogs/StandardDialog.svelte';
10+
import StandardButton from './StandardButton.svelte';
11+
import createAiTestingPage from '../imgs/createai_testing_page.png';
12+
import { initialShowConsent } from '../script/stores/complianceStore';
13+
14+
let isOpen = true;
15+
16+
const createAIVersionRedirect = () => {
17+
window.location.href = 'https://createai.microbit.org/';
18+
};
19+
20+
const onClose = () => {
21+
isOpen = false;
22+
initialShowConsent();
23+
};
24+
</script>
25+
26+
<StandardDialog
27+
{isOpen}
28+
hasCloseButton
29+
closeOnOutsideClick={false}
30+
closeOnEscape={false}
31+
class="w-110 space-y-5"
32+
{onClose}>
33+
<svelte:fragment slot="heading">
34+
{$t('popup.createAIVersionRedirect.header')}
35+
</svelte:fragment>
36+
<svelte:fragment slot="body">
37+
<div class="space-y-5">
38+
<img src={createAiTestingPage} alt="" />
39+
<div class="space-y-2">
40+
<p>{$t('popup.createAIVersionRedirect.explain1')}</p>
41+
<p>{$t('popup.createAIVersionRedirect.explain2')}</p>
42+
</div>
43+
<div class="flex flex-col justify-end space-y-2">
44+
<StandardButton
45+
type="primary"
46+
size="normal"
47+
class="w-170px"
48+
onClick={createAIVersionRedirect}
49+
>{$t('popup.createAIVersionRedirect.button.redirect')}</StandardButton>
50+
<StandardButton onClick={onClose} type="secondary" size="normal" class="w-170px"
51+
>{$t('popup.createAIVersionRedirect.button.stay')}</StandardButton>
52+
</div>
53+
</div>
54+
</svelte:fragment>
55+
</StandardDialog>

src/components/dialogs/StandardDialog.svelte

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
};
2828
2929
const onCloseDialog = () => {
30+
if (!isOpen) {
31+
// Don't close dialog if already closed.
32+
return;
33+
}
3034
onClose();
3135
if (finalFocusRef) {
3236
(finalFocusRef as HTMLElement).focus();

src/imgs/createai_testing_page.png

59.7 KB
Loading

src/messages/ui.en.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,11 @@
285285
"popup.outdatedmicrobit.button.update": "Update now",
286286
"popup.outdatedmicrobit.button.update.mkcd": "Open MakeCode",
287287

288-
"popup.appVersionRedirect.header": "Are you a UK* primary school teacher?",
289-
"popup.appVersionRedirect.explain": "If you are not a UK* primary school teacher, you will be redirected to our prototype version of this tool. This version is only for the UK's BBC micro:bit playground survey.",
290-
"popup.appVersionRedirect.button.redirect": "I'm not a UK primary school teacher",
291-
"popup.appVersionRedirect.button.stay": "I'm a UK primary school teacher",
292-
"popup.appVersionRedirect.uk": "*includes crown dependencies Jersey, Guernsey and the Isle of Man",
288+
"popup.createAIVersionRedirect.header": "Try micro:bit CreateAI",
289+
"popup.createAIVersionRedirect.explain1": "micro:bit CreateAI is our updated version of the micro:bit machine learning tool.",
290+
"popup.createAIVersionRedirect.explain2": "Using CreateAI you can train and test a machine learning model then use it in a Microsoft MakeCode program on your micro:bit.",
291+
"popup.createAIVersionRedirect.button.redirect": "Try CreateAI",
292+
"popup.createAIVersionRedirect.button.stay": "Not now",
293293

294294
"arrowIconRight.altText": "arrow pointing right",
295295
"arrowIconDown.altText": "arrow pointing down",

src/script/stores/complianceStore.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ function showConsent(
6868
w.commonConsent?.show({ userTriggered, config });
6969
}
7070

71+
export function initialShowConsent() {
72+
if (w.commonConsent) {
73+
showConsent();
74+
} else {
75+
w.addEventListener('consentinit', showConsent);
76+
}
77+
}
78+
7179
export function manageCookies() {
7280
showConsent({ userTriggered: true });
7381
}
@@ -79,8 +87,3 @@ const updateListener = (event: CustomEvent<CookieConsent>) => {
7987
consent.set(event.detail);
8088
};
8189
w.addEventListener('consentchange', updateListener);
82-
if (w.commonConsent) {
83-
showConsent();
84-
} else {
85-
w.addEventListener('consentinit', showConsent);
86-
}

src/script/stores/uiStore.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ if (compatibilityResult.bluetooth) {
4343

4444
export const isCompatibilityWarningDialogOpen = writable<boolean>(false);
4545

46-
export const hasSeenAppVersionRedirectDialog = persistantWritable<boolean>(
47-
'hasSeenAppVersionRedirectDialog',
48-
false,
49-
);
50-
5146
export enum ModelView {
5247
TILE,
5348
STACK,

src/script/utils/api.ts

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

0 commit comments

Comments
 (0)