Skip to content

Commit

Permalink
Merge branch 'devel' into CB-5706-cell-height
Browse files Browse the repository at this point in the history
  • Loading branch information
dariamarutkina authored Oct 21, 2024
2 parents 83d4076 + cbceee6 commit f956ef0
Show file tree
Hide file tree
Showing 25 changed files with 1,021 additions and 84 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/backend-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Clone Deps Repositories
uses: dbeaver/github-actions/clone-repositories@devel
with:
project_deps_path: './cloudbeaver/project.deps'
project_deps_path: "./cloudbeaver/project.deps"

- name: Set up JDK 17
uses: actions/setup-java@v4
Expand All @@ -34,9 +34,9 @@ jobs:
shell: bash
working-directory: ./cloudbeaver/deploy

- name: Archive build artifacts
uses: actions/upload-artifact@v4
with:
name: backend-build-artifacts
path: cloudbeaver/deploy/cloudbeaver
if-no-files-found: error
# - name: Archive build artifacts
# uses: actions/upload-artifact@v4
# with:
# name: backend-build-artifacts
# path: cloudbeaver/deploy/cloudbeaver
# if-no-files-found: error
14 changes: 7 additions & 7 deletions .github/workflows/frontend-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ jobs:
run: yarn clear

- run: yarn install --immutable

- run: yarn bundle
working-directory: ./webapp/packages/product-default

- run: yarn test

- name: Archive build artifacts
uses: actions/upload-artifact@v4
with:
name: frontend-build-artifacts
path: webapp/packages/product-default/lib
if-no-files-found: error
# - name: Archive build artifacts
# uses: actions/upload-artifact@v4
# with:
# name: frontend-build-artifacts
# path: webapp/packages/product-default/lib
# if-no-files-found: error
27 changes: 20 additions & 7 deletions deploy/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,35 @@ copy ..\config\DefaultConfiguration\GlobalConfiguration\.dbeaver\data-sources.js

move drivers cloudbeaver >NUL

echo Build static content
echo "Build static content"

cd ..\
mkdir .\cloudbeaver\web

cd ..\cloudbeaver\webapp
cd ..\webapp

call yarn
call yarn lerna bootstrap
call yarn lerna run bundle --no-bail --stream --scope=@cloudbeaver/product-default &::-- -- --env source-map
cd .\packages\product-default
call yarn run bundle

if %ERRORLEVEL% neq 0 (
echo 'Application build failed'
exit /b %ERRORLEVEL%
)

cd ..\..\
call yarn test

if %ERRORLEVEL% neq 0 (
echo 'Frontend tests failed'
exit /b %ERRORLEVEL%
)

cd ..\deploy

echo Copy static content
echo "Copy static content"

xcopy /E /Q ..\webapp\packages\product-default\lib cloudbeaver\web >NUL

echo Cloudbeaver is ready. Run run-server.bat in cloudbeaver folder to start the server.
echo "Cloudbeaver is ready. Run run-server.bat in cloudbeaver folder to start the server."

