Skip to content

Commit 2036bcd

Browse files
committed
Merge branch 'develop' into fb_exceptionsCAN256
# Conflicts: # packages/components/package-lock.json # packages/components/package.json # packages/components/releaseNotes/components.md
2 parents 341cc6d + ed6e69c commit 2036bcd

7 files changed

Lines changed: 52 additions & 28 deletions

File tree

packages/components/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@labkey/components",
3-
"version": "6.43.3-exceptionsCAN256.0",
3+
"version": "6.44.0",
44
"description": "Components, models, actions, and utility functions for LabKey applications and pages",
55
"sideEffects": false,
66
"files": [

packages/components/releaseNotes/components.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ Components, models, actions, and utility functions for LabKey applications and p
55
*Released*: TBD
66
- Issue 53164: AssayPicker.tsx gives JS error if no specialty assay providers available for server
77

8+
### version 6.44.0
9+
*Released*: 27 May 2025
10+
- QueryModel/QueryConfig change useSavedSettings from boolean to enum SavedSettings
11+
- Consumers can now opt into 'none', 'all', or 'noFilters'
12+
813
### version 6.43.3
914
*Released*: 26 May 2025
1015
- Migrate `isSetEqual` to `@labkey/components`. Extend with additional support for deep comparison.

packages/components/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ import {
640640
wrapDraggable,
641641
} from './internal/test/testHelpers';
642642
import { renderWithAppContext } from './internal/test/reactTestLibraryHelpers';
643-
import { flattenValuesFromRow, QueryModel } from './public/QueryModel/QueryModel';
643+
import { flattenValuesFromRow, QueryModel, SavedSettings } from './public/QueryModel/QueryModel';
644644
import { getExpandQueryInfo, includedColumnsForCustomizationFilter } from './public/QueryModel/CustomizeGridViewModal';
645645
import { ChangeType, withQueryModels } from './public/QueryModel/withQueryModels';
646646
import { GridPanel, GridPanelWithModel } from './public/QueryModel/GridPanel';
@@ -1776,6 +1776,7 @@ export {
17761776
// QueryModel
17771777
GRID_CHECKBOX_OPTIONS,
17781778
QueryModel,
1779+
SavedSettings,
17791780
ChangeType,
17801781
withQueryModels,
17811782
GridPanel,

packages/components/src/internal/components/user/UsersGridPanel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { SetURLSearchParams, useSearchParams } from 'react-router-dom';
1010

1111
import { getSelected } from '../../actions';
1212

13-
import { QueryModel } from '../../../public/QueryModel/QueryModel';
13+
import { QueryModel, SavedSettings } from '../../../public/QueryModel/QueryModel';
1414
import { removeParameters } from '../../util/URL';
1515

1616
import { UserLimitSettings } from '../permissions/actions';
@@ -134,7 +134,7 @@ export class UsersGridPanelImpl extends PureComponent<Props, State> {
134134
bindURL: true,
135135
urlPrefix: usersView, // each model needs to have its own urlPrefix for paging to work across models
136136
includeTotalCount: true,
137-
useSavedSettings: true,
137+
useSavedSettings: SavedSettings.all,
138138
},
139139
true,
140140
true

packages/components/src/public/QueryModel/QueryModel.ts

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ export interface GridMessage {
103103
type?: string;
104104
}
105105

106+
export enum SavedSettings {
107+
all = 'all', // Restores filters, maxRows, sorts, and view
108+
noFilters = 'noFilters', // Restores maxRows and sorts only
109+
none = 'none',
110+
}
111+
106112
export interface QueryConfig {
107113
/**
108114
* An array of base [Filter.IFilter](https://labkey.github.io/labkey-api-js/interfaces/Filter.IFilter.html)
@@ -209,12 +215,17 @@ export interface QueryConfig {
209215
urlPrefix?: string;
210216

211217
/**
212-
* If true we will load filters, sorts, pageSize, and viewName from localStorage when initially loading the model,
213-
* but only if there are no settings on the URL. Important: If you are using this flag you must ensure your grid id
214-
* is stable and unique. It must be stable between page loads/visits, or we won't be able to fetch the settings. It
215-
* must be unique, or we'll override settings for other grid models.
218+
* Used to optionally load saved settings from localStorage when initially loading the model, but only if there are
219+
* no settings on the URL.
220+
* - 'all' will load filters, sorts, pageSize, and viewName
221+
* - 'noFilters' will load sorts and pageSize
222+
* - 'none' disables this feature
223+
*
224+
* Important: If you are using this flag you must ensure your grid id is stable and unique. It must be stable
225+
* between page loads/visits, or we won't be able to fetch the settings. It must be unique, or we'll override other
226+
* grid models.
216227
*/
217-
useSavedSettings?: boolean;
228+
useSavedSettings?: SavedSettings;
218229
}
219230

220231
export const DEFAULT_OFFSET = 0;
@@ -345,12 +356,17 @@ export class QueryModel {
345356
*/
346357
readonly urlPrefix?: string;
347358
/**
348-
* If true we will load filters, sorts, pageSize, and viewName from localStorage when initially loading the model,
349-
* but only if there are no settings on the URL. Defaults to false. Important: If you are using this flag you must
350-
* ensure your grid id is stable and unique. It must be stable between page loads/visits, or we won't be able to
351-
* fetch the settings. It must be unique, or we'll override settings for other grid models.
359+
* Used to optionally load saved settings from localStorage when initially loading the model, but only if there are
360+
* no settings on the URL.
361+
* - 'all' will load filters, sorts, pageSize, and viewName
362+
* - 'noFilters' will load sorts and pageSize
363+
* - 'none' disables this feature
364+
*
365+
* Important: If you are using this flag you must ensure your grid id is stable and unique. It must be stable
366+
* between page loads/visits, or we won't be able to fetch the settings. It must be unique, or we'll override other
367+
* grid models.
352368
*/
353-
useSavedSettings?: boolean;
369+
readonly useSavedSettings?: SavedSettings;
354370

355371
/**
356372
* An array of [Filter.IFilter](https://labkey.github.io/labkey-api-js/interfaces/Filter.IFilter.html)
@@ -505,7 +521,7 @@ export class QueryModel {
505521
this.totalCountError = undefined;
506522
this.totalCountLoadingState = LoadingState.INITIALIZED;
507523
this.urlPrefix = queryConfig.urlPrefix ?? 'query'; // match Data Region defaults
508-
this.useSavedSettings = queryConfig.useSavedSettings ?? false;
524+
this.useSavedSettings = queryConfig.useSavedSettings ?? SavedSettings.none;
509525
this.charts = undefined;
510526
this.chartsError = undefined;
511527
this.chartsLoadingState = LoadingState.INITIALIZED;

packages/components/src/public/QueryModel/withQueryModels.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
QueryConfig,
2727
QueryModel,
2828
removeSettingsFromLocalStorage,
29+
SavedSettings,
2930
saveSettingsToLocalStorage,
3031
} from './QueryModel';
3132

@@ -247,16 +248,17 @@ function applySavedSettings(id: string, model: QueryModel): QueryModel {
247248
const settings = getSettingsFromLocalStorage(id, model.containerPath);
248249
if (settings !== undefined) {
249250
const { filterArray, maxRows, sorts, viewName } = settings;
250-
let schemaQuery = model.schemaQuery;
251-
if (viewName !== undefined) {
252-
schemaQuery = new SchemaQuery(model.schemaName, model.queryName, viewName);
251+
const mutations: Partial<Draft<QueryModel>> = { maxRows, sorts };
252+
253+
if (model.useSavedSettings === SavedSettings.all) {
254+
mutations.filterArray = filterArray;
255+
256+
if (viewName !== undefined) {
257+
mutations.schemaQuery = new SchemaQuery(model.schemaName, model.queryName, viewName);
258+
}
253259
}
254-
return model.mutate({
255-
filterArray,
256-
maxRows,
257-
schemaQuery,
258-
sorts,
259-
});
260+
261+
return model.mutate(mutations as Partial<QueryModel>);
260262
}
261263
return model;
262264
}
@@ -282,7 +284,7 @@ export function withQueryModels<Props>(
282284

283285
if (model.bindURL && hasQueryParamSettings) {
284286
model = model.mutate(model.attributesForURLQueryParams(searchParams, true));
285-
} else if (model.useSavedSettings) {
287+
} else if (model.useSavedSettings !== SavedSettings.none) {
286288
if (!model.containerPath) {
287289
console.error('A model.containerPath is required when useSavedSettings is true: ' + model.id);
288290
} else {
@@ -1288,7 +1290,7 @@ export function withQueryModels<Props>(
12881290
autoLoad: false,
12891291
modelLoader: DefaultQueryModelLoader,
12901292
queryConfigs: {},
1291-
useSavedSettings: false,
1293+
useSavedSettings: SavedSettings.none,
12921294
};
12931295

12941296
return withSearchParams(ComponentWithQueryModels) as ComponentType<Props & MakeQueryModels>;

0 commit comments

Comments
 (0)