-
Notifications
You must be signed in to change notification settings - Fork 526
dbeaver/pro#7562 [CB] keep data editor filter state during session #4261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SychevAndrey
wants to merge
28
commits into
devel
Choose a base branch
from
7562-cb-keep-data-editor-filter-state-during-session
base: devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+413
−35
Open
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
1458076
dbeaver/pro#7562 feat: persist data editor filter state after reconnect
SychevAndrey 98de428
dbeaver/pro#7562 feat: update data viewer to persist filter state
SychevAndrey 3e0e86f
dbeaver/pro#7562 feat: enhance constraint resolution in WebSQLDataFilter
SychevAndrey 472815d
dbeaver/pro#7562 refactor: don't use options
SychevAndrey 6b2f4f9
dbeaver/pro#7562 fix: stale constraints in UI
SychevAndrey 52dd2b8
dbeaver/pro#7562 refactor: add method to retrieve pinned column names…
SychevAndrey 0517067
dbeaver/pro#7562 refactor: simplify state validation using schema
SychevAndrey 8038250
dbeaver/pro#7562 refactor: simplify state management in useDataViewer…
SychevAndrey b897cc2
Merge branch 'devel' into 7562-cb-keep-data-editor-filter-state-after…
SychevAndrey e3563d4
dbeaver/pro#7562 refactor: move persisted state to IDataViewerPageState
SychevAndrey 1c0eea7
Merge branch '7562-cb-keep-data-editor-filter-state-after-reconnect' …
SychevAndrey 9d26ed9
dbeaver/pro#7562 fix: initial pageState
SychevAndrey 17e733e
dbeaver/pro#7562 refactor: simplify getPinnedColumnNames method in Gr…
SychevAndrey 3ba78e6
dbeaver/pro#7562 refactor: shadowed column renamed to c for clarity
SychevAndrey a7bd511
dbeaver/pro#7562 refactor: change type of value in IPersistedConstrai…
SychevAndrey 576cfeb
dbeaver/pro#7562 refactor: remove manual state operations
SychevAndrey f1f5a6c
Merge branch 'devel' into 7562-cb-keep-data-editor-filter-state-after…
SychevAndrey 281c3dd
dbeaver/pro#7562 refactor: introduce DatabasePersistedStateAction for…
SychevAndrey 7cdb1a9
Merge branch 'devel' into 7562-cb-keep-data-editor-filter-state-after…
SychevAndrey 64fe0ae
Merge branch 'devel' into 7562-cb-keep-data-editor-filter-state-after…
SychevAndrey 32cb99d
dbeaver/pro#7562 fix
SychevAndrey 04bec45
dbeaver/pro#7562 refactor: replace reaction with when
SychevAndrey 98d7c92
Revert "dbeaver/pro#7562 feat: enhance constraint resolution in WebSQ…
SychevAndrey b228b7b
dbeaver/pro#7562 fix: make pinColumns optional
SychevAndrey 094c231
dbeaver/pro#7562 refactor: simplify pinned column handling
SychevAndrey 4229081
dbeaver/pro#7562 refactor: initialize store in DatabasePersistedState…
SychevAndrey f07eb1e
dbeaver/pro#7562 refactor: rename getColumnNameByPosition to getColum…
SychevAndrey ccd6c7b
dbeaver/pro#7562 refactor: move DatabasePersistedStateAction to sourc…
SychevAndrey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
webapp/packages/plugin-data-viewer/src/DataViewerTableState/IDataViewerPersistedState.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| /* | ||
| * CloudBeaver - Cloud Database Manager | ||
| * Copyright (C) 2020-2026 DBeaver Corp and others | ||
| * | ||
| * Licensed under the Apache License, Version 2.0. | ||
| * you may not use this file except in compliance with the License. | ||
| */ | ||
|
|
||
| export interface IDataViewerPersistedState { | ||
| constraints: IPersistedConstraint[]; | ||
| whereFilter: string; | ||
| pinnedColumns?: string[]; | ||
| columnOrder?: string[]; | ||
| } | ||
|
|
||
| export interface IPersistedConstraint { | ||
| attributeName: string; | ||
| operator?: string; | ||
| value?: unknown; | ||
| orderAsc?: boolean; | ||
| orderPosition?: number; | ||
| } |
29 changes: 29 additions & 0 deletions
29
webapp/packages/plugin-data-viewer/src/DataViewerTableState/validatePersistedState.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /* | ||
| * CloudBeaver - Cloud Database Manager | ||
| * Copyright (C) 2020-2026 DBeaver Corp and others | ||
| * | ||
| * Licensed under the Apache License, Version 2.0. | ||
| * you may not use this file except in compliance with the License. | ||
| */ | ||
| import { schema } from '@cloudbeaver/core-utils'; | ||
|
|
||
| import type { IDataViewerPersistedState } from './IDataViewerPersistedState.js'; | ||
|
|
||
| const persistedConstraintSchema = schema.object({ | ||
| attributeName: schema.string().min(1), | ||
| operator: schema.string().optional(), | ||
| value: schema.unknown().optional(), | ||
| orderAsc: schema.boolean().optional(), | ||
| orderPosition: schema.number().optional(), | ||
| }); | ||
|
|
||
| const persistedStateSchema = schema.object({ | ||
| constraints: schema.array(persistedConstraintSchema), | ||
| whereFilter: schema.string(), | ||
| pinnedColumns: schema.array(schema.string()).optional().default([]), | ||
| columnOrder: schema.array(schema.string()).optional(), | ||
| }); | ||
|
|
||
| export function validatePersistedState(data: unknown): data is IDataViewerPersistedState { | ||
| return persistedStateSchema.safeParse(data).success; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
.../plugin-data-viewer/src/DatabaseDataModel/Actions/General/DatabasePersistedStateAction.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| /* | ||
| * CloudBeaver - Cloud Database Manager | ||
| * Copyright (C) 2020-2026 DBeaver Corp and others | ||
| * | ||
| * Licensed under the Apache License, Version 2.0. | ||
| * you may not use this file except in compliance with the License. | ||
| */ | ||
| import { makeObservable, observable } from 'mobx'; | ||
|
|
||
| import type { IDatabasePersistedStateAction } from '../IDatabasePersistedStateAction.js'; | ||
| import { validatePersistedState } from '../../../DataViewerTableState/validatePersistedState.js'; | ||
|
|
||
| export class DatabasePersistedStateAction implements IDatabasePersistedStateAction { | ||
| private store: Record<string, unknown>; | ||
| private readonly source: { options: any }; | ||
|
|
||
| constructor(source: { options: any }) { | ||
| this.source = source; | ||
| this.store = {}; | ||
|
|
||
| makeObservable<this, 'store'>(this, { | ||
| store: observable.ref, | ||
| }); | ||
| } | ||
|
|
||
| setStore(store: Record<string, unknown>): void { | ||
| this.store = store; | ||
| this.applyPersistedConstraints(); | ||
| } | ||
|
|
||
| has(key: string): boolean { | ||
| return key in this.store; | ||
| } | ||
|
|
||
| get<T>(key: string): T | undefined { | ||
| return this.store[key] as T | undefined; | ||
| } | ||
|
|
||
| set(key: string, value: unknown): void { | ||
| this.store[key] = value; | ||
| } | ||
|
|
||
| delete(key: string): void { | ||
| delete this.store[key]; | ||
| } | ||
|
|
||
| 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 || ''; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please change it's name because it's not an action anymore