Skip to content

Commit

Permalink
Merge branch 'devel' into CB-4289-te-dataset-change-name-for-export-f…
Browse files Browse the repository at this point in the history
…ile-to-dataset-name
  • Loading branch information
kseniaguzeeva authored Jan 22, 2024
2 parents 15630fc + 6b12407 commit 093f0b7
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ List<SMUserProvisioning> listExternalUsers(
@NotNull SMAuthProviderCustomConfiguration customConfiguration,
@NotNull SMProvisioningFilter filter
) throws DBException;

default boolean isAuthRoleProvided(SMAuthProviderCustomConfiguration configuration) {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import io.cloudbeaver.auth.CBAuthConstants;
import org.jkiss.dbeaver.DBException;

import java.util.List;

public interface WebAuthApplication extends WebApplication {
WebAuthConfiguration getAuthConfiguration();

Expand All @@ -30,4 +32,6 @@ default long getMaxSessionIdleTime() {
}

void flushConfiguration() throws DBException;

String getDefaultAuthRole();
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ public boolean isPrivate() {
public boolean isRequired() {
return descriptor.isRequired();
}
public boolean isAuthRoleProvided(SMAuthProviderCustomConfiguration configuration) {
if (descriptor.getInstance() instanceof SMProvisioner provisioner) {
return provisioner.isAuthRoleProvided(configuration);
}
return false;
}

public boolean isSupportProvisioning() {
return descriptor.getInstance() instanceof SMProvisioner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type AuthProviderConfiguration {
id: ID!
displayName: String!
disabled: Boolean!
authRoleProvided: Boolean

iconURL: String
description: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ public void createUser(
try (Connection dbCon = database.openConnection()) {
try (JDBCTransaction txn = new JDBCTransaction(dbCon)) {
createUser(dbCon, userId, metaParameters, enabled, defaultAuthRole);
String defaultTeamName = application.getAppConfiguration().getDefaultUserTeam();
if (!CommonUtils.isEmpty(defaultTeamName)) {
setUserTeams(dbCon, userId, new String[]{defaultTeamName}, userId);
}
txn.commit();
}
} catch (SQLException e) {
Expand Down Expand Up @@ -167,31 +163,32 @@ public void createUser(
dbStat.execute();
}
saveSubjectMetas(dbCon, userId, metaParameters);

String defaultTeamName = application.getAppConfiguration().getDefaultUserTeam();
if (!CommonUtils.isEmpty(defaultTeamName)) {
setUserTeams(dbCon, userId, new String[]{defaultTeamName}, userId);
}
}

@Override
public void importUsers(@NotNull SMUserImportList userImportList) throws DBException {
for (SMUserProvisioning user : userImportList.getUsers()) {
if (isSubjectExists(user.getUserId())) {
log.info("Skip already exist user: " + user.getUserId());
setUserAuthRole(user.getUserId(), userImportList.getAuthRole());
continue;
}
createUser(user.getUserId(), user.getMetaParameters(), true, userImportList.getAuthRole());
}
try (var dbCon = database.openConnection()) {
importUsers(dbCon, userImportList);
} catch (SQLException e) {
log.error("Failed attempt import user: " + e.getMessage());
}
}

protected void importUsers(@NotNull Connection connection, @NotNull SMUserImportList userImportList)
throws DBException, SQLException {
for (SMUserProvisioning user : userImportList.getUsers()) {
String authRole = user.getAuthRole() == null ? userImportList.getAuthRole() : user.getAuthRole();
if (isSubjectExists(user.getUserId())) {
log.info("User already exist : " + user.getUserId());
setUserAuthRole(connection, user.getUserId(), userImportList.getAuthRole());
setUserAuthRole(connection, user.getUserId(), authRole);
enableUser(connection, user.getUserId(), true);
continue;
}
createUser(connection, user.getUserId(), user.getMetaParameters(), true, userImportList.getAuthRole());
createUser(connection, user.getUserId(), user.getMetaParameters(), true, authRole);
}
}

Expand Down
1 change: 0 additions & 1 deletion webapp/packages/core-authentication/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ export * from './TeamMetaParametersResource';
export * from './EAdminPermission';
export * from './AUTH_SETTINGS_GROUP';
export * from './PasswordPolicyService';
export * from './usePasswordPolicy';
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.treeNodeIcon {
position: relative;
box-sizing: border-box;
pointer-events: none;
flex-shrink: 0;
width: 16px;
height: 16px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { useS } from '../../useS';
import style from './TreeNodeNested.m.css';

interface Props extends React.PropsWithChildren {
expanded?: boolean;
root?: boolean;
className?: string;
}
Expand Down
1 change: 1 addition & 0 deletions webapp/packages/core-blocks/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,5 @@ export * from './Snackbars/ActionSnackbar';
export * from './Snackbars/ProcessSnackbar';
export * from './useUserData';
export * from './useMergeRefs';
export * from './usePasswordValidation';
export * from './manifest';
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
*/
import { useCustomInputValidation } from '@cloudbeaver/core-blocks';
import { PasswordPolicyService } from '@cloudbeaver/core-authentication';
import { useService } from '@cloudbeaver/core-di';

import { PasswordPolicyService } from './PasswordPolicyService';
import { useCustomInputValidation } from './FormControls/useCustomInputValidation';

export function usePasswordPolicy() {
export function usePasswordValidation() {
const passwordPolicyService = useService(PasswordPolicyService);

const ref = useCustomInputValidation<string>(value => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
fragment AuthProviderConfigurationInfo on AuthProviderConfiguration {
id
displayName
authRoleProvided
iconURL
description
signInLink
Expand Down
2 changes: 1 addition & 1 deletion webapp/packages/core-ui/src/DragAndDrop/useDNDData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function useDNDData(context: IDataContextProvider, options: IOptions = {}
}
}

state.isDragging = monitor.isDragging();
state.isDragging = dragging;
},
}));

Expand Down
19 changes: 8 additions & 11 deletions webapp/packages/core-utils/src/TempMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class TempMap<TKey, TValue> implements Map<TKey, TValue> {
return 'TempMap';
}

private readonly deleted: TKey[];
private readonly deleted: Map<TKey, boolean>;
private readonly temp: Map<TKey, TValue>;
private flushTask: NodeJS.Timeout | null;
private readonly keysTemp: ICachedValueObject<TKey[]>;
Expand All @@ -33,7 +33,7 @@ export class TempMap<TKey, TValue> implements Map<TKey, TValue> {
constructor(private readonly target: Map<TKey, TValue>, private readonly onSync?: () => void) {
this.temp = new Map();
this.flushTask = null;
this.deleted = [];
this.deleted = new Map();
this.keysTemp = cacheValue();
this.entriesTemp = cacheValue();
this.valuesTemp = cacheValue();
Expand All @@ -45,7 +45,7 @@ export class TempMap<TKey, TValue> implements Map<TKey, TValue> {
}

isDeleted(key: TKey): boolean {
return this.deleted.includes(key);
return this.deleted.get(key) || false;
}

/**
Expand All @@ -56,7 +56,7 @@ export class TempMap<TKey, TValue> implements Map<TKey, TValue> {
clearTimeout(this.flushTask);
this.flushTask = null;
}
this.deleted.splice(0, this.deleted.length);
this.deleted.clear();
this.temp.clear();
this.keysTemp.invalidate();
this.valuesTemp.invalidate();
Expand All @@ -65,7 +65,7 @@ export class TempMap<TKey, TValue> implements Map<TKey, TValue> {

delete(key: TKey): boolean {
this.temp.delete(key);
this.deleted.push(key);
this.deleted.set(key, true);
this.scheduleFlush();
return this.has(key);
}
Expand Down Expand Up @@ -105,10 +105,7 @@ export class TempMap<TKey, TValue> implements Map<TKey, TValue> {
set(key: TKey, value: TValue): this {
this.temp.set(key, value);

const indexOfDeleted = this.deleted.indexOf(key);
if (indexOfDeleted !== -1) {
this.deleted.splice(indexOfDeleted, 1);
}
this.deleted.delete(key);

this.scheduleFlush();
return this;
Expand Down Expand Up @@ -139,10 +136,10 @@ export class TempMap<TKey, TValue> implements Map<TKey, TValue> {

this.flushTask = setTimeout(
action(() => {
for (const deleted of this.deleted) {
for (const [deleted] of this.deleted) {
this.target.delete(deleted);
}
this.deleted.splice(0, this.deleted.length);
this.deleted.clear();

for (const [key, value] of this.temp) {
this.target.set(key, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@
*/
import { observer } from 'mobx-react-lite';

import { AUTH_PROVIDER_LOCAL_ID, AuthProvidersResource, isLocalUser, usePasswordPolicy, UsersResource } from '@cloudbeaver/core-authentication';
import { Container, GroupTitle, InputField, useCustomInputValidation, useResource, useTranslate } from '@cloudbeaver/core-blocks';
import { AUTH_PROVIDER_LOCAL_ID, AuthProvidersResource, isLocalUser, UsersResource } from '@cloudbeaver/core-authentication';
import {
Container,
GroupTitle,
InputField,
useCustomInputValidation,
usePasswordValidation,
useResource,
useTranslate,
} from '@cloudbeaver/core-blocks';
import { FormMode } from '@cloudbeaver/core-ui';
import { isValuesEqual } from '@cloudbeaver/core-utils';

Expand All @@ -33,7 +41,7 @@ export const UserFormInfoCredentials = observer<Props>(function UserFormInfoCred
{ active: tabSelected && editing },
);
const authProvidersResource = useResource(UserFormInfoCredentials, AuthProvidersResource, null);
const passwordPolicyRef = usePasswordPolicy();
const passwordValidationRef = usePasswordValidation();

let local = authProvidersResource.resource.isEnabled(AUTH_PROVIDER_LOCAL_ID);

Expand All @@ -57,7 +65,7 @@ export const UserFormInfoCredentials = observer<Props>(function UserFormInfoCred
{local && (
<>
<InputField
ref={passwordPolicyRef}
ref={passwordValidationRef}
type="password"
name="password"
state={tabState.state}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ import React, { useContext, useEffect, useRef } from 'react';

import { getComputed, useExecutor, useObjectRef } from '@cloudbeaver/core-blocks';
import { useService } from '@cloudbeaver/core-di';
import { SyncExecutor } from '@cloudbeaver/core-executor';
import { EObjectFeature, type NavNode, NavNodeInfoResource } from '@cloudbeaver/core-navigation-tree';
import { resourceKeyList } from '@cloudbeaver/core-resource';
import type { IDNDData } from '@cloudbeaver/core-ui';

import { useChildren } from '../../../NodesManager/useChildren';
import { useNode } from '../../../NodesManager/useNode';
import { ElementsTreeContext } from '../ElementsTreeContext';
import type { IElementsTreeAction } from '../IElementsTreeAction';
import type { NavTreeControlComponent } from '../NavigationNodeComponent';
import type { IElementsTree } from '../useElementsTree';

Expand Down Expand Up @@ -94,7 +92,7 @@ export function useNavigationNode(node: NavNode, path: string[]): INavigationNod
}, []);

useExecutor({
executor: contextRef.context?.tree.actions || new SyncExecutor<IElementsTreeAction>(),
executor: contextRef.context?.tree.actions,
handlers: [
function refreshRoot({ type, nodeId }) {
if (type === 'show' && nodeId === node.id) {
Expand Down

0 comments on commit 093f0b7

Please sign in to comment.