Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CB-5134. Added flag for node features #2770

Merged
merged 21 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
fe70629
CB-5134. Added flag for node features
DenisSinelnikov Jul 9, 2024
a822428
Merge branch 'devel' into CB-5134-add-filter-for-non-folders
devnaumov Jul 9, 2024
3da7eae
CB-5134 check canFilter feature
devnaumov Jul 9, 2024
9d4df36
Merge branch 'devel' into CB-5134-add-filter-for-non-folders
DenisSinelnikov Jul 9, 2024
eaa4f51
CB-5134. Added filter for connections when connected
DenisSinelnikov Jul 10, 2024
bcc6bb6
Merge branch 'devel' into CB-5134-add-filter-for-non-folders
dariamarutkina Jul 12, 2024
93336a0
Merge branch 'devel' into CB-5134-add-filter-for-non-folders
dariamarutkina Jul 12, 2024
6bb9e86
CB-5134. Fix filter for schemas
DenisSinelnikov Jul 12, 2024
5e2c531
Merge branch 'devel' into CB-5134-add-filter-for-non-folders
dariamarutkina Jul 15, 2024
6c8592e
CB-5314. Fix diagram view
DenisSinelnikov Jul 15, 2024
60892f8
CB-5314. Fix diagram view
DenisSinelnikov Jul 15, 2024
496d75f
CB-5314. Fix diagram view
DenisSinelnikov Jul 15, 2024
3c0aaf1
Merge remote-tracking branch 'origin/CB-5134-add-filter-for-non-folde…
DenisSinelnikov Jul 15, 2024
f891c2e
Merge branch 'devel' into CB-5134-add-filter-for-non-folders
dariamarutkina Jul 15, 2024
7975773
CB-5134. Refactor after review
DenisSinelnikov Jul 16, 2024
8c7f1cb
Merge branch 'devel' into CB-5134-add-filter-for-non-folders
DenisSinelnikov Jul 16, 2024
789aa35
CB-5134 fix: typescript error
Wroud Jul 16, 2024
60771ed
CB-5134 fix: typescript error
Wroud Jul 16, 2024
da63484
Merge branch 'devel' into CB-5134-add-filter-for-non-folders
Wroud Jul 16, 2024
b36e313
Merge branch 'devel' into CB-5134-add-filter-for-non-folders
dariamarutkina Jul 22, 2024
0cdacff
Merge branch 'devel' into CB-5134-add-filter-for-non-folders
alexander-skoblikov Jul 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.*;
import org.jkiss.dbeaver.model.meta.Property;
import org.jkiss.dbeaver.model.navigator.DBNDataSource;
import org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor;
import org.jkiss.dbeaver.model.struct.*;
import org.jkiss.dbeaver.model.struct.rdb.DBSCatalog;
import org.jkiss.dbeaver.model.struct.rdb.DBSSchema;
import org.jkiss.dbeaver.model.struct.rdb.DBSTable;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;


