aboutsummaryrefslogtreecommitdiffstats
path: root/src/containers/settings/SettingsWindow.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/containers/settings/SettingsWindow.tsx')
-rw-r--r--src/containers/settings/SettingsWindow.tsx58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/containers/settings/SettingsWindow.tsx b/src/containers/settings/SettingsWindow.tsx
new file mode 100644
index 000000000..fb1e2fd2d
--- /dev/null
+++ b/src/containers/settings/SettingsWindow.tsx
@@ -0,0 +1,58 @@
1import { Component, ReactNode, ReactPortal } from 'react';
2import ReactDOM from 'react-dom';
3import { observer, inject } from 'mobx-react';
4
5import { StoresProps } from 'src/@types/ferdium-components.types';
6
7import Layout from '../../components/settings/SettingsLayout';
8import Navigation from '../../components/settings/navigation/SettingsNavigation';
9import ErrorBoundary from '../../components/util/ErrorBoundary';
10import { workspaceStore } from '../../features/workspaces';
11
12interface SettingsContainerProps extends StoresProps {
13 children: ReactNode;
14}
15
16class SettingsContainer extends Component<SettingsContainerProps> {
17 portalRoot: any;
18
19 el: HTMLDivElement;
20
21 constructor(props: SettingsContainerProps) {
22 super(props);
23
24 this.portalRoot = document.querySelector('#portalContainer');
25 this.el = document.createElement('div');
26 }
27
28 componentDidMount(): void {
29 this.portalRoot.append(this.el);
30 }
31
32 componentWillUnmount(): void {
33 this.el.remove();
34 }
35
36 render(): ReactPortal {
37 const { children, stores } = this.props;
38 const { closeSettings } = this.props.actions.ui;
39
40 const navigation = (
41 <Navigation
42 serviceCount={stores.services.all.length}
43 workspaceCount={workspaceStore.workspaces.length}
44 />
45 );
46
47 return ReactDOM.createPortal(
48 <ErrorBoundary>
49 <Layout navigation={navigation} closeSettings={closeSettings}>
50 {children}
51 </Layout>
52 </ErrorBoundary>,
53 this.el,
54 );
55 }
56}
57
58export default inject('stores', 'actions')(observer(SettingsContainer));