aboutsummaryrefslogtreecommitdiffstats
path: root/packages/renderer/src/components/ServicePanel.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/renderer/src/components/ServicePanel.tsx')
-rw-r--r--packages/renderer/src/components/ServicePanel.tsx85
1 files changed, 85 insertions, 0 deletions
diff --git a/packages/renderer/src/components/ServicePanel.tsx b/packages/renderer/src/components/ServicePanel.tsx
new file mode 100644
index 0000000..507bc15
--- /dev/null
+++ b/packages/renderer/src/components/ServicePanel.tsx
@@ -0,0 +1,85 @@
1/*
2 * Copyright (C) 2021-2022 Kristóf Marussy <kristof@marussy.com>
3 *
4 * This file is part of Sophie.
5 *
6 * Sophie is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as
8 * published by the Free Software Foundation, version 3.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 *
18 * SPDX-License-Identifier: AGPL-3.0-only
19 */
20
21import Box from '@mui/material/Box';
22import { styled } from '@mui/material/styles';
23import { observer } from 'mobx-react-lite';
24import React from 'react';
25
26import type RendererStore from '../stores/RendererStore.js';
27import Service from '../stores/Service.js';
28
29import BrowserViewPlaceholder from './BrowserViewPlaceholder.js';
30import InsecureConnectionBanner from './banner/InsecureConnectionBanner.js';
31import NewWindowBanner from './banner/NewWindowBanner.js';
32import ErrorPage from './errorPage/ErrorPage.js';
33import LocationBar from './locationBar/LocationBar.js';
34
35const ServicePanelRoot = styled(Box, {
36 shouldForwardProp: (prop) => prop !== 'hidden',
37})(({ hidden }) => ({
38 position: 'absolute',
39 top: 0,
40 left: 0,
41 bottom: 0,
42 right: 0,
43 display: 'flex',
44 overflow: 'hidden',
45 visibility: hidden ? 'hidden' : 'visible',
46 flexDirection: 'column',
47 alignItems: 'stretch',
48}));
49
50export function getServicePanelID(service: Service): string {
51 return `Sophie-${service.id}-ServicePanel`;
52}
53
54function ServicePanel({
55 store,
56 service,
57}: {
58 store: RendererStore;
59 service: Service;
60}): JSX.Element {
61 const {
62 settings: { selectedService },
63 } = store;
64 const {
65 settings: { name },
66 } = service;
67
68 return (
69 <ServicePanelRoot
70 id={getServicePanelID(service)}
71 role="tabpanel"
72 aria-label={name}
73 hidden={service !== selectedService}
74 >
75 <LocationBar store={store} service={service} />
76 <InsecureConnectionBanner service={service} />
77 <NewWindowBanner service={service} />
78 <BrowserViewPlaceholder service={service}>
79 <ErrorPage service={service} />
80 </BrowserViewPlaceholder>
81 </ServicePanelRoot>
82 );
83}
84
85export default observer(ServicePanel);