Grids: extract dataController remoteOperations normalization into utils - #34673
Grids: extract dataController remoteOperations normalization into utils#34673bit-byte0 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors Grid Core’s data controller to normalize the remoteOperations option via a dedicated utility helper, aiming to keep behavior unchanged while improving encapsulation and testability.
Changes:
- Extracted
remoteOperationsnormalization (including'auto',true, andgroupPaginghandling) intoutils/adapter.ts. - Simplified
DataController._createDataSourceAdapterby delegating normalization to the helper. - Added Jest coverage for the new normalization and store-type helpers.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/devextreme/js/__internal/grids/grid_core/data_controller/utils/adapter.ts | Introduces store-type checks and remoteOperations normalization helper. |
| packages/devextreme/js/__internal/grids/grid_core/data_controller/utils/tests/adapter.test.ts | Adds Jest tests covering store detection and normalization behavior. |
| packages/devextreme/js/__internal/grids/grid_core/data_controller/types.ts | Adds new types for remoteOperations mode/options used by the helper. |
| packages/devextreme/js/__internal/grids/grid_core/data_controller/data_controller.ts | Replaces inline normalization with a call to the extracted helper. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (1)
packages/devextreme/js/__internal/grids/grid_core/data_controller/utils/adapter.ts:27
- The
groupPagingnormalization currently uses object spread ({ ...enabledRemoteOperations, ...remoteOperations }). This subtly changes behavior vs the previousextend(...)logic: spread will overwrite defaults withundefinedvalues (disabling operations that were previously kept enabled) and it ignores enumerable properties coming from the prototype chain. To keep normalization behavior stable, merge via afor..inloop that skipsundefinedvalues (and guards against__proto__/constructor).
// groupPaging only works when every operation runs remotely.
if (isObject(remoteOperations) && remoteOperations.groupPaging) {
return { ...enabledRemoteOperations, ...remoteOperations };
}
cfccd4f to
7d9f707
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (2)
packages/devextreme/js/__internal/grids/grid_core/data_controller/utils/tests/adapter.test.ts:80
- The new tests cover the main normalization branches, but they don’t assert the legacy behavior that
undefinedflags should not override the default enabled operations in thegroupPagingmerge (previouslyextendskippedundefined). Adding a regression test for this helps prevent reintroducing the subtleundefined→falsy behavior change.
it('groupPaging object overrides individual operation flags', () => {
const result = normalizeRemoteOperations({ groupPaging: true, filtering: false }, remoteStore);
expect(result).toEqual({
filtering: false,
sorting: true,
paging: true,
grouping: true,
summary: true,
groupPaging: true,
});
});
packages/devextreme/js/__internal/grids/grid_core/data_controller/utils/adapter.ts:27
remoteOperations.groupPagingbranch uses object spread to merge defaults, but the previous implementation usedextend, which intentionally skips keys whose value isundefined. With the current spread merge, a user-provided object like{ groupPaging: true, filtering: undefined }will overwrite the defaultfiltering: truewithundefined, which then behaves asfalsein downstream checks (e.g.!remoteOperations.filtering). Consider merging while ignoringundefinedvalues to preserve the old semantics.
// groupPaging only works when every operation runs remotely.
if (isObject(remoteOperations) && remoteOperations.groupPaging) {
return { ...enabledRemoteOperations, ...remoteOperations };
}
What
The grids' data controller now resolves the
remoteOperationsoption through a dedicated helper instead of inline logiсHow
The
'auto',trueandgroupPagingnormalization and the store-type checks moved out of_createDataSourceAdapterinto a new utils/adapter.ts module that the controller calls