2024-07-20 02:30:45 +02:00
|
|
|
import * as React from "bloatless-react";
|
|
|
|
|
|
|
|
|
|
import ConnectionViewModel from "../../ViewModel/connectionViewModel";
|
2024-07-20 03:34:54 +02:00
|
|
|
import { DeletableListItem } from "../Components/deletableListItem";
|
2024-07-20 02:30:45 +02:00
|
|
|
import { translations } from "../translations";
|
|
|
|
|
|
|
|
|
|
export function ConnectionModal(connectionViewModel: ConnectionViewModel) {
|
2024-07-20 03:34:54 +02:00
|
|
|
const previousAddressConverter: React.StateItemConverter<string> = (
|
|
|
|
|
address: string
|
|
|
|
|
) => {
|
2024-07-20 03:39:47 +02:00
|
|
|
function connnect() {
|
|
|
|
|
connectionViewModel.connectToAddress(address);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const cannotConnect = React.createProxyState(
|
|
|
|
|
[connectionViewModel.isConnected],
|
2024-07-20 22:44:23 +02:00
|
|
|
() =>
|
|
|
|
|
connectionViewModel.isConnected.value == true &&
|
|
|
|
|
connectionViewModel.connectionModel.address == address
|
2024-07-20 03:39:47 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return DeletableListItem(
|
|
|
|
|
address,
|
|
|
|
|
<button
|
|
|
|
|
class="primary"
|
|
|
|
|
on:click={connnect}
|
|
|
|
|
toggle:disabled={cannotConnect}
|
|
|
|
|
aria-label={translations.connectionModal.connectButtonAudioLabel}
|
|
|
|
|
>
|
|
|
|
|
<span class="icon">link</span>
|
|
|
|
|
</button>,
|
|
|
|
|
() => {
|
|
|
|
|
connectionViewModel.removePreviousAddress(address);
|
|
|
|
|
}
|
|
|
|
|
);
|
2024-07-20 03:34:54 +02:00
|
|
|
};
|
|
|
|
|
|
2024-07-20 02:30:45 +02:00
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
class="modal"
|
|
|
|
|
toggle:open={connectionViewModel.isShowingConnectionModal}
|
|
|
|
|
>
|
|
|
|
|
<div>
|
2024-07-20 02:56:44 +02:00
|
|
|
<main>
|
|
|
|
|
<h2>{translations.connectionModal.connectionModalHeadline}</h2>
|
|
|
|
|
|
2024-07-20 03:34:54 +02:00
|
|
|
<div
|
|
|
|
|
class="flex-column gap"
|
|
|
|
|
children:append={[
|
|
|
|
|
connectionViewModel.previousAddresses,
|
|
|
|
|
previousAddressConverter,
|
|
|
|
|
]}
|
|
|
|
|
></div>
|
2024-07-20 02:56:44 +02:00
|
|
|
</main>
|
2024-07-20 02:30:45 +02:00
|
|
|
<button on:click={connectionViewModel.hideConnectionModal}>
|
2024-07-20 03:34:54 +02:00
|
|
|
{translations.general.closeButtonAudioLabel}
|
2024-07-20 02:30:45 +02:00
|
|
|
<span class="icon">close</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|