@xh/hoist 68.0.0-SNAPSHOT.1726258981470 → 68.0.0-SNAPSHOT.1726599173889

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,9 +2,19 @@
2
2
 
3
3
  ## 68.0.0-SNAPSHOT - unreleased
4
4
 
5
+ ### 💥 Breaking Changes (upgrade difficulty: 🟢 LOW - Hoist Core update only)
6
+
7
+ * Requires `hoist-core >= 21.1` for consolidated polling of Alert Banner updates (see below).
8
+
5
9
  ### ⚙️ Technical
6
10
 
7
11
  * Updated Admin Console's Cluster tab to refresh more frequently.
12
+ * Consolidated the polling check for Alert Banner updates into existing `EnvironmentService`
13
+ polling, avoiding an extra request and improving alert banner responsiveness.
14
+
15
+ ### ⚙️ Typescript API Adjustments
16
+
17
+ * Corrected types of enhanced `Promise` methods.
8
18
 
9
19
  ## 67.0.0 - 2024-09-03
10
20
 
@@ -119,8 +119,7 @@ export const correlationId: ColumnSpec = {
119
119
  export const error: ColumnSpec = {
120
120
  field: {
121
121
  name: 'error',
122
- type: 'string',
123
- displayName: 'Error Details'
122
+ type: 'string'
124
123
  },
125
124
  flex: true,
126
125
  minWidth: 150,
@@ -54,7 +54,10 @@ export class BaseInstanceModel extends HoistModel {
54
54
  forOwn(stats, (v, k) => {
55
55
  // Convert numbers that look like recent timestamps to date values.
56
56
  if (
57
- (k.endsWith('Time') || k.endsWith('Date') || k == 'timestamp') &&
57
+ (k.endsWith('Time') ||
58
+ k.endsWith('Date') ||
59
+ k.endsWith('Timestamp') ||
60
+ k == 'timestamp') &&
58
61
  isNumber(v) &&
59
62
  v > Date.now() - 365 * DAYS
60
63
  ) {
@@ -48,14 +48,6 @@ export class DetailsModel extends HoistModel {
48
48
  loadSpec
49
49
  });
50
50
  if (loadSpec.isStale) return;
51
- this.preprocessRawData(resp);
52
51
  this.stats = resp;
53
52
  }
54
-
55
- private preprocessRawData(resp) {
56
- // Format distributed objects for readability
57
- resp.distributedObjects?.forEach(obj => {
58
- obj.name = obj.name.substring(obj.name.indexOf('_') + 1);
59
- });
60
- }
61
53
  }
@@ -10,13 +10,13 @@ import {FormModel} from '@xh/hoist/cmp/form';
10
10
  import {fragment, p} from '@xh/hoist/cmp/layout';
11
11
  import {HoistModel, Intent, LoadSpec, managed, PlainObject, XH} from '@xh/hoist/core';
12
12
  import {dateIs, required} from '@xh/hoist/data';
13
- import {action, computed, makeObservable, observable} from '@xh/hoist/mobx';
13
+ import {action, bindable, computed, makeObservable, observable} from '@xh/hoist/mobx';
14
14
  import {AlertBannerSpec} from '@xh/hoist/svc';
15
15
  import {isEqual, isMatch, sortBy, without} from 'lodash';
16
16
 
17
17
  export class AlertBannerModel extends HoistModel {
18
- savedValue;
19
- @observable.ref savedPresets: PlainObject[] = [];
18
+ savedValue: AlertBannerSpec;
19
+ @bindable.ref savedPresets: PlainObject[] = [];
20
20
 
21
21
  @managed
22
22
  formModel = new FormModel({
@@ -118,7 +118,6 @@ export class AlertBannerModel extends HoistModel {
118
118
  this.formModel.setValues({...preset, expires: null});
119
119
  }
120
120
 
121
- @action
122
121
  addPreset() {
123
122
  const {message, intent, iconName, enableClose, clientApps} = this.formModel.values,
124
123
  dateCreated = Date.now(),
@@ -188,24 +187,6 @@ export class AlertBannerModel extends HoistModel {
188
187
  }
189
188
  }
190
189
 
191
- async saveBannerSpecAsync(spec: AlertBannerSpec) {
192
- const {active, message, intent, iconName, enableClose, clientApps} = spec;
193
- try {
194
- await XH.fetchService.postJson({
195
- url: 'alertBannerAdmin/setAlertSpec',
196
- body: spec,
197
- track: {
198
- category: 'Audit',
199
- message: 'Updated Alert Banner',
200
- data: {active, message, intent, iconName, enableClose, clientApps},
201
- logData: ['active']
202
- }
203
- });
204
- } catch (e) {
205
- XH.handleException(e);
206
- }
207
- }
208
-
209
190
  //----------------
210
191
  // Implementation
211
192
  //----------------
@@ -232,7 +213,7 @@ export class AlertBannerModel extends HoistModel {
232
213
  let preservedPublishDate = null;
233
214
 
234
215
  // Ask some questions if we are dealing with live stuff
235
- if (XH.alertBannerService.enabled && (active || savedValue?.active)) {
216
+ if (active || savedValue?.active) {
236
217
  // Question 1. Reshow when modifying an active && already active, closable banner?
237
218
  if (
238
219
  active &&
@@ -299,7 +280,25 @@ export class AlertBannerModel extends HoistModel {
299
280
  };
300
281
 
301
282
  await this.saveBannerSpecAsync(value);
302
- await XH.alertBannerService.checkForBannerAsync();
283
+ await XH.environmentService.pollServerAsync();
303
284
  await this.refreshAsync();
304
285
  }
286
+
287
+ private async saveBannerSpecAsync(spec: AlertBannerSpec) {
288
+ const {active, message, intent, iconName, enableClose, clientApps} = spec;
289
+ try {
290
+ await XH.fetchService.postJson({
291
+ url: 'alertBannerAdmin/setAlertSpec',
292
+ body: spec,
293
+ track: {
294
+ category: 'Audit',
295
+ message: 'Updated Alert Banner',
296
+ data: {active, message, intent, iconName, enableClose, clientApps},
297
+ logData: ['active']
298
+ }
299
+ });
300
+ } catch (e) {
301
+ XH.handleException(e);
302
+ }
303
+ }
305
304
  }
@@ -37,7 +37,7 @@ import {toolbar} from '@xh/hoist/desktop/cmp/toolbar';
37
37
  import {dateTimeRenderer} from '@xh/hoist/format';
38
38
  import {Icon} from '@xh/hoist/icon';
39
39
  import {menu, menuItem, popover} from '@xh/hoist/kit/blueprint';
40
- import {LocalDate, SECONDS} from '@xh/hoist/utils/datetime';
40
+ import {LocalDate} from '@xh/hoist/utils/datetime';
41
41
  import {isEmpty} from 'lodash';
42
42
  import {ReactNode} from 'react';
43
43
  import {AlertBannerModel} from './AlertBannerModel';
@@ -72,15 +72,13 @@ const formPanel = hoistCmp.factory<AlertBannerModel>(({model}) => {
72
72
  labelWidth: 100
73
73
  },
74
74
  items: [
75
- XH.alertBannerService.enabled
75
+ XH.getConf('xhAlertBannerConfig', {}).enabled
76
76
  ? div({
77
77
  className: `${baseClassName}__intro`,
78
78
  items: [
79
79
  p(`Show an alert banner to all ${XH.appName} users.`),
80
80
  p(
81
- `Configure and preview below. Presets can be saved and loaded via bottom bar menu. Banner will appear to all users within ${
82
- XH.alertBannerService.interval / SECONDS
83
- }s once marked Active and saved.`
81
+ 'Configure and preview below. Presets can be saved and loaded via bottom bar menu. Banner will appear to all users once marked Active and saved.'
84
82
  )
85
83
  ]
86
84
  })
@@ -8,5 +8,4 @@ export declare class DetailsModel extends HoistModel {
8
8
  get selectedRecord(): StoreRecord;
9
9
  onLinked(): void;
10
10
  doLoadAsync(loadSpec: LoadSpec): Promise<void>;
11
- private preprocessRawData;
12
11
  }
@@ -2,7 +2,7 @@ import { FormModel } from '@xh/hoist/cmp/form';
2
2
  import { HoistModel, Intent, LoadSpec, PlainObject } from '@xh/hoist/core';
3
3
  import { AlertBannerSpec } from '@xh/hoist/svc';
4
4
  export declare class AlertBannerModel extends HoistModel {
5
- savedValue: any;
5
+ savedValue: AlertBannerSpec;
6
6
  savedPresets: PlainObject[];
7
7
  formModel: FormModel;
8
8
  bannerModel: any;
@@ -10,7 +10,7 @@ export declare class AlertBannerModel extends HoistModel {
10
10
  get iconOptions(): string[];
11
11
  constructor();
12
12
  doLoadAsync(loadSpec: LoadSpec): Promise<void>;
13
- saveAsync(): Promise<any>;
13
+ saveAsync(): Promise<void>;
14
14
  resetForm(): void;
15
15
  loadPreset(preset: PlainObject): void;
16
16
  addPreset(): void;
@@ -19,7 +19,7 @@ export declare class AlertBannerModel extends HoistModel {
19
19
  get shouldDisableAddPreset(): boolean;
20
20
  loadPresetsAsync(): Promise<void>;
21
21
  savePresetsAsync(): Promise<void>;
22
- saveBannerSpecAsync(spec: AlertBannerSpec): Promise<void>;
23
22
  private syncPreview;
24
23
  private saveInternalAsync;
24
+ private saveBannerSpecAsync;
25
25
  }
@@ -10,7 +10,7 @@ export declare class ConfigPanelModel extends HoistModel {
10
10
  gridModel: RestGridModel;
11
11
  differModel: DifferModel;
12
12
  constructor();
13
- doLoadAsync(loadSpec: LoadSpec): Promise<any>;
13
+ doLoadAsync(loadSpec: LoadSpec): Promise<void>;
14
14
  openDiffer(): void;
15
15
  closeDiffer(): void;
16
16
  private valueRenderer;
@@ -8,7 +8,7 @@ export declare class JsonBlobModel extends HoistModel {
8
8
  gridModel: RestGridModel;
9
9
  differModel: DifferModel;
10
10
  constructor();
11
- doLoadAsync(loadSpec: LoadSpec): Promise<any>;
11
+ doLoadAsync(loadSpec: LoadSpec): Promise<void>;
12
12
  openDiffer(): void;
13
13
  closeDiffer(): void;
14
14
  }
@@ -10,7 +10,7 @@ export declare class PrefEditorModel extends HoistModel {
10
10
  gridModel: RestGridModel;
11
11
  differModel: DifferModel;
12
12
  constructor();
13
- doLoadAsync(loadSpec: LoadSpec): Promise<any>;
13
+ doLoadAsync(loadSpec: LoadSpec): Promise<void>;
14
14
  openDiffer(): void;
15
15
  closeDiffer(): void;
16
16
  }
@@ -8,5 +8,5 @@ export declare class UserModel extends HoistModel {
8
8
  withRolesOnly: boolean;
9
9
  gridModel: GridModel;
10
10
  constructor();
11
- doLoadAsync(loadSpec: LoadSpec): Promise<any>;
11
+ doLoadAsync(loadSpec: LoadSpec): Promise<void>;
12
12
  }
@@ -90,8 +90,8 @@ export declare class RestGridModel extends HoistModel {
90
90
  loadData(rawData: PlainObject[], rawSummaryData?: PlainObject): void;
91
91
  addRecord(): void;
92
92
  cloneRecord(record: StoreRecord): void;
93
- deleteRecordAsync(record: StoreRecord): Promise<any>;
94
- bulkDeleteRecordsAsync(records: StoreRecord[]): Promise<any>;
93
+ deleteRecordAsync(record: StoreRecord): Promise<void>;
94
+ bulkDeleteRecordsAsync(records: StoreRecord[]): Promise<void>;
95
95
  editRecord(record: StoreRecord): void;
96
96
  viewRecord(record: StoreRecord): void;
97
97
  confirmDeleteRecords(): void;
@@ -34,7 +34,7 @@ export declare class RestFormModel extends HoistModel {
34
34
  openEdit(rec: any): void;
35
35
  openClone(data: any): void;
36
36
  openView(rec: any): void;
37
- validateAndSaveAsync(): Promise<any>;
37
+ validateAndSaveAsync(): Promise<void>;
38
38
  private initForm;
39
39
  private saveRecordAsync;
40
40
  fieldModelConfig(editor: RestGridEditor): {
@@ -1,4 +1,4 @@
1
- import { Thunkable, ExceptionHandlerOptions, TaskObserver, TrackOptions } from '@xh/hoist/core';
1
+ import { Thunkable, ExceptionHandlerOptions, TaskObserver, TrackOptions, Some, Awaitable } from '@xh/hoist/core';
2
2
  /**
3
3
  * Enhancements to the Global Promise object.
4
4
  * Merged in to definition here and implemented on the prototype below.
@@ -9,7 +9,7 @@ declare global {
9
9
  * Version of `then()` that wraps the callback in a MobX action, for use in a Promise chain
10
10
  * that modifies MobX observables.
11
11
  */
12
- thenAction(onFulfilled?: (value: T) => any, onRejected?: (reason: any) => any): Promise<any>;
12
+ thenAction<TResult>(onFulfilled: (value: T) => Awaitable<TResult>): Promise<TResult>;
13
13
  /**
14
14
  * Version of `catch()` that will only catch certain exceptions.
15
15
  *
@@ -18,16 +18,16 @@ declare global {
18
18
  * selector will be handled by this method.
19
19
  * @param fn - catch handler
20
20
  */
21
- catchWhen(selector: ((e: any) => boolean) | string | string[], fn?: (reason: any) => any): Promise<any>;
21
+ catchWhen<TResult = undefined>(selector: ((e: any) => boolean) | Some<string>, fn?: (reason: any) => Awaitable<TResult>): Promise<T | TResult>;
22
22
  /**
23
23
  * Version of `catch()` that passes the error onto Hoist's default exception handler for
24
24
  * convention-driven logging and alerting. Typically called last in a Promise chain.
25
25
  */
26
- catchDefault(options?: ExceptionHandlerOptions): Promise<any>;
26
+ catchDefault(options?: ExceptionHandlerOptions): Promise<T | undefined>;
27
27
  /**
28
28
  * Version of `catchDefault()` that will only catch certain exceptions.
29
29
  */
30
- catchDefaultWhen(selector: ((e: any) => boolean) | string | string[], options: ExceptionHandlerOptions): Promise<any>;
30
+ catchDefaultWhen(selector: ((e: any) => boolean) | Some<string>, options: ExceptionHandlerOptions): Promise<T | undefined>;
31
31
  /**
32
32
  * Wait on a potentially async function before passing on the original value.
33
33
  * Useful when we want to block and do something on the promise chain, but do not want to
@@ -2,18 +2,14 @@ import { BannerSpec, HoistService, Intent } from '@xh/hoist/core';
2
2
  /**
3
3
  * Service to display an app-wide alert banner, as configured via the Hoist Admin console.
4
4
  *
5
- * For this service to be active, a client-visible `xhAlertBannerConfig` config must be specified
6
- * as `{enabled:true, interval: x}`, where `x` sets this service's polling frequency in seconds.
5
+ * Note that the client is provided with updated banner data from the server via
6
+ * EnvironmentService, and its regular polling. See 'xhEnvPollConfig' for more information.
7
7
  */
8
8
  export declare class AlertBannerService extends HoistService {
9
9
  xhImpl: boolean;
10
10
  static instance: AlertBannerService;
11
- private timer;
12
- get interval(): number;
13
- get enabled(): boolean;
14
11
  get lastDismissed(): number;
15
- initAsync(): Promise<void>;
16
- checkForBannerAsync(): Promise<void>;
12
+ updateBanner(spec: AlertBannerSpec): Promise<void>;
17
13
  genBannerSpec(message: string, intent: Intent, iconName: string, enableClose: boolean): BannerSpec;
18
14
  private onClose;
19
15
  private isTargetedApp;
@@ -1,7 +1,7 @@
1
1
  import { HoistService } from '@xh/hoist/core';
2
2
  /**
3
3
  * Load and report on the client and server environment, including software versions, timezones, and
4
- * and other technical information.
4
+ * other technical information.
5
5
  */
6
6
  export declare class EnvironmentService extends HoistService {
7
7
  static instance: EnvironmentService;
@@ -30,9 +30,13 @@ export declare class EnvironmentService extends HoistService {
30
30
  isTest(): boolean;
31
31
  isMinHoistCoreVersion(version: string): boolean;
32
32
  isMaxHoistCoreVersion(version: string): boolean;
33
+ /**
34
+ * Update critical environment information from server.
35
+ * @internal - not for app use. Called by `pollTimer` and as needed by Hoist code.
36
+ */
37
+ pollServerAsync(): Promise<void>;
33
38
  constructor();
34
39
  private startPolling;
35
- private pollServerAsync;
36
40
  private setServerInfo;
37
41
  private get pollIntervalMs();
38
42
  }
@@ -54,7 +54,7 @@ export declare class IdentityService extends HoistService {
54
54
  */
55
55
  impersonateAsync(username: string): Promise<void>;
56
56
  /** Exit any active impersonation, reloading the app to resume accessing it as yourself. */
57
- endImpersonateAsync(): Promise<any>;
57
+ endImpersonateAsync(): Promise<void>;
58
58
  private createUser;
59
59
  private hasGate;
60
60
  private canUserImpersonate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "68.0.0-SNAPSHOT.1726258981470",
3
+ "version": "68.0.0-SNAPSHOT.1726599173889",
4
4
  "description": "Hoist add-on for building and deploying React Applications.",
5
5
  "repository": "github:xh/hoist-react",
6
6
  "homepage": "https://xh.io",
@@ -10,7 +10,9 @@ import {
10
10
  ExceptionHandlerOptions,
11
11
  TaskObserver,
12
12
  TrackOptions,
13
- XH
13
+ XH,
14
+ Some,
15
+ Awaitable
14
16
  } from '@xh/hoist/core';
15
17
  import {action} from '@xh/hoist/mobx';
16
18
  import {olderThan, SECONDS} from '@xh/hoist/utils/datetime';
@@ -26,10 +28,7 @@ declare global {
26
28
  * Version of `then()` that wraps the callback in a MobX action, for use in a Promise chain
27
29
  * that modifies MobX observables.
28
30
  */
29
- thenAction(
30
- onFulfilled?: (value: T) => any,
31
- onRejected?: (reason: any) => any
32
- ): Promise<any>;
31
+ thenAction<TResult>(onFulfilled: (value: T) => Awaitable<TResult>): Promise<TResult>;
33
32
 
34
33
  /**
35
34
  * Version of `catch()` that will only catch certain exceptions.
@@ -39,24 +38,24 @@ declare global {
39
38
  * selector will be handled by this method.
40
39
  * @param fn - catch handler
41
40
  */
42
- catchWhen(
43
- selector: ((e: any) => boolean) | string | string[],
44
- fn?: (reason: any) => any
45
- ): Promise<any>;
41
+ catchWhen<TResult = undefined>(
42
+ selector: ((e: any) => boolean) | Some<string>,
43
+ fn?: (reason: any) => Awaitable<TResult>
44
+ ): Promise<T | TResult>;
46
45
 
47
46
  /**
48
47
  * Version of `catch()` that passes the error onto Hoist's default exception handler for
49
48
  * convention-driven logging and alerting. Typically called last in a Promise chain.
50
49
  */
51
- catchDefault(options?: ExceptionHandlerOptions): Promise<any>;
50
+ catchDefault(options?: ExceptionHandlerOptions): Promise<T | undefined>;
52
51
 
53
52
  /**
54
53
  * Version of `catchDefault()` that will only catch certain exceptions.
55
54
  */
56
55
  catchDefaultWhen(
57
- selector: ((e: any) => boolean) | string | string[],
56
+ selector: ((e: any) => boolean) | Some<string>,
58
57
  options: ExceptionHandlerOptions
59
- ): Promise<any>;
58
+ ): Promise<T | undefined>;
60
59
 
61
60
  /**
62
61
  * Wait on a potentially async function before passing on the original value.
@@ -6,52 +6,28 @@
6
6
  */
7
7
  import {BannerModel} from '@xh/hoist/appcontainer/BannerModel';
8
8
  import {markdown} from '@xh/hoist/cmp/markdown';
9
- import {BannerSpec, HoistService, Intent, managed, XH} from '@xh/hoist/core';
9
+ import {BannerSpec, HoistService, Intent, XH} from '@xh/hoist/core';
10
10
  import {Icon} from '@xh/hoist/icon';
11
- import {Timer} from '@xh/hoist/utils/async';
12
- import {SECONDS} from '@xh/hoist/utils/datetime';
13
11
  import {compact, isEmpty, map, trim} from 'lodash';
14
12
 
15
13
  /**
16
14
  * Service to display an app-wide alert banner, as configured via the Hoist Admin console.
17
15
  *
18
- * For this service to be active, a client-visible `xhAlertBannerConfig` config must be specified
19
- * as `{enabled:true, interval: x}`, where `x` sets this service's polling frequency in seconds.
16
+ * Note that the client is provided with updated banner data from the server via
17
+ * EnvironmentService, and its regular polling. See 'xhEnvPollConfig' for more information.
20
18
  */
21
19
  export class AlertBannerService extends HoistService {
22
20
  override xhImpl = true;
23
21
 
24
22
  static instance: AlertBannerService;
25
23
 
26
- @managed
27
- private timer: Timer;
28
-
29
- get interval(): number {
30
- const conf = XH.getConf('xhAlertBannerConfig', {});
31
- return conf.enabled && conf.interval ? conf.interval * SECONDS : -1;
32
- }
33
-
34
- get enabled(): boolean {
35
- return this.interval > 0;
36
- }
37
-
38
24
  get lastDismissed(): number {
39
25
  return XH.localStorageService.get('xhAlertBanner.lastDismissed');
40
26
  }
41
27
 
42
- override async initAsync() {
43
- this.timer = Timer.create({
44
- runFn: () => this.checkForBannerAsync(),
45
- interval: this.interval
46
- });
47
- }
48
-
49
- async checkForBannerAsync() {
50
- if (!this.enabled) return;
51
-
52
- const data: AlertBannerSpec = await XH.fetchJson({url: 'xh/alertBanner'}),
53
- {active, expires, publishDate, message, intent, iconName, enableClose, clientApps} =
54
- data,
28
+ async updateBanner(spec: AlertBannerSpec) {
29
+ const {active, expires, publishDate, message, intent, iconName, enableClose, clientApps} =
30
+ spec,
55
31
  {lastDismissed, onClose} = this;
56
32
 
57
33
  if (
@@ -18,7 +18,7 @@ import {version as reactVersion} from 'react';
18
18
 
19
19
  /**
20
20
  * Load and report on the client and server environment, including software versions, timezones, and
21
- * and other technical information.
21
+ * other technical information.
22
22
  */
23
23
  export class EnvironmentService extends HoistService {
24
24
  static instance: EnvironmentService;
@@ -49,7 +49,7 @@ export class EnvironmentService extends HoistService {
49
49
  private pollTimer: Timer;
50
50
 
51
51
  override async initAsync() {
52
- const {pollConfig, instanceName, ...serverEnv} = await XH.fetchJson({
52
+ const {pollConfig, instanceName, alertBanner, ...serverEnv} = await XH.fetchJson({
53
53
  url: 'xh/environment'
54
54
  }),
55
55
  clientTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone ?? 'Unknown',
@@ -81,7 +81,10 @@ export class EnvironmentService extends HoistService {
81
81
  this.pollConfig = pollConfig;
82
82
  this.addReaction({
83
83
  when: () => XH.appIsRunning,
84
- run: this.startPolling
84
+ run: () => {
85
+ XH.alertBannerService.updateBanner(alertBanner);
86
+ this.startPolling();
87
+ }
85
88
  });
86
89
  }
87
90
 
@@ -109,23 +112,11 @@ export class EnvironmentService extends HoistService {
109
112
  return checkMaxVersion(this.get('hoistCoreVersion'), version);
110
113
  }
111
114
 
112
- //------------------------------
113
- // Implementation
114
- //------------------------------
115
- constructor() {
116
- super();
117
- makeObservable(this);
118
- }
119
-
120
- private startPolling() {
121
- this.pollTimer = Timer.create({
122
- runFn: () => this.pollServerAsync(),
123
- interval: this.pollIntervalMs,
124
- delay: true
125
- });
126
- }
127
-
128
- private async pollServerAsync() {
115
+ /**
116
+ * Update critical environment information from server.
117
+ * @internal - not for app use. Called by `pollTimer` and as needed by Hoist code.
118
+ */
119
+ async pollServerAsync() {
129
120
  let data;
130
121
  try {
131
122
  data = await XH.fetchJson({url: 'xh/environmentPoll'});
@@ -135,10 +126,11 @@ export class EnvironmentService extends HoistService {
135
126
  }
136
127
 
137
128
  // Update config/interval, and server info
138
- const {pollConfig, instanceName, appVersion, appBuild} = data;
129
+ const {pollConfig, instanceName, alertBanner, appVersion, appBuild} = data;
139
130
  this.pollConfig = pollConfig;
140
131
  this.pollTimer.setInterval(this.pollIntervalMs);
141
132
  this.setServerInfo(instanceName, appVersion, appBuild);
133
+ XH.alertBannerService.updateBanner(alertBanner);
142
134
 
143
135
  // Handle version change
144
136
  if (appVersion != XH.getEnv('appVersion') || appBuild != XH.getEnv('appBuild')) {
@@ -163,6 +155,22 @@ export class EnvironmentService extends HoistService {
163
155
  }
164
156
  }
165
157
 
158
+ //------------------------------
159
+ // Implementation
160
+ //------------------------------
161
+ constructor() {
162
+ super();
163
+ makeObservable(this);
164
+ }
165
+
166
+ private startPolling() {
167
+ this.pollTimer = Timer.create({
168
+ runFn: () => this.pollServerAsync(),
169
+ interval: this.pollIntervalMs,
170
+ delay: true
171
+ });
172
+ }
173
+
166
174
  @action
167
175
  private setServerInfo(serverInstance: string, serverVersion: string, serverBuild: string) {
168
176
  this.serverInstance = serverInstance;