Skip to content

Commit cda64de

Browse files
authored
Merge branch 'devel' into dbeaver/pro#7465/refactor/context-menu-ariakit
2 parents 45e9305 + a39af0f commit cda64de

File tree

46 files changed

+334
-225
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+334
-225
lines changed

server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/WebConnectionConfigInputHandler.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import io.cloudbeaver.model.WebConnectionConfig;
2020
import io.cloudbeaver.model.app.WebAppConfiguration;
21+
import io.cloudbeaver.model.session.WebSession;
2122
import io.cloudbeaver.utils.ServletAppUtils;
2223
import io.cloudbeaver.utils.WebDataSourceUtils;
2324
import org.jkiss.code.NotNull;
@@ -32,8 +33,10 @@ public class WebConnectionConfigInputHandler<T extends WebConnectionConfig, C ex
3233
private static final Log log = Log.getLog(WebConnectionConfigInputHandler.class);
3334
protected final T input;
3435
protected final DBPDataSourceRegistry registry;
36+
protected final WebSession webSession;
3537

36-
public WebConnectionConfigInputHandler(@NotNull DBPDataSourceRegistry registry, T configInput) {
38+
public WebConnectionConfigInputHandler(@NotNull WebSession webSession, @NotNull DBPDataSourceRegistry registry, T configInput) {
39+
this.webSession = webSession;
3740
this.registry = registry;
3841
this.input = configInput;
3942
}
@@ -52,6 +55,7 @@ public C createDataSourceContainer() throws DBWebException {
5255
}
5356

5457
WebDataSourceUtils.saveAuthProperties(
58+
webSession.getProgressMonitor(),
5559
newDataSource,
5660
newDataSource.getConnectionConfiguration(),
5761
input.getCredentials(),
@@ -81,6 +85,7 @@ public void updateDataSource(@NotNull C dataSource) throws DBWebException {
8185
input
8286
);
8387
WebDataSourceUtils.saveAuthProperties(
88+
webSession.getProgressMonitor(),
8489
dataSource,
8590
dataSource.getConnectionConfiguration(),
8691
input.getCredentials(),

server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/WebSessionProjectImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ public synchronized boolean updateProjectDataSources(@NotNull WSDataSourceEvent
244244
return sendDataSourceUpdatedEvent;
245245
}
246246

247+
// TODO: load project settings on project load
247248
public void refreshProjectSettings() throws DBException {
248249
if (webSession.getUser() == null) {
249250
projectSettings.clear();
@@ -359,7 +360,7 @@ public WebConnectionConfig getConnectionConfigInput(@Nullable Map<String, Object
359360

360361
@NotNull
361362
protected WebConnectionConfigInputHandler getInputConfigHandler(@NotNull WebConnectionConfig configInput) {
362-
return new WebConnectionConfigInputHandler<>(getDataSourceRegistry(), configInput);
363+
return new WebConnectionConfigInputHandler<>(webSession, getDataSourceRegistry(), configInput);
363364
}
364365

365366

server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/session/WebSession.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,6 @@ private WebSessionProjectImpl createWebProject(RMProject project) throws DBExcep
324324
} else {
325325
sessionProject = createSessionProject(project);
326326
}
327-
sessionProject.refreshProjectSettings();
328327
// do not load data sources for anonymous project
329328
if (project.getType() == RMProjectType.USER && userContext.getUser() == null) {
330329
sessionProject.setInMemory(true);
@@ -841,7 +840,7 @@ public boolean provideAuthParameters(
841840
// uncommented because we had the problem with non-native auth models
842841
// (for example, can't connect to DynamoDB if credentials are not saved)
843842
DBAAuthCredentials credentials = configuration.getAuthModel().loadCredentials(dataSourceContainer, configuration);
844-
WebDataSourceUtils.updateCredentialsFromProperties(credentials, configuration.getAuthProperties());
843+
WebDataSourceUtils.updateCredentialsFromProperties(this.progressMonitor, credentials, configuration.getAuthProperties());
845844

846845
configuration.getAuthModel().provideCredentials(dataSourceContainer, configuration, credentials);
847846
} catch (DBException e) {

server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/utils/WebDataSourceUtils.java

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
*/
1717
package io.cloudbeaver.utils;
1818

19-
import com.google.gson.Gson;
20-
import com.google.gson.GsonBuilder;
21-
import com.google.gson.InstanceCreator;
22-
import com.google.gson.Strictness;
2319
import io.cloudbeaver.DBWConstants;
2420
import io.cloudbeaver.DBWebException;
2521
import io.cloudbeaver.WebSessionProjectImpl;
@@ -34,7 +30,6 @@
3430
import org.jkiss.dbeaver.model.DBConstants;
3531
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
3632
import org.jkiss.dbeaver.model.access.DBAAuthCredentials;
37-
import org.jkiss.dbeaver.model.access.DBAAuthCredentialsWithComplexProperties;
3833
import org.jkiss.dbeaver.model.app.DBPDataSourceRegistry;
3934
import org.jkiss.dbeaver.model.app.DBPProject;
4035
import org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration;
@@ -43,7 +38,9 @@
4338
import org.jkiss.dbeaver.model.impl.auth.AuthModelDatabaseNativeCredentials;
4439
import org.jkiss.dbeaver.model.net.DBWHandlerConfiguration;
4540
import org.jkiss.dbeaver.model.net.ssh.SSHConstants;
41+
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
4642
import org.jkiss.dbeaver.model.websocket.event.datasource.WSDataSourceDisconnectEvent;
43+
import org.jkiss.dbeaver.registry.DataSourceUtils;
4744
import org.jkiss.dbeaver.registry.network.NetworkHandlerDescriptor;
4845
import org.jkiss.dbeaver.registry.network.NetworkHandlerRegistry;
4946
import org.jkiss.dbeaver.runtime.DBWorkbench;
@@ -211,31 +208,30 @@ public static WebConnectionInfo getWebConnectionInfo(
211208
return webSession.getAccessibleProjectById(projectId).getWebConnectionInfo(connectionId);
212209
}
213210

214-
215-
public static void updateCredentialsFromProperties(@NotNull DBAAuthCredentials credentials, @NotNull Map<String, ?> properties) {
216-
InstanceCreator<DBAAuthCredentials> credTypeAdapter = type -> credentials;
217-
Gson credGson = new GsonBuilder()
218-
.setStrictness(Strictness.LENIENT)
219-
.registerTypeAdapter(credentials.getClass(), credTypeAdapter)
220-
.create();
221-
222-
if (credentials instanceof DBAAuthCredentialsWithComplexProperties complexProperties) {
223-
complexProperties.updateCredentialsFromComplexProperties(properties);
211+
public static void updateCredentialsFromProperties(
212+
@NotNull DBRProgressMonitor progressMonitor,
213+
@NotNull DBAAuthCredentials credentials,
214+
@Nullable Map<String, ?> properties
215+
) {
216+
if (properties == null) {
217+
return;
224218
}
225-
credGson.fromJson(credGson.toJsonTree(properties), credentials.getClass());
219+
DataSourceUtils.updateCredentialsFromProperties(progressMonitor, credentials, properties);
226220
}
227221

228222
public static void saveAuthProperties(
223+
@NotNull DBRProgressMonitor progressMonitor,
229224
@NotNull DBPDataSourceContainer dataSourceContainer,
230225
@NotNull DBPConnectionConfiguration configuration,
231226
@Nullable Map<String, Object> authProperties,
232227
boolean saveCredentials,
233228
boolean sharedCredentials
234229
) {
235-
saveAuthProperties(dataSourceContainer, configuration, authProperties, saveCredentials, sharedCredentials, false);
230+
saveAuthProperties(progressMonitor, dataSourceContainer, configuration, authProperties, saveCredentials, sharedCredentials, false);
236231
}
237232

238233
public static void saveAuthProperties(
234+
@NotNull DBRProgressMonitor progressMonitor,
239235
@NotNull DBPDataSourceContainer dataSourceContainer,
240236
@NotNull DBPConnectionConfiguration configuration,
241237
@Nullable Map<String, Object> authProperties,
@@ -271,7 +267,7 @@ public static void saveAuthProperties(
271267
configuration.setAuthProperties(currentAuthProps);
272268
}
273269
if (!authProperties.isEmpty()) {
274-
updateCredentialsFromProperties(credentials, authProperties);
270+
updateCredentialsFromProperties(progressMonitor, credentials, authProperties);
275271
}
276272

277273
configuration.getAuthModel().saveCredentials(dataSourceContainer, configuration, credentials);

server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/core/impl/WebServiceCore.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ public WebConnectionInfo initConnection(
373373
if (saveCredentials) {
374374
// Save all passed credentials in the datasource container
375375
WebDataSourceUtils.saveAuthProperties(
376+
webSession.getProgressMonitor(),
376377
dataSourceContainer,
377378
dataSourceContainer.getConnectionConfiguration(),
378379
authProperties,
@@ -529,6 +530,7 @@ public WebConnectionInfo testConnection(
529530
}
530531
}
531532
WebDataSourceUtils.saveAuthProperties(
533+
webSession.getProgressMonitor(),
532534
testDataSource,
533535
testDataSource.getConnectionConfiguration(),
534536
configInput.getCredentials(),

server/bundles/io.cloudbeaver.service.ldap.auth/src/io/cloudbeaver/service/ldap/auth/LdapAuthProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ private String getUserDN(LdapSettings ldapSettings, String displayName) {
533533
@NotNull
534534
private List<String> getGroupForMember(String fullDN, LdapSettings ldapSettings, Map<String, Object> authParameters) {
535535
DirContext context = null;
536-
List<String> result = new ArrayList<>();
536+
Set<String> result = new LinkedHashSet<>();
537537
try {
538538
Map<String, String> environment = creteAuthEnvironment(ldapSettings);
539539
if (CommonUtils.isEmpty(ldapSettings.getBindUserDN())) {
@@ -570,7 +570,7 @@ private List<String> getGroupForMember(String fullDN, LdapSettings ldapSettings,
570570
log.error("Close resource of ldap group search failed", e);
571571
}
572572
}
573-
return result;
573+
return new ArrayList<>(result);
574574
}
575575

576576
private List<String> findGroupsByMemberOfAttribute(String fullDN, DirContext context) throws NamingException {

webapp/common-react/@dbeaver/ui-kit/src/ColorPicker/ColorGrid.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { ColorIndicator } from './ColorIndicator.js';
1010
import { type UseColorPaletteResult } from './useColorPalette.js';
1111
import { memo } from 'react';
1212
import { useTranslate } from '@dbeaver/react-translate';
13-
import { Command } from '../Command.js';
13+
import { Command } from '../Command/Command.js';
1414

1515
interface ColorGridProps {
1616
colorPalette: UseColorPaletteResult;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* CloudBeaver - Cloud Database Manager
3+
* Copyright (C) 2020-2025 DBeaver Corp and others
4+
*
5+
* Licensed under the Apache License, Version 2.0.
6+
* you may not use this file except in compliance with the License.
7+
*/
8+
import { Command as AriakitCommand, type CommandProps as AriakitCommandProps } from '@ariakit/react';
9+
10+
export interface CommandProps extends AriakitCommandProps {}
11+
12+
export function Command({ ...props }: CommandProps): React.ReactElement {
13+
return <AriakitCommand {...props} />;
14+
}

webapp/common-react/@dbeaver/ui-kit/src/Command.tsx renamed to webapp/common-react/@dbeaver/ui-kit/src/Command/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
* you may not use this file except in compliance with the License.
77
*/
88

9-
export { Command } from '@ariakit/react';
9+
export { Command, type CommandProps } from './Command.js';

webapp/common-react/@dbeaver/ui-kit/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export {
3838
type SelectItemProps,
3939
} from './Select/Select.js';
4040
export * from './Combobox/Combobox.js';
41+
export * from './Command/Command.js';
4142
export { SelectField, type SelectFieldProps, type SelectItem } from './Select/SelectField.js';
4243
export { Spinner, type SpinnerProps } from './Spinner/Spinner.js';
4344
export { Radio, RadioGroup, useRadioContext, useRadioStore, type RadioProviderProps, type RadioProps, type RadioGroupProps } from './Radio/index.js';

0 commit comments

Comments
 (0)