Skip to content

Commit

Permalink
Merge branch 'devel' into CB-5368-create-api-for-kill-session-sm
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisSinelnikov authored Oct 24, 2024
2 parents e9978c0 + 0126b20 commit 9a45d20
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,14 @@ public DBSObjectFilter getFilter() throws DBWebException {
if (!(node instanceof DBNDatabaseNode dbNode)) {
throw new DBWebException("Invalid navigator node type: " + node.getClass().getName());
}
DBSObjectFilter filter = dbNode.getNodeFilter(dbNode.getItemsMeta(), true);
return filter == null || filter.isEmpty() || !filter.isEnabled() ? null : filter;
try {
DBSObjectFilter filter = dbNode.getNodeFilter(
DBNUtils.getValidItemsMeta(session.getProgressMonitor(), dbNode),
true);
return filter == null || filter.isEmpty() || !filter.isEnabled() ? null : filter;
} catch (DBException e) {
throw new DBWebException(e);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import io.cloudbeaver.BaseWebProjectImpl;
import io.cloudbeaver.DBWebException;
import io.cloudbeaver.WebProjectImpl;
import io.cloudbeaver.WebServiceUtils;
import io.cloudbeaver.model.WebCommandContext;
import io.cloudbeaver.model.WebConnectionInfo;
Expand All @@ -43,6 +42,8 @@
import org.jkiss.dbeaver.model.exec.DBCExecutionContext;
import org.jkiss.dbeaver.model.exec.DBCExecutionContextDefaults;
import org.jkiss.dbeaver.model.navigator.*;
import org.jkiss.dbeaver.model.navigator.meta.DBXTreeItem;
import org.jkiss.dbeaver.model.rm.RMControllerProvider;
import org.jkiss.dbeaver.model.rm.RMProject;
import org.jkiss.dbeaver.model.rm.RMProjectPermission;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
Expand Down Expand Up @@ -229,8 +230,11 @@ public boolean setNavigatorNodeFilter(
}
filter.setEnabled(true);
if (node instanceof DBNDatabaseNode dbNode) {
dbNode.setNodeFilter(dbNode.getItemsMeta(), filter, true);
if (hasNodeEditPermission(webSession, node, ((WebProjectImpl) node.getOwnerProject()).getRMProject())) {
DBXTreeItem itemsMeta = DBNUtils.getValidItemsMeta(webSession.getProgressMonitor(), dbNode);
dbNode.setNodeFilter(itemsMeta, filter, true);
if (node.getOwnerProject() instanceof RMControllerProvider rmControllerProvider &&
hasNodeEditPermission(webSession, node, rmControllerProvider.getRMProject())
) {
// Save settings
dbNode.getDataSourceContainer().persistConfiguration();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,6 @@ public boolean isShowValues() {

@Override
public SQLCompletionProposalBase createProposal(@NotNull SQLCompletionRequest request, @NotNull String displayString, @NotNull String replacementString, int cursorPosition, @Nullable DBPImage image, @NotNull DBPKeywordType proposalType, @Nullable String description, @Nullable DBPNamedObject object, @NotNull Map<String, Object> params) {
return new SQLCompletionProposalBase(this, request.getWordDetector(), displayString, replacementString, cursorPosition, image, proposalType, description, object, params);
return new SQLCompletionProposalBase(request, displayString, replacementString, cursorPosition, image, proposalType, description, object, params);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
*/
import type { ILoadableState } from '@cloudbeaver/core-utils';

import type { IRouteParams } from './IRouteParams.js';

export enum AdministrationItemType {
Expand Down Expand Up @@ -84,6 +86,7 @@ export interface IAdministrationItemOptions {
replace?: IAdministrationItemReplaceOptions;
defaultSub?: string;
defaultParam?: string;
getLoader?: () => ILoadableState[] | ILoadableState;
getDrawerComponent: () => AdministrationItemDrawerComponent;
getContentComponent: () => AdministrationItemContentComponent;
onLoad?: AdministrationItemEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
box-sizing: border-box;
padding-top: 4px;
min-height: 24px;
word-break: break-word;

&.invalid {
color: var(--theme-negative);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ import {
type StyleRegistry,
ToolsActionStyles,
ToolsPanelStyles,
useAutoLoad,
useS,
} from '@cloudbeaver/core-blocks';
import { useService } from '@cloudbeaver/core-di';
import { OptionsPanelService, TabList, TabListStyles, TabsState, TabStyles } from '@cloudbeaver/core-ui';
import type { ILoadableState } from '@cloudbeaver/core-utils';
import { CaptureView } from '@cloudbeaver/core-view';

import { AdministrationCaptureViewContext } from './AdministrationCaptureViewContext.js';
Expand Down Expand Up @@ -95,6 +97,9 @@ export const Administration = observer<React.PropsWithChildren<Props>>(function
const OptionsPanel = optionsPanelService.getPanelComponent();
const visibleItems = administrationItemService.getActiveItems(configurationWizard);
const onlyActiveItem = administrationItemService.items.find(filterOnlyActive(configurationWizard));
const loaders = administrationItemService.items.reduce<ILoadableState[]>((acc, item) => [...acc, item.getLoader?.() || []].flat(), []);

useAutoLoad(Administration, loaders);

useLayoutEffect(() => {
contentRef.current?.scrollTo({ top: 0, left: 0 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const ConnectionList = observer<Props>(function ConnectionList({ connecti
}, []);

const connections = getFilteredConnections(connectionList, connectionsOrigins, filterState.filterValue);
const keys = connections.map(connection => connection.id);
const keys = connectionList.map(connection => connection.id);

return (
<Group className={s(style, { group: true })} box border medium overflow vertical>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const GrantedConnectionList = observer<Props>(function GrantedConnectionL
const [filterState] = useState<IFilterState>(() => observable({ filterValue: '' }));

const connections = getFilteredConnections(grantedConnections, connectionsOrigins, filterState.filterValue);
const keys = connections.map(connection => connection.id);
const keys = grantedConnections.map(connection => connection.id);

const selected = getComputed(() => Array.from(selectedSubjects.values()).some(v => v));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const GrantedUserList = observer<Props>(function GrantedUserList({ grante
const selected = getComputed(() => Array.from(selectedSubjects.values()).some(v => v));

const users = getFilteredUsers(grantedUsers, filterState.filterValue) as IGrantedUser[];
const keys = users.map(user => user.userId);
const keys = grantedUsers.map(user => user.userId);

const revoke = useCallback(() => {
props.onRevoke(getSelectedItems(selectedSubjects));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const UserList = observer<Props>(function UserList({ userList, grantedUse
const selected = getComputed(() => Array.from(selectedSubjects.values()).some(v => v));

const users = getFilteredUsers(userList, filterState.filterValue);
const keys = users.map(user => user.userId);
const keys = userList.map(user => user.userId);

const grant = useCallback(() => {
props.onGrant(getSelectedItems(selectedSubjects));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const ConnectionAccessGrantedList = observer<Props>(function ConnectionAc

const teams = getFilteredTeams(grantedTeams, filterState.filterValue);
const users = getFilteredUsers(grantedUsers, filterState.filterValue);
const keys = teams.map(team => team.teamId).concat(users.map(user => user.userId));
const keys = grantedTeams.map(team => team.teamId).concat(grantedUsers.map(user => user.userId));

let tableInfoText: TLocalizationToken = 'connections_connection_access_admin_info';
if (!keys.length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const ConnectionAccessList = observer<Props>(function ConnectionAccessLis

const teams = getFilteredTeams(teamList, filterState.filterValue);
const users = getFilteredUsers(userList, filterState.filterValue);
const keys = teams.map(team => team.teamId).concat(users.map(user => user.userId));
const keys = teamList.map(team => team.teamId).concat(userList.map(user => user.userId));

const selected = getComputed(() => Array.from(selectedSubjects.values()).some(v => v));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class DataGridContextMenuCellEditingService {
onClick(context) {
const source = context.data.model.source as unknown as ResultSetDataSource;
const editor = source.getAction(context.data.resultIndex, ResultSetEditAction);
editor.duplicateRow(context.data.key.row);
editor.duplicateRow(context.data.key);
},
});
this.dataGridContextMenuService.add(this.getMenuEditingToken(), {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,17 @@
border-bottom-color: var(--theme-positive) !important;
}

:global(.rdg-cell:first-child) {
border-left: 2px solid rgba(0, 0, 0, 0) !important;
}

:global(.rdg-cell-custom-highlighted-row) {
background: var(--data-grid-selected-row-color) !important;

&:global(.rdg-cell:first-child) {
border-left: 2px solid var(--data-grid-index-cell-border-color) !important;
&:global(.rdg-cell:first-child::before) {
position: absolute;
content: '';
top: 0;
left: 0;
width: 2px;
height: 100%;
background-color: var(--data-grid-index-cell-border-color);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,32 +206,32 @@ export class ResultSetEditAction extends DatabaseEditAction<IResultSetElementKey
}

duplicate(...keys: IResultSetElementKey[]): void {
const rows: IResultSetRowKey[] = [];
const result: IResultSetElementKey[] = [];
const rowKeys = new Set<string>();

for (const key of keys) {
const serialized = ResultSetDataKeysUtils.serialize(key.row);

if (!rowKeys.has(serialized)) {
rows.push(key.row);
result.push(key);
rowKeys.add(serialized);
}
}

this.duplicateRow(...rows);
this.duplicateRow(...result);
}

duplicateRow(...rows: IResultSetRowKey[]): void {
for (const row of rows) {
let value = this.data.getRowValue(row);
duplicateRow(...keys: IResultSetElementKey[]): void {
for (const key of keys) {
let value = this.data.getRowValue(key.row);

const editedValue = this.editorData.get(ResultSetDataKeysUtils.serialize(row));
const editedValue = this.editorData.get(ResultSetDataKeysUtils.serialize(key.row));

if (editedValue) {
value = editedValue.update;
}

this.addRow(row, JSON.parse(JSON.stringify(value)));
this.addRow(key.row, JSON.parse(JSON.stringify(value)), key.column);
}
}

Expand Down

0 comments on commit 9a45d20

Please sign in to comment.