pause
45 changes: 26 additions & 19 deletions server/bundles/io.cloudbeaver.server/schema/service.core.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -514,18 +514,21 @@ input ConnectionConfig {
# Host, port, serverName, databaseName are also stored in mainPropertyValues for custom pages
mainPropertyValues: Object @since(version: "24.1.2")

# Connection url jdbc:{driver}://{host}[:{port}]/[{database}]
# Return connection URL jdbc:{driver}://{host}[:{port}]/[{database}]
url: String
# Properties

# Return properties list
properties: Object

# Keep-Alive interval
# Return keep-alive interval
keepAliveInterval: Int

# Return auto-commit connection state
autocommit: Boolean

# Template connection
# Return template connection state
template: Boolean
# Read-onyl connection
# Return read-only connection state
readOnly: Boolean

# User credentials
Expand All @@ -536,12 +539,10 @@ input ConnectionConfig {
selectedSecretId: ID @since(version: "23.3.5")
credentials: Object

# Map of provider properties (name/value)

# Return map of provider properties (name/value)
providerProperties: Object

# Network handlers. Map of id->property map (name/value).

# Return network handlers configuration. Map of id->property map (name/value).
networkHandlersConfig: [NetworkHandlerConfigInput!]

#### deprecated fields
Expand All @@ -565,25 +566,27 @@ input ConnectionConfig {
####################################################

extend type Query {
# Returns server config
# Return server config
serverConfig: ServerConfig!

# Return product settings
productSettings: ProductSettings! @since(version: "24.0.1")

# Returns session state ( initialize if not )
# Return session state ( initialize if not )
sessionState: SessionInfo!

# Session permissions
# Return session permissions
sessionPermissions: [ID]!

# Get driver info
driverList( id: ID ): [ DriverInfo! ]!
authModels: [DatabaseAuthModel!]!
networkHandlers: [NetworkHandlerDescriptor!]!

# List of user connections.
# Return list of user connections
userConnections( projectId: ID, id: ID, projectIds: [ID!] ): [ ConnectionInfo! ]!
# List of template connections.

# Return list of template connections by project ID
templateConnections( projectId: ID ): [ ConnectionInfo! ]!

# List of connection folders
Expand Down Expand Up @@ -613,21 +616,25 @@ extend type Mutation {
# Refresh session connection list
refreshSessionConnections: Boolean

# Refreshes session on server and returns its state
# Change session language to specified
changeSessionLanguage(locale: String): Boolean

# Create new custom connection. Custom connections exist only within the current session.
# Create new custom connection
createConnection( config: ConnectionConfig!, projectId: ID ): ConnectionInfo!

# Update specified connection
updateConnection( config: ConnectionConfig!, projectId: ID ): ConnectionInfo!

# Delete specified connection
deleteConnection( id: ID!, projectId: ID ): Boolean!

# Create new custom connection from template
createConnectionFromTemplate( templateId: ID!, projectId: ID!, connectionName: String ): ConnectionInfo!

# Create new folder
# Create new folder for connections
createConnectionFolder(parentFolderPath: ID, folderName: String!, projectId: ID ): ConnectionFolderInfo!

# Delete specified connection folder
deleteConnectionFolder( folderPath: ID!, projectId: ID ): Boolean!

# Copies connection configuration from node
Expand All @@ -636,7 +643,7 @@ extend type Mutation {
# Test connection configuration. Returns remote server version
testConnection( config: ConnectionConfig!, projectId: ID): ConnectionInfo!

# Test connection configuration. Returns remote server version
# Test network handler
testNetworkHandler( config: NetworkHandlerConfigInput! ): NetworkEndpointInfo!

# Initiate existing connection
Expand All @@ -646,7 +653,7 @@ extend type Mutation {
# Disconnect from database
closeConnection( id: ID!, projectId: ID ): ConnectionInfo!

# Changes navigator settings for connection
# Change navigator settings for connection
setConnectionNavigatorSettings( id: ID!, projectId: ID, settings: NavigatorSettingsInput!): ConnectionInfo!

#### Generic async functions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Vendor: Cloudbeaver LDAP
Bundle-Name: Cloudbeaver Web Service - LDAP
Bundle-Vendor: DBeaver Corp
Bundle-SymbolicName: io.cloudbeaver.service.ldap.auth;singleton:=true
Bundle-Version: 1.0.0.qualifier
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Vendor: Cloudbeaver Web Service - Security
Bundle-Name: Cloudbeaver Web Service - Security
Bundle-Vendor: DBeaver Corp
Bundle-SymbolicName: io.cloudbeaver.service.security;singleton:=true
Bundle-Version: 1.0.64.qualifier
Expand Down
1 change: 0 additions & 1 deletion webapp/packages/core-blocks/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ export * from './useClipboard.js';
export * from './useCombinedHandler.js';
export * from './useCombinedRef.js';
export * from './useExecutor.js';
export * from './useFn.js';
export * from './useFocus.js';
export * from './useFormValidator.js';
export * from './ResourcesHooks/useOffsetPagination.js';
Expand Down
159 changes: 159 additions & 0 deletions webapp/packages/core-blocks/src/useActivationDelay.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
/*
* 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 { afterEach, beforeEach, describe, expect, it, jest } from '@jest/globals';
import { act, renderHook } from '@testing-library/react';

import { useActivationDelay } from './useActivationDelay.js';

describe('useActivationDelay', () => {
beforeEach(() => {
jest.useFakeTimers();
});

afterEach(() => {
jest.clearAllTimers();
jest.useRealTimers();
});

it('should initially return false', () => {
const { result } = renderHook(() => useActivationDelay(false, 1000));
expect(result.current).toBe(false);
});

it('should not change state before delay when activated', () => {
const { result } = renderHook(() => useActivationDelay(true, 1000));

expect(result.current).toBe(false);

act(() => {
jest.advanceTimersByTime(500);
});

expect(result.current).toBe(false);
});

it('should change state after delay when activated', () => {
const { result } = renderHook(() => useActivationDelay(true, 1000));

act(() => {
jest.advanceTimersByTime(1000);
});

expect(result.current).toBe(true);
});

it('should fire callback after delay when activated', () => {
const callback = jest.fn();
renderHook(() => useActivationDelay(true, 1000, callback));

expect(callback).not.toHaveBeenCalled();

act(() => {
jest.advanceTimersByTime(1000);
});

expect(callback).toHaveBeenCalledTimes(1);
});

it('should handle callback changes', () => {
const initialCallback = jest.fn();
const newCallback = jest.fn();

const { rerender } = renderHook(({ callback }) => useActivationDelay(true, 1000, callback), { initialProps: { callback: initialCallback } });

rerender({ callback: newCallback });

act(() => {
jest.advanceTimersByTime(1000);
});

expect(initialCallback).not.toHaveBeenCalled();
expect(newCallback).toHaveBeenCalledTimes(1);
});

it('should clear timeout on unmount', () => {
const callback = jest.fn();
const { unmount } = renderHook(() => useActivationDelay(true, 1000, callback));

unmount();

act(() => {
jest.advanceTimersByTime(1000);
});

expect(callback).not.toHaveBeenCalled();
});

it('should not fire callback if delay changed', () => {
const callback = jest.fn();
const { rerender } = renderHook(({ delay }) => useActivationDelay(true, delay, callback), { initialProps: { delay: 1000 } });

act(() => {
jest.advanceTimersByTime(500);
});

rerender({ delay: 2000 });

act(() => {
jest.advanceTimersByTime(1500);
});

expect(callback).toHaveBeenCalledTimes(0);
});

it('should not fire callback when state changed to false', () => {
const callback = jest.fn();
const { rerender } = renderHook(({ state }) => useActivationDelay(state, 1000, callback), { initialProps: { state: true } });

act(() => {
jest.advanceTimersByTime(500);
});

rerender({ state: false });

act(() => {
jest.advanceTimersByTime(500);
});

expect(callback).toHaveBeenCalledTimes(0);
});

it('should handle rapid state changes', () => {
const callback = jest.fn();
const { rerender } = renderHook(({ state }) => useActivationDelay(state, 1000, callback), { initialProps: { state: true } });

act(() => {
jest.advanceTimersByTime(500);
});

rerender({ state: false });

act(() => {
jest.advanceTimersByTime(100);
});

rerender({ state: true });

act(() => {
jest.advanceTimersByTime(1000);
});

expect(callback).toHaveBeenCalledTimes(1);
});

it('should work with zero delay', () => {
const callback = jest.fn();
renderHook(() => useActivationDelay(true, 0, callback));

act(() => {
jest.advanceTimersByTime(0);
});

expect(callback).toHaveBeenCalledTimes(1);
});
});
Loading

0 comments on commit f956ef0

Please sign in to comment.