Skip to content

Commit ad3bb11

Browse files
committed
fix(App): Improve layout rendering of services
1 parent fb3988a commit ad3bb11

File tree

2 files changed

+45
-35
lines changed

2 files changed

+45
-35
lines changed

src/components/layout/AppLayout.js

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import Todos from '../../features/todos/containers/TodosScreen';
1515
import TrialStatusBar from '../../features/trialStatusBar/containers/TrialStatusBarScreen';
1616
import WebControlsScreen from '../../features/webControls/containers/WebControlsScreen';
1717
import Service from '../../models/Service';
18+
import { workspaceStore } from '../../features/workspaces';
1819

1920
function createMarkup(HTMLString) {
2021
return { __html: HTMLString };
@@ -109,7 +110,6 @@ class AppLayout extends Component {
109110
{workspacesDrawer}
110111
{sidebar}
111112
<div className="app__service">
112-
<WorkspaceSwitchingIndicator />
113113
{news.length > 0 && news.map(item => (
114114
<InfoBar
115115
key={item.id}
@@ -133,16 +133,16 @@ class AppLayout extends Component {
133133
<TrialActivationInfoBar />
134134
)}
135135
{!areRequiredRequestsSuccessful && showRequiredRequestsError && (
136-
<InfoBar
137-
type="danger"
138-
ctaLabel="Try again"
139-
ctaLoading={areRequiredRequestsLoading}
140-
sticky
141-
onClick={retryRequiredRequests}
142-
>
143-
<span className="mdi mdi-flash" />
144-
{intl.formatMessage(messages.requiredRequestsFailed)}
145-
</InfoBar>
136+
<InfoBar
137+
type="danger"
138+
ctaLabel="Try again"
139+
ctaLoading={areRequiredRequestsLoading}
140+
sticky
141+
onClick={retryRequiredRequests}
142+
>
143+
<span className="mdi mdi-flash" />
144+
{intl.formatMessage(messages.requiredRequestsFailed)}
145+
</InfoBar>
146146
)}
147147
{showServicesUpdatedInfoBar && (
148148
<InfoBar
@@ -165,11 +165,16 @@ class AppLayout extends Component {
165165
/>
166166
)}
167167
{isDelayAppScreenVisible ? <DelayApp /> : (
168-
<div className="app__service-size-container">
169-
{services}
170-
{children}
171-
<Todos />
172-
</div>
168+
<>
169+
<WorkspaceSwitchingIndicator />
170+
{!workspaceStore.isSwitchingWorkspace && (
171+
<div className="app__service-size-container">
172+
{services}
173+
{children}
174+
<Todos />
175+
</div>
176+
)}
177+
</>
173178
)}
174179
<TrialStatusBar />
175180
</div>

src/components/services/content/Services.js

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { Component } from 'react';
1+
import React, { Component, useEffect, useRef } from 'react';
22
import PropTypes from 'prop-types';
33
import { observer } from 'mobx-react';
44
import { Link } from 'react-router';
@@ -25,6 +25,7 @@ const messages = defineMessages({
2525
const styles = {
2626
container: {
2727
display: 'flex',
28+
flex: 1,
2829

2930
'&>span': {
3031
display: 'block',
@@ -51,23 +52,6 @@ export default @injectSheet(styles) @observer class Services extends Component {
5152
intl: intlShape,
5253
};
5354

54-
serviceContainerRef = React.createRef()
55-
56-
resizeObserver = new window.ResizeObserver(([element]) => {
57-
const bounds = element.target.getBoundingClientRect();
58-
59-
ipcRenderer.send(RESIZE_SERVICE_VIEWS, {
60-
width: bounds.width,
61-
height: bounds.height,
62-
x: bounds.x,
63-
y: element.target.offsetTop,
64-
});
65-
});
66-
67-
componentDidMount() {
68-
this.resizeObserver.observe(this.serviceContainerRef.current);
69-
}
70-
7155
componentWillUnmount() {
7256
if (this._confettiTimeout) {
7357
clearTimeout(this._confettiTimeout);
@@ -127,10 +111,31 @@ export default @injectSheet(styles) @observer class Services extends Component {
127111
upgrade={() => openSettings({ path: 'user' })}
128112
/>
129113
)}
114+
<ResizeBWServiceComponent />
130115
</>
131116
)}
132-
<div className="services" ref={this.serviceContainerRef} />
133117
</>
134118
);
135119
}
136120
}
121+
122+
const resizeObserver = new window.ResizeObserver(([element]) => {
123+
const bounds = element.target.getBoundingClientRect();
124+
125+
ipcRenderer.send(RESIZE_SERVICE_VIEWS, {
126+
width: bounds.width,
127+
height: bounds.height,
128+
x: bounds.x,
129+
y: element.target.offsetTop,
130+
});
131+
});
132+
133+
const ResizeBWServiceComponent = () => {
134+
const serviceContainerRef = useRef();
135+
136+
useEffect(() => {
137+
resizeObserver.observe(serviceContainerRef.current);
138+
}, [serviceContainerRef]);
139+
140+
return <div className="services" ref={serviceContainerRef} />;
141+
};

0 commit comments

Comments
 (0)