summaryrefslogtreecommitdiffstats
path: root/src/components/layout/AppLayout.js
diff options
context:
space:
mode:
authorLibravatar André Oliveira <37463445+SpecialAro@users.noreply.github.com>2022-07-19 12:52:31 +0100
committerLibravatar GitHub <noreply@github.com>2022-07-19 12:52:31 +0100
commit3bb1ca7825a0381ddd8dbe7f44f7dcf4a788b165 (patch)
tree6b414b9ef3be7656da1717b0d6def62e95d1fb90 /src/components/layout/AppLayout.js
parentfix: remove autoHibernate (diff)
downloadferdium-app-3bb1ca7825a0381ddd8dbe7f44f7dcf4a788b165.tar.gz
ferdium-app-3bb1ca7825a0381ddd8dbe7f44f7dcf4a788b165.tar.zst
ferdium-app-3bb1ca7825a0381ddd8dbe7f44f7dcf4a788b165.zip
Feature: Add Release Notes (#491)
Co-authored-by: Vijay A <vraravam@users.noreply.github.com> Co-authored-by: Ricardo Cino <ricardo@cino.io>
Diffstat (limited to 'src/components/layout/AppLayout.js')
-rw-r--r--src/components/layout/AppLayout.js216
1 files changed, 0 insertions, 216 deletions
diff --git a/src/components/layout/AppLayout.js b/src/components/layout/AppLayout.js
deleted file mode 100644
index f7860afc6..000000000
--- a/src/components/layout/AppLayout.js
+++ /dev/null
@@ -1,216 +0,0 @@
1import { Component } from 'react';
2import PropTypes from 'prop-types';
3import { observer } from 'mobx-react';
4import { defineMessages, injectIntl } from 'react-intl';
5import { TitleBar } from 'electron-react-titlebar/renderer';
6import injectSheet from 'react-jss';
7import { ipcRenderer } from 'electron';
8
9import { mdiFlash, mdiPowerPlug } from '@mdi/js';
10import { Outlet } from 'react-router-dom';
11import InfoBar from '../ui/InfoBar';
12import { Component as BasicAuth } from '../../features/basicAuth';
13import { Component as QuickSwitch } from '../../features/quickSwitch';
14import { Component as PublishDebugInfo } from '../../features/publishDebugInfo';
15import ErrorBoundary from '../util/ErrorBoundary';
16
17// import globalMessages from '../../i18n/globalMessages';
18
19import { isWindows, isMac } from '../../environment';
20import WorkspaceSwitchingIndicator from '../../features/workspaces/components/WorkspaceSwitchingIndicator';
21import { workspaceStore } from '../../features/workspaces';
22import AppUpdateInfoBar from '../AppUpdateInfoBar';
23import Todos from '../../features/todos/containers/TodosScreen';
24import Icon from '../ui/icon';
25
26import LockedScreen from '../../containers/auth/LockedScreen';
27
28const messages = defineMessages({
29 servicesUpdated: {
30 id: 'infobar.servicesUpdated',
31 defaultMessage: 'Your services have been updated.',
32 },
33 buttonReloadServices: {
34 id: 'infobar.buttonReloadServices',
35 defaultMessage: 'Reload services',
36 },
37 requiredRequestsFailed: {
38 id: 'infobar.requiredRequestsFailed',
39 defaultMessage: 'Could not load services and user information',
40 },
41 authRequestFailed: {
42 id: 'infobar.authRequestFailed',
43 defaultMessage:
44 'There were errors while trying to perform an authenticated request. Please try logging out and back in if this error persists.',
45 },
46});
47
48let transition = 'none';
49
50if (window && window.matchMedia('(prefers-reduced-motion: no-preference)')) {
51 transition = 'transform 0.5s ease';
52}
53
54const styles = theme => ({
55 appContent: {
56 // width: `calc(100% + ${theme.workspaces.drawer.width}px)`,
57 width: '100%',
58 transition,
59 transform() {
60 return workspaceStore.isWorkspaceDrawerOpen
61 ? 'translateX(0)'
62 : `translateX(-${theme.workspaces.drawer.width}px)`;
63 },
64 },
65 titleBar: {
66 display: 'block',
67 zIndex: 1,
68 width: '100%',
69 height: '10px',
70 position: 'absolute',
71 top: 0,
72 },
73});
74
75const toggleFullScreen = () => {
76 ipcRenderer.send('window.toolbar-double-clicked');
77};
78
79class AppLayout extends Component {
80 static propTypes = {
81 classes: PropTypes.object.isRequired,
82 settings: PropTypes.object.isRequired,
83 isFullScreen: PropTypes.bool.isRequired,
84 sidebar: PropTypes.element.isRequired,
85 workspacesDrawer: PropTypes.element.isRequired,
86 services: PropTypes.element.isRequired,
87 showServicesUpdatedInfoBar: PropTypes.bool.isRequired,
88 appUpdateIsDownloaded: PropTypes.bool.isRequired,
89 authRequestFailed: PropTypes.bool.isRequired,
90 installAppUpdate: PropTypes.func.isRequired,
91 showRequiredRequestsError: PropTypes.bool.isRequired,
92 areRequiredRequestsSuccessful: PropTypes.bool.isRequired,
93 retryRequiredRequests: PropTypes.func.isRequired,
94 areRequiredRequestsLoading: PropTypes.bool.isRequired,
95 };
96
97 state = {
98 shouldShowAppUpdateInfoBar: true,
99 shouldShowServicesUpdatedInfoBar: true,
100 };
101
102 render() {
103 const {
104 classes,
105 isFullScreen,
106 workspacesDrawer,
107 sidebar,
108 services,
109 showServicesUpdatedInfoBar,
110 appUpdateIsDownloaded,
111 authRequestFailed,
112 installAppUpdate,
113 settings,
114 showRequiredRequestsError,
115 areRequiredRequestsSuccessful,
116 retryRequiredRequests,
117 areRequiredRequestsLoading,
118 } = this.props;
119
120 const { intl } = this.props;
121
122 const { locked, automaticUpdates } = settings.app;
123 if (locked) {
124 return <LockedScreen />;
125 }
126
127 return (
128 <>
129 {isMac && !isFullScreen && (
130 <div className="window-draggable" />
131 )}
132 <ErrorBoundary>
133 <div className="app">
134 {isWindows && !isFullScreen && (
135 <TitleBar
136 menu={window['ferdium'].menu.template}
137 icon="assets/images/logo.svg"
138 />
139 )}
140 {isMac && !isFullScreen && (
141 <span
142 onDoubleClick={toggleFullScreen}
143 className={classes.titleBar}
144 />
145 )}
146 <div className={`app__content ${classes.appContent}`}>
147 {workspacesDrawer}
148 {sidebar}
149 <div className="app__service">
150 <WorkspaceSwitchingIndicator />
151 {!areRequiredRequestsSuccessful && showRequiredRequestsError && (
152 <InfoBar
153 type="danger"
154 ctaLabel="Try again"
155 ctaLoading={areRequiredRequestsLoading}
156 sticky
157 onClick={retryRequiredRequests}
158 >
159 <Icon icon={mdiFlash} />
160 {intl.formatMessage(messages.requiredRequestsFailed)}
161 </InfoBar>
162 )}
163 {authRequestFailed && (
164 <InfoBar
165 type="danger"
166 ctaLabel="Try again"
167 ctaLoading={areRequiredRequestsLoading}
168 sticky
169 onClick={retryRequiredRequests}
170 >
171 <Icon icon={mdiFlash} />
172 {intl.formatMessage(messages.authRequestFailed)}
173 </InfoBar>
174 )}
175 {automaticUpdates && showServicesUpdatedInfoBar &&
176 this.state.shouldShowServicesUpdatedInfoBar && (
177 <InfoBar
178 type="primary"
179 ctaLabel={intl.formatMessage(messages.buttonReloadServices)}
180 onClick={() => window.location.reload()}
181 onHide={() => {
182 this.setState({
183 shouldShowServicesUpdatedInfoBar: false,
184 });
185 }}
186 >
187 <Icon icon={mdiPowerPlug} />
188 {intl.formatMessage(messages.servicesUpdated)}
189 </InfoBar>
190 )}
191 {automaticUpdates && appUpdateIsDownloaded && this.state.shouldShowAppUpdateInfoBar && (
192 <AppUpdateInfoBar
193 onInstallUpdate={installAppUpdate}
194 onHide={() => {
195 this.setState({ shouldShowAppUpdateInfoBar: false });
196 }}
197 />
198 )}
199 <BasicAuth />
200 <QuickSwitch />
201 <PublishDebugInfo />
202 {services}
203 <Outlet />
204 </div>
205 <Todos />
206 </div>
207 </div>
208 </ErrorBoundary>
209 </>
210 );
211 }
212}
213
214export default injectIntl(
215 injectSheet(styles, { injectTheme: true })(observer(AppLayout)),
216);