Expand Down Expand Up @@ -174,11 +177,12 @@ private static void getObjectFeatures(DBSObject object, List<String> features) {
}
if (object instanceof DBSSchema) features.add(OBJECT_FEATURE_SCHEMA);
if (object instanceof DBSCatalog) features.add(OBJECT_FEATURE_CATALOG);
if (object instanceof DBSObjectContainer) {
if (object instanceof DBSObjectContainer objectContainer) {
features.add(OBJECT_FEATURE_OBJECT_CONTAINER);
try {
Class<? extends DBSObject> childType = ((DBSObjectContainer) object).getPrimaryChildType(null);
if (DBSTable.class.isAssignableFrom(childType)) {
Class<? extends DBSObject> childType = objectContainer.getPrimaryChildType(null);
Collection<? extends DBSObject> childrenCollection = objectContainer.getChildren(null);
DenisSinelnikov marked this conversation as resolved.
Show resolved Hide resolved
if (DBSTable.class.isAssignableFrom(childType) && childrenCollection != null) {
features.add(OBJECT_FEATURE_ENTITY_CONTAINER);
}
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
import org.jkiss.dbeaver.model.navigator.*;
import org.jkiss.dbeaver.model.navigator.fs.DBNFileSystem;
import org.jkiss.dbeaver.model.navigator.fs.DBNPathBase;
import org.jkiss.dbeaver.model.navigator.meta.DBXTreeFolder;
import org.jkiss.dbeaver.model.navigator.meta.DBXTreeItem;
import org.jkiss.dbeaver.model.navigator.meta.DBXTreeNode;
import org.jkiss.dbeaver.model.rm.RMProject;
import org.jkiss.dbeaver.model.rm.RMProjectPermission;
import org.jkiss.dbeaver.model.struct.DBSEntity;
Expand All @@ -62,6 +65,7 @@ public class WebNavigatorNodeInfo {
public static final String NODE_FEATURE_CONTAINER = "container";
public static final String NODE_FEATURE_SHARED = "shared";
public static final String NODE_FEATURE_CAN_DELETE = "canDelete";
public static final String NODE_FEATURE_CAN_FILTER = "canFilter";
public static final String NODE_FEATURE_CAN_RENAME = "canRename";
private final WebSession session;
private final DBNNode node;
Expand Down Expand Up @@ -184,14 +188,30 @@ public String[] getFeatures() {
if (object instanceof DBSEntity || object instanceof DBSProcedure) {
features.add(NODE_FEATURE_LEAF);
}

}
if (node instanceof DBNContainer) {
features.add(NODE_FEATURE_CONTAINER);
}
boolean isShared = false;
if (node instanceof DBNDatabaseNode) {
isShared = !((DBNDatabaseNode) node).getOwnerProject().getName().equals(session.getUserId());
if (node instanceof DBNDataSource dataSource) {
if (dataSource.getDataSourceContainer().getDataSource() != null) {
boolean hasNonFolderNode = DBXTreeNode.hasNonFolderNode(dataSource.getMeta().getChildren(null));
if (hasNonFolderNode) {
features.add(NODE_FEATURE_CAN_FILTER);
}
}
} else if (node instanceof DBNDatabaseItem item) {
if (item.getDataSourceContainer().getDataSource() != null) {
boolean hasNonFolderNode = DBXTreeNode.hasNonFolderNode(item.getMeta().getChildren(null));
if (hasNonFolderNode) {
features.add(NODE_FEATURE_CAN_FILTER);
}
}
} else {
features.add(NODE_FEATURE_CAN_FILTER);
}
isShared = !node.getOwnerProject().getName().equals(session.getUserId());
} else if (node instanceof DBNLocalFolder) {
DataSourceFolder folder = (DataSourceFolder) ((DBNLocalFolder) node).getFolder();
DBPProject project = folder.getDataSourceRegistry().getProject();
Expand Down Expand Up @@ -300,10 +320,10 @@ public String getObjectId() {

@Property
public DBSObjectFilter getFilter() throws DBWebException {
if (!(node instanceof DBNDatabaseFolder)) {
if (!(node instanceof DBNDatabaseNode)) {
throw new DBWebException("Invalid navigator node type: " + node.getClass().getName());
}
DBSObjectFilter filter = ((DBNDatabaseFolder) node).getNodeFilter(((DBNDatabaseFolder) node).getItemsMeta(), true);
DBSObjectFilter filter = ((DBNDatabaseNode) node).getNodeFilter(((DBNDatabaseNode) node).getItemsMeta(), true);
return filter == null || filter.isEmpty() || !filter.isEnabled() ? null : filter;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,6 @@ public boolean setNavigatorNodeFilter(
if (node == null) {
throw new DBWebException("Navigator node '" + nodePath + "' not found");
}
if (!(node instanceof DBNDatabaseFolder)) {
throw new DBWebException("Invalid navigator node type: " + node.getClass().getName());
}
DBSObjectFilter filter = new DBSObjectFilter();
if (!CommonUtils.isEmpty(include)) {
filter.setInclude(include);
Expand All @@ -231,11 +228,11 @@ public boolean setNavigatorNodeFilter(
filter.setExclude(exclude);
}
filter.setEnabled(true);
((DBNDatabaseFolder) node).setNodeFilter(
((DBNDatabaseFolder) node).getItemsMeta(), filter, true);
((DBNDatabaseNode) node).setNodeFilter(
((DBNDatabaseNode) node).getItemsMeta(), filter, true);
if (hasNodeEditPermission(webSession, node, ((WebProjectImpl) node.getOwnerProject()).getRmProject())) {
// Save settings
((DBNDatabaseFolder) node).getDataSourceContainer().persistConfiguration();
((DBNDatabaseNode) node).getDataSourceContainer().persistConfiguration();
}
} catch (DBException e) {
if (e instanceof DBWebException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ export enum ENodeFeature {
'leaf' = 'leaf',
'canDelete' = 'canDelete',
'canRename' = 'canRename',
'canFilter' = 'canFilter',
'shared' = 'shared',
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import { CommonDialogService } from '@cloudbeaver/core-dialogs';
import { NotificationService } from '@cloudbeaver/core-events';
import { LocalizationService } from '@cloudbeaver/core-localization';
import { DATA_CONTEXT_NAV_NODE, NavTreeResource, NodeManagerUtils } from '@cloudbeaver/core-navigation-tree';
import { DATA_CONTEXT_NAV_NODE, ENodeFeature, NavTreeResource, NodeManagerUtils } from '@cloudbeaver/core-navigation-tree';

Check warning on line 13 in webapp/packages/plugin-navigation-tree-filters/src/NavigationTreeFiltersBootstrap.ts

View check run for this annotation

Jenkins-CI-integration / CheckStyle TypeScript Report

webapp/packages/plugin-navigation-tree-filters/src/NavigationTreeFiltersBootstrap.ts#L13

NodeManagerUtils is defined but never used. (@typescript-eslint/no-unused-vars)
import { DATA_CONTEXT_MENU, MenuBaseItem, MenuService } from '@cloudbeaver/core-view';

import { MENU_NAVIGATION_TREE_FILTERS } from './MENU_NAVIGATION_TREE_FILTERS';
Expand Down Expand Up @@ -38,7 +38,7 @@
isApplicable: context => {
const node = context.get(DATA_CONTEXT_NAV_NODE)!;

if (!node.folder || !NodeManagerUtils.isDatabaseObject(node.id)) {
if (!node.features?.includes(ENodeFeature.canFilter)) {
return false;
}

Expand Down
Loading