From d118287b0ec57fdc215a6d392b30edef244fd26d Mon Sep 17 00:00:00 2001 From: sergeyteleshev Date: Mon, 12 Aug 2024 13:12:18 +0200 Subject: [PATCH 1/3] Cb 5378 dm ability to use custom ssl certificate (#2808) * CB-5378 add getDomainFromUrl util function * CB-5378 add uplodable prop to textarea --------- Co-authored-by: naumov Co-authored-by: kseniaguzeeva <112612526+kseniaguzeeva@users.noreply.github.com> --- .../src/FormControls/Textarea.module.css | 4 ++ .../core-blocks/src/FormControls/Textarea.tsx | 43 ++++++++++++++++--- .../core-utils/src/getDomainFromUrl.ts | 17 ++++++++ webapp/packages/core-utils/src/index.ts | 1 + 4 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 webapp/packages/core-utils/src/getDomainFromUrl.ts diff --git a/webapp/packages/core-blocks/src/FormControls/Textarea.module.css b/webapp/packages/core-blocks/src/FormControls/Textarea.module.css index 715c8b9d85..81e048286c 100644 --- a/webapp/packages/core-blocks/src/FormControls/Textarea.module.css +++ b/webapp/packages/core-blocks/src/FormControls/Textarea.module.css @@ -30,3 +30,7 @@ display: none; } } + +.uploadButton { + margin-top: 4px; +} diff --git a/webapp/packages/core-blocks/src/FormControls/Textarea.tsx b/webapp/packages/core-blocks/src/FormControls/Textarea.tsx index fe46613168..0e93bf3b7d 100644 --- a/webapp/packages/core-blocks/src/FormControls/Textarea.tsx +++ b/webapp/packages/core-blocks/src/FormControls/Textarea.tsx @@ -8,9 +8,14 @@ import { observer } from 'mobx-react-lite'; import { useCallback, useContext, useLayoutEffect, useRef } from 'react'; +import { getTextFileReadingProcess } from '@cloudbeaver/core-utils'; + +import { Button } from '../Button'; import { filterLayoutFakeProps, getLayoutProps } from '../Containers/filterLayoutFakeProps'; import type { ILayoutSizeProps } from '../Containers/ILayoutSizeProps'; +import { useTranslate } from '../localization/useTranslate'; import { s } from '../s'; +import { UploadArea } from '../UploadArea'; import { useS } from '../useS'; import { Field } from './Field'; import { FieldDescription } from './FieldDescription'; @@ -24,6 +29,7 @@ type BaseProps = Omit, 'onChan labelTooltip?: string; embedded?: boolean; cursorInitiallyAtEnd?: boolean; + uploadable?: boolean; }; type ControlledProps = BaseProps & { @@ -56,9 +62,11 @@ export const Textarea: TextareaType = observer(function Textarea({ labelTooltip, embedded, cursorInitiallyAtEnd, + uploadable, onChange = () => {}, ...rest }: ControlledProps | ObjectProps) { + const translate = useTranslate(); const textareaRef = useRef(null); const layoutProps = getLayoutProps(rest); rest = filterLayoutFakeProps(rest); @@ -66,15 +74,15 @@ export const Textarea: TextareaType = observer(function Textarea({ const context = useContext(FormContext); const handleChange = useCallback( - (event: React.ChangeEvent) => { + (value: string) => { if (state) { - state[name] = event.target.value; + state[name] = value; } if (onChange) { - onChange(event.target.value, name); + onChange(value, name); } if (context) { - context.change(event.target.value, name); + context.change(value, name); } }, [state, name, onChange], @@ -102,9 +110,34 @@ export const Textarea: TextareaType = observer(function Textarea({ value={value ?? ''} name={name} data-embedded={embedded} - onChange={handleChange} + onChange={event => handleChange(event.target.value)} /> {description && {description}} + {uploadable && ( + { + const file = event.target.files?.[0]; + + if (!file) { + throw new Error('File is not found'); + } + + const process = getTextFileReadingProcess(file); + const value = await process.promise; + + if (value) { + handleChange(value); + } + }} + > + + + )} ); }); diff --git a/webapp/packages/core-utils/src/getDomainFromUrl.ts b/webapp/packages/core-utils/src/getDomainFromUrl.ts new file mode 100644 index 0000000000..dc0e6350d8 --- /dev/null +++ b/webapp/packages/core-utils/src/getDomainFromUrl.ts @@ -0,0 +1,17 @@ +/* + * 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 getDomainFromUrl(url: string): string { + try { + const urlObject = new URL(url); + return urlObject.hostname; + } catch (e) { + console.error('Invalid URL:', e); + return ''; + } +} diff --git a/webapp/packages/core-utils/src/index.ts b/webapp/packages/core-utils/src/index.ts index 8f1c2d4534..a821ad96d9 100644 --- a/webapp/packages/core-utils/src/index.ts +++ b/webapp/packages/core-utils/src/index.ts @@ -87,3 +87,4 @@ export * from './toSafeHtmlString'; export * from './getProgressPercent'; export * from './types/UndefinedToNull'; export * from './bindFunctions'; +export * from './getDomainFromUrl'; From de00a60aadcfb3d1b7ffc961c7d91409d6bf8a5b Mon Sep 17 00:00:00 2001 From: Ainur <59531286+yagudin10@users.noreply.github.com> Date: Mon, 12 Aug 2024 13:14:27 +0200 Subject: [PATCH 2/3] CB-4511 clear secure props if save password is disabled (#2835) Co-authored-by: Evgenia Bezborodova <139753579+EvgeniaBzzz@users.noreply.github.com> --- .../src/io/cloudbeaver/utils/WebDataSourceUtils.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/utils/WebDataSourceUtils.java b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/utils/WebDataSourceUtils.java index 6c402c6eef..aba7767b06 100644 --- a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/utils/WebDataSourceUtils.java +++ b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/utils/WebDataSourceUtils.java @@ -97,6 +97,10 @@ public static void updateHandlerConfig(DBWHandlerConfiguration handlerConfig, We private static void setSecureProperties(DBWHandlerConfiguration handlerConfig, WebNetworkHandlerConfigInput cfgInput, boolean ignoreNulls) { var secureProperties = cfgInput.getSecureProperties(); if (secureProperties == null) { + if (!handlerConfig.isSavePassword()) { + // clear all secure properties from handler config + handlerConfig.setSecureProperties(Map.of()); + } return; } for (var pr : secureProperties.entrySet()) { From 2d45b29a07c872e2938449d96a72b07ae541bda7 Mon Sep 17 00:00:00 2001 From: Ainur <59531286+yagudin10@users.noreply.github.com> Date: Mon, 12 Aug 2024 13:14:52 +0200 Subject: [PATCH 3/3] CB-5025 update cloudbeaver features fix for ai (#2823) Co-authored-by: kseniaguzeeva <112612526+kseniaguzeeva@users.noreply.github.com> --- .../src/io/cloudbeaver/service/DBWServiceInitializer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/DBWServiceInitializer.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/DBWServiceInitializer.java index cafe4bf624..23bf4529fc 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/DBWServiceInitializer.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/DBWServiceInitializer.java @@ -16,14 +16,14 @@ */ package io.cloudbeaver.service; +import io.cloudbeaver.server.CBApplication; import org.jkiss.dbeaver.DBException; -import org.jkiss.dbeaver.model.app.DBPApplication; /** * Web service implementation */ public interface DBWServiceInitializer extends DBWServiceBinding { - void initializeService(DBPApplication application) throws DBException; + void initializeService(CBApplication application) throws DBException; }