Skip to content

Commit acb0079

Browse files
authored
Don't render ActionBarView during loading (#4612)
* don't render ActionBarView during loading (fixes #4597 and contributes to #4572) * only show full navbar when model loading was successful * update changelog
1 parent 15a211a commit acb0079

File tree

4 files changed

+64
-61
lines changed

4 files changed

+64
-61
lines changed

CHANGELOG.unreleased.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
1515
-
1616

1717
### Changed
18-
18+
- Improved the UI in navigation bar during loading of tracings and datasets. [#4612](https://github.com/scalableminds/webknossos/pull/4612)
1919
- Improved logging in case of very slow annotation saving. Additionally, the user is also warned when there are unsaved changes older than two minutes. [#4593](https://github.com/scalableminds/webknossos/pull/4593)
2020

2121
### Fixed

frontend/javascripts/oxalis/controller.js

+8-12
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ import constants, { ControlModeEnum, type ViewMode } from "oxalis/constants";
4343
import messages from "messages";
4444
import window, { document } from "libs/window";
4545

46-
type ControllerStatus = "loading" | "loaded" | "failedLoading";
46+
export type ControllerStatus = "loading" | "loaded" | "failedLoading";
4747
type OwnProps = {|
4848
initialAnnotationType: AnnotationType,
4949
initialCommandType: TraceOrViewCommand,
50+
controllerStatus: ControllerStatus,
51+
setControllerStatus: ControllerStatus => void,
5052
|};
5153
type StateProps = {|
5254
viewMode: ViewMode,
@@ -55,19 +57,13 @@ type StateProps = {|
5557
type Props = {| ...OwnProps, ...StateProps |};
5658
type PropsWithRouter = {| ...Props, history: RouterHistory |};
5759

58-
type State = {
59-
status: ControllerStatus,
60-
};
60+
type State = {};
6161

6262
class Controller extends React.PureComponent<PropsWithRouter, State> {
6363
keyboard: InputKeyboard;
6464
keyboardNoLoop: InputKeyboardNoLoop;
6565
isMounted: boolean;
6666

67-
state = {
68-
status: "loading",
69-
};
70-
7167
// Main controller, responsible for setting modes and everything
7268
// that has to be controlled in any mode.
7369
//
@@ -104,14 +100,14 @@ class Controller extends React.PureComponent<PropsWithRouter, State> {
104100
}
105101

106102
tryFetchingModel() {
107-
this.setState({ status: "loading" });
103+
this.props.setControllerStatus("loading");
108104
// Preview a working annotation version if the showVersionRestore URL parameter is supplied
109105
const versions = Utils.hasUrlParam("showVersionRestore") ? { skeleton: 1 } : undefined;
110106

111107
Model.fetch(this.props.initialAnnotationType, this.props.initialCommandType, true, versions)
112108
.then(() => this.modelFetchDone())
113109
.catch(error => {
114-
this.setState({ status: "failedLoading" });
110+
this.props.setControllerStatus("failedLoading");
115111
// Don't throw errors for errors already handled by the model.
116112
if (error !== HANDLED_ERROR) {
117113
throw error;
@@ -159,7 +155,7 @@ class Controller extends React.PureComponent<PropsWithRouter, State> {
159155
// Give wk (sagas and bucket loading) a bit time to catch air before
160156
// showing the UI as "ready". The goal here is to avoid that the
161157
// UI is still freezing after the loading indicator is gone.
162-
this.setState({ status: "loaded" });
158+
this.props.setControllerStatus("loaded");
163159
}, 200);
164160
}
165161

@@ -277,7 +273,7 @@ class Controller extends React.PureComponent<PropsWithRouter, State> {
277273
}
278274

279275
render() {
280-
const { status } = this.state;
276+
const status = this.props.controllerStatus;
281277
const { user, viewMode } = this.props;
282278
if (status === "loading") {
283279
return <BrainSpinner />;

frontend/javascripts/oxalis/view/layouting/tracing_layout_view.js

+53-46
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import MappingInfoView from "oxalis/view/right-menu/mapping_info_view";
2525
import MeshesView from "oxalis/view/right-menu/meshes_view";
2626
import NmlUploadZoneContainer from "oxalis/view/nml_upload_zone_container";
2727
import OxalisController from "oxalis/controller";
28+
import type { ControllerStatus } from "oxalis/controller";
2829
import RecordingSwitch from "oxalis/view/recording_switch";
2930
import SettingsView from "oxalis/view/settings/settings_view";
3031
import MergerModeController from "oxalis/controller/merger_mode_controller";
@@ -68,6 +69,7 @@ type State = {
6869
isSettingsCollapsed: boolean,
6970
activeLayout: string,
7071
hasError: boolean,
72+
status: ControllerStatus,
7173
};
7274

7375
const canvasAndLayoutContainerID = "canvasAndLayoutContainer";
@@ -108,6 +110,7 @@ class TracingLayoutView extends React.PureComponent<PropsWithRouter, State> {
108110
isSettingsCollapsed: true,
109111
activeLayout: lastActiveLayout,
110112
hasError: false,
113+
status: "loading",
111114
};
112115
}
113116

@@ -190,57 +193,61 @@ class TracingLayoutView extends React.PureComponent<PropsWithRouter, State> {
190193
<OxalisController
191194
initialAnnotationType={this.props.initialAnnotationType}
192195
initialCommandType={this.props.initialCommandType}
196+
controllerStatus={this.state.status}
197+
setControllerStatus={(status: ControllerStatus) => this.setState({ status })}
193198
/>
194199
<CrossOriginApi />
195200
<Layout className="tracing-layout">
196201
<RenderToPortal portalId="navbarTracingSlot">
197-
<div style={{ flex: "0 1 auto", zIndex: 210, display: "flex" }}>
198-
<ButtonComponent
199-
className={this.state.isSettingsCollapsed ? "" : "highlight-togglable-button"}
200-
onClick={this.handleSettingsCollapse}
201-
shape="circle"
202-
>
203-
<Icon
204-
type="setting"
205-
className="withoutMargin"
206-
style={{ display: "flex", alignItems: "center", justifyContent: "center" }}
207-
/>
208-
</ButtonComponent>
209-
<ActionBarView
210-
layoutProps={{
211-
storedLayoutNamesForView: currentLayoutNames,
212-
activeLayout: this.state.activeLayout,
213-
layoutKey: layoutType,
214-
setCurrentLayout: layoutName => {
215-
this.setState({ activeLayout: layoutName });
216-
setActiveLayout(layoutType, layoutName);
217-
},
218-
saveCurrentLayout: this.saveCurrentLayout,
219-
setAutoSaveLayouts: this.props.setAutoSaveLayouts,
220-
autoSaveLayouts: this.props.autoSaveLayouts,
221-
}}
222-
/>
223-
{isDatasetOnScratchVolume ? (
224-
<Tooltip title={messages["dataset.is_scratch"]}>
225-
<Alert
226-
className="hide-on-small-screen"
227-
style={{
228-
height: 30,
229-
paddingTop: 4,
230-
backgroundColor: "#f17a27",
231-
color: "white",
232-
}}
233-
message={
234-
<span>
235-
Dataset is on tmpscratch!{" "}
236-
<Icon type="warning" theme="filled" style={{ margin: "0 0 0 6px" }} />
237-
</span>
238-
}
239-
type="error"
202+
{this.state.status === "loaded" ? (
203+
<div style={{ flex: "0 1 auto", zIndex: 210, display: "flex" }}>
204+
<ButtonComponent
205+
className={this.state.isSettingsCollapsed ? "" : "highlight-togglable-button"}
206+
onClick={this.handleSettingsCollapse}
207+
shape="circle"
208+
>
209+
<Icon
210+
type="setting"
211+
className="withoutMargin"
212+
style={{ display: "flex", alignItems: "center", justifyContent: "center" }}
240213
/>
241-
</Tooltip>
242-
) : null}
243-
</div>
214+
</ButtonComponent>
215+
<ActionBarView
216+
layoutProps={{
217+
storedLayoutNamesForView: currentLayoutNames,
218+
activeLayout: this.state.activeLayout,
219+
layoutKey: layoutType,
220+
setCurrentLayout: layoutName => {
221+
this.setState({ activeLayout: layoutName });
222+
setActiveLayout(layoutType, layoutName);
223+
},
224+
saveCurrentLayout: this.saveCurrentLayout,
225+
setAutoSaveLayouts: this.props.setAutoSaveLayouts,
226+
autoSaveLayouts: this.props.autoSaveLayouts,
227+
}}
228+
/>
229+
{isDatasetOnScratchVolume ? (
230+
<Tooltip title={messages["dataset.is_scratch"]}>
231+
<Alert
232+
className="hide-on-small-screen"
233+
style={{
234+
height: 30,
235+
paddingTop: 4,
236+
backgroundColor: "#f17a27",
237+
color: "white",
238+
}}
239+
message={
240+
<span>
241+
Dataset is on tmpscratch!{" "}
242+
<Icon type="warning" theme="filled" style={{ margin: "0 0 0 6px" }} />
243+
</span>
244+
}
245+
type="error"
246+
/>
247+
</Tooltip>
248+
) : null}
249+
</div>
250+
) : null}
244251
</RenderToPortal>
245252
<Layout style={{ display: "flex" }}>
246253
<Sider

frontend/javascripts/oxalis/view/right-menu/dataset_info_tab_view.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ class DatasetInfoTabView extends React.PureComponent<Props> {
287287

288288
return (
289289
<div className="flex-overflow">
290-
<p>{annotationTypeLabel}</p>
291-
<p>{descriptionEditField}</p>
290+
<div>{annotationTypeLabel}</div>
291+
<div>{descriptionEditField}</div>
292292
</div>
293293
);
294294
}

0 commit comments

Comments
 (0)