Skip to content

Commit

Permalink
Add methods to load / refresh a TabContainer directly (#2930)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomTirapani authored Oct 7, 2022
1 parent 2e9b578 commit ac25412
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* `DashCanvasAddViewButton` exported as a public component to support adding views to `DashCanvas`.
* `ModelSelector` used for model lookup and matching will now accept the class name of the model to
match. Previously only a class reference could be provided.
* Added `TabContainerModel.refreshContextModel`, allowing apps to programmatically load a
TabContainer.
* The Admin Console diff tool for Configs, Prefs, and JSONBlobs now displays who updated each value
and when.
* New "Hoist Inspector" tool available in Desktop apps for displaying and querying Models,
Expand Down
7 changes: 5 additions & 2 deletions cmp/tab/TabContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* Copyright © 2022 Extremely Heavy Industries Inc.
*/
import {hoistCmp, ModelPublishMode, uses, XH} from '@xh/hoist/core';
import {hoistCmp, ModelPublishMode, uses, XH, refreshContextView} from '@xh/hoist/core';
import {tabContainerImpl as desktopTabContainerImpl} from '@xh/hoist/dynamics/desktop';
import {tabContainerImpl as mobileTabContainerImpl} from '@xh/hoist/dynamics/mobile';
import PT from 'prop-types';
Expand Down Expand Up @@ -32,7 +32,10 @@ export const [TabContainer, tabContainer] = hoistCmp.withFactory({
className: 'xh-tab-container',

render(props, ref) {
return XH.isMobileApp ? mobileTabContainerImpl(props, ref) : desktopTabContainerImpl(props, ref);
return refreshContextView({
model: props.model.refreshContextModel,
item: XH.isMobileApp ? mobileTabContainerImpl(props, ref) : desktopTabContainerImpl(props, ref)
});
}
});

Expand Down
7 changes: 6 additions & 1 deletion cmp/tab/TabContainerModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* Copyright © 2022 Extremely Heavy Industries Inc.
*/
import {HoistModel, managed, PersistenceProvider, RefreshMode, RenderMode, XH} from '@xh/hoist/core';
import {HoistModel, managed, RefreshContextModel, PersistenceProvider, RefreshMode, RenderMode, XH} from '@xh/hoist/core';
import {action, observable, makeObservable} from '@xh/hoist/mobx';
import {ensureUniqueBy, throwIf} from '@xh/hoist/utils/js';
import {find, isString, isUndefined, without, difference} from 'lodash';
Expand Down Expand Up @@ -46,6 +46,10 @@ export class TabContainerModel extends HoistModel {
/** @member {(string|ReactNode)} */
emptyText;

/** @member {RefreshContextModel} */
@managed
refreshContextModel;

_lastActiveTabId;

/**
Expand Down Expand Up @@ -102,6 +106,7 @@ export class TabContainerModel extends HoistModel {
this.route = route;
this.track = track;
this.setTabs(tabs);
this.refreshContextModel = new RefreshContextModel();

if (route) {
if (XH.isMobileApp) {
Expand Down

0 comments on commit ac25412

Please sign in to comment.