diff options
Diffstat (limited to 'packages/renderer/src/components/ServicePanel.tsx')
-rw-r--r-- | packages/renderer/src/components/ServicePanel.tsx | 85 |
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 | |||
21 | import Box from '@mui/material/Box'; | ||
22 | import { styled } from '@mui/material/styles'; | ||
23 | import { observer } from 'mobx-react-lite'; | ||
24 | import React from 'react'; | ||
25 | |||
26 | import type RendererStore from '../stores/RendererStore.js'; | ||
27 | import Service from '../stores/Service.js'; | ||
28 | |||
29 | import BrowserViewPlaceholder from './BrowserViewPlaceholder.js'; | ||
30 | import InsecureConnectionBanner from './banner/InsecureConnectionBanner.js'; | ||
31 | import NewWindowBanner from './banner/NewWindowBanner.js'; | ||
32 | import ErrorPage from './errorPage/ErrorPage.js'; | ||
33 | import LocationBar from './locationBar/LocationBar.js'; | ||
34 | |||
35 | const 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 | |||
50 | export function getServicePanelID(service: Service): string { | ||
51 | return `Sophie-${service.id}-ServicePanel`; | ||
52 | } | ||
53 | |||
54 | function 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 | |||
85 | export default observer(ServicePanel); | ||