diff options
author | André Oliveira <37463445+SpecialAro@users.noreply.github.com> | 2022-07-19 12:52:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-19 12:52:31 +0100 |
commit | 3bb1ca7825a0381ddd8dbe7f44f7dcf4a788b165 (patch) | |
tree | 6b414b9ef3be7656da1717b0d6def62e95d1fb90 /src/components/layout/AppLayout.js | |
parent | fix: remove autoHibernate (diff) | |
download | ferdium-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.js | 216 |
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 @@ | |||
1 | import { Component } from 'react'; | ||
2 | import PropTypes from 'prop-types'; | ||
3 | import { observer } from 'mobx-react'; | ||
4 | import { defineMessages, injectIntl } from 'react-intl'; | ||
5 | import { TitleBar } from 'electron-react-titlebar/renderer'; | ||
6 | import injectSheet from 'react-jss'; | ||
7 | import { ipcRenderer } from 'electron'; | ||
8 | |||
9 | import { mdiFlash, mdiPowerPlug } from '@mdi/js'; | ||
10 | import { Outlet } from 'react-router-dom'; | ||
11 | import InfoBar from '../ui/InfoBar'; | ||
12 | import { Component as BasicAuth } from '../../features/basicAuth'; | ||
13 | import { Component as QuickSwitch } from '../../features/quickSwitch'; | ||
14 | import { Component as PublishDebugInfo } from '../../features/publishDebugInfo'; | ||
15 | import ErrorBoundary from '../util/ErrorBoundary'; | ||
16 | |||
17 | // import globalMessages from '../../i18n/globalMessages'; | ||
18 | |||
19 | import { isWindows, isMac } from '../../environment'; | ||
20 | import WorkspaceSwitchingIndicator from '../../features/workspaces/components/WorkspaceSwitchingIndicator'; | ||
21 | import { workspaceStore } from '../../features/workspaces'; | ||
22 | import AppUpdateInfoBar from '../AppUpdateInfoBar'; | ||
23 | import Todos from '../../features/todos/containers/TodosScreen'; | ||
24 | import Icon from '../ui/icon'; | ||
25 | |||
26 | import LockedScreen from '../../containers/auth/LockedScreen'; | ||
27 | |||
28 | const 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 | |||
48 | let transition = 'none'; | ||
49 | |||
50 | if (window && window.matchMedia('(prefers-reduced-motion: no-preference)')) { | ||
51 | transition = 'transform 0.5s ease'; | ||
52 | } | ||
53 | |||
54 | const 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 | |||
75 | const toggleFullScreen = () => { | ||
76 | ipcRenderer.send('window.toolbar-double-clicked'); | ||
77 | }; | ||
78 | |||
79 | class 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 | |||
214 | export default injectIntl( | ||
215 | injectSheet(styles, { injectTheme: true })(observer(AppLayout)), | ||
216 | ); | ||