|
| 1 | +/* |
| 2 | +Copyright 2023 The Matrix.org Foundation C.I.C. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +import {Builder, TemplateView} from "../../general/TemplateView"; |
| 18 | +import {ErrorView} from "../../general/ErrorView"; |
| 19 | +import type {InvitePanelViewModel} from "../../../../../domain/session/rightpanel/InvitePanelViewModel"; |
| 20 | + |
| 21 | +export class InvitePanelView extends TemplateView<InvitePanelViewModel> { |
| 22 | + render(t: Builder<InvitePanelViewModel>, vm: InvitePanelViewModel) { |
| 23 | + const input = t.input({ |
| 24 | + className: "InvitePanelView__input", |
| 25 | + type: "text", |
| 26 | + placeholder: "Enter user-id of user", |
| 27 | + onkeydown: (e: KeyboardEvent) => { |
| 28 | + if (e.key === "Enter") { |
| 29 | + vm.invite((input as HTMLInputElement).value); |
| 30 | + } |
| 31 | + } |
| 32 | + }); |
| 33 | + return t.div({ className: "InvitePanelView" }, [ |
| 34 | + t.h3({ className: "InvitePanelView__heading" }, |
| 35 | + (vm: InvitePanelViewModel) => vm.i18n`Invite to ${vm.roomName}` |
| 36 | + ), |
| 37 | + t.div({ className: "InvitePanelView__form" }, [ |
| 38 | + input, |
| 39 | + t.button({ |
| 40 | + className: "InvitePanelView__btn button-action primary", |
| 41 | + onClick: () => vm.invite((input as HTMLInputElement).value), |
| 42 | + }, "Invite"), |
| 43 | + ]), |
| 44 | + t.div({ className: "InvitePanelView__error" }, [ |
| 45 | + t.ifView(vm => !!vm.errorViewModel, vm => new ErrorView(vm.errorViewModel!)), |
| 46 | + ]), |
| 47 | + ]); |
| 48 | + } |
| 49 | + |
| 50 | +} |
0 commit comments