@xh/hoist 88.0.0 → 88.1.0
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 +33 -0
- package/appcontainer/AppStateModel.ts +8 -7
- package/build/types/appcontainer/AppStateModel.d.ts +0 -4
- package/build/types/cmp/store/StoreFilterField.d.ts +11 -9
- package/build/types/cmp/store/impl/StoreFilterFieldImplModel.d.ts +10 -2
- package/build/types/cmp/zoneGrid/ZoneGridModel.d.ts +6 -1
- package/build/types/desktop/cmp/grid/find/GridFindField.d.ts +11 -7
- package/build/types/desktop/cmp/grid/find/impl/GridFindFieldImplModel.d.ts +5 -1
- package/build/types/security/BaseOAuthClient.d.ts +10 -3
- package/build/types/security/Types.d.ts +5 -0
- package/build/types/security/msal/MsalClient.d.ts +2 -3
- package/cmp/store/StoreFilterField.ts +11 -9
- package/cmp/store/impl/StoreFilterFieldImplModel.ts +56 -27
- package/cmp/zoneGrid/ZoneGridModel.ts +22 -1
- package/desktop/cmp/dash/container/DashContainerModel.ts +12 -10
- package/desktop/cmp/form/FormField.ts +25 -8
- package/desktop/cmp/grid/find/GridFindField.ts +12 -8
- package/desktop/cmp/grid/find/impl/GridFindFieldImplModel.ts +59 -35
- package/package.json +1 -1
- package/public/preflight.js +3 -1
- package/security/BaseOAuthClient.ts +17 -3
- package/security/README.md +4 -0
- package/security/Types.ts +6 -0
- package/security/authzero/AuthZeroClient.ts +11 -5
- package/security/msal/MsalClient.ts +8 -6
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,39 @@
|
|
|
12
12
|
3. Plain ASCII punctuation only. Use " - " for in-sentence breaks, never an em dash.
|
|
13
13
|
-->
|
|
14
14
|
|
|
15
|
+
## 88.1.0 - 2026-10-01
|
|
16
|
+
|
|
17
|
+
### 🎁 New Features
|
|
18
|
+
|
|
19
|
+
* Both `StoreFilterField` and `GridFindField` now fully support `ZoneGrid`. Their `gridModel` prop
|
|
20
|
+
accepts a `ZoneGridModel`, in which case they search the fields mapped to the grid's zones, not
|
|
21
|
+
its two zone columns. With no prop, both bind to the nearest `GridModel` or `ZoneGridModel` in
|
|
22
|
+
context. Both now also re-derive their searchable fields when columns are shown or hidden, not
|
|
23
|
+
only when the grid's columns are replaced.
|
|
24
|
+
* `BaseOAuthClient.initAsync()` now accepts an optional `CallContextLike`, and tags its span with
|
|
25
|
+
`xh.auth.method` (`acquireSilent`, `ssoSilent`, `loginPopup`, or `loginRedirect`) so auth latency
|
|
26
|
+
can be broken down by token path. Both `MsalClient` and `AuthZeroClient` report the method, also
|
|
27
|
+
available as `BaseOAuthClient.lastAuthMethod`. Apps opt in by passing the ctx from
|
|
28
|
+
`HoistAuthModel.completeAuthAsync()` to `client.initAsync(ctx)`.
|
|
29
|
+
|
|
30
|
+
### 🐞 Bug Fixes
|
|
31
|
+
* Fixed `defaultReadonlyRenderer` reformatting plain strings that happen to parse as JSON scalars -
|
|
32
|
+
e.g. a JsonBlob token like `3473e37` rendered as `3.473e+40` in read-only form fields. Only JSON
|
|
33
|
+
objects and arrays are now pretty-printed, and other strings render as-is.
|
|
34
|
+
* Fixed `StoreFilterField` ignoring changes to its `gridModel` or `store` props after mount.
|
|
35
|
+
* Fixed app load tracking recording inflated load times for pages hidden at any point during load,
|
|
36
|
+
such as a page opened in a background tab or switched away from while loading. These loads now
|
|
37
|
+
omit `elapsed` and report `hiddenDuringLoad: true` in their data. This also drops them from the
|
|
38
|
+
server's `xh.client.load.*` metrics.
|
|
39
|
+
* Fixed `DashContainer` views intermittently rendering blank until their tab was re-selected or
|
|
40
|
+
dragged. Active state was set on a fixed timer that could fire before the view's model existed,
|
|
41
|
+
most often on slower clients. Affected tabs could also miss their context menu and title updates.
|
|
42
|
+
|
|
43
|
+
### ✨ Styles
|
|
44
|
+
|
|
45
|
+
* Increased the default width of `GridFindField` from 180px to 240px, leaving room to type once its
|
|
46
|
+
match count and nav buttons appear.
|
|
47
|
+
|
|
15
48
|
## 88.0.0 - 2026-09-29
|
|
16
49
|
|
|
17
50
|
### 💥 Breaking Changes (upgrade difficulty: 🔴 HIGH - TC39 decorators + Rsbuild, AG Grid 36, MobX 7, removals)
|
|
@@ -24,10 +24,7 @@ export class AppStateModel extends HoistModel {
|
|
|
24
24
|
suspendData: AppSuspendData;
|
|
25
25
|
accessDeniedMessage: string = 'Access Denied';
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
* Timestamp when the app first started loading, prior to even JS download/eval.
|
|
29
|
-
* Read from timestamp set on window within index.html.
|
|
30
|
-
*/
|
|
27
|
+
// Captured by preflight.js, before any Hoist JS has loaded.
|
|
31
28
|
readonly loadStarted: number = window['_xhLoadTimestamp'];
|
|
32
29
|
readonly timings: Record<AppState, number> = {} as Record<AppState, number>;
|
|
33
30
|
|
|
@@ -82,24 +79,28 @@ export class AppStateModel extends HoistModel {
|
|
|
82
79
|
// Implementation
|
|
83
80
|
//------------------
|
|
84
81
|
private trackLoad() {
|
|
85
|
-
const {timings, loadStarted} = this;
|
|
86
82
|
this.addReaction({
|
|
87
83
|
when: () => this.state === 'RUNNING',
|
|
88
84
|
run: () => {
|
|
85
|
+
const {timings, loadStarted} = this,
|
|
86
|
+
loginTime = timings.LOGIN_REQUIRED ?? 0,
|
|
87
|
+
hiddenDuringLoad = window['_xhWasHidden'];
|
|
89
88
|
XH.track({
|
|
90
89
|
category: 'App',
|
|
91
90
|
message: `Loaded ${XH.clientAppCode}`,
|
|
92
91
|
timestamp: loadStarted,
|
|
93
|
-
|
|
92
|
+
// Hidden pages may be throttled, elapsed time is misleading
|
|
93
|
+
elapsed: hiddenDuringLoad ? null : Date.now() - loadStarted - loginTime,
|
|
94
94
|
data: {
|
|
95
95
|
timings: mapKeys(timings, (v, k) => camelCase(k)),
|
|
96
|
+
hiddenDuringLoad,
|
|
96
97
|
clientHealth: XH.clientHealthService.getReport(),
|
|
97
98
|
window: this.getWindowData(),
|
|
98
99
|
screen: this.getScreenData()
|
|
99
100
|
},
|
|
100
101
|
omit: !XH.appSpec.trackAppLoad
|
|
101
102
|
});
|
|
102
|
-
this.logDebug('Load timings',
|
|
103
|
+
this.logDebug('Load timings', timings);
|
|
103
104
|
}
|
|
104
105
|
});
|
|
105
106
|
}
|
|
@@ -11,10 +11,6 @@ export declare class AppStateModel extends HoistModel {
|
|
|
11
11
|
lastActivityMs: number;
|
|
12
12
|
suspendData: AppSuspendData;
|
|
13
13
|
accessDeniedMessage: string;
|
|
14
|
-
/**
|
|
15
|
-
* Timestamp when the app first started loading, prior to even JS download/eval.
|
|
16
|
-
* Read from timestamp set on window within index.html.
|
|
17
|
-
*/
|
|
18
14
|
readonly loadStarted: number;
|
|
19
15
|
readonly timings: Record<AppState, number>;
|
|
20
16
|
private lastStateChangeTime;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { GridModel } from '@xh/hoist/cmp/grid';
|
|
2
|
+
import type { ZoneGridModel } from '@xh/hoist/cmp/zoneGrid';
|
|
2
3
|
import { DefaultHoistProps, HoistModel } from '@xh/hoist/core';
|
|
3
4
|
import type { FilterMatchMode, FilterTestFn, Store } from '@xh/hoist/data';
|
|
4
5
|
export interface StoreFilterFieldProps extends DefaultHoistProps {
|
|
@@ -23,11 +24,12 @@ export interface StoreFilterFieldProps extends DefaultHoistProps {
|
|
|
23
24
|
*/
|
|
24
25
|
filterBuffer?: number;
|
|
25
26
|
/**
|
|
26
|
-
* GridModel whose Store this control should filter. When given a GridModel,
|
|
27
|
-
* will, by default, use the fields for all *visible* columns when matching, as
|
|
28
|
-
* groupBy field.
|
|
27
|
+
* GridModel or ZoneGridModel whose Store this control should filter. When given a GridModel,
|
|
28
|
+
* this component will, by default, use the fields for all *visible* columns when matching, as
|
|
29
|
+
* well as any groupBy field. When given a ZoneGridModel, it uses the fields currently mapped
|
|
30
|
+
* to any of its zones. Do not configure this and `store` on the same component.
|
|
29
31
|
*/
|
|
30
|
-
gridModel?: GridModel;
|
|
32
|
+
gridModel?: GridModel | ZoneGridModel;
|
|
31
33
|
/**
|
|
32
34
|
* Names of field(s) to include in search. Required if neither a store nor gridModel are
|
|
33
35
|
* provided, as otherwise fields cannot be inferred.
|
|
@@ -61,11 +63,11 @@ export interface StoreFilterFieldProps extends DefaultHoistProps {
|
|
|
61
63
|
* its value to the value of configured fields on a candidate object. If any field values match, the
|
|
62
64
|
* object itself is considered a match.
|
|
63
65
|
*
|
|
64
|
-
* This component is designed to be bound to a Store via either its `store` OR `gridModel` props
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* to auto-generate the fields in the store to be included in the filter and
|
|
68
|
-
* apply the filter to the Store.
|
|
66
|
+
* This component is designed to be bound to a Store via either its `store` OR `gridModel` props,
|
|
67
|
+
* the latter accepting either a GridModel or a ZoneGridModel. If not configured with either, it
|
|
68
|
+
* binds by default to the nearest GridModel or ZoneGridModel found in context. Binding in this way
|
|
69
|
+
* allows the component to auto-generate the fields in the store to be included in the filter and
|
|
70
|
+
* to automatically apply the filter to the Store.
|
|
69
71
|
*
|
|
70
72
|
* In cases where the application is combining this filter with other filters, or applying
|
|
71
73
|
* additional application logic, the filter can be managed manually by setting `autoApply` to
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GridModel } from '@xh/hoist/cmp/grid';
|
|
2
|
+
import { ZoneGridModel } from '@xh/hoist/cmp/zoneGrid';
|
|
2
3
|
import { HoistModel } from '@xh/hoist/core';
|
|
3
4
|
import type { FilterMatchMode, StoreRecord } from '@xh/hoist/data';
|
|
4
5
|
import { Store } from '@xh/hoist/data';
|
|
@@ -8,11 +9,12 @@ import { Store } from '@xh/hoist/data';
|
|
|
8
9
|
export declare class StoreFilterFieldImplModel extends HoistModel {
|
|
9
10
|
xhImpl: boolean;
|
|
10
11
|
model: any;
|
|
11
|
-
gridModel: GridModel;
|
|
12
|
-
store: Store;
|
|
13
12
|
private filter;
|
|
14
13
|
private bufferedApplyFilter;
|
|
15
14
|
get matchMode(): FilterMatchMode;
|
|
15
|
+
/** GridModel or ZoneGridModel to filter - from props, or the nearest found in context. */
|
|
16
|
+
get boundModel(): GridModel | ZoneGridModel;
|
|
17
|
+
get store(): Store;
|
|
16
18
|
onLinked(): void;
|
|
17
19
|
get filterText(): string;
|
|
18
20
|
setFilterText(v: string): void;
|
|
@@ -20,4 +22,10 @@ export declare class StoreFilterFieldImplModel extends HoistModel {
|
|
|
20
22
|
regenerateFilter(): void;
|
|
21
23
|
getActiveFields(): string[];
|
|
22
24
|
getValGetters(fieldName: string): ((record: StoreRecord) => any)[] | ((rec: StoreRecord) => any);
|
|
25
|
+
private get innerGridModel();
|
|
26
|
+
/**
|
|
27
|
+
* Columns whose fields the user can see, and so should be able to search. A ZoneGrid renders
|
|
28
|
+
* its mapped fields within two zone columns, so use the columns backing those fields instead.
|
|
29
|
+
*/
|
|
30
|
+
private getSearchColumns;
|
|
23
31
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CellClickedEvent, CellContextMenuEvent, CellDoubleClickedEvent, RowClickedEvent, RowDoubleClickedEvent } from '@xh/hoist/kit/ag-grid';
|
|
2
|
-
import { ColumnRenderer, ColumnSpec, GridContextMenuItemLike, GridContextMenuSpec, GridGroupSortFn, GridModel, GridSorter, GridSorterLike, GroupRowRenderer, RowClassFn, RowClassRuleFn, TreeStyle } from '@xh/hoist/cmp/grid';
|
|
2
|
+
import { Column, ColumnRenderer, ColumnSpec, GridContextMenuItemLike, GridContextMenuSpec, GridGroupSortFn, GridModel, GridSorter, GridSorterLike, GroupRowRenderer, RowClassFn, RowClassRuleFn, TreeStyle } from '@xh/hoist/cmp/grid';
|
|
3
3
|
import { Awaitable, HoistModel, LoadSpec, PlainObject, Some, Thunkable, VSide } from '@xh/hoist/core';
|
|
4
4
|
import { Store, StoreConfig, StoreRecordOrId, StoreSelectionConfig, StoreSelectionModel, StoreTransaction } from '@xh/hoist/data';
|
|
5
5
|
import { ReactNode } from 'react';
|
|
@@ -242,6 +242,11 @@ export declare class ZoneGridModel extends HoistModel {
|
|
|
242
242
|
restoreDefaultsAsync(): Promise<boolean>;
|
|
243
243
|
showMapper(): void;
|
|
244
244
|
setMappings(mappings: Record<Zone, Some<string | ZoneMapping>>): void;
|
|
245
|
+
/**
|
|
246
|
+
* Columns backing the fields currently mapped to any zone. These columns are hidden within the
|
|
247
|
+
* underlying GridModel, but their fields are what the user sees rendered within each row.
|
|
248
|
+
*/
|
|
249
|
+
getMappedColumns(): Column[];
|
|
245
250
|
getDefaultContextMenu: () => GridContextMenuItemLike[];
|
|
246
251
|
get sortBy(): GridSorter;
|
|
247
252
|
setSortBy(cfg: GridSorterLike): void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { GridModel } from '@xh/hoist/cmp/grid';
|
|
2
|
+
import type { ZoneGridModel } from '@xh/hoist/cmp/zoneGrid';
|
|
2
3
|
import { LayoutProps } from '@xh/hoist/core';
|
|
3
4
|
import type { FilterMatchMode } from '@xh/hoist/data';
|
|
4
5
|
import { TextInputProps } from '@xh/hoist/desktop/cmp/input';
|
|
@@ -6,10 +7,12 @@ import '@xh/hoist/desktop/register';
|
|
|
6
7
|
import './GridFindField.scss';
|
|
7
8
|
export interface GridFindFieldProps extends TextInputProps, LayoutProps {
|
|
8
9
|
/**
|
|
9
|
-
* GridModel whose data this control should search.
|
|
10
|
-
* fields for all *visible* columns when matching, as
|
|
10
|
+
* GridModel or ZoneGridModel whose data this control should search. When given a GridModel,
|
|
11
|
+
* this component will, by default, use the fields for all *visible* columns when matching, as
|
|
12
|
+
* well as any groupBy field. When given a ZoneGridModel, it uses the fields currently mapped
|
|
13
|
+
* to any of its zones.
|
|
11
14
|
*/
|
|
12
|
-
gridModel?: GridModel;
|
|
15
|
+
gridModel?: GridModel | ZoneGridModel;
|
|
13
16
|
/** Mode to use when searching (default 'startWord'). */
|
|
14
17
|
matchMode?: FilterMatchMode;
|
|
15
18
|
/**
|
|
@@ -29,10 +32,11 @@ export interface GridFindFieldProps extends TextInputProps, LayoutProps {
|
|
|
29
32
|
* the entered search term based on simple word-boundary matching of its value to the value of
|
|
30
33
|
* configured fields on a record. If any field values match, the record itself is considered a match.
|
|
31
34
|
*
|
|
32
|
-
* This component is designed to be bound to a GridModel via `gridModel` prop.
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* be searched by the field and to automatically select
|
|
35
|
+
* This component is designed to be bound to a GridModel or ZoneGridModel via its `gridModel` prop.
|
|
36
|
+
* If not configured, it binds by default to the nearest GridModel or ZoneGridModel found in
|
|
37
|
+
* context. Binding in this way allows the component to
|
|
38
|
+
* auto-generate the fields in the store to be searched by the field and to automatically select
|
|
39
|
+
* the results in the Grid.
|
|
36
40
|
*
|
|
37
41
|
* Fields to be searched can be automatically determined from the bound Grid's Store, and/or
|
|
38
42
|
* customized via the include/excludeFields props. See prop comments for details.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GridModel } from '@xh/hoist/cmp/grid';
|
|
2
|
+
import { ZoneGridModel } from '@xh/hoist/cmp/zoneGrid';
|
|
2
3
|
import { HoistModel } from '@xh/hoist/core';
|
|
3
4
|
import type { FilterMatchMode, StoreRecord } from '@xh/hoist/data';
|
|
4
5
|
import { TextInputModel } from '@xh/hoist/desktop/cmp/input';
|
|
@@ -21,7 +22,8 @@ export declare class GridFindFieldImplModel extends HoistModel {
|
|
|
21
22
|
get hasFocus(): boolean;
|
|
22
23
|
get hasQuery(): boolean;
|
|
23
24
|
get hasResults(): boolean;
|
|
24
|
-
|
|
25
|
+
/** GridModel or ZoneGridModel to search - from props, or the nearest found in context. */
|
|
26
|
+
get boundModel(): GridModel | ZoneGridModel;
|
|
25
27
|
onLinked(): void;
|
|
26
28
|
selectPrev(): void;
|
|
27
29
|
selectNext(): void;
|
|
@@ -29,4 +31,6 @@ export declare class GridFindFieldImplModel extends HoistModel {
|
|
|
29
31
|
private getRecords;
|
|
30
32
|
private getActiveFields;
|
|
31
33
|
private getValGetters;
|
|
34
|
+
private get innerGridModel();
|
|
35
|
+
private getSearchColumns;
|
|
32
36
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { HoistBase } from '@xh/hoist/core';
|
|
1
|
+
import { CallContextLike, HoistBase } from '@xh/hoist/core';
|
|
2
2
|
import { Token } from '@xh/hoist/security/Token';
|
|
3
|
-
import { AccessTokenSpec, TokenMap } from './Types';
|
|
3
|
+
import { AccessTokenSpec, AuthMethod, TokenMap } from './Types';
|
|
4
4
|
export type LoginMethod = 'REDIRECT' | 'POPUP';
|
|
5
5
|
/**
|
|
6
6
|
* Base configuration shared by all OAuth client implementations. Extended by
|
|
@@ -92,6 +92,8 @@ export declare abstract class BaseOAuthClient<C extends BaseOAuthClientConfig<S>
|
|
|
92
92
|
protected idScopes: string[];
|
|
93
93
|
/** Specification for Access Tokens */
|
|
94
94
|
protected accessSpecs: Record<string, S>;
|
|
95
|
+
/** Method of last successful authentication for this client, if any. */
|
|
96
|
+
lastAuthMethod: AuthMethod;
|
|
95
97
|
private timer;
|
|
96
98
|
private lastRefreshAttempt;
|
|
97
99
|
private TIMER_INTERVAL;
|
|
@@ -100,8 +102,11 @@ export declare abstract class BaseOAuthClient<C extends BaseOAuthClientConfig<S>
|
|
|
100
102
|
constructor(config: C);
|
|
101
103
|
/**
|
|
102
104
|
* Main entry point for this object.
|
|
105
|
+
*
|
|
106
|
+
* @param ctx - tracing context, typically the one supplied to
|
|
107
|
+
* {@link HoistAuthModel.completeAuthAsync}.
|
|
103
108
|
*/
|
|
104
|
-
initAsync(): Promise<void>;
|
|
109
|
+
initAsync(ctx?: CallContextLike): Promise<void>;
|
|
105
110
|
/**
|
|
106
111
|
* Request an interactive login with the underlying OAuth provider.
|
|
107
112
|
*/
|
|
@@ -144,6 +149,8 @@ export declare abstract class BaseOAuthClient<C extends BaseOAuthClientConfig<S>
|
|
|
144
149
|
protected abstract fetchAccessTokenAsync(spec: S, useCache: boolean): Promise<Token>;
|
|
145
150
|
protected abstract doLogoutAsync(): Promise<void>;
|
|
146
151
|
protected abstract interactiveLoginNeeded(exception: unknown): boolean;
|
|
152
|
+
/** Record the path by which authentication completed. Call from `doInitAsync` and login impls. */
|
|
153
|
+
protected noteAuthComplete(authMethod: AuthMethod): void;
|
|
147
154
|
protected get redirectUrl(): string;
|
|
148
155
|
protected get postLogoutRedirectUrl(): string;
|
|
149
156
|
protected get loginMethod(): LoginMethod;
|
|
@@ -12,3 +12,8 @@ export interface AccessTokenSpec {
|
|
|
12
12
|
scopes: string[];
|
|
13
13
|
}
|
|
14
14
|
export type TokenMap = Record<string, Token>;
|
|
15
|
+
/**
|
|
16
|
+
* Path by which an OAuth client completed authentication. Not every client uses every path -
|
|
17
|
+
* e.g. only `MsalClient` supports `ssoSilent`.
|
|
18
|
+
*/
|
|
19
|
+
export type AuthMethod = 'acquireSilent' | 'ssoSilent' | 'loginPopup' | 'loginRedirect';
|
|
@@ -3,7 +3,7 @@ import { LogLevel } from '@azure/msal-browser';
|
|
|
3
3
|
import { PlainObject } from '@xh/hoist/core';
|
|
4
4
|
import { Token } from '@xh/hoist/security/Token';
|
|
5
5
|
import { BaseOAuthClient, BaseOAuthClientConfig } from '../BaseOAuthClient';
|
|
6
|
-
import { AccessTokenSpec, TokenMap } from '../Types';
|
|
6
|
+
import { AccessTokenSpec, AuthMethod, TokenMap } from '../Types';
|
|
7
7
|
/**
|
|
8
8
|
* Configuration for a {@link MsalClient} - the Microsoft Entra ID (Azure AD) OAuth client.
|
|
9
9
|
* Extends {@link BaseOAuthClientConfig} with MSAL-specific options.
|
|
@@ -122,10 +122,9 @@ export declare class MsalClient extends BaseOAuthClient<MsalClientConfig, MsalTo
|
|
|
122
122
|
private get loginExtraScopesToConsent();
|
|
123
123
|
private get refreshOffsetArgs();
|
|
124
124
|
private setAccount;
|
|
125
|
-
|
|
125
|
+
protected noteAuthComplete(authMethod: AuthMethod): void;
|
|
126
126
|
private authRequestCore;
|
|
127
127
|
}
|
|
128
|
-
type AuthMethod = 'acquireSilent' | 'ssoSilent' | 'loginPopup' | 'loginRedirect';
|
|
129
128
|
/**
|
|
130
129
|
* Telemetry produced by this client (if enabled) + included in {@link ClientHealthService}
|
|
131
130
|
* reporting. Leverages MSAL's opt-in support for emitting performance events.
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* Copyright © 2026 Extremely Heavy Industries Inc.
|
|
6
6
|
*/
|
|
7
7
|
import type {GridModel} from '@xh/hoist/cmp/grid';
|
|
8
|
+
import type {ZoneGridModel} from '@xh/hoist/cmp/zoneGrid';
|
|
8
9
|
import {DefaultHoistProps, hoistCmp, HoistModel, useLocalModel, XH} from '@xh/hoist/core';
|
|
9
10
|
import type {FilterMatchMode, FilterTestFn, Store} from '@xh/hoist/data';
|
|
10
11
|
import {storeFilterFieldImpl as desktopStoreFilterFieldImpl} from '@xh/hoist/dynamics/desktop';
|
|
@@ -37,11 +38,12 @@ export interface StoreFilterFieldProps extends DefaultHoistProps {
|
|
|
37
38
|
filterBuffer?: number;
|
|
38
39
|
|
|
39
40
|
/**
|
|
40
|
-
* GridModel whose Store this control should filter. When given a GridModel,
|
|
41
|
-
* will, by default, use the fields for all *visible* columns when matching, as
|
|
42
|
-
* groupBy field.
|
|
41
|
+
* GridModel or ZoneGridModel whose Store this control should filter. When given a GridModel,
|
|
42
|
+
* this component will, by default, use the fields for all *visible* columns when matching, as
|
|
43
|
+
* well as any groupBy field. When given a ZoneGridModel, it uses the fields currently mapped
|
|
44
|
+
* to any of its zones. Do not configure this and `store` on the same component.
|
|
43
45
|
*/
|
|
44
|
-
gridModel?: GridModel;
|
|
46
|
+
gridModel?: GridModel | ZoneGridModel;
|
|
45
47
|
|
|
46
48
|
/**
|
|
47
49
|
* Names of field(s) to include in search. Required if neither a store nor gridModel are
|
|
@@ -83,11 +85,11 @@ export interface StoreFilterFieldProps extends DefaultHoistProps {
|
|
|
83
85
|
* its value to the value of configured fields on a candidate object. If any field values match, the
|
|
84
86
|
* object itself is considered a match.
|
|
85
87
|
*
|
|
86
|
-
* This component is designed to be bound to a Store via either its `store` OR `gridModel` props
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* to auto-generate the fields in the store to be included in the filter and
|
|
90
|
-
* apply the filter to the Store.
|
|
88
|
+
* This component is designed to be bound to a Store via either its `store` OR `gridModel` props,
|
|
89
|
+
* the latter accepting either a GridModel or a ZoneGridModel. If not configured with either, it
|
|
90
|
+
* binds by default to the nearest GridModel or ZoneGridModel found in context. Binding in this way
|
|
91
|
+
* allows the component to auto-generate the fields in the store to be included in the filter and
|
|
92
|
+
* to automatically apply the filter to the Store.
|
|
91
93
|
*
|
|
92
94
|
* In cases where the application is combining this filter with other filters, or applying
|
|
93
95
|
* additional application logic, the filter can be managed manually by setting `autoApply` to
|
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Copyright © 2026 Extremely Heavy Industries Inc.
|
|
6
6
|
*/
|
|
7
|
-
import {GridModel} from '@xh/hoist/cmp/grid';
|
|
7
|
+
import {Column, GridModel} from '@xh/hoist/cmp/grid';
|
|
8
|
+
import {ZoneGridModel} from '@xh/hoist/cmp/zoneGrid';
|
|
8
9
|
import {HoistModel, lookup} from '@xh/hoist/core';
|
|
9
10
|
import type {FilterMatchMode, StoreRecord} from '@xh/hoist/data';
|
|
10
11
|
import {appendFilter, getFilterRegex, Store} from '@xh/hoist/data';
|
|
11
|
-
import {action, compareStructural} from '@xh/hoist/mobx';
|
|
12
|
-
import {stripTags, throwIf, warnIf
|
|
12
|
+
import {action, compareStructural, computed} from '@xh/hoist/mobx';
|
|
13
|
+
import {stripTags, throwIf, warnIf} from '@xh/hoist/utils/js';
|
|
13
14
|
import {
|
|
14
15
|
debounce,
|
|
15
16
|
filter,
|
|
@@ -30,9 +31,6 @@ export class StoreFilterFieldImplModel extends HoistModel {
|
|
|
30
31
|
|
|
31
32
|
@lookup('*') model;
|
|
32
33
|
|
|
33
|
-
gridModel: GridModel;
|
|
34
|
-
store: Store;
|
|
35
|
-
|
|
36
34
|
private filter: (rec: StoreRecord) => boolean;
|
|
37
35
|
private bufferedApplyFilter;
|
|
38
36
|
|
|
@@ -40,28 +38,42 @@ export class StoreFilterFieldImplModel extends HoistModel {
|
|
|
40
38
|
return this.componentProps.matchMode ?? 'startWord';
|
|
41
39
|
}
|
|
42
40
|
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
/** GridModel or ZoneGridModel to filter - from props, or the nearest found in context. */
|
|
42
|
+
@computed
|
|
43
|
+
get boundModel(): GridModel | ZoneGridModel {
|
|
44
|
+
const {gridModel, store} = this.componentProps;
|
|
45
|
+
if (store) return null;
|
|
46
|
+
return (
|
|
47
|
+
gridModel ??
|
|
48
|
+
this.lookupModel(it => it instanceof GridModel || it instanceof ZoneGridModel)
|
|
49
|
+
);
|
|
50
|
+
}
|
|
45
51
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
@computed
|
|
53
|
+
get store(): Store {
|
|
54
|
+
return this.componentProps.store ?? this.boundModel?.store ?? null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
override onLinked() {
|
|
58
|
+
const {componentProps, store} = this,
|
|
59
|
+
{bind, includeFields, filterBuffer = 200} = componentProps;
|
|
60
|
+
throwIf(
|
|
61
|
+
componentProps.gridModel && componentProps.store,
|
|
62
|
+
"Cannot specify both 'gridModel' and 'store' props."
|
|
63
|
+
);
|
|
51
64
|
warnIf(
|
|
52
|
-
!
|
|
65
|
+
!store && isEmpty(includeFields),
|
|
53
66
|
"Must specify one of 'gridModel', 'store', or 'includeFields' or the filter will be a no-op."
|
|
54
67
|
);
|
|
55
68
|
throwIf(!store && !bind, "Must specify either 'bind' or a 'store' in StoreFilterField.");
|
|
56
|
-
this.store = store;
|
|
57
|
-
this.gridModel = gridModel;
|
|
58
69
|
|
|
59
70
|
this.bufferedApplyFilter = debounce(() => this.applyFilter(), filterBuffer);
|
|
60
71
|
|
|
61
72
|
this.addReaction(
|
|
62
73
|
{
|
|
63
|
-
track: () => [this.filterText,
|
|
74
|
+
track: () => [this.store, this.filterText, ...this.getSearchColumns()],
|
|
64
75
|
run: () => this.regenerateFilter(),
|
|
76
|
+
equals: 'shallow',
|
|
65
77
|
fireImmediately: true
|
|
66
78
|
},
|
|
67
79
|
{
|
|
@@ -134,22 +146,22 @@ export class StoreFilterFieldImplModel extends HoistModel {
|
|
|
134
146
|
}
|
|
135
147
|
|
|
136
148
|
getActiveFields(): string[] {
|
|
137
|
-
const {
|
|
149
|
+
const {boundModel, store, componentProps} = this,
|
|
138
150
|
{includeFields, excludeFields} = componentProps;
|
|
139
151
|
|
|
140
152
|
let ret = store ? ['id', ...store.fieldNames] : [];
|
|
141
153
|
if (includeFields) ret = store ? intersection(ret, includeFields) : includeFields;
|
|
142
154
|
if (excludeFields) ret = without(ret, ...excludeFields);
|
|
143
155
|
|
|
144
|
-
if (
|
|
145
|
-
const
|
|
156
|
+
if (boundModel) {
|
|
157
|
+
const searchCols = this.getSearchColumns();
|
|
146
158
|
|
|
147
159
|
// Push on dot-delimited grid column fields. These are supported by Grid and traverse
|
|
148
160
|
// sub-objects in StoreRecord.data to display nested properties. Given that Grid treats these
|
|
149
161
|
// as first-class fields and displays them w/o the need for renderers, we want to
|
|
150
162
|
// include them here. (But only if their "root" is in the field list derived from the
|
|
151
163
|
// Store and any given include/excludeField configs.)
|
|
152
|
-
|
|
164
|
+
searchCols.forEach(col => {
|
|
153
165
|
const {fieldPath} = col;
|
|
154
166
|
if (!isArray(fieldPath)) return;
|
|
155
167
|
|
|
@@ -167,7 +179,7 @@ export class StoreFilterFieldImplModel extends HoistModel {
|
|
|
167
179
|
ret = ret.filter(f => {
|
|
168
180
|
return (
|
|
169
181
|
(includeFields && includeFields.includes(f)) ||
|
|
170
|
-
|
|
182
|
+
searchCols.find(c => c.field === f)
|
|
171
183
|
);
|
|
172
184
|
});
|
|
173
185
|
}
|
|
@@ -176,7 +188,7 @@ export class StoreFilterFieldImplModel extends HoistModel {
|
|
|
176
188
|
}
|
|
177
189
|
|
|
178
190
|
getValGetters(fieldName: string) {
|
|
179
|
-
const {
|
|
191
|
+
const {boundModel} = this;
|
|
180
192
|
|
|
181
193
|
// If a GridModel has been configured, the user is looking at rendered values in a grid and
|
|
182
194
|
// would reasonably expect the filter to work off what they see. Rendering can be expensive,
|
|
@@ -185,12 +197,12 @@ export class StoreFilterFieldImplModel extends HoistModel {
|
|
|
185
197
|
// with a flag to manage performance tradeoffs.
|
|
186
198
|
//
|
|
187
199
|
// Note corresponding impl. in GridFindFieldModel - review together if updating.
|
|
188
|
-
if (
|
|
189
|
-
const {store} =
|
|
200
|
+
if (boundModel) {
|
|
201
|
+
const {store} = boundModel,
|
|
190
202
|
field = store.getField(fieldName);
|
|
191
203
|
|
|
192
204
|
if (field?.type === 'date' || field?.type === 'localDate') {
|
|
193
|
-
const cols = filter(
|
|
205
|
+
const cols = filter(this.getSearchColumns(), {field: fieldName});
|
|
194
206
|
|
|
195
207
|
// Empty return if no columns - even if this field has been force-included,
|
|
196
208
|
// we can't match it if we can't render it.
|
|
@@ -203,7 +215,7 @@ export class StoreFilterFieldImplModel extends HoistModel {
|
|
|
203
215
|
record,
|
|
204
216
|
field: field.name,
|
|
205
217
|
column,
|
|
206
|
-
gridModel,
|
|
218
|
+
gridModel: this.innerGridModel,
|
|
207
219
|
store,
|
|
208
220
|
agParams: null
|
|
209
221
|
},
|
|
@@ -221,4 +233,21 @@ export class StoreFilterFieldImplModel extends HoistModel {
|
|
|
221
233
|
? (rec: StoreRecord) => get(rec.data, fieldName)
|
|
222
234
|
: (rec: StoreRecord) => rec.data[fieldName];
|
|
223
235
|
}
|
|
236
|
+
|
|
237
|
+
private get innerGridModel(): GridModel {
|
|
238
|
+
const {boundModel} = this;
|
|
239
|
+
return boundModel instanceof ZoneGridModel ? boundModel.gridModel : boundModel;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Columns whose fields the user can see, and so should be able to search. A ZoneGrid renders
|
|
244
|
+
* its mapped fields within two zone columns, so use the columns backing those fields instead.
|
|
245
|
+
*/
|
|
246
|
+
private getSearchColumns(): Column[] {
|
|
247
|
+
const {boundModel} = this;
|
|
248
|
+
if (!boundModel) return [];
|
|
249
|
+
return boundModel instanceof ZoneGridModel
|
|
250
|
+
? boundModel.getMappedColumns()
|
|
251
|
+
: boundModel.getVisibleLeafColumns();
|
|
252
|
+
}
|
|
224
253
|
}
|
|
@@ -56,7 +56,17 @@ import {
|
|
|
56
56
|
import {Icon} from '@xh/hoist/icon';
|
|
57
57
|
import {action, observableRef, bindableRef} from '@xh/hoist/mobx';
|
|
58
58
|
import {executeIfFunction, throwIf, withDefault} from '@xh/hoist/utils/js';
|
|
59
|
-
import {
|
|
59
|
+
import {
|
|
60
|
+
castArray,
|
|
61
|
+
find,
|
|
62
|
+
flatMap,
|
|
63
|
+
forOwn,
|
|
64
|
+
isEmpty,
|
|
65
|
+
isFinite,
|
|
66
|
+
isPlainObject,
|
|
67
|
+
isString,
|
|
68
|
+
uniq
|
|
69
|
+
} from 'lodash';
|
|
60
70
|
import {ReactNode} from 'react';
|
|
61
71
|
import {initPersist} from './impl/InitPersist';
|
|
62
72
|
import {ZoneMapperConfig, ZoneMapperModel} from './impl/ZoneMapperModel';
|
|
@@ -445,6 +455,17 @@ export class ZoneGridModel extends HoistModel {
|
|
|
445
455
|
this.gridModel.setColumns(this.getColumns());
|
|
446
456
|
}
|
|
447
457
|
|
|
458
|
+
/**
|
|
459
|
+
* Columns backing the fields currently mapped to any zone. These columns are hidden within the
|
|
460
|
+
* underlying GridModel, but their fields are what the user sees rendered within each row.
|
|
461
|
+
*/
|
|
462
|
+
getMappedColumns(): Column[] {
|
|
463
|
+
const fields = uniq(
|
|
464
|
+
flatMap(this.mappings, zoneMappings => zoneMappings.map(it => it.field))
|
|
465
|
+
);
|
|
466
|
+
return this.gridModel.getLeafColumns().filter(col => fields.includes(col.field));
|
|
467
|
+
}
|
|
468
|
+
|
|
448
469
|
getDefaultContextMenu = (): GridContextMenuItemLike[] => [
|
|
449
470
|
'filter',
|
|
450
471
|
'-',
|
|
@@ -30,7 +30,6 @@ import {
|
|
|
30
30
|
isEqual,
|
|
31
31
|
isFinite,
|
|
32
32
|
isNil,
|
|
33
|
-
last,
|
|
34
33
|
partition,
|
|
35
34
|
reject,
|
|
36
35
|
startCase
|
|
@@ -262,6 +261,16 @@ export class DashContainerModel
|
|
|
262
261
|
{
|
|
263
262
|
track: () => this.viewState,
|
|
264
263
|
run: () => this.updateState()
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
// ViewModels are created async as GL's React roots render, after GL has fired its
|
|
267
|
+
// own active item events. Sync active state and tab headers once they exist.
|
|
268
|
+
track: () => [this.goldenLayout, this.viewModels],
|
|
269
|
+
run: () => {
|
|
270
|
+
this.refreshActiveViews();
|
|
271
|
+
this.updateTabHeaders();
|
|
272
|
+
},
|
|
273
|
+
debounce: 0
|
|
265
274
|
}
|
|
266
275
|
);
|
|
267
276
|
}
|
|
@@ -336,13 +345,8 @@ export class DashContainerModel
|
|
|
336
345
|
this.destroyGoldenLayout();
|
|
337
346
|
this.goldenLayout = this.createGoldenLayout(containerEl, stateWithViewModelIds);
|
|
338
347
|
})
|
|
339
|
-
//
|
|
348
|
+
// Hold the mask briefly while GL's React roots render and views settle.
|
|
340
349
|
.wait(500)
|
|
341
|
-
.then(() => {
|
|
342
|
-
if (refIsStale()) return;
|
|
343
|
-
this.refreshActiveViews();
|
|
344
|
-
this.updateTabHeaders();
|
|
345
|
-
})
|
|
346
350
|
.linkTo(this.loadingStateTask)
|
|
347
351
|
);
|
|
348
352
|
}
|
|
@@ -378,8 +382,6 @@ export class DashContainerModel
|
|
|
378
382
|
|
|
379
383
|
if (!isFinite(index)) index = container.contentItems.length;
|
|
380
384
|
container.addChild(goldenLayoutConfig(viewSpec, this.genViewId(specId)), index);
|
|
381
|
-
const stack = container.isStack ? container : last(container.contentItems);
|
|
382
|
-
wait(1).then(() => this.onStackActiveItemChange(stack));
|
|
383
385
|
}
|
|
384
386
|
|
|
385
387
|
/**
|
|
@@ -753,7 +755,7 @@ export class DashContainerModel
|
|
|
753
755
|
track: () => model.fullTitle,
|
|
754
756
|
run: () => {
|
|
755
757
|
// Item lookup requires a mounted react component and can miss during
|
|
756
|
-
// a GL (re)build -
|
|
758
|
+
// a GL (re)build - the viewModels reaction in the constructor covers it.
|
|
757
759
|
const item = this.getItemByViewModel(viewModelId);
|
|
758
760
|
if (!item?.tab) return;
|
|
759
761
|
|
|
@@ -34,7 +34,17 @@ import {
|
|
|
34
34
|
useOnUnmount
|
|
35
35
|
} from '@xh/hoist/utils/react';
|
|
36
36
|
import classNames from 'classnames';
|
|
37
|
-
import {
|
|
37
|
+
import {
|
|
38
|
+
first,
|
|
39
|
+
isDate,
|
|
40
|
+
isEmpty,
|
|
41
|
+
isFinite,
|
|
42
|
+
isNil,
|
|
43
|
+
isObjectLike,
|
|
44
|
+
isString,
|
|
45
|
+
isUndefined,
|
|
46
|
+
kebabCase
|
|
47
|
+
} from 'lodash';
|
|
38
48
|
import {
|
|
39
49
|
Children,
|
|
40
50
|
cloneElement,
|
|
@@ -380,17 +390,24 @@ const editableChild = hoistCmp.factory<FieldModel>({
|
|
|
380
390
|
// Helper Functions
|
|
381
391
|
//---------------------------------
|
|
382
392
|
export function defaultReadonlyRenderer(value: any): ReactNode {
|
|
393
|
+
// First try type-specific formatting
|
|
383
394
|
if (isLocalDate(value)) return fmtDate(value);
|
|
384
395
|
if (isDate(value)) return fmtDateTime(value);
|
|
385
396
|
if (isFinite(value)) return fmtNumber(value);
|
|
386
|
-
if (
|
|
387
|
-
|
|
388
|
-
//
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
397
|
+
if (isObjectLike(value)) return fmtJson(value);
|
|
398
|
+
|
|
399
|
+
// ... pretty printing json strings as well.
|
|
400
|
+
if (isString(value)) {
|
|
401
|
+
const trimmed = value.trim();
|
|
402
|
+
if (trimmed.startsWith('{') || trimmed.startsWith('[')) {
|
|
403
|
+
try {
|
|
404
|
+
value = fmtJson(trimmed);
|
|
405
|
+
} catch {}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
392
408
|
|
|
393
|
-
|
|
409
|
+
// Otherwise just fall back to string rendering
|
|
410
|
+
return span(value?.toString());
|
|
394
411
|
}
|
|
395
412
|
|
|
396
413
|
const blockChildren = ['CodeInput', 'JsonInput', 'Select', 'TextInput'];
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* Copyright © 2026 Extremely Heavy Industries Inc.
|
|
6
6
|
*/
|
|
7
7
|
import type {GridModel} from '@xh/hoist/cmp/grid';
|
|
8
|
+
import type {ZoneGridModel} from '@xh/hoist/cmp/zoneGrid';
|
|
8
9
|
import {hbox, span, vbox} from '@xh/hoist/cmp/layout';
|
|
9
10
|
import {hoistCmp, LayoutProps, useLocalModel} from '@xh/hoist/core';
|
|
10
11
|
import type {FilterMatchMode} from '@xh/hoist/data';
|
|
@@ -19,10 +20,12 @@ import {GridFindFieldImplModel} from './impl/GridFindFieldImplModel';
|
|
|
19
20
|
|
|
20
21
|
export interface GridFindFieldProps extends TextInputProps, LayoutProps {
|
|
21
22
|
/**
|
|
22
|
-
* GridModel whose data this control should search.
|
|
23
|
-
* fields for all *visible* columns when matching, as
|
|
23
|
+
* GridModel or ZoneGridModel whose data this control should search. When given a GridModel,
|
|
24
|
+
* this component will, by default, use the fields for all *visible* columns when matching, as
|
|
25
|
+
* well as any groupBy field. When given a ZoneGridModel, it uses the fields currently mapped
|
|
26
|
+
* to any of its zones.
|
|
24
27
|
*/
|
|
25
|
-
gridModel?: GridModel;
|
|
28
|
+
gridModel?: GridModel | ZoneGridModel;
|
|
26
29
|
|
|
27
30
|
/** Mode to use when searching (default 'startWord'). */
|
|
28
31
|
matchMode?: FilterMatchMode;
|
|
@@ -47,10 +50,11 @@ export interface GridFindFieldProps extends TextInputProps, LayoutProps {
|
|
|
47
50
|
* the entered search term based on simple word-boundary matching of its value to the value of
|
|
48
51
|
* configured fields on a record. If any field values match, the record itself is considered a match.
|
|
49
52
|
*
|
|
50
|
-
* This component is designed to be bound to a GridModel via `gridModel` prop.
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* be searched by the field and to automatically select
|
|
53
|
+
* This component is designed to be bound to a GridModel or ZoneGridModel via its `gridModel` prop.
|
|
54
|
+
* If not configured, it binds by default to the nearest GridModel or ZoneGridModel found in
|
|
55
|
+
* context. Binding in this way allows the component to
|
|
56
|
+
* auto-generate the fields in the store to be searched by the field and to automatically select
|
|
57
|
+
* the results in the Grid.
|
|
54
58
|
*
|
|
55
59
|
* Fields to be searched can be automatically determined from the bound Grid's Store, and/or
|
|
56
60
|
* customized via the include/excludeFields props. See prop comments for details.
|
|
@@ -66,7 +70,7 @@ export const [GridFindField, gridFindField] = hoistCmp.withFactory<GridFindField
|
|
|
66
70
|
const impl = useLocalModel(GridFindFieldImplModel);
|
|
67
71
|
|
|
68
72
|
return hbox({
|
|
69
|
-
width:
|
|
73
|
+
width: 240,
|
|
70
74
|
className,
|
|
71
75
|
...layoutProps,
|
|
72
76
|
items: [
|
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Copyright © 2026 Extremely Heavy Industries Inc.
|
|
6
6
|
*/
|
|
7
|
-
import {GridModel} from '@xh/hoist/cmp/grid';
|
|
7
|
+
import {Column, GridModel} from '@xh/hoist/cmp/grid';
|
|
8
|
+
import {ZoneGridModel} from '@xh/hoist/cmp/zoneGrid';
|
|
8
9
|
import {HoistModel} from '@xh/hoist/core';
|
|
9
10
|
import type {FilterMatchMode, StoreRecord} from '@xh/hoist/data';
|
|
10
11
|
import {getFilterRegex} from '@xh/hoist/data';
|
|
11
12
|
import {TextInputModel} from '@xh/hoist/desktop/cmp/input';
|
|
12
13
|
import {action, bindable, computed, observableRef, compareStructural} from '@xh/hoist/mobx';
|
|
13
|
-
import {stripTags
|
|
14
|
+
import {stripTags} from '@xh/hoist/utils/js';
|
|
14
15
|
import {createObservableRef} from '@xh/hoist/utils/react';
|
|
15
16
|
import {
|
|
16
17
|
filter,
|
|
@@ -58,7 +59,7 @@ export class GridFindFieldImplModel extends HoistModel {
|
|
|
58
59
|
|
|
59
60
|
get selectedIdx(): number {
|
|
60
61
|
if (!this.count) return null;
|
|
61
|
-
const matchIdx = this.results.indexOf(this.
|
|
62
|
+
const matchIdx = this.results.indexOf(this.innerGridModel.selectedId);
|
|
62
63
|
return matchIdx > -1 ? matchIdx : null;
|
|
63
64
|
}
|
|
64
65
|
|
|
@@ -83,21 +84,26 @@ export class GridFindFieldImplModel extends HoistModel {
|
|
|
83
84
|
return !isNil(this.results) && !isEmpty(this.results);
|
|
84
85
|
}
|
|
85
86
|
|
|
87
|
+
/** GridModel or ZoneGridModel to search - from props, or the nearest found in context. */
|
|
86
88
|
@computed
|
|
87
|
-
get
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
this.
|
|
91
|
-
|
|
92
|
-
this.logError('GridFindField must be bound to GridModel with selection enabled.');
|
|
93
|
-
}
|
|
94
|
-
return ret;
|
|
89
|
+
get boundModel(): GridModel | ZoneGridModel {
|
|
90
|
+
return (
|
|
91
|
+
this.componentProps.gridModel ??
|
|
92
|
+
this.lookupModel(it => it instanceof GridModel || it instanceof ZoneGridModel)
|
|
93
|
+
);
|
|
95
94
|
}
|
|
96
95
|
|
|
97
96
|
//------------------------------------------------------------------
|
|
98
97
|
// Trampoline value to grid
|
|
99
98
|
//------------------------------------------------------------------
|
|
100
99
|
override onLinked() {
|
|
100
|
+
const {boundModel} = this;
|
|
101
|
+
if (!boundModel) {
|
|
102
|
+
this.logError("No GridModel available. Provide via a 'gridModel' prop, or context.");
|
|
103
|
+
} else if (!boundModel.selModel?.isEnabled) {
|
|
104
|
+
this.logError('GridFindField must be bound to GridModel with selection enabled.');
|
|
105
|
+
}
|
|
106
|
+
|
|
101
107
|
this.addReaction(
|
|
102
108
|
{
|
|
103
109
|
track: () => this.query,
|
|
@@ -105,16 +111,20 @@ export class GridFindFieldImplModel extends HoistModel {
|
|
|
105
111
|
debounce: this.queryBuffer
|
|
106
112
|
},
|
|
107
113
|
{
|
|
108
|
-
track: () =>
|
|
109
|
-
this
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
+
track: () => {
|
|
115
|
+
const {innerGridModel} = this;
|
|
116
|
+
return [
|
|
117
|
+
innerGridModel?.store.records,
|
|
118
|
+
innerGridModel?.sortBy,
|
|
119
|
+
innerGridModel?.groupBy,
|
|
120
|
+
...this.getSearchColumns()
|
|
121
|
+
];
|
|
122
|
+
},
|
|
114
123
|
run: () => {
|
|
115
124
|
this._records = null;
|
|
116
125
|
if (this.hasQuery) this.updateResults();
|
|
117
126
|
},
|
|
127
|
+
equals: 'shallow',
|
|
118
128
|
debounce: this.queryBuffer
|
|
119
129
|
},
|
|
120
130
|
{
|
|
@@ -126,28 +136,28 @@ export class GridFindFieldImplModel extends HoistModel {
|
|
|
126
136
|
}
|
|
127
137
|
|
|
128
138
|
selectPrev() {
|
|
129
|
-
const {hasResults, results, selectedIdx,
|
|
139
|
+
const {hasResults, results, selectedIdx, innerGridModel} = this;
|
|
130
140
|
if (!hasResults) return;
|
|
131
141
|
const endIdx = results.length - 1;
|
|
132
142
|
if (!isFinite(selectedIdx)) {
|
|
133
|
-
|
|
143
|
+
innerGridModel.selectAsync(results[endIdx]);
|
|
134
144
|
return;
|
|
135
145
|
}
|
|
136
146
|
|
|
137
147
|
const idx = (selectedIdx - 1) % results.length;
|
|
138
|
-
|
|
148
|
+
innerGridModel.selectAsync(results[idx < 0 ? endIdx : idx]);
|
|
139
149
|
}
|
|
140
150
|
|
|
141
151
|
selectNext() {
|
|
142
|
-
const {hasResults, results, selectedIdx,
|
|
152
|
+
const {hasResults, results, selectedIdx, innerGridModel} = this;
|
|
143
153
|
if (!hasResults) return;
|
|
144
154
|
if (!isFinite(selectedIdx)) {
|
|
145
|
-
|
|
155
|
+
innerGridModel.selectAsync(results[0]);
|
|
146
156
|
return;
|
|
147
157
|
}
|
|
148
158
|
|
|
149
159
|
const idx = (selectedIdx + 1) % results.length;
|
|
150
|
-
|
|
160
|
+
innerGridModel.selectAsync(results[idx]);
|
|
151
161
|
}
|
|
152
162
|
|
|
153
163
|
//------------------------
|
|
@@ -156,7 +166,7 @@ export class GridFindFieldImplModel extends HoistModel {
|
|
|
156
166
|
@action
|
|
157
167
|
private updateResults(autoSelect = false) {
|
|
158
168
|
// Track ids of matching records
|
|
159
|
-
const {query,
|
|
169
|
+
const {query, innerGridModel} = this,
|
|
160
170
|
activeFields = this.getActiveFields();
|
|
161
171
|
|
|
162
172
|
if (!query || isEmpty(activeFields)) {
|
|
@@ -175,19 +185,19 @@ export class GridFindFieldImplModel extends HoistModel {
|
|
|
175
185
|
|
|
176
186
|
// Auto-select first matching result
|
|
177
187
|
if (autoSelect && this.hasResults && !isFinite(this.selectedIdx)) {
|
|
178
|
-
|
|
188
|
+
innerGridModel?.selectAsync(this.results[0]);
|
|
179
189
|
}
|
|
180
190
|
}
|
|
181
191
|
|
|
182
192
|
private getRecords(): StoreRecord[] {
|
|
183
|
-
return (this._records ??= this.
|
|
193
|
+
return (this._records ??= this.innerGridModel.getSortedRecords());
|
|
184
194
|
}
|
|
185
195
|
|
|
186
196
|
private getActiveFields(): string[] {
|
|
187
|
-
const {
|
|
188
|
-
|
|
197
|
+
const {innerGridModel, includeFields, excludeFields} = this,
|
|
198
|
+
searchCols = this.getSearchColumns();
|
|
189
199
|
|
|
190
|
-
let ret = ['id', ...
|
|
200
|
+
let ret = ['id', ...innerGridModel.store.fieldNames];
|
|
191
201
|
if (includeFields) ret = intersection(ret, includeFields);
|
|
192
202
|
if (excludeFields) ret = without(ret, ...excludeFields);
|
|
193
203
|
|
|
@@ -196,7 +206,7 @@ export class GridFindFieldImplModel extends HoistModel {
|
|
|
196
206
|
// as first-class fields and displays them w/o the need for renderers, we want to
|
|
197
207
|
// include them here. (But only if their "root" is in the field list derived from the
|
|
198
208
|
// Store and any given include/excludeField configs.)
|
|
199
|
-
|
|
209
|
+
searchCols.forEach(col => {
|
|
200
210
|
const {fieldPath} = col;
|
|
201
211
|
if (!isArray(fieldPath)) return;
|
|
202
212
|
|
|
@@ -213,7 +223,7 @@ export class GridFindFieldImplModel extends HoistModel {
|
|
|
213
223
|
// keyed to groupBy, so query results stay stable across regrouping (see #4070).
|
|
214
224
|
ret = ret.filter(f => {
|
|
215
225
|
return (
|
|
216
|
-
(includeFields && includeFields.includes(f)) ||
|
|
226
|
+
(includeFields && includeFields.includes(f)) || searchCols.find(c => c.field === f)
|
|
217
227
|
);
|
|
218
228
|
});
|
|
219
229
|
|
|
@@ -221,13 +231,13 @@ export class GridFindFieldImplModel extends HoistModel {
|
|
|
221
231
|
}
|
|
222
232
|
|
|
223
233
|
private getValGetters(fieldName: string) {
|
|
224
|
-
const {
|
|
225
|
-
{store} =
|
|
234
|
+
const {innerGridModel} = this,
|
|
235
|
+
{store} = innerGridModel,
|
|
226
236
|
field = store.getField(fieldName);
|
|
227
237
|
|
|
228
238
|
// See corresponding method in StoreFilterFieldImplModel for notes on this implementation.
|
|
229
239
|
if (field?.type === 'date' || field?.type === 'localDate') {
|
|
230
|
-
const cols = filter(
|
|
240
|
+
const cols = filter(this.getSearchColumns(), {field: fieldName});
|
|
231
241
|
if (!cols) return [];
|
|
232
242
|
|
|
233
243
|
return cols.map(column => {
|
|
@@ -237,7 +247,7 @@ export class GridFindFieldImplModel extends HoistModel {
|
|
|
237
247
|
record,
|
|
238
248
|
field: fieldName,
|
|
239
249
|
column,
|
|
240
|
-
gridModel,
|
|
250
|
+
gridModel: innerGridModel,
|
|
241
251
|
store,
|
|
242
252
|
agParams: null
|
|
243
253
|
},
|
|
@@ -254,4 +264,18 @@ export class GridFindFieldImplModel extends HoistModel {
|
|
|
254
264
|
? (rec: StoreRecord) => get(rec.data, fieldName)
|
|
255
265
|
: (rec: StoreRecord) => rec.data[fieldName];
|
|
256
266
|
}
|
|
267
|
+
|
|
268
|
+
private get innerGridModel(): GridModel {
|
|
269
|
+
const {boundModel} = this;
|
|
270
|
+
return boundModel instanceof ZoneGridModel ? boundModel.gridModel : boundModel;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// See corresponding method in StoreFilterFieldImplModel.
|
|
274
|
+
private getSearchColumns(): Column[] {
|
|
275
|
+
const {boundModel} = this;
|
|
276
|
+
if (!boundModel) return [];
|
|
277
|
+
return boundModel instanceof ZoneGridModel
|
|
278
|
+
? boundModel.getMappedColumns()
|
|
279
|
+
: boundModel.getVisibleLeafColumns();
|
|
280
|
+
}
|
|
257
281
|
}
|
package/package.json
CHANGED
package/public/preflight.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Record load info as early as possible - read later in AppStateModel.trackLoad().
|
|
2
2
|
window._xhLoadTimestamp = Date.now();
|
|
3
|
+
window._xhWasHidden = document.visibilityState === 'hidden';
|
|
4
|
+
document.addEventListener('visibilitychange', function () {window._xhWasHidden = true});
|
|
3
5
|
|
|
4
6
|
// Check browser compatibility with features / syntax we can't polyfill. Currently Mobx 5+ has
|
|
5
7
|
// a hard requirement for Proxy (test w/string access for max safety), which effectively filters
|
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import {br, fragment} from '@xh/hoist/cmp/layout';
|
|
8
8
|
import {isHoistException} from '@xh/hoist/exception';
|
|
9
|
-
import {HoistBase, managed, XH} from '@xh/hoist/core';
|
|
9
|
+
import {CallContextLike, HoistBase, managed, XH} from '@xh/hoist/core';
|
|
10
10
|
import {Icon} from '@xh/hoist/icon';
|
|
11
11
|
import {action} from '@xh/hoist/mobx';
|
|
12
12
|
import {never, wait} from '@xh/hoist/promise';
|
|
13
13
|
import {Token} from '@xh/hoist/security/Token';
|
|
14
|
-
import {AccessTokenSpec, TokenMap} from './Types';
|
|
14
|
+
import {AccessTokenSpec, AuthMethod, TokenMap} from './Types';
|
|
15
15
|
import {Timer} from '@xh/hoist/utils/async';
|
|
16
16
|
import {MINUTES, olderThan, ONE_MINUTE, SECONDS} from '@xh/hoist/utils/datetime';
|
|
17
17
|
import {isJSON, logError, throwIf} from '@xh/hoist/utils/js';
|
|
@@ -126,6 +126,9 @@ export abstract class BaseOAuthClient<
|
|
|
126
126
|
/** Specification for Access Tokens */
|
|
127
127
|
protected accessSpecs: Record<string, S>;
|
|
128
128
|
|
|
129
|
+
/** Method of last successful authentication for this client, if any. */
|
|
130
|
+
lastAuthMethod: AuthMethod = null;
|
|
131
|
+
|
|
129
132
|
@managed private timer: Timer;
|
|
130
133
|
private lastRefreshAttempt: number;
|
|
131
134
|
private TIMER_INTERVAL = 2 * SECONDS;
|
|
@@ -155,10 +158,14 @@ export abstract class BaseOAuthClient<
|
|
|
155
158
|
|
|
156
159
|
/**
|
|
157
160
|
* Main entry point for this object.
|
|
161
|
+
*
|
|
162
|
+
* @param ctx - tracing context, typically the one supplied to
|
|
163
|
+
* {@link HoistAuthModel.completeAuthAsync}.
|
|
158
164
|
*/
|
|
159
|
-
async initAsync(): Promise<void> {
|
|
165
|
+
async initAsync(ctx?: CallContextLike): Promise<void> {
|
|
160
166
|
try {
|
|
161
167
|
const tokens = await this.doInitAsync();
|
|
168
|
+
ctx?.span?.setTag('xh.auth.method', this.lastAuthMethod);
|
|
162
169
|
this.logDebug('Successfully initialized with following tokens:');
|
|
163
170
|
this.logTokensDebug(tokens);
|
|
164
171
|
if (this.config.autoRefreshSecs > 0) {
|
|
@@ -254,6 +261,12 @@ export abstract class BaseOAuthClient<
|
|
|
254
261
|
//---------------------------------------
|
|
255
262
|
// Implementation
|
|
256
263
|
//---------------------------------------
|
|
264
|
+
/** Record the path by which authentication completed. Call from `doInitAsync` and login impls. */
|
|
265
|
+
protected noteAuthComplete(authMethod: AuthMethod) {
|
|
266
|
+
this.lastAuthMethod = authMethod;
|
|
267
|
+
this.logInfo(`Authenticated user '${this.getSelectedUsername()}' via ${authMethod}`);
|
|
268
|
+
}
|
|
269
|
+
|
|
257
270
|
protected get redirectUrl() {
|
|
258
271
|
const url = this.config.redirectUrl;
|
|
259
272
|
return url === 'APP_BASE_URL' ? this.baseUrl : url;
|
|
@@ -458,6 +471,7 @@ export abstract class BaseOAuthClient<
|
|
|
458
471
|
this.lastRelogin = XH.appContainerModel.lastRelogin = {started, completed};
|
|
459
472
|
})
|
|
460
473
|
.then(() => {
|
|
474
|
+
this.noteAuthComplete('loginPopup');
|
|
461
475
|
XH.track({
|
|
462
476
|
category: 'App',
|
|
463
477
|
message: 'Interactive reauthentication succeeded',
|
package/security/README.md
CHANGED
|
@@ -49,6 +49,10 @@ The abstract `BaseOAuthClient` manages the core OAuth lifecycle:
|
|
|
49
49
|
6. **Logout** (`logoutAsync`) — Clears state and delegates to provider logout
|
|
50
50
|
7. **Redirect state** — Captures and restores URL routing state across redirect flows
|
|
51
51
|
|
|
52
|
+
After init, `lastAuthMethod` reports which path succeeded: `acquireSilent`, `ssoSilent` (MSAL only),
|
|
53
|
+
`loginPopup`, or `loginRedirect`. Pass the ctx from `completeAuthAsync()` to `initAsync(ctx)` to
|
|
54
|
+
also record it as an `xh.auth.method` tag on the `xh.client.auth` span.
|
|
55
|
+
|
|
52
56
|
### BaseOAuthClientConfig
|
|
53
57
|
|
|
54
58
|
| Config | Type | Description |
|
package/security/Types.ts
CHANGED
|
@@ -22,3 +22,9 @@ export interface AccessTokenSpec {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export type TokenMap = Record<string, Token>;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Path by which an OAuth client completed authentication. Not every client uses every path -
|
|
28
|
+
* e.g. only `MsalClient` supports `ssoSilent`.
|
|
29
|
+
*/
|
|
30
|
+
export type AuthMethod = 'acquireSilent' | 'ssoSilent' | 'loginPopup' | 'loginRedirect';
|
|
@@ -79,7 +79,9 @@ export class AuthZeroClient extends BaseOAuthClient<AuthZeroClientConfig, AuthZe
|
|
|
79
79
|
const {appState} = await client.handleRedirectCallback();
|
|
80
80
|
this.restoreRedirectState(appState);
|
|
81
81
|
await this.noteUserAuthenticatedAsync();
|
|
82
|
-
|
|
82
|
+
const ret = await this.fetchAllTokensAsync({eagerOnly: true});
|
|
83
|
+
this.noteAuthComplete('loginRedirect');
|
|
84
|
+
return ret;
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
// 1) If we are logged in, try to just reload tokens silently. This is the happy path on
|
|
@@ -87,18 +89,22 @@ export class AuthZeroClient extends BaseOAuthClient<AuthZeroClientConfig, AuthZe
|
|
|
87
89
|
if (await client.isAuthenticated()) {
|
|
88
90
|
try {
|
|
89
91
|
this.logDebug('Attempting silent token load.');
|
|
90
|
-
|
|
92
|
+
const ret = await this.fetchAllTokensAsync({eagerOnly: true});
|
|
93
|
+
this.noteAuthComplete('acquireSilent');
|
|
94
|
+
return ret;
|
|
91
95
|
} catch (e) {
|
|
92
96
|
this.logDebug('Failed to load tokens on init, fall back to login', e.message ?? e);
|
|
93
97
|
}
|
|
94
98
|
}
|
|
95
99
|
|
|
96
|
-
// 2) otherwise full
|
|
100
|
+
// 2) otherwise full login.
|
|
97
101
|
this.logDebug('Logging in');
|
|
98
102
|
await this.loginAsync();
|
|
99
103
|
|
|
100
|
-
//
|
|
101
|
-
|
|
104
|
+
// 2a) ... and a redirect never returns above, so this was a popup.
|
|
105
|
+
const ret = await this.fetchAllTokensAsync({eagerOnly: true});
|
|
106
|
+
this.noteAuthComplete('loginPopup');
|
|
107
|
+
return ret;
|
|
102
108
|
}
|
|
103
109
|
|
|
104
110
|
protected override async doLoginRedirectAsync(): Promise<void> {
|
|
@@ -21,7 +21,7 @@ import {logDebug, logError, logInfo, logWarn, mergeDeep, throwIf} from '@xh/hois
|
|
|
21
21
|
import {withFormattedTimestamps} from '@xh/hoist/format';
|
|
22
22
|
import {flatMap, union, uniq} from 'lodash';
|
|
23
23
|
import {BaseOAuthClient, BaseOAuthClientConfig} from '../BaseOAuthClient';
|
|
24
|
-
import {AccessTokenSpec, TokenMap} from '../Types';
|
|
24
|
+
import {AccessTokenSpec, AuthMethod, TokenMap} from '../Types';
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Configuration for a {@link MsalClient} - the Microsoft Entra ID (Azure AD) OAuth client.
|
|
@@ -207,7 +207,11 @@ export class MsalClient extends BaseOAuthClient<MsalClientConfig, MsalTokenSpec>
|
|
|
207
207
|
// user involvement but will require at least a redirect or cursory auto-closing popup.
|
|
208
208
|
this.logDebug('Attempting Login');
|
|
209
209
|
await this.loginAsync();
|
|
210
|
-
|
|
210
|
+
|
|
211
|
+
// 3a) ... and a redirect never returns above, so this was a popup.
|
|
212
|
+
const ret = await this.fetchAllTokensAsync({eagerOnly: true});
|
|
213
|
+
this.noteAuthComplete('loginPopup');
|
|
214
|
+
return ret;
|
|
211
215
|
}
|
|
212
216
|
|
|
213
217
|
protected override async doLoginPopupAsync(): Promise<void> {
|
|
@@ -217,7 +221,6 @@ export class MsalClient extends BaseOAuthClient<MsalClientConfig, MsalTokenSpec>
|
|
|
217
221
|
overrideInteractionInProgress: true
|
|
218
222
|
});
|
|
219
223
|
this.setAccount(ret.account);
|
|
220
|
-
this.noteAuthComplete('loginPopup');
|
|
221
224
|
} catch (e) {
|
|
222
225
|
if (e.errorCode === 'popup_window_error' || e.errorCode === 'empty_window_error') {
|
|
223
226
|
throw XH.exception({
|
|
@@ -455,9 +458,9 @@ export class MsalClient extends BaseOAuthClient<MsalClientConfig, MsalTokenSpec>
|
|
|
455
458
|
this.logDebug('Target account identified:', account.username);
|
|
456
459
|
}
|
|
457
460
|
|
|
458
|
-
|
|
461
|
+
protected override noteAuthComplete(authMethod: AuthMethod) {
|
|
462
|
+
super.noteAuthComplete(authMethod);
|
|
459
463
|
if (this.telemetry) this.telemetry.authMethod = authMethod;
|
|
460
|
-
this.logInfo(`Authenticated user '${this.account.username}' via ${authMethod}`);
|
|
461
464
|
}
|
|
462
465
|
|
|
463
466
|
private authRequestCore(): AuthRequestCore {
|
|
@@ -483,7 +486,6 @@ type AuthRequestCore = Pick<
|
|
|
483
486
|
CommonAuthorizationUrlRequest,
|
|
484
487
|
'domainHint' | 'scopes' | 'extraScopesToConsent' | 'account' | 'loginHint' | 'redirectUri'
|
|
485
488
|
>;
|
|
486
|
-
type AuthMethod = 'acquireSilent' | 'ssoSilent' | 'loginPopup' | 'loginRedirect';
|
|
487
489
|
|
|
488
490
|
/**
|
|
489
491
|
* Telemetry produced by this client (if enabled) + included in {@link ClientHealthService}
|