CB-4098 add prompt dialog to the sql editor (#2055)

* CB-4098 add prompt dialog to the sql editor

* CB-4098 add api integration

* CB-4046 add events

* CB-4046 fixes after review

* CB-3913 move AI feature to the ee

---------

Co-authored-by: Ainur <yagudin10@yandex.ru>
Co-authored-by: Daria Marutkina <125263541+dariamarutkina@users.noreply.github.com>
This commit is contained in:
alex
2023-10-18 13:37:23 +03:00
committed by GitHub
co-authored by Ainur Daria Marutkina
parent 3831abc880
commit 245d49b892
8 changed files with 86 additions and 2 deletions
@@ -47,7 +47,6 @@
<extension point="org.jkiss.dbeaver.ws.event.handler">
<eventHandler class="io.cloudbeaver.server.events.WSDefaultEventHandler">
<topic id="cb_config"/>
<topic id="cb_workspace_configuration"/>
</eventHandler>
<eventHandler class="io.cloudbeaver.server.events.WSDataSourceUpdatedEventHandlerImpl">
<topic id="cb_datasource"/>
@@ -73,6 +72,9 @@
<eventHandler class="io.cloudbeaver.server.events.WSLogEventHandler">
<topic id="cb_session_log"/>
</eventHandler>
<eventHandler class="io.cloudbeaver.server.events.WSEventHandlerWorkspaceConfigUpdate">
<topic id="cb_workspace_configuration"/>
</eventHandler>
<eventHandler class="io.cloudbeaver.server.events.WSDeleteTempFileHandler">
<topic id="cb_delete_temp_folder"/>
</eventHandler>
@@ -0,0 +1,35 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2023 DBeaver Corp
*
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of DBeaver Corp and its suppliers, if any.
* The intellectual and technical concepts contained
* herein are proprietary to DBeaver Corp and its suppliers
* and may be covered by U.S. and Foreign Patents,
* patents in process, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from DBeaver Corp.
*/
package io.cloudbeaver.server.events;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.WorkspaceConfigEventManager;
import org.jkiss.dbeaver.model.websocket.event.WSEventType;
import org.jkiss.dbeaver.model.websocket.event.WSWorkspaceConfigurationChangedEvent;
public class WSEventHandlerWorkspaceConfigUpdate extends WSDefaultEventHandler<WSWorkspaceConfigurationChangedEvent> {
private static final Log log = Log.getLog(WSEventHandlerWorkspaceConfigUpdate.class);
@Override
public void handleEvent(@NotNull WSWorkspaceConfigurationChangedEvent event) {
String configFileName = event.getConfigFilePath();
WorkspaceConfigEventManager.fireConfigChangedEvent(configFileName);
super.handleEvent(event);
}
}
+1
View File
@@ -68,3 +68,4 @@ export * from './createLastPromiseGetter';
export * from './removeMetadataFromBase64';
export * from './renamePathName';
export * from './removeLineBreak';
export * from './replaceSubstring';
@@ -0,0 +1,28 @@
import { replaceSubstring } from './replaceSubstring';
describe('replaceSubstring', () => {
it('should replace a substring correctly', () => {
const result = replaceSubstring('Hello, world!', 7, 12, 'there');
expect(result).toBe('Hello, there!');
});
it('should handle beginIndex at the start', () => {
const result = replaceSubstring('Hello, world!', 0, 5, 'Hi');
expect(result).toBe('Hi, world!');
});
it('should handle endIndex at the end', () => {
const result = replaceSubstring('Hello, world!', 7, 13, 'everyone');
expect(result).toBe('Hello, everyone');
});
it('should handle empty replacement', () => {
const result = replaceSubstring('Hello, world!', 7, 13, '');
expect(result).toBe('Hello, ');
});
it('should handle replacement longer than the substring', () => {
const result = replaceSubstring('Hello, world!', 7, 12, 'everyone out there');
expect(result).toBe('Hello, everyone out there!');
});
});
@@ -0,0 +1,13 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2023 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 function replaceSubstring(str: string, beginIndex: number, endIndex: number, replacement: string) {
const beforeSubstring = str.slice(0, beginIndex);
const afterSubstring = str.slice(endIndex);
return beforeSubstring + replacement + afterSubstring;
}
@@ -59,6 +59,7 @@ export interface ISQLEditorData {
executeScript(): Promise<void>;
switchEditing(): Promise<void>;
getHintProposals(position: number, simple: boolean): Promise<SQLProposal[]>;
getResolvedSegment(): Promise<ISQLScriptSegment | undefined>;
executeQueryAction<T>(
segment: ISQLScriptSegment | undefined,
action: (query: ISQLScriptSegment) => Promise<T>,
@@ -1,3 +1,8 @@
.sqlActions {
display: flex;
flex-direction: column;
}
.sqlActions.menuBar {
height: unset;
width: 32px;
@@ -54,7 +54,6 @@ interface ISQLEditorDataPrivate extends ISQLEditorData {
updateParserScripts(): Promise<void>;
loadDatabaseDataModels(): Promise<void>;
getExecutingQuery(script: boolean): ISQLScriptSegment | undefined;
getResolvedSegment(): Promise<ISQLScriptSegment | undefined>;
getSubQuery(): ISQLScriptSegment | undefined;
}