Skip to content

Commit

Permalink
New bindable AppContainerModel.intializingLoadMaskMessage (#3763)
Browse files Browse the repository at this point in the history
+ Allow apps to customize the loading mask message shown during app initialization.
  • Loading branch information
jacob-xhio authored Aug 22, 2024
1 parent 567d7b8 commit d2739e2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
* New property `FetchOptions.asJson` to instruct `FetchService` to decode an HTTP response as JSON.
Note that `FetchService` methods suffixed with `Json` will set this property automatically.
* `GridModel` will now accept `contextMenu: false` to omit context menus.
* Swapped locations of `primaryOnly` and `active` sliders in `MonitorEditorDialog`.
* New bindable `AppContainerModel.intializingLoadMaskMessage` property to allow apps to customize
the loading mask message shown during app initialization.

### 🐞 Bug Fixes

Expand Down
9 changes: 8 additions & 1 deletion appcontainer/AppContainerModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ import {
XH
} from '@xh/hoist/core';
import {Icon} from '@xh/hoist/icon';
import {action, when as mobxWhen} from '@xh/hoist/mobx';
import {action, bindable, when as mobxWhen} from '@xh/hoist/mobx';
import {never, wait} from '@xh/hoist/promise';
import numbro from 'numbro';
import {ReactNode} from 'react';
import {createRoot} from 'react-dom/client';
import {
AlertBannerService,
Expand Down Expand Up @@ -97,6 +98,12 @@ export class AppContainerModel extends HoistModel {
@managed themeModel = new ThemeModel();
@managed userAgentModel = new UserAgentModel();

/**
* Message shown on spinner while the application is in the INITIALIZING state.
* Update within `AppModel.initAsync()` to relay app-specific initialization status.
*/
@bindable initializingLoadMaskMessage: ReactNode;

/**
* Main entry point. Initialize and render application code.
*/
Expand Down
8 changes: 5 additions & 3 deletions desktop/appcontainer/AppContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const AppContainer = hoistCmp({
},
errorRenderer: () => null
},
item: viewForState()
item: viewForState({model})
}),
// Modal component helpers rendered here at top-level to support display of messages
// and exceptions at any point during the app lifecycle.
Expand All @@ -101,11 +101,13 @@ export const AppContainer = hoistCmp({
//-----------------------------------------
// Implementation
//-----------------------------------------
function viewForState() {
function viewForState({model}) {
switch (XH.appState) {
case 'PRE_AUTH':
case 'INITIALIZING':
return viewport(mask({spinner: true, isDisplayed: true}));
return viewport(
mask({spinner: true, isDisplayed: true, message: model.initializingLoadMaskMessage})
);
case 'LOGIN_REQUIRED':
return loginPanel();
case 'ACCESS_DENIED':
Expand Down
8 changes: 5 additions & 3 deletions mobile/appcontainer/AppContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const AppContainer = hoistCmp({
},
errorRenderer: () => null
},
item: viewForState()
item: viewForState({model})
}),
// Modal component helpers rendered here at top-level to support display of messages
// and exceptions at any point during the app lifecycle.
Expand All @@ -86,11 +86,13 @@ export const AppContainer = hoistCmp({
//-------------------
// Implementation
//-------------------
function viewForState() {
function viewForState({model}) {
switch (XH.appState) {
case 'PRE_AUTH':
case 'INITIALIZING':
return viewport(mask({spinner: true, isDisplayed: true}));
return viewport(
mask({spinner: true, isDisplayed: true, message: model.initializingLoadMaskMessage})
);
case 'LOGIN_REQUIRED':
return loginPanel();
case 'ACCESS_DENIED':
Expand Down

0 comments on commit d2739e2

Please sign in to comment.