From 0bf13689d53bd493fb4d0a4213c1801013b5aa8a Mon Sep 17 00:00:00 2001 From: Ricardo Cino Date: Mon, 27 Jun 2022 18:21:31 +0200 Subject: chore: transform containers/settings from js to tsx (#384) --- src/containers/layout/AppLayoutContainer.tsx | 172 +++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 src/containers/layout/AppLayoutContainer.tsx (limited to 'src/containers/layout/AppLayoutContainer.tsx') diff --git a/src/containers/layout/AppLayoutContainer.tsx b/src/containers/layout/AppLayoutContainer.tsx new file mode 100644 index 000000000..c6a9dfb0d --- /dev/null +++ b/src/containers/layout/AppLayoutContainer.tsx @@ -0,0 +1,172 @@ +import { Children, Component, ReactElement, ReactNode } from 'react'; +import { inject, observer } from 'mobx-react'; +import { ThemeProvider } from 'react-jss'; + +import { StoresProps } from 'src/@types/ferdium-components.types'; +import AppLayout from '../../components/layout/AppLayout'; +import Sidebar from '../../components/layout/Sidebar'; +import Services from '../../components/services/content/Services'; +import AppLoader from '../../components/ui/AppLoader'; + +import WorkspaceDrawer from '../../features/workspaces/components/WorkspaceDrawer'; +import { workspaceStore } from '../../features/workspaces'; + +interface AppLayoutContainerProps extends StoresProps { + children: ReactNode; +} + +class AppLayoutContainer extends Component { + render(): ReactElement { + const { + app, + features, + services, + ui, + settings, + globalError, + requests, + user, + router, + } = this.props.stores; + + /* HOTFIX for: + [mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: 'Reaction[bound ]' TypeError: Cannot read properties of null (reading 'push') + at RouterStore.push (store.js:25) + at UserStore._requireAuthenticatedUser + */ + if (!user.isLoggedIn) { + router.push('/auth/welcome'); + } + + const { + setActive, + handleIPCMessage, + setWebviewReference, + detachService, + openWindow, + reorder, + reload, + toggleNotifications, + toggleAudio, + toggleDarkMode, + deleteService, + updateService, + hibernate, + awake, + } = this.props.actions.service; + + const { retryRequiredRequests } = this.props.actions.requests; + + const { installUpdate, toggleMuteApp, toggleCollapseMenu } = + this.props.actions.app; + + const { openSettings, closeSettings } = this.props.actions.ui; + + const { children } = this.props; + + const isLoadingFeatures = + features.featuresRequest.isExecuting && + !features.featuresRequest.wasExecuted; + + const isLoadingServices = + services.allServicesRequest.isExecuting && + services.allServicesRequest.isExecutingFirstTime; + + const isLoadingSettings = !settings.loaded; + + if (isLoadingSettings || isLoadingFeatures || isLoadingServices) { + return ( + + + + ); + } + + const workspacesDrawer = ( + + workspace + ? workspaceStore.getWorkspaceServices(workspace).map(s => s.name) + : services.all.map(s => s.name) + } + /> + ); + + const sidebar = ( + + ); + + const servicesContainer = ( + + ); + + return ( + + + {Children.count(children) > 0 ? children : null} + + + ); + } +} + +export default inject('stores', 'actions')(observer(AppLayoutContainer)); -- cgit v1.2.3-70-g09d2