Skip to content

Commit

Permalink
Merge branch 'devel' into CB-5123-license-status-insufficient-amount-…
Browse files Browse the repository at this point in the history
…users
  • Loading branch information
DenisSinelnikov committed Aug 12, 2024
2 parents 5a5b713 + 2d45b29 commit 8e4865c
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@
display: none;
}
}

.uploadButton {
margin-top: 4px;
}
43 changes: 38 additions & 5 deletions webapp/packages/core-blocks/src/FormControls/Textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -24,6 +29,7 @@ type BaseProps = Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'onChan
labelTooltip?: string;
embedded?: boolean;
cursorInitiallyAtEnd?: boolean;
uploadable?: boolean;
};

type ControlledProps = BaseProps & {
Expand Down Expand Up @@ -56,25 +62,27 @@ export const Textarea: TextareaType = observer(function Textarea({
labelTooltip,
embedded,
cursorInitiallyAtEnd,
uploadable,
onChange = () => {},
...rest
}: ControlledProps | ObjectProps<any, any>) {
const translate = useTranslate();
const textareaRef = useRef<HTMLTextAreaElement | null>(null);
const layoutProps = getLayoutProps(rest);
rest = filterLayoutFakeProps(rest);
const styles = useS(textareaStyle);
const context = useContext(FormContext);

const handleChange = useCallback(
(event: React.ChangeEvent<HTMLTextAreaElement>) => {
(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],
Expand Down Expand Up @@ -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 && <FieldDescription>{description}</FieldDescription>}
{uploadable && (
<UploadArea
className={s(styles, { uploadButton: true })}
disabled={rest.disabled || rest.readOnly}
reset
onChange={async event => {
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);
}
}}
>
<Button tag="div" disabled={rest.disabled || rest.readOnly} mod={['outlined']}>
{translate('ui_file')}
</Button>
</UploadArea>
)}
</Field>
);
});
17 changes: 17 additions & 0 deletions webapp/packages/core-utils/src/getDomainFromUrl.ts
Original file line number Diff line number Diff line change
@@ -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 '';
}
}
1 change: 1 addition & 0 deletions webapp/packages/core-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,4 @@ export * from './toSafeHtmlString';
export * from './getProgressPercent';
export * from './types/UndefinedToNull';
export * from './bindFunctions';
export * from './getDomainFromUrl';

0 comments on commit 8e4865c

Please sign in to comment.