dbeaver/pro#7562 [CB] keep data editor filter state during session#4261
dbeaver/pro#7562 [CB] keep data editor filter state during session#4261SychevAndrey wants to merge 31 commits intodevelfrom
Conversation
allow using attrName without attrPosition
replaced private restorePendingState() with public restoreViewState(pinnedColumnNames, columnOrderNames?) that takes data directly as arguments
bug with skipping constraints if any without a position.
if (!prevColumn) {
return;
}
… in GridViewAction
…of github.com:dbeaver/cloudbeaver into 7562-cb-keep-data-editor-filter-state-after-reconnect
… centralized state persistence
…LDataFilter" This reverts commit 3e0e86f. Last test showed that we don't need any additional logic on BE. It handles all constraints properly.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 4 |
TIP This summary will be updated as you push new changes. Give us feedback
| { | ||
| static dataFormat: ResultDataFormat[] | null = null; | ||
|
|
||
| private store: Record<string, unknown> = {}; |
There was a problem hiding this comment.
please initialize it in the constructor and make it observable.ref
There was a problem hiding this comment.
Seems like Its still not in the constructor
webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/Grid/GridDataResultAction.ts
Outdated
Show resolved
Hide resolved
…Action constructor as observable
…nNameAt for clarity
…e level, simplify persisted state sync - Make DatabasePersistedStateAction a standalone class on DatabaseDataSource instead of per-result action - Convert options to getter - Auto-sync constraints to persisted state via autorun + action batching - Restore view state (pinned columns, column order) in GridViewAction constructor
| { | ||
| static dataFormat: ResultDataFormat[] | null = null; | ||
|
|
||
| private store: Record<string, unknown> = {}; |
There was a problem hiding this comment.
Seems like Its still not in the constructor
webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/Grid/GridDataResultAction.ts
Outdated
Show resolved
Hide resolved
| try { | ||
| const persistedState = pageState?.persistedState; | ||
|
|
||
| if (persistedState && validatePersistedState(persistedState) && model.source.options) { |
There was a problem hiding this comment.
What should throw here? validatePersistedState uses .safeParse which does not throw
...ges/plugin-data-viewer/src/DatabaseDataModel/Actions/General/DatabasePersistedStateAction.ts
Outdated
Show resolved
Hide resolved
...p/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/IDatabasePersistedStateAction.ts
Outdated
Show resolved
Hide resolved
…DatabasePersistedStateStore and update related references
…f github.com:dbeaver/cloudbeaver into 7562-cb-keep-data-editor-filter-state-during-session
| private applyPersistedConstraints(): void { | ||
| const options = this.source.options; | ||
|
|
||
| if (!options || !validatePersistedState(this.store)) { | ||
| return; | ||
| } | ||
|
|
||
| if ('constraints' in options && 'whereFilter' in options) { | ||
| options.constraints = this.store.constraints.map(c => ({ | ||
| attributeName: c.attributeName, | ||
| operator: c.operator, | ||
| value: c.value, | ||
| orderAsc: c.orderAsc, | ||
| orderPosition: c.orderPosition, | ||
| })); | ||
| options.whereFilter = this.store.whereFilter || ''; | ||
| } | ||
| } |
There was a problem hiding this comment.
please move to result set data source
| for (const name of pinnedColumnNames) { | ||
| const key = this.columnKeys.find(k => this.getColumnName(k) === name); | ||
|
|
||
| if (key) { | ||
| this.pinnedColumns.add(GridDataKeysUtils.serialize(key)); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
i will suggest to move validation logic for pinned columns and columns order to the updateResult method
| ps.set(COLUMN_ORDER_KEY, isCustomOrder ? columnNames : []); | ||
| } | ||
|
|
||
| restoreViewState(state: IRestoreViewState): void { |
There was a problem hiding this comment.
try to use direct states from store instead of syncing private properties with state
| return this.result.data?.columns?.find(c => c.position === colIdx)?.name; | ||
| } | ||
|
|
||
| private persistConstraints(): void { |
There was a problem hiding this comment.
we need to persist datasource options object (whereFilter) maybe it will be better to persist constraints in the same place instead of splitting it across classes
No description provided.