From c2899e04713e1a9570b987b156639dc456d65776 Mon Sep 17 00:00:00 2001 From: naumov Date: Mon, 25 Sep 2023 12:41:52 +0200 Subject: [PATCH 1/4] CB-3197 add interface comments --- .../src/DVResultSetGroupingPresentation.tsx | 2 +- .../src/DatabaseDataModel/IDatabaseDataModel.ts | 6 ++++++ .../src/DatabaseDataModel/IDatabaseDataOptions.ts | 2 ++ .../src/DatabaseDataModel/IDatabaseDataSource.ts | 4 ++++ .../plugin-data-viewer/src/TableViewer/TableViewer.tsx | 1 + .../src/NavigationTree/ElementsTree/ElementsTree.tsx | 9 +++++++++ .../src/NavigationTree/ElementsTree/useElementsTree.ts | 3 +++ 7 files changed, 26 insertions(+), 1 deletion(-) diff --git a/webapp/packages/plugin-data-viewer-result-set-grouping/src/DVResultSetGroupingPresentation.tsx b/webapp/packages/plugin-data-viewer-result-set-grouping/src/DVResultSetGroupingPresentation.tsx index 9ab3d72630..62d9456b3d 100755 --- a/webapp/packages/plugin-data-viewer-result-set-grouping/src/DVResultSetGroupingPresentation.tsx +++ b/webapp/packages/plugin-data-viewer-result-set-grouping/src/DVResultSetGroupingPresentation.tsx @@ -15,11 +15,11 @@ import { CaptureViewContext, useDataContext } from '@cloudbeaver/core-view'; import { DataPresentationComponent, IDatabaseResultSet, TableViewerLoader } from '@cloudbeaver/plugin-data-viewer'; import { DATA_CONTEXT_DV_DDM_RS_GROUPING } from './DataContext/DATA_CONTEXT_DV_DDM_RS_GROUPING'; +import { DEFAULT_GROUPING_QUERY_OPERATION } from './DEFAULT_GROUPING_QUERY_OPERATION'; import type { IGroupingQueryState } from './IGroupingQueryState'; import { useGroupingData } from './useGroupingData'; import { useGroupingDataModel } from './useGroupingDataModel'; import { useGroupingDnDColumns } from './useGroupingDnDColumns'; -import { DEFAULT_GROUPING_QUERY_OPERATION } from './DEFAULT_GROUPING_QUERY_OPERATION'; const styles = css` drop-area { diff --git a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataModel.ts b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataModel.ts index 44be18e79c..5bf9b79f5f 100644 --- a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataModel.ts +++ b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataModel.ts @@ -16,12 +16,18 @@ export interface IRequestEventData; } +/** Represents an interface for interacting with a database. It is used for managing and requesting data. */ export interface IDatabaseDataModel { readonly id: string; readonly name: string | null; readonly source: IDatabaseDataSource; + /** Holds metadata about a data request. */ readonly requestInfo: IRequestInfo; readonly supportedDataFormats: ResultDataFormat[]; + /** + * Represents the count of records loaded from the database per request. + * It can be updated using the setCountGain method. + */ readonly countGain: number; readonly onOptionsChange: IExecutor; diff --git a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataOptions.ts b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataOptions.ts index 50f56e43e0..95a970d28d 100644 --- a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataOptions.ts +++ b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataOptions.ts @@ -12,7 +12,9 @@ export interface IDatabaseDataOptions { connectionKey: IConnectionInfoParams; schema?: string; catalog?: string; + /** A raw string representation of the query filter conditions ("id=4") */ whereFilter: string; + /** A complex object that can represent filters and sorting options of the result set */ constraints: SqlDataFilterConstraint[]; readLogs?: boolean; } diff --git a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataSource.ts b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataSource.ts index 00d33aa2a8..6d757ca5a2 100644 --- a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataSource.ts +++ b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataSource.ts @@ -17,6 +17,7 @@ export interface IRequestInfo { readonly originalQuery: string; readonly requestDuration: number; readonly requestMessage: string; + /** A string representation of the filters constraints applied to the data request. Also returns as it is in case of whereFilter */ readonly requestFilter: string; readonly source: string | null; } @@ -30,11 +31,13 @@ export interface IDatabaseDataSource; readonly results: TResult[]; readonly offset: number; readonly count: number; + /** Options of the previous request */ readonly prevOptions: Readonly | null; readonly options: TOptions | null; readonly requestInfo: IRequestInfo; @@ -80,6 +83,7 @@ export interface IDatabaseDataSource this; retry: () => Promise; + /** Allows to execute task after request or save action is done */ runTask: (task: () => Promise) => Promise; requestData: () => Promise | void; refreshData: () => Promise | void; diff --git a/webapp/packages/plugin-data-viewer/src/TableViewer/TableViewer.tsx b/webapp/packages/plugin-data-viewer/src/TableViewer/TableViewer.tsx index d16c21b5fd..53bd85dc38 100644 --- a/webapp/packages/plugin-data-viewer/src/TableViewer/TableViewer.tsx +++ b/webapp/packages/plugin-data-viewer/src/TableViewer/TableViewer.tsx @@ -99,6 +99,7 @@ interface Props { resultIndex: number | undefined; presentationId: string | undefined; valuePresentationId: string | null | undefined; + /** Hide tools panel from Table Viewer */ simple?: boolean; context?: IDataContext; className?: string; diff --git a/webapp/packages/plugin-navigation-tree/src/NavigationTree/ElementsTree/ElementsTree.tsx b/webapp/packages/plugin-navigation-tree/src/NavigationTree/ElementsTree/ElementsTree.tsx index 5dc3a73a93..ffe89ebb23 100644 --- a/webapp/packages/plugin-navigation-tree/src/NavigationTree/ElementsTree/ElementsTree.tsx +++ b/webapp/packages/plugin-navigation-tree/src/NavigationTree/ElementsTree/ElementsTree.tsx @@ -100,9 +100,18 @@ const oldStyles = css` `; export interface ElementsTreeProps extends IElementsTreeOptions, React.PropsWithChildren { + /** + * Specifies the root node for the elements tree, if applicable. + */ root?: string; selectionTree?: boolean; + /** + * Specifies a custom control component for navigation tree. + */ control?: NavTreeControlComponent; + /** + * A placeholder component to be displayed when the elements tree is empty. + */ emptyPlaceholder?: React.FC; big?: boolean; style?: ComponentStyle; diff --git a/webapp/packages/plugin-navigation-tree/src/NavigationTree/ElementsTree/useElementsTree.ts b/webapp/packages/plugin-navigation-tree/src/NavigationTree/ElementsTree/useElementsTree.ts index ab8d236078..21c746ce5b 100644 --- a/webapp/packages/plugin-navigation-tree/src/NavigationTree/ElementsTree/useElementsTree.ts +++ b/webapp/packages/plugin-navigation-tree/src/NavigationTree/ElementsTree/useElementsTree.ts @@ -71,6 +71,9 @@ export interface IElementsTreeOptions { renderers?: IElementsTreeCustomRenderer[]; nodeInfoTransformers?: IElementsTreeCustomNodeInfo[]; expandStateGetters?: IElementsTreeNodeExpandInfoGetter[]; + /** + * A field that stores the state of the node in the local storage. Ensuring that the state persists after a page refresh. + */ localState?: MetadataMap; getChildren: (id: string) => string[] | undefined; loadChildren: (id: string, manual: boolean) => Promise; From ed77027ee29405fd0ca77a8a3f8df595d2c13f0e Mon Sep 17 00:00:00 2001 From: naumov Date: Wed, 27 Sep 2023 13:55:04 +0200 Subject: [PATCH 2/4] CB-3197 make comments cleaner --- .../src/DatabaseDataModel/IDatabaseDataModel.ts | 5 +---- .../src/DatabaseDataModel/IDatabaseDataSource.ts | 2 +- .../src/TableViewer/TableViewer.tsx | 2 +- .../src/NavigationTree/ElementsTree/ElementsTree.tsx | 12 +++--------- .../NavigationTree/ElementsTree/useElementsTree.ts | 4 +--- 5 files changed, 7 insertions(+), 18 deletions(-) diff --git a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataModel.ts b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataModel.ts index 5bf9b79f5f..84ce052e64 100644 --- a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataModel.ts +++ b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataModel.ts @@ -24,10 +24,7 @@ export interface IDatabaseDataModel this; retry: () => Promise; - /** Allows to execute task after request or save action is done */ + /** Allows to perform an asynchronous action on the data source, this action will wait previous action to finish and save or load requests. The data source will have a loading and disabled state while performing an action */ runTask: (task: () => Promise) => Promise; requestData: () => Promise | void; refreshData: () => Promise | void; diff --git a/webapp/packages/plugin-data-viewer/src/TableViewer/TableViewer.tsx b/webapp/packages/plugin-data-viewer/src/TableViewer/TableViewer.tsx index 53bd85dc38..066b65ce0f 100644 --- a/webapp/packages/plugin-data-viewer/src/TableViewer/TableViewer.tsx +++ b/webapp/packages/plugin-data-viewer/src/TableViewer/TableViewer.tsx @@ -99,7 +99,7 @@ interface Props { resultIndex: number | undefined; presentationId: string | undefined; valuePresentationId: string | null | undefined; - /** Hide tools panel from Table Viewer */ + /** Display data in simple mode, some features will be hidden or disabled */ simple?: boolean; context?: IDataContext; className?: string; diff --git a/webapp/packages/plugin-navigation-tree/src/NavigationTree/ElementsTree/ElementsTree.tsx b/webapp/packages/plugin-navigation-tree/src/NavigationTree/ElementsTree/ElementsTree.tsx index ffe89ebb23..068abd6b6e 100644 --- a/webapp/packages/plugin-navigation-tree/src/NavigationTree/ElementsTree/ElementsTree.tsx +++ b/webapp/packages/plugin-navigation-tree/src/NavigationTree/ElementsTree/ElementsTree.tsx @@ -100,18 +100,12 @@ const oldStyles = css` `; export interface ElementsTreeProps extends IElementsTreeOptions, React.PropsWithChildren { - /** - * Specifies the root node for the elements tree, if applicable. - */ + /** Specifies the root path for the tree. ROOT_NODE_PATH will be used if not defined */ root?: string; selectionTree?: boolean; - /** - * Specifies a custom control component for navigation tree. - */ + /** Specifies a custom control component for navigation tree */ control?: NavTreeControlComponent; - /** - * A placeholder component to be displayed when the elements tree is empty. - */ + /** A placeholder component to be displayed when the elements tree is empty */ emptyPlaceholder?: React.FC; big?: boolean; style?: ComponentStyle; diff --git a/webapp/packages/plugin-navigation-tree/src/NavigationTree/ElementsTree/useElementsTree.ts b/webapp/packages/plugin-navigation-tree/src/NavigationTree/ElementsTree/useElementsTree.ts index 21c746ce5b..18e63c8e9f 100644 --- a/webapp/packages/plugin-navigation-tree/src/NavigationTree/ElementsTree/useElementsTree.ts +++ b/webapp/packages/plugin-navigation-tree/src/NavigationTree/ElementsTree/useElementsTree.ts @@ -71,9 +71,7 @@ export interface IElementsTreeOptions { renderers?: IElementsTreeCustomRenderer[]; nodeInfoTransformers?: IElementsTreeCustomNodeInfo[]; expandStateGetters?: IElementsTreeNodeExpandInfoGetter[]; - /** - * A field that stores the state of the node in the local storage. Ensuring that the state persists after a page refresh. - */ + /** Allows to pass external state. It can be used to manipulate a tree state from the outside or to store it in an external state */ localState?: MetadataMap; getChildren: (id: string) => string[] | undefined; loadChildren: (id: string, manual: boolean) => Promise; From 0fb44e262a68286a8ad3ff26bb70994cff7215f1 Mon Sep 17 00:00:00 2001 From: naumov Date: Wed, 27 Sep 2023 15:27:56 +0200 Subject: [PATCH 3/4] CB-3197 add comment for the indeterminateSelected --- webapp/packages/core-blocks/src/Tree/TreeNode/ITreeNodeState.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/webapp/packages/core-blocks/src/Tree/TreeNode/ITreeNodeState.ts b/webapp/packages/core-blocks/src/Tree/TreeNode/ITreeNodeState.ts index 0fc859df39..ea4b281b07 100644 --- a/webapp/packages/core-blocks/src/Tree/TreeNode/ITreeNodeState.ts +++ b/webapp/packages/core-blocks/src/Tree/TreeNode/ITreeNodeState.ts @@ -11,6 +11,7 @@ export interface ITreeNodeState { disabled?: boolean; loading?: boolean; selected?: boolean; + /** It is true when the node is neither selected nor unselected, used to indicate a mixed or partial selection in a group of sub-options */ indeterminateSelected?: boolean; externalExpanded?: boolean; expanded?: boolean; From e0a80721be07ad3df3c2667f3f783f4266b77a6c Mon Sep 17 00:00:00 2001 From: naumov Date: Thu, 28 Sep 2023 12:13:26 +0200 Subject: [PATCH 4/4] CB-3197 fix code style --- .../packages/core-blocks/src/Tree/TreeNode/ITreeNodeState.ts | 2 +- .../src/DatabaseDataModel/IDatabaseDataSource.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/webapp/packages/core-blocks/src/Tree/TreeNode/ITreeNodeState.ts b/webapp/packages/core-blocks/src/Tree/TreeNode/ITreeNodeState.ts index ea4b281b07..712f03f81d 100644 --- a/webapp/packages/core-blocks/src/Tree/TreeNode/ITreeNodeState.ts +++ b/webapp/packages/core-blocks/src/Tree/TreeNode/ITreeNodeState.ts @@ -11,7 +11,7 @@ export interface ITreeNodeState { disabled?: boolean; loading?: boolean; selected?: boolean; - /** It is true when the node is neither selected nor unselected, used to indicate a mixed or partial selection in a group of sub-options */ + /** It is true when the node is neither selected nor unselected, used to indicate a mixed or partial selection in a group of sub-options */ indeterminateSelected?: boolean; externalExpanded?: boolean; expanded?: boolean; diff --git a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataSource.ts b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataSource.ts index 58db211cdc..8a081b7f7c 100644 --- a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataSource.ts +++ b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataSource.ts @@ -83,7 +83,8 @@ export interface IDatabaseDataSource this; retry: () => Promise; - /** Allows to perform an asynchronous action on the data source, this action will wait previous action to finish and save or load requests. The data source will have a loading and disabled state while performing an action */ + /** Allows to perform an asynchronous action on the data source, this action will wait previous action to finish and save or load requests. + * The data source will have a loading and disabled state while performing an action */ runTask: (task: () => Promise) => Promise; requestData: () => Promise | void; refreshData: () => Promise | void;