2020-12-02 15:36:54 +01:00
|
|
|
/*
|
|
|
|
Copyright 2020 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import {TemplateView} from "../utils/TemplateView.js";
|
|
|
|
import {ClientListView} from "./ClientListView.js";
|
|
|
|
import {PreviewView} from "../preview/PreviewView.js";
|
2020-12-04 12:34:31 +01:00
|
|
|
import {ServerConsentView} from "./ServerConsentView.js";
|
2020-12-02 15:36:54 +01:00
|
|
|
|
|
|
|
export class OpenLinkView extends TemplateView {
|
|
|
|
render(t, vm) {
|
|
|
|
return t.div({className: "OpenLinkView card"}, [
|
2020-12-04 12:34:31 +01:00
|
|
|
t.mapView(vm => vm.previewViewModel, previewVM => previewVM ?
|
|
|
|
new ShowLinkView(vm) :
|
|
|
|
new ServerConsentView(vm.serverConsentViewModel)
|
|
|
|
),
|
2020-12-02 15:36:54 +01:00
|
|
|
]);
|
|
|
|
}
|
2020-12-03 17:11:46 +01:00
|
|
|
}
|
2020-12-04 12:34:31 +01:00
|
|
|
|
|
|
|
class ShowLinkView extends TemplateView {
|
|
|
|
render(t, vm) {
|
|
|
|
return t.div([
|
|
|
|
t.view(new PreviewView(vm.previewViewModel)),
|
2020-12-07 14:05:57 +01:00
|
|
|
t.view(new ClientListView(vm.clientsViewModel)),
|
2020-12-04 13:59:52 +01:00
|
|
|
t.p({className: {previewSource: true, hidden: vm => !vm.previewDomain}}, [
|
2020-12-04 14:00:50 +01:00
|
|
|
vm => vm.previewFailed ? `${vm.previewDomain} has not returned a preview.` : `Preview provided by ${vm.previewDomain}.`,
|
2020-12-04 13:59:52 +01:00
|
|
|
" ",
|
|
|
|
t.button({className: "text", onClick: () => vm.changeServer()}, "Change"),
|
|
|
|
]),
|
2020-12-04 12:34:31 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|