|
| 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 ExternalLinkIcon from 'virtual:icons/ri/external-link-line'; |
| 9 | + import StandardButton from './StandardButton.svelte'; |
| 10 | + import { t } from '../i18n'; |
| 11 | + import { state } from '../script/stores/uiStore'; |
| 12 | + import { reconnect } from '../script/utils/reconnect'; |
| 13 | + import StandardDialog from './dialogs/StandardDialog.svelte'; |
| 14 | + import { stateOnHideReconnectHelp } from '../script/microbit-interfacing/state-updaters'; |
| 15 | +
|
| 16 | + export let isOpen: boolean = false; |
| 17 | +
|
| 18 | + $: content = (() => { |
| 19 | + switch ($state.reconnectState.connectionType) { |
| 20 | + case 'bluetooth': { |
| 21 | + return { |
| 22 | + heading: |
| 23 | + $state.showReconnectHelp === 'userTriggered' |
| 24 | + ? 'reconnectFailed.bluetoothHeading' |
| 25 | + : 'disconnectedWarning.bluetoothHeading', |
| 26 | + subtitle: |
| 27 | + $state.showReconnectHelp === 'userTriggered' |
| 28 | + ? 'reconnectFailed.bluetooth1' |
| 29 | + : 'disconnectedWarning.bluetooth1', |
| 30 | + listHeading: 'disconnectedWarning.bluetooth2', |
| 31 | + bulletOne: 'disconnectedWarning.bluetooth3', |
| 32 | + bulletTwo: 'disconnectedWarning.bluetooth4', |
| 33 | + }; |
| 34 | + } |
| 35 | + case 'bridge': { |
| 36 | + return { |
| 37 | + heading: |
| 38 | + $state.showReconnectHelp === 'userTriggered' |
| 39 | + ? 'reconnectFailed.bridgeHeading' |
| 40 | + : 'disconnectedWarning.bridgeHeading', |
| 41 | + subtitle: |
| 42 | + $state.showReconnectHelp === 'userTriggered' |
| 43 | + ? 'reconnectFailed.bridge1' |
| 44 | + : 'disconnectedWarning.bridge1', |
| 45 | + listHeading: 'connectMB.usbTryAgain.replugMicrobit2', |
| 46 | + bulletOne: 'connectMB.usbTryAgain.replugMicrobit3', |
| 47 | + bulletTwo: 'connectMB.usbTryAgain.replugMicrobit4', |
| 48 | + }; |
| 49 | + } |
| 50 | + case 'remote': { |
| 51 | + return { |
| 52 | + heading: |
| 53 | + $state.showReconnectHelp === 'userTriggered' |
| 54 | + ? 'reconnectFailed.remoteHeading' |
| 55 | + : 'disconnectedWarning.remoteHeading', |
| 56 | + subtitle: |
| 57 | + $state.showReconnectHelp === 'userTriggered' |
| 58 | + ? 'reconnectFailed.remote1' |
| 59 | + : 'disconnectedWarning.remote1', |
| 60 | + listHeading: 'disconnectedWarning.bluetooth2', |
| 61 | + bulletOne: 'disconnectedWarning.bluetooth3', |
| 62 | + bulletTwo: 'disconnectedWarning.bluetooth4', |
| 63 | + }; |
| 64 | + } |
| 65 | + default: { |
| 66 | + return { |
| 67 | + heading: '', |
| 68 | + subtitle: '', |
| 69 | + listHeading: '', |
| 70 | + bulletOne: '', |
| 71 | + bulletTwo: '', |
| 72 | + }; |
| 73 | + } |
| 74 | + } |
| 75 | + })(); |
| 76 | +</script> |
| 77 | + |
| 78 | +{#if $state.reconnectState.connectionType !== 'none'} |
| 79 | + <StandardDialog {isOpen} onClose={stateOnHideReconnectHelp} class="w-150 space-y-5"> |
| 80 | + <svelte:fragment slot="heading"> |
| 81 | + {$t(content.heading)} |
| 82 | + </svelte:fragment> |
| 83 | + <svelte:fragment slot="body"> |
| 84 | + <p>{$t(content.subtitle)}</p> |
| 85 | + <div> |
| 86 | + <p>{$t(content.listHeading)}</p> |
| 87 | + <ul class="list-disc pl-10"> |
| 88 | + <li>{$t(content.bulletOne)}</li> |
| 89 | + <li>{$t(content.bulletTwo)}</li> |
| 90 | + </ul> |
| 91 | + </div> |
| 92 | + |
| 93 | + <div class="flex justify-end gap-x-5"> |
| 94 | + <a |
| 95 | + class="inline-flex mr-auto gap-x-1 items-center text-link outline-none focus-visible:ring-4 focus-visible:ring-offset-1 focus-visible:ring-ring" |
| 96 | + href="" |
| 97 | + target="_blank" |
| 98 | + rel="noopener"> |
| 99 | + {$t('connectMB.troubleshooting')} |
| 100 | + <ExternalLinkIcon /> |
| 101 | + </a> |
| 102 | + <StandardButton onClick={stateOnHideReconnectHelp} |
| 103 | + >{$t('actions.cancel')}</StandardButton> |
| 104 | + <StandardButton type="primary" onClick={() => reconnect(true)} |
| 105 | + >{$t('actions.reconnect')}</StandardButton> |
| 106 | + </div> |
| 107 | + </svelte:fragment> |
| 108 | + </StandardDialog> |
| 109 | +{/if} |
0 commit comments