Skip to content

Commit

Permalink
Merge branch 'devel' into CB-4829-te-identical-connections-i-ds-break…
Browse files Browse the repository at this point in the history
…-connections
  • Loading branch information
kseniaguzeeva authored Apr 2, 2024
2 parents 6da3744 + 44b6f8a commit 83bc6a3
Show file tree
Hide file tree
Showing 22 changed files with 168 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package io.cloudbeaver.server.jetty;

import io.cloudbeaver.model.app.WebServerConfigurationController;
import io.cloudbeaver.registry.WebServiceRegistry;
import io.cloudbeaver.server.CBApplication;
import io.cloudbeaver.server.CBServerConfig;
Expand Down Expand Up @@ -201,31 +200,19 @@ private void initSessionManager(
}
}

SessionHandler sessionHandler = new SessionHandler()/* {
public HttpCookie access(HttpSession session, boolean secure) {
HttpCookie cookie = getSessionCookie(session, _context == null ? "/" : (_context.getContextPath()), secure);
return cookie;
}
@Override
public int getRefreshCookieAge() {
// Refresh cookie always (we need it for FA requests)
return 1;
}
}*/;
var maxIdleSeconds = application.getMaxSessionIdleTime();
SessionHandler sessionHandler = new SessionHandler();
var maxIdleTime = application.getMaxSessionIdleTime();
int intMaxIdleSeconds;
if (maxIdleSeconds > Integer.MAX_VALUE) {
if (maxIdleTime > Integer.MAX_VALUE) {
log.warn("Max session idle time value is greater than Integer.MAX_VALUE. Integer.MAX_VALUE will be used instead");
intMaxIdleSeconds = Integer.MAX_VALUE;
} else {
intMaxIdleSeconds = (int) maxIdleSeconds;
maxIdleTime = Integer.MAX_VALUE;
}
intMaxIdleSeconds = (int) (maxIdleTime / 1000);
log.debug("Max http session idle time: " + intMaxIdleSeconds + "s");
sessionHandler.setMaxInactiveInterval(intMaxIdleSeconds);

DefaultSessionCache sessionCache = new DefaultSessionCache(sessionHandler);
FileSessionDataStore sessionStore = new FileSessionDataStore();

sessionStore.setStoreDir(sessionCacheFolder.toFile());
sessionCache.setSessionDataStore(sessionStore);
sessionHandler.setSessionCache(sessionCache);
Expand Down
17 changes: 7 additions & 10 deletions webapp/packages/core-blocks/src/Containers/Group.m.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
padding: 24px;
border-radius: var(--theme-group-element-radius);

> .groupTitle {
&.gap > .groupTitle {
padding: 24px 0;
margin: -24px 0;
}

&.dense {
padding: 8px;

> .groupTitle {
&.gap > .groupTitle {
padding: 8px 0;
margin: -8px 0;
}
Expand All @@ -36,16 +36,13 @@
margin-right: 25%;
}

&.box {
padding: 0;
overflow: hidden;

> .groupTitle {
padding: 24px;
margin: 0;
}
&.box > .groupTitle {
padding: 24px;
margin: 0;
}

&.box,
&.box.dense,
&.boxNoOverflow {
padding: 0;
overflow: initial;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
margin: 0;
text-transform: uppercase;
opacity: 0.9;
background-color: inherit;

&.sticky {
position: sticky;
background-color: inherit;
top: 0;
z-index: 1;
opacity: 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,8 @@ export const InputFieldState: InputFieldType = observer<InputFieldStateProps<any
return null;
}

return (
<InputFieldBase
{...rest}
ref={ref}
name={name}
value={(controlState.stringValue || controlState.defaultValue) ?? ''}
onChange={controlState.onChange}
/>
);
const defaultValue = rest.type === 'password' ? null : controlState.defaultStringValue;

return <InputFieldBase {...rest} ref={ref} name={name} value={controlState.stringValue ?? defaultValue ?? ''} onChange={controlState.onChange} />;
}),
) as InputFieldType;
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ export function useFormStateControl<TState extends Record<string, any>, TKey ext
value = value[name];
}

let stringValue: string | typeof value;
let defaultStringValue: string | typeof defaultValue;
let stringValue: string | typeof value | null;
let defaultStringValue: string | typeof defaultValue | null;
if (mapToString) {
stringValue = mapToString(value as any);
defaultStringValue = mapToString(defaultValue as any);
} else {
stringValue = isNotNullDefined(value) ? String(value) : '';
defaultStringValue = isNotNullDefined(defaultValue) ? String(defaultValue) : '';
stringValue = isNotNullDefined(value) ? String(value) : null;
defaultStringValue = isNotNullDefined(defaultValue) ? String(defaultValue) : null;
}

const hide = 'autoHide' in rest && !!rest.autoHide && presented === false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const UserFormInfoTeams = observer<Props>(function UserFormInfoTeams({ fo
return (
<>
<GroupTitle>{translate('authentication_user_team')}</GroupTitle>
<Group boxNoOverflow gap dense>
<Group boxNoOverflow box gap dense>
{teams.map(team => {
const isDefault = team.teamId === defaultTeam;
const label = `${team.teamId}${team.teamName && team.teamName !== team.teamId ? ' (' + team.teamName + ')' : ''}`;
Expand Down
12 changes: 12 additions & 0 deletions webapp/packages/plugin-data-viewer/src/TableViewer/TableGrid.m.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* 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.
*/

.presentation {
flex: 1;
overflow: auto;
}
22 changes: 12 additions & 10 deletions webapp/packages/plugin-data-viewer/src/TableViewer/TableGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
* you may not use this file except in compliance with the License.
*/
import { observer } from 'mobx-react-lite';
import styled, { css } from 'reshadow';

import { TextPlaceholder } from '@cloudbeaver/core-blocks';
import { s, TextPlaceholder } from '@cloudbeaver/core-blocks';
import type { ResultDataFormat } from '@cloudbeaver/core-sdk';

import type { IDatabaseDataModel } from '../DatabaseDataModel/IDatabaseDataModel';
import type { IDataPresentationOptions } from '../DataPresentationService';
import type { IDataTableActions } from './IDataTableActions';
import styles from './TableGrid.m.css';
import { TableStatistics } from './TableStatistics';

interface Props {
Expand All @@ -26,13 +26,6 @@ interface Props {
isStatistics: boolean;
}

const styles = css`
Presentation {
flex: 1;
overflow: auto;
}
`;

export const TableGrid = observer<Props>(function TableGrid({ model, actions, dataFormat, presentation, resultIndex, simple, isStatistics }) {
if ((presentation.dataFormat !== undefined && dataFormat !== presentation.dataFormat) || !model.source.hasResult(resultIndex)) {
if (model.isLoading()) {
Expand All @@ -49,5 +42,14 @@ export const TableGrid = observer<Props>(function TableGrid({ model, actions, da
return <TableStatistics model={model} resultIndex={resultIndex} />;
}

return styled(styles)(<Presentation dataFormat={dataFormat} model={model} actions={actions} resultIndex={resultIndex} simple={simple} />);
return (
<Presentation
dataFormat={dataFormat}
model={model}
actions={actions}
resultIndex={resultIndex}
simple={simple}
className={s(styles, { presentation: true })}
/>
);
});
4 changes: 2 additions & 2 deletions webapp/packages/plugin-help/src/Shortcuts/SHORTCUTS_DATA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ function transformKeys(keyBinding: IKeyBinding): string[] {

function transformModToDisplayKey(key: string): string {
const OS = getOS();
if (OS === OperatingSystem.windowsOS || OperatingSystem.linuxOS) {
if (OS === OperatingSystem.windowsOS || OS === OperatingSystem.linuxOS) {
return key.replace('MOD', 'CTRL');
}

if (OS === OperatingSystem.macOS) {
return key.replace('MOD', 'CMD');
return key.replace('MOD', 'CMD').replace('ALT', 'OPTION').replace('BACKSPACE', 'DELETE');
}
return key;
}
1 change: 1 addition & 0 deletions webapp/packages/plugin-help/src/Shortcuts/Shortcut.m.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
flex-shrink: 0;
font-family: monospace;
font-weight: bold;
text-transform: uppercase;
width: max-content;
padding: 4px 8px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@
}
.container {
composes: theme-typography--body2 from global;
gap: 32px;
}
.group {
gap: 16px;
}
.groupTitle,
.group {
padding: 0 !important;
}
.groupTitle {
font-weight: bold;
Expand Down
8 changes: 4 additions & 4 deletions webapp/packages/plugin-help/src/Shortcuts/ShortcutsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export const ShortcutsDialog: DialogComponent<null> = function ShortcutsDialog({
<CommonDialogWrapper size="large">
<CommonDialogHeader title={translate('shortcuts_title')} onReject={rejectDialog} />
<CommonDialogBody>
<Container className={s(styles, { container: true })} wrap overflow>
<Group className={s(styles, { group: true })} overflow>
<Container className={s(styles, { container: true })} gap wrap overflow>
<Group gap box dense overflow>
<GroupTitle className={s(styles, { groupTitle: true })}>
<Link href="https://dbeaver.com/docs/cloudbeaver/Data-editor/" target="_blank" wrapper indicator>
Data Viewer
Expand All @@ -44,7 +44,7 @@ export const ShortcutsDialog: DialogComponent<null> = function ShortcutsDialog({
<Shortcut key={shortcut.label} shortcut={shortcut} />
))}
</Group>
<Group className={s(styles, { group: true })} overflow>
<Group gap box dense overflow>
<GroupTitle className={s(styles, { groupTitle: true })}>
<Link href="https://dbeaver.com/docs/cloudbeaver/SQL-Editor/" target="_blank" wrapper indicator>
SQL Editor
Expand All @@ -54,7 +54,7 @@ export const ShortcutsDialog: DialogComponent<null> = function ShortcutsDialog({
<Shortcut key={shortcut.label} shortcut={shortcut} />
))}
</Group>
<Group className={s(styles, { group: true })} overflow>
<Group gap box dense overflow>
<GroupTitle className={s(styles, { groupTitle: true })}>
<Link href="https://dbeaver.com/docs/cloudbeaver/Database-Navigator/" target="_blank" wrapper indicator>
Navigation Tree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class ObjectPropertyTableFooterService {
menus: [MENU_OBJECT_VIEWER_FOOTER],
isApplicable: context => {
const selected = context.tryGet(DATA_CONTEXT_NAV_NODES);
return selected !== undefined && !this.navTreeSettingsService.deleting;
return selected !== undefined && this.navTreeSettingsService.deleting;
},
getItems: (_, items) => [...items, ACTION_DELETE],
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* 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 { createAction } from '@cloudbeaver/core-view';

export const ACTION_TAB_CLOSE_SQL_RESULT_GROUP = createAction('tab-close-sql-result-group', {
label: 'plugin_sql_editor_action_close_group',
tooltip: 'plugin_sql_editor_action_close_group',
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* 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 type { IDataContextProvider } from '@cloudbeaver/core-data-context';
import { Bootstrap, injectable } from '@cloudbeaver/core-di';
import { DATA_CONTEXT_TABS_CONTEXT, MENU_TAB } from '@cloudbeaver/core-ui';
import { ActionService, DATA_CONTEXT_MENU, menuExtractItems, MenuService } from '@cloudbeaver/core-view';

import { ACTION_TAB_CLOSE_SQL_RESULT_GROUP } from './ACTION_TAB_CLOSE_SQL_RESULT_GROUP';
import { DATA_CONTEXT_SQL_EDITOR_STATE } from './DATA_CONTEXT_SQL_EDITOR_STATE';
import { DATA_CONTEXT_SQL_EDITOR_RESULT_ID } from './SqlResultTabs/DATA_CONTEXT_SQL_EDITOR_RESULT_ID';
import { SqlResultTabsService } from './SqlResultTabs/SqlResultTabsService';

@injectable()
export class SqlEditorGroupTabsBootstrap extends Bootstrap {
constructor(
private readonly actionService: ActionService,
private readonly menuService: MenuService,
private readonly sqlResultTabsService: SqlResultTabsService,
) {
super();
}

register(): void {
this.menuService.addCreator({
isApplicable: context => {
const tab = context.tryGet(DATA_CONTEXT_SQL_EDITOR_RESULT_ID);
const state = context.tryGet(DATA_CONTEXT_TABS_CONTEXT);
const menu = context.hasValue(DATA_CONTEXT_MENU, MENU_TAB);
return !!tab && !!state?.enabledBaseActions && menu;
},
getItems: (context, items) => [...items, ACTION_TAB_CLOSE_SQL_RESULT_GROUP],
orderItems: (context, items) => {
const actions = menuExtractItems(items, [ACTION_TAB_CLOSE_SQL_RESULT_GROUP]);

if (actions.length > 0) {
items.push(...actions);
}

return items;
},
});

this.actionService.addHandler({
id: 'result-tabs-group-base-handler',
isActionApplicable: (context, action) => {
const menu = context.hasValue(DATA_CONTEXT_MENU, MENU_TAB);
const tab = context.tryGet(DATA_CONTEXT_SQL_EDITOR_RESULT_ID);
const sqlEditorState = context.tryGet(DATA_CONTEXT_SQL_EDITOR_STATE);

const groupId = sqlEditorState?.resultTabs.find(tabState => tabState.tabId === tab?.id)?.groupId;
const hasTabsInGroup = (sqlEditorState?.resultTabs.filter(tabState => tabState.groupId === groupId) ?? []).length > 1;

if (!menu || !tab || !hasTabsInGroup) {
return false;
}
return [ACTION_TAB_CLOSE_SQL_RESULT_GROUP].includes(action);
},
handler: async (context, action) => {
switch (action) {
case ACTION_TAB_CLOSE_SQL_RESULT_GROUP:
this.closeResultTabGroup(context);
break;
default:
break;
}
},
});
}

async closeResultTabGroup(context: IDataContextProvider) {
const tab = context.get(DATA_CONTEXT_SQL_EDITOR_RESULT_ID);
const sqlEditorState = context.get(DATA_CONTEXT_SQL_EDITOR_STATE);
const tabsContext = context.get(DATA_CONTEXT_TABS_CONTEXT);
const resultTabs = this.sqlResultTabsService.getResultTabs(sqlEditorState);

const resultTab = resultTabs.find(tabState => tabState.tabId === tab.id);
const groupResultTabs = resultTabs.filter(tab => tab.groupId === resultTab?.groupId);

groupResultTabs.forEach(groupTab => {
tabsContext.close(groupTab.tabId);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export const SqlResultTabs = observer<Props>(function SqlDataResult({ state, onT
onTabSelect?.(tab.tabId);
}

async function handleClose(tab: ITabData) {
const canClose = await sqlResultTabsService.canCloseResultTab(state, tab.tabId);
function handleClose(tab: ITabData) {
const canClose = handleCanClose(tab);

if (canClose) {
sqlResultTabsService.removeResultTab(state, tab.tabId);
Expand Down
Loading

0 comments on commit 83bc6a3

Please sign in to comment.