From f75caccb736f81cba864be8931a797087039bf88 Mon Sep 17 00:00:00 2001 From: alex <48489896+devnaumov@users.noreply.github.com> Date: Thu, 7 Nov 2024 11:25:34 +0100 Subject: [PATCH 01/11] CB-5907 add labels to user and team form (#3049) * CB-5907 add labels to user and team form * CB-5907 fix structure --------- Co-authored-by: mr-anton-t <42037741+mr-anton-t@users.noreply.github.com> --- .../src/Administration/Users/Teams/TeamsTable/TeamEdit.tsx | 2 +- .../src/Administration/Users/UsersTable/UserEdit.tsx | 2 +- .../plugin-authentication-administration/src/locales/en.ts | 3 +++ .../plugin-authentication-administration/src/locales/fr.ts | 2 ++ .../plugin-authentication-administration/src/locales/it.ts | 3 +++ .../plugin-authentication-administration/src/locales/ru.ts | 3 +++ .../plugin-authentication-administration/src/locales/zh.ts | 3 +++ 7 files changed, 16 insertions(+), 2 deletions(-) diff --git a/webapp/packages/plugin-authentication-administration/src/Administration/Users/Teams/TeamsTable/TeamEdit.tsx b/webapp/packages/plugin-authentication-administration/src/Administration/Users/Teams/TeamsTable/TeamEdit.tsx index 23952f8c8a..3225b4f3d8 100644 --- a/webapp/packages/plugin-authentication-administration/src/Administration/Users/Teams/TeamsTable/TeamEdit.tsx +++ b/webapp/packages/plugin-authentication-administration/src/Administration/Users/Teams/TeamsTable/TeamEdit.tsx @@ -31,7 +31,7 @@ export const TeamEdit = observer(function TeamEdit({ item }) { data.config.teamId = item; return ( - + diff --git a/webapp/packages/plugin-authentication-administration/src/Administration/Users/UsersTable/UserEdit.tsx b/webapp/packages/plugin-authentication-administration/src/Administration/Users/UsersTable/UserEdit.tsx index f7de2e7db8..0d6a4266f0 100644 --- a/webapp/packages/plugin-authentication-administration/src/Administration/Users/UsersTable/UserEdit.tsx +++ b/webapp/packages/plugin-authentication-administration/src/Administration/Users/UsersTable/UserEdit.tsx @@ -53,7 +53,7 @@ export const UserEdit = observer>(function UserEdit }); return ( - + diff --git a/webapp/packages/plugin-authentication-administration/src/locales/en.ts b/webapp/packages/plugin-authentication-administration/src/locales/en.ts index 4e61e5157e..2415424ac3 100644 --- a/webapp/packages/plugin-authentication-administration/src/locales/en.ts +++ b/webapp/packages/plugin-authentication-administration/src/locales/en.ts @@ -142,4 +142,7 @@ export default [ ['plugin_authentication_administration_team_default_users_tooltip', 'Default team. Contains all users'], ['plugin_authentication_administration_team_user_team_role_supervisor', 'Supervisor'], ['plugin_authentication_administration_team_user_team_role_supervisor_description', 'Supervisors can view their team’s executed queries'], + + ['plugin_authentication_administration_team_form_edit_label', 'Team editing form'], + ['plugin_authentication_administration_user_form_edit_label', 'User editing form'], ]; diff --git a/webapp/packages/plugin-authentication-administration/src/locales/fr.ts b/webapp/packages/plugin-authentication-administration/src/locales/fr.ts index c9351c4be1..9d69a3ffe3 100644 --- a/webapp/packages/plugin-authentication-administration/src/locales/fr.ts +++ b/webapp/packages/plugin-authentication-administration/src/locales/fr.ts @@ -132,4 +132,6 @@ export default [ 'administration_teams_delete_confirmation_users_note', "Notez que les utilisateurs perdront leur affiliation à l'équipe et toutes les permissions associées", ], + ['plugin_authentication_administration_team_form_edit_label', 'Team editing form'], + ['plugin_authentication_administration_user_form_edit_label', 'User editing form'], ]; diff --git a/webapp/packages/plugin-authentication-administration/src/locales/it.ts b/webapp/packages/plugin-authentication-administration/src/locales/it.ts index 653292da9c..ef3b9202a8 100644 --- a/webapp/packages/plugin-authentication-administration/src/locales/it.ts +++ b/webapp/packages/plugin-authentication-administration/src/locales/it.ts @@ -86,4 +86,7 @@ export default [ ['plugin_authentication_administration_team_default_users_tooltip', 'Default team. Contains all users'], ['plugin_authentication_administration_team_user_team_role_supervisor', 'Supervisor'], ['plugin_authentication_administration_team_user_team_role_supervisor_description', 'Supervisors can view their team’s executed queries'], + + ['plugin_authentication_administration_team_form_edit_label', 'Team editing form'], + ['plugin_authentication_administration_user_form_edit_label', 'User editing form'], ]; diff --git a/webapp/packages/plugin-authentication-administration/src/locales/ru.ts b/webapp/packages/plugin-authentication-administration/src/locales/ru.ts index 70e9a8873a..87e8803a88 100644 --- a/webapp/packages/plugin-authentication-administration/src/locales/ru.ts +++ b/webapp/packages/plugin-authentication-administration/src/locales/ru.ts @@ -150,4 +150,7 @@ export default [ 'plugin_authentication_administration_team_user_team_role_supervisor_description', 'Супервайзеры могут просматривать выполненные запросы своей команды', ], + + ['plugin_authentication_administration_team_form_edit_label', 'Форма редактирования команды'], + ['plugin_authentication_administration_user_form_edit_label', 'Форма редактирования пользователя'], ]; diff --git a/webapp/packages/plugin-authentication-administration/src/locales/zh.ts b/webapp/packages/plugin-authentication-administration/src/locales/zh.ts index 56a7fb058e..de20b86eef 100644 --- a/webapp/packages/plugin-authentication-administration/src/locales/zh.ts +++ b/webapp/packages/plugin-authentication-administration/src/locales/zh.ts @@ -121,4 +121,7 @@ export default [ ['plugin_authentication_administration_team_default_users_tooltip', 'Default team. Contains all users'], ['plugin_authentication_administration_team_user_team_role_supervisor', 'Supervisor'], ['plugin_authentication_administration_team_user_team_role_supervisor_description', 'Supervisors can view their team’s executed queries'], + + ['plugin_authentication_administration_team_form_edit_label', 'Team editing form'], + ['plugin_authentication_administration_user_form_edit_label', 'User editing form'], ]; From fec65a24ea1239394eea999f26c68ac766bfeab4 Mon Sep 17 00:00:00 2001 From: Alexander Skoblikov Date: Thu, 7 Nov 2024 14:21:10 +0300 Subject: [PATCH 02/11] CB-5725 hide desktop handlers in auth dialog (#3052) Co-authored-by: kseniaguzeeva <112612526+kseniaguzeeva@users.noreply.github.com> Co-authored-by: Ainur <59531286+yagudin10@users.noreply.github.com> --- .../io/cloudbeaver/model/WebConnectionInfo.java | 14 ++++++++++++-- .../service/core/impl/WebServiceCore.java | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/WebConnectionInfo.java b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/WebConnectionInfo.java index 85f9d249d3..c41c22e7fb 100644 --- a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/WebConnectionInfo.java +++ b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/WebConnectionInfo.java @@ -42,6 +42,8 @@ import org.jkiss.dbeaver.model.rm.RMConstants; import org.jkiss.dbeaver.model.rm.RMProjectPermission; import org.jkiss.dbeaver.model.runtime.DBRRunnableParametrized; +import org.jkiss.dbeaver.registry.network.NetworkHandlerDescriptor; +import org.jkiss.dbeaver.registry.network.NetworkHandlerRegistry; import org.jkiss.dbeaver.runtime.DBWorkbench; import org.jkiss.utils.CommonUtils; @@ -356,8 +358,16 @@ public WebPropertyInfo[] getAuthProperties() { @Property public List getNetworkHandlersConfig() { - return dataSourceContainer.getConnectionConfiguration().getHandlers().stream() - .map(WebNetworkHandlerConfig::new).collect(Collectors.toList()); + var registry = NetworkHandlerRegistry.getInstance(); + return dataSourceContainer.getConnectionConfiguration() + .getHandlers() + .stream() + .filter(handlerConf -> { + NetworkHandlerDescriptor descriptor = registry.getDescriptor(handlerConf.getId()); + return descriptor != null && !descriptor.isDesktopHandler(); + }) + .map(WebNetworkHandlerConfig::new) + .collect(Collectors.toList()); } @Property diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/core/impl/WebServiceCore.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/core/impl/WebServiceCore.java index bb9617728e..d2751c20e7 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/core/impl/WebServiceCore.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/core/impl/WebServiceCore.java @@ -99,6 +99,7 @@ public List getAuthModels(@NotNull WebSession webSession) @Override public List getNetworkHandlers(@NotNull WebSession webSession) { return NetworkHandlerRegistry.getInstance().getDescriptors().stream() + .filter(d -> !d.isDesktopHandler()) .map(d -> new WebNetworkHandlerDescriptor(webSession, d)).collect(Collectors.toList()); } From b46bcce0a75b7b0807a3410e42f839d91e866a9f Mon Sep 17 00:00:00 2001 From: Georgii Date: Fri, 8 Nov 2024 13:51:11 +0400 Subject: [PATCH 03/11] dbeaver/dbeaver-infra#155 add node-modules to exclude (#3057) --- osgi-app.properties | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osgi-app.properties b/osgi-app.properties index 423b98ad5f..1681d2bbb2 100644 --- a/osgi-app.properties +++ b/osgi-app.properties @@ -30,4 +30,6 @@ testBundlePaths=\ additionalModuleRoots=\ opt; optionalFeatureRepositories=\ - dbeaver/product/repositories \ No newline at end of file + dbeaver/product/repositories +excludeOutputs=\ + cloudbeaver/webapp/node_modules \ No newline at end of file From 7735550544708a4a5ee6860c488e69c21b86003e Mon Sep 17 00:00:00 2001 From: alex <48489896+devnaumov@users.noreply.github.com> Date: Fri, 8 Nov 2024 15:59:31 +0100 Subject: [PATCH 04/11] CB-5743 add autoGenerated field to api (#3043) Co-authored-by: Evgenia <139753579+EvgeniaBzzz@users.noreply.github.com> --- .../io.cloudbeaver.server/schema/service.sql.graphqls | 1 + .../service/sql/WebSQLQueryResultColumn.java | 5 +++++ .../src/queries/grid/getSqlExecuteTaskResults.gql | 1 + webapp/packages/core-utils/src/index.ts | 1 + webapp/packages/core-utils/src/isNumber.ts | 10 ++++++++++ 5 files changed, 18 insertions(+) create mode 100644 webapp/packages/core-utils/src/isNumber.ts diff --git a/server/bundles/io.cloudbeaver.server/schema/service.sql.graphqls b/server/bundles/io.cloudbeaver.server/schema/service.sql.graphqls index db942decd4..a1d12c3dd5 100644 --- a/server/bundles/io.cloudbeaver.server/schema/service.sql.graphqls +++ b/server/bundles/io.cloudbeaver.server/schema/service.sql.graphqls @@ -86,6 +86,7 @@ type SQLResultColumn { precision: Int required: Boolean! + autoGenerated: Boolean! readOnly: Boolean! readOnlyStatus: String diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/sql/WebSQLQueryResultColumn.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/sql/WebSQLQueryResultColumn.java index 9dfdc218c8..1f03d70e0b 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/sql/WebSQLQueryResultColumn.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/sql/WebSQLQueryResultColumn.java @@ -105,6 +105,11 @@ public boolean isRequired() { return attrMeta.isRequired(); } + @Property + public boolean isAutoGenerated() { + return attrMeta.isAutoGenerated(); + } + @Property public boolean isReadOnly() { return DBExecUtils.isAttributeReadOnly(attrMeta); diff --git a/webapp/packages/core-sdk/src/queries/grid/getSqlExecuteTaskResults.gql b/webapp/packages/core-sdk/src/queries/grid/getSqlExecuteTaskResults.gql index 9b1ef04431..d0838d2eee 100644 --- a/webapp/packages/core-sdk/src/queries/grid/getSqlExecuteTaskResults.gql +++ b/webapp/packages/core-sdk/src/queries/grid/getSqlExecuteTaskResults.gql @@ -22,6 +22,7 @@ mutation getSqlExecuteTaskResults($taskId: ID!) { position precision required + autoGenerated readOnly readOnlyStatus scale diff --git a/webapp/packages/core-utils/src/index.ts b/webapp/packages/core-utils/src/index.ts index 9344e0c195..e6da19c3d7 100644 --- a/webapp/packages/core-utils/src/index.ts +++ b/webapp/packages/core-utils/src/index.ts @@ -88,3 +88,4 @@ export * from './getProgressPercent.js'; export * from './types/UndefinedToNull.js'; export * from './bindFunctions.js'; export * from './getDomainFromUrl.js'; +export * from './isNumber.js'; diff --git a/webapp/packages/core-utils/src/isNumber.ts b/webapp/packages/core-utils/src/isNumber.ts new file mode 100644 index 0000000000..df54dd65df --- /dev/null +++ b/webapp/packages/core-utils/src/isNumber.ts @@ -0,0 +1,10 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2024 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 isNumber(value: any): boolean { + return !isNaN(parseFloat(value)) && isFinite(value); +} From addeeb0c28b79b3050063c2c19e1942720923b26 Mon Sep 17 00:00:00 2001 From: Sychev Andrey <44414066+SychevAndrey@users.noreply.github.com> Date: Fri, 8 Nov 2024 16:01:12 +0100 Subject: [PATCH 05/11] CB-5765 refactor: remove word local from the phrase (#3063) Co-authored-by: Daria Marutkina <125263541+dariamarutkina@users.noreply.github.com> --- webapp/packages/plugin-connection-search/src/locales/en.ts | 2 +- webapp/packages/plugin-connection-search/src/locales/fr.ts | 2 +- webapp/packages/plugin-connection-search/src/locales/it.ts | 2 +- webapp/packages/plugin-connection-search/src/locales/ru.ts | 2 +- webapp/packages/plugin-connection-search/src/locales/zh.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/webapp/packages/plugin-connection-search/src/locales/en.ts b/webapp/packages/plugin-connection-search/src/locales/en.ts index d99b5104c5..47382d9b47 100644 --- a/webapp/packages/plugin-connection-search/src/locales/en.ts +++ b/webapp/packages/plugin-connection-search/src/locales/en.ts @@ -6,7 +6,7 @@ * you may not use this file except in compliance with the License. */ export default [ - ['plugin_connection_search_action_search_label', 'Find Local Database'], + ['plugin_connection_search_action_search_label', 'Find Database'], ['plugin_connection_search_settings_disable', 'Disable "{alias:plugin_connection_search_action_search_label}"'], ['plugin_connection_search_settings_disable_description', 'Disable the ability to search connections on a specific address'], ]; diff --git a/webapp/packages/plugin-connection-search/src/locales/fr.ts b/webapp/packages/plugin-connection-search/src/locales/fr.ts index a371fbcb02..47382d9b47 100644 --- a/webapp/packages/plugin-connection-search/src/locales/fr.ts +++ b/webapp/packages/plugin-connection-search/src/locales/fr.ts @@ -6,7 +6,7 @@ * you may not use this file except in compliance with the License. */ export default [ - ['plugin_connection_search_action_search_label', 'Trouver une base de données locale'], + ['plugin_connection_search_action_search_label', 'Find Database'], ['plugin_connection_search_settings_disable', 'Disable "{alias:plugin_connection_search_action_search_label}"'], ['plugin_connection_search_settings_disable_description', 'Disable the ability to search connections on a specific address'], ]; diff --git a/webapp/packages/plugin-connection-search/src/locales/it.ts b/webapp/packages/plugin-connection-search/src/locales/it.ts index d99b5104c5..47382d9b47 100644 --- a/webapp/packages/plugin-connection-search/src/locales/it.ts +++ b/webapp/packages/plugin-connection-search/src/locales/it.ts @@ -6,7 +6,7 @@ * you may not use this file except in compliance with the License. */ export default [ - ['plugin_connection_search_action_search_label', 'Find Local Database'], + ['plugin_connection_search_action_search_label', 'Find Database'], ['plugin_connection_search_settings_disable', 'Disable "{alias:plugin_connection_search_action_search_label}"'], ['plugin_connection_search_settings_disable_description', 'Disable the ability to search connections on a specific address'], ]; diff --git a/webapp/packages/plugin-connection-search/src/locales/ru.ts b/webapp/packages/plugin-connection-search/src/locales/ru.ts index 4730465083..3c2dcffd7a 100644 --- a/webapp/packages/plugin-connection-search/src/locales/ru.ts +++ b/webapp/packages/plugin-connection-search/src/locales/ru.ts @@ -6,7 +6,7 @@ * you may not use this file except in compliance with the License. */ export default [ - ['plugin_connection_search_action_search_label', 'Найти локальную базу данных'], + ['plugin_connection_search_action_search_label', 'Найти базу данных'], ['plugin_connection_search_settings_disable', 'Отключить "{alias:plugin_connection_search_action_search_label}"'], ['plugin_connection_search_settings_disable_description', 'Отключить возможность поиска подключений по заданному адресу'], ]; diff --git a/webapp/packages/plugin-connection-search/src/locales/zh.ts b/webapp/packages/plugin-connection-search/src/locales/zh.ts index fd82a90802..47382d9b47 100644 --- a/webapp/packages/plugin-connection-search/src/locales/zh.ts +++ b/webapp/packages/plugin-connection-search/src/locales/zh.ts @@ -6,7 +6,7 @@ * you may not use this file except in compliance with the License. */ export default [ - ['plugin_connection_search_action_search_label', '查找本地数据库'], + ['plugin_connection_search_action_search_label', 'Find Database'], ['plugin_connection_search_settings_disable', 'Disable "{alias:plugin_connection_search_action_search_label}"'], ['plugin_connection_search_settings_disable_description', 'Disable the ability to search connections on a specific address'], ]; From c9a87275db42678989eeca2a129118864de9ae3e Mon Sep 17 00:00:00 2001 From: Sychev Andrey <44414066+SychevAndrey@users.noreply.github.com> Date: Mon, 11 Nov 2024 12:21:24 +0100 Subject: [PATCH 06/11] CB-3757 fix: change white-space prop (#3065) --- .../src/ConfigurationWizard/Finish/FinishPage.module.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/packages/plugin-administration/src/ConfigurationWizard/Finish/FinishPage.module.css b/webapp/packages/plugin-administration/src/ConfigurationWizard/Finish/FinishPage.module.css index b7372b3744..51ea02727a 100644 --- a/webapp/packages/plugin-administration/src/ConfigurationWizard/Finish/FinishPage.module.css +++ b/webapp/packages/plugin-administration/src/ConfigurationWizard/Finish/FinishPage.module.css @@ -27,5 +27,5 @@ .message { line-height: 2; - white-space: pre; + white-space: pre-wrap; } From f1d1bb2bc22fe4e523cf0bc94794cdd511726d75 Mon Sep 17 00:00:00 2001 From: sergeyteleshev Date: Mon, 11 Nov 2024 12:23:27 +0100 Subject: [PATCH 07/11] CB-5691 AI prompt - add shortcut for Translate action (#3059) * CB-5691 adds ctrl+enter submit for textarea in form * CB-5691 removes unneeded prop: disableCtrlEnterSubmit --------- Co-authored-by: alex <48489896+devnaumov@users.noreply.github.com> --- .../core-blocks/src/FormControls/FormContext.ts | 2 +- .../core-blocks/src/FormControls/Textarea.tsx | 4 ++++ .../packages/core-blocks/src/FormControls/useForm.ts | 11 +++++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/webapp/packages/core-blocks/src/FormControls/FormContext.ts b/webapp/packages/core-blocks/src/FormControls/FormContext.ts index a676cecee9..67b2fa5c05 100644 --- a/webapp/packages/core-blocks/src/FormControls/FormContext.ts +++ b/webapp/packages/core-blocks/src/FormControls/FormContext.ts @@ -11,7 +11,7 @@ import type { IExecutor, SyncExecutor } from '@cloudbeaver/core-executor'; export type FormChangeValues = string | number | boolean | FileList | null | undefined; export type FormChangeHandler = (value: FormChangeValues, name: string | undefined) => void; -type KeyHandler = (event: React.KeyboardEvent) => void; +type KeyHandler = (event: React.KeyboardEvent) => void; export interface IChangeData { value: FormChangeValues; diff --git a/webapp/packages/core-blocks/src/FormControls/Textarea.tsx b/webapp/packages/core-blocks/src/FormControls/Textarea.tsx index 929ddd47f5..68e8a71fe2 100644 --- a/webapp/packages/core-blocks/src/FormControls/Textarea.tsx +++ b/webapp/packages/core-blocks/src/FormControls/Textarea.tsx @@ -16,6 +16,7 @@ import type { ILayoutSizeProps } from '../Containers/ILayoutSizeProps.js'; import { useTranslate } from '../localization/useTranslate.js'; import { s } from '../s.js'; import { UploadArea } from '../UploadArea.js'; +import { useCombinedHandler } from '../useCombinedHandler.js'; import { useS } from '../useS.js'; import { Field } from './Field.js'; import { FieldDescription } from './FieldDescription.js'; @@ -63,6 +64,7 @@ export const Textarea: TextareaType = observer(function Textarea({ embedded, cursorInitiallyAtEnd, uploadable, + onKeyDown, onChange = () => {}, ...rest }: ControlledProps | ObjectProps) { @@ -72,6 +74,7 @@ export const Textarea: TextareaType = observer(function Textarea({ rest = filterLayoutFakeProps(rest); const styles = useS(textareaStyle); const context = useContext(FormContext); + const handleKeyDown = useCombinedHandler(onKeyDown, context?.keyDown); const handleChange = useCallback( (value: string) => { @@ -110,6 +113,7 @@ export const Textarea: TextareaType = observer(function Textarea({ value={value ?? ''} name={name} data-embedded={embedded} + onKeyDown={handleKeyDown} onChange={event => handleChange(event.target.value)} /> {description && {description}} diff --git a/webapp/packages/core-blocks/src/FormControls/useForm.ts b/webapp/packages/core-blocks/src/FormControls/useForm.ts index 50d67bb655..1ea664b631 100644 --- a/webapp/packages/core-blocks/src/FormControls/useForm.ts +++ b/webapp/packages/core-blocks/src/FormControls/useForm.ts @@ -78,10 +78,17 @@ export function useForm(options?: IOptions): IFormContext { this.onChange.execute({ value, name }); } }, - keyDown(event: React.KeyboardEvent) { + keyDown(event: React.KeyboardEvent) { + const isCtrlEnterSubmit = + event.key === 'Enter' && + (event.ctrlKey || event.metaKey) && + this.disableEnterSubmit === false && + event.target instanceof HTMLTextAreaElement; + const isEnterSubmit = event.key === 'Enter' && this.disableEnterSubmit === false && event.target instanceof HTMLInputElement; + if (this.parent) { this.parent.keyDown(event); - } else if (event.key === 'Enter' && this.disableEnterSubmit === false) { + } else if (isCtrlEnterSubmit || isEnterSubmit) { event.preventDefault(); if (this.ref) { this.ref?.requestSubmit(); From 59c924c3d7849c59a2f4c17eae1e2c1ead440764 Mon Sep 17 00:00:00 2001 From: Sychev Andrey <44414066+SychevAndrey@users.noreply.github.com> Date: Mon, 11 Nov 2024 12:24:29 +0100 Subject: [PATCH 08/11] CB-5555 fix cursor going to the beginning on undo/redo (#3055) This commit handles the situations and sets fallback when there are text changes but selection has not been set (for example, its position outside of the doc). It that case we set the cursor in the end of the result string. It helps us to keep the cursor position more consistent. Co-authored-by: Evgenia <139753579+EvgeniaBzzz@users.noreply.github.com> Co-authored-by: mr-anton-t <42037741+mr-anton-t@users.noreply.github.com> --- .../plugin-codemirror6/src/ReactCodemirror.tsx | 10 +++++++++- .../plugin-codemirror6/src/hasInsertProperty.ts | 12 ++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 webapp/packages/plugin-codemirror6/src/hasInsertProperty.ts diff --git a/webapp/packages/plugin-codemirror6/src/ReactCodemirror.tsx b/webapp/packages/plugin-codemirror6/src/ReactCodemirror.tsx index 9c5372af72..84c683b68e 100644 --- a/webapp/packages/plugin-codemirror6/src/ReactCodemirror.tsx +++ b/webapp/packages/plugin-codemirror6/src/ReactCodemirror.tsx @@ -13,6 +13,7 @@ import { forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useS import { useObjectRef } from '@cloudbeaver/core-blocks'; +import { hasInsertProperty } from './hasInsertProperty.js'; import type { IEditorRef } from './IEditorRef.js'; import type { IReactCodeMirrorProps } from './IReactCodemirrorProps.js'; import { type IReactCodemirrorContext, ReactCodemirrorContext } from './ReactCodemirrorContext.js'; @@ -192,10 +193,17 @@ export const ReactCodemirror = observer( } } - if (cursor && isCursorInDoc && (view.state.selection.main.anchor !== cursor.anchor || view.state.selection.main.head !== cursor.head)) { + if (cursor && isCursorInDoc) { transaction.selection = cursor; } + if (hasInsertProperty(transaction.changes) && !transaction.selection) { + transaction.selection = { + anchor: transaction.changes.insert?.length ?? 0, + head: transaction.changes.insert?.length ?? 0, + }; + } + if (transaction.changes || transaction.selection) { view.dispatch(transaction); } diff --git a/webapp/packages/plugin-codemirror6/src/hasInsertProperty.ts b/webapp/packages/plugin-codemirror6/src/hasInsertProperty.ts new file mode 100644 index 0000000000..c6f6a45492 --- /dev/null +++ b/webapp/packages/plugin-codemirror6/src/hasInsertProperty.ts @@ -0,0 +1,12 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2024 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 type { ChangeSpec, Text } from '@codemirror/state'; + +export function hasInsertProperty(spec: ChangeSpec | undefined): spec is { from: number; to?: number; insert?: string | Text } { + return typeof spec === 'object' && spec !== null && 'insert' in spec; +} From 3b9275c00aabab7a977fb71a600c7f1adc38db00 Mon Sep 17 00:00:00 2001 From: sergeyteleshev Date: Mon, 11 Nov 2024 12:27:04 +0100 Subject: [PATCH 09/11] CB-5891 User - error after disabling and deleting (#3056) * CB-5891 on disable user changes form state according to its real state * CB-5891 pr fixes * CB-5891 cleanup * CB-5891 pr fixes --------- Co-authored-by: Evgenia <139753579+EvgeniaBzzz@users.noreply.github.com> --- .../Users/UserForm/AdministrationUserForm.tsx | 6 +++++- .../UserForm/AdministrationUserFormDeleteButton.tsx | 9 ++++++++- .../Administration/Users/UserForm/DisableUserDialog.tsx | 6 ++---- .../Users/UserForm/Info/UserFormInfoPart.ts | 8 ++++++++ 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/webapp/packages/plugin-authentication-administration/src/Administration/Users/UserForm/AdministrationUserForm.tsx b/webapp/packages/plugin-authentication-administration/src/Administration/Users/UserForm/AdministrationUserForm.tsx index 89251c7f6e..19e56943b7 100644 --- a/webapp/packages/plugin-authentication-administration/src/Administration/Users/UserForm/AdministrationUserForm.tsx +++ b/webapp/packages/plugin-authentication-administration/src/Administration/Users/UserForm/AdministrationUserForm.tsx @@ -77,7 +77,11 @@ export const AdministrationUserForm = observer(function AdministrationUse {editing && ( - + )}