-
Notifications
You must be signed in to change notification settings - Fork 472
dbeaver/pro#6327 refactor: sql editor & vqb #3742
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
Merged
+558
−434
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
efaa548
dbeaver/pro#6327 refactor: sql editor & vqb
Wroud 2957ad2
Merge branch 'devel' into dbeaver/pro#6327/refactor-sql-editor-vqb
Wroud 1693643
Merge branch 'devel' into dbeaver/pro#6327/refactor-sql-editor-vqb
mr-anton-t c8ef08b
fix: state sync
Wroud d726d13
Merge branch 'devel' into dbeaver/pro#6327/refactor-sql-editor-vqb
EvgeniaBzzz 7854d52
fix: segment resolution
Wroud c0e2f8f
chore: add comment
Wroud 2e54e31
Merge branch 'devel' into dbeaver/pro#6327/refactor-sql-editor-vqb
mr-anton-t f1e9ba2
refactor: remove old code, add todo about problem
Wroud ce47a2b
Merge branch 'devel' into dbeaver/pro#6327/refactor-sql-editor-vqb
EvgeniaBzzz dd519e2
Merge remote-tracking branch 'origin/devel' into dbeaver/pro#6327/ref…
Wroud 1e7737e
fix: yarn.lock
Wroud 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
Some comments aren't visible on the classic Files Changed page.
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
9 changes: 9 additions & 0 deletions
9
webapp/common-typescript/@dbeaver/js-helpers/src/debouncePromise.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,9 @@ | ||
/* | ||
* CloudBeaver - Cloud Database Manager | ||
* Copyright (C) 2020-2025 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 { default as debouncePromise } from 'p-debounce'; | ||
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 |
---|---|---|
@@ -1,3 +1,13 @@ | ||
/* | ||
* CloudBeaver - Cloud Database Manager | ||
* Copyright (C) 2020-2025 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 * from './debouncePromise.js'; | ||
export * from './isDefined.js'; | ||
export * from './isNotNullDefined.js'; | ||
export * from './memoizeLast.js'; | ||
export * from './mutex.js'; |
19 changes: 19 additions & 0 deletions
19
webapp/common-typescript/@dbeaver/js-helpers/src/memoizeLast.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,19 @@ | ||
/* | ||
* CloudBeaver - Cloud Database Manager | ||
* Copyright (C) 2020-2025 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 pMemoize from 'p-memoize'; | ||
import QuickLRU from 'quick-lru'; | ||
|
||
const cacheKey = (args: unknown[]) => JSON.stringify(args); | ||
|
||
export function memoizeLast<T extends (...a: any[]) => Promise<any>>(fn: T) { | ||
return pMemoize(fn, { | ||
cache: new QuickLRU({ maxSize: 5 }), | ||
cacheKey, | ||
}); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* CloudBeaver - Cloud Database Manager | ||
* Copyright (C) 2020-2025 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 { mutex } from '@dbeaver/js-helpers'; | ||
import { useEffect, useState } from 'react'; | ||
import { useObjectRef } from './useObjectRef.js'; | ||
|
||
interface ISyncHook { | ||
markOutdated(): void; | ||
} | ||
|
||
export function useSync(callback: () => void | Promise<void>, canSync = true): ISyncHook { | ||
const [syncMutex] = useState(() => new mutex.Mutex()); | ||
const [outdated, setOutdated] = useState(false); | ||
const [delayedOutdated, setDelayedOutdated] = useState(false); | ||
sergeyteleshev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
function markOutdated() { | ||
if (syncMutex.isLocked()) { | ||
setDelayedOutdated(true); | ||
} else { | ||
setOutdated(true); | ||
} | ||
} | ||
|
||
function markUpdated() { | ||
if (delayedOutdated) { | ||
setDelayedOutdated(false); | ||
setOutdated(true); | ||
} else { | ||
setOutdated(false); | ||
} | ||
} | ||
|
||
const data = useObjectRef(() => ({ | ||
markOutdated, | ||
markUpdated, | ||
})); | ||
|
||
useEffect(() => { | ||
if (outdated && !syncMutex.isLocked() && canSync) { | ||
syncMutex | ||
.runExclusive(async () => { | ||
try { | ||
await callback(); | ||
} finally { | ||
data.markUpdated(); | ||
} | ||
}) | ||
.catch(error => console.error(error)); | ||
} | ||
}); | ||
|
||
return data; | ||
} |
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
19 changes: 3 additions & 16 deletions
19
webapp/packages/plugin-sql-editor-new/src/SQLEditor/SQLCodeEditor/SQLCodeEditorLoader.tsx
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 |
---|---|---|
@@ -1,23 +1,10 @@ | ||
/* | ||
* CloudBeaver - Cloud Database Manager | ||
* Copyright (C) 2020-2024 DBeaver Corp and others | ||
* Copyright (C) 2020-2025 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 { observer } from 'mobx-react-lite'; | ||
import { forwardRef } from 'react'; | ||
import { importLazyComponent } from '@cloudbeaver/core-blocks'; | ||
|
||
import { ComplexLoader, createComplexLoader } from '@cloudbeaver/core-blocks'; | ||
import type { IDefaultExtensions, IEditorProps, IEditorRef } from '@cloudbeaver/plugin-codemirror6'; | ||
|
||
const loader = createComplexLoader(async function loader() { | ||
const { SQLCodeEditor } = await import('./SQLCodeEditor.js'); | ||
return { SQLCodeEditor }; | ||
}); | ||
|
||
export const SQLCodeEditorLoader = observer<IEditorProps & IDefaultExtensions, IEditorRef>( | ||
forwardRef(function SQLCodeEditorLoader(props, ref) { | ||
return <ComplexLoader loader={loader}>{({ SQLCodeEditor }) => <SQLCodeEditor {...props} ref={ref} />}</ComplexLoader>; | ||
}), | ||
); | ||
export const SQLCodeEditorLoader = importLazyComponent(() => import('./SQLCodeEditor.js').then(m => m.SQLCodeEditor)); |
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.