Skip to content

James/feat/datatable#3116

Merged
James-Baloyi merged 6 commits intoshesha-io:mainfrom
James-Baloyi:james/feat/datatable
Apr 4, 2025
Merged

James/feat/datatable#3116
James-Baloyi merged 6 commits intoshesha-io:mainfrom
James-Baloyi:james/feat/datatable

Conversation

@James-Baloyi
Copy link
Copy Markdown
Contributor

@James-Baloyi James-Baloyi commented Apr 4, 2025

Summary by CodeRabbit

  • New Features
    • Enhanced double-click behavior on table rows with configurable actions for improved interactivity.
    • Expanded table settings with additional options for security, appearance (including dimensions and style customization), and event handling.
    • Streamlined configuration interface consolidates common settings for a more intuitive user experience.
    • New optional property dblClickActionConfiguration added to support double-click actions in table components.
    • New onDblClick prop introduced for the DataTable component to handle double-click actions based on configuration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 4, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The changes consolidate and expand the handling of double-click events across the data table components. The double-click property is removed from one interface and added to another, allowing it to accept either a configurable action or a callback function. In the ReactTable component, the double-click functionality is enhanced through a new method that dispatches actions using a configurable action dispatcher. Additionally, designer components have been updated with new properties and extended settings for appearance, security, and events, with the TableWrapper now passing the new double-click configuration to the DataTable component.

Changes

File(s) Change Summary
shesha-reactjs/src/components/dataTable/interfaces.ts Added optional onDblClick property to IShaDataTableInlineEditableProps (accepting a configurable action or callback) and removed onDblClick from IShaDataTableProps.
shesha-reactjs/src/components/reactTable/index.tsx
shesha-reactjs/src/components/reactTable/interfaces.ts
Introduced performOnRowDoubleClick in ReactTable to dispatch configurable actions via useConfigurableActionDispatcher; updated onRowDoubleClick prop type to accept either a configurable action or a function.
shesha-reactjs/src/designer-components/dataTable/table/models.ts Added dblClickActionConfiguration property to ITableComponentBaseProps.
shesha-reactjs/src/designer-components/dataTable/table/tableSettings.ts Expanded table settings: New inputs for permissions, appearance (minHeight, maxHeight, containerStyle, tableStyle), empty states, and events (configurable double-click and row-save success actions) with consolidation of some common settings.
shesha-reactjs/src/designer-components/dataTable/table/tableWrapper.tsx Added new onDblClick prop in the TableWrapper component to forward dblClickActionConfiguration to the DataTable component.

Sequence Diagram(s)

sequenceDiagram
    participant User as User
    participant RT as ReactTable
    participant Dispatcher as ConfigurableActionDispatcher
    participant Action as ConfigurableAction

    User->>RT: Double-click on row (rowData, index)
    RT->>RT: Call performOnRowDoubleClick(rowData, index)
    RT->>Dispatcher: Dispatch onRowDoubleClick action
    Dispatcher->>Action: Execute action or callback
    Action-->>Dispatcher: Action result
    Dispatcher-->>RT: Return result
Loading
sequenceDiagram
    participant TW as TableWrapper
    participant DT as DataTable

    TW->>DT: Pass onDblClick (from dblClickActionConfiguration)
Loading

Poem

I'm a bunny in a field of code,
Hopping along a fresh, new mode.
Double-click actions now set the pace,
Configurable magic all over the place.
With every tweak and careful hop,
Bugs vanish and improvements never stop.
Cheers from me, the coding rabbit, nonstop! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f345a34 and c2f35ff.

📒 Files selected for processing (1)
  • shesha-reactjs/src/designer-components/dataTable/table/tableSettings.ts (17 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
shesha-reactjs/src/components/reactTable/index.tsx (3)

328-345: Ensure consistent usage of row data.
Currently, performOnRowDoubleClick accepts the entire row but refers to it as data. If only the row's original data is needed, consider passing row.original instead, to avoid confusion or unintended property usage.

-return (data,) => {
-  const evaluationContext = {
-    data,
-  };
+return (row) => {
+  const evaluationContext = {
+    data: row.original,
+  };

347-353: Validate onRowDoubleClick type.
The code assumes an object is an IConfigurableActionConfiguration and a function implies a callback. Consider adding a safeguard for null/undefined or unexpected object shapes to avoid potential runtime errors.


388-388: Arrow function creation on every render.
This inline arrow function is redefined for each row, which is typical in React, but be mindful of any performance impacts for very large tables. Caching or memoizing might be worth considering if performance becomes an issue.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d7a4164 and f345a34.

📒 Files selected for processing (6)
  • shesha-reactjs/src/components/dataTable/interfaces.ts (1 hunks)
  • shesha-reactjs/src/components/reactTable/index.tsx (3 hunks)
  • shesha-reactjs/src/components/reactTable/interfaces.ts (2 hunks)
  • shesha-reactjs/src/designer-components/dataTable/table/models.ts (2 hunks)
  • shesha-reactjs/src/designer-components/dataTable/table/tableSettings.ts (4 hunks)
  • shesha-reactjs/src/designer-components/dataTable/table/tableWrapper.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build-and-test
🔇 Additional comments (10)
shesha-reactjs/src/designer-components/dataTable/table/tableWrapper.tsx (1)

125-125: Looks good - double-click action configuration added correctly

The new onDblClick prop is successfully passed to the DataTable component, allowing it to handle double-click actions based on the provided configuration.

shesha-reactjs/src/designer-components/dataTable/table/models.ts (2)

2-2: Import added correctly

The import of IConfigurableActionConfiguration is properly added to support the new double-click action functionality.


19-19: Double-click action configuration property added correctly

The new dblClickActionConfiguration property extends the interface appropriately, maintaining consistency with the changes in other files.

shesha-reactjs/src/components/reactTable/interfaces.ts (2)

1-1: Import added correctly

The import of IConfigurableActionConfiguration is properly added to support the enhanced double-click functionality.


160-160: Enhanced double-click functionality

The onRowDoubleClick property has been successfully updated to accept either a configurable action or a callback function, providing more flexibility for handling double-click events.

shesha-reactjs/src/components/dataTable/interfaces.ts (1)

70-70: Double-click property added correctly

The onDblClick property has been successfully added to the IShaDataTableInlineEditableProps interface, consolidating double-click handling functionality and allowing for either a configurable action or a callback function.

shesha-reactjs/src/components/reactTable/index.tsx (1)

25-25: Import usage is valid.
No issues with importing multiple hooks from the same provider.

shesha-reactjs/src/designer-components/dataTable/table/tableSettings.ts (3)

123-141: Security tab additions look good.
The new permissions input correctly aligns with the intended security model.


143-256: Appearance tab additions are consistent.
The new fields (minHeight, maxHeight, containerStyle, tableStyle, noDataIcon, etc.) provide useful styling and empty-state options. No immediate concerns.


504-507: Label change is clear.
Renaming to “On Row Save” matches the corresponding logic. No issues.

Comment on lines 570 to 595
{
key: 'security',
title: 'Security',
key: 'events',
title: 'Events',
id: securityTabId,
components: [
...new DesignerToolbarSettings()
.addSettingsInput({
.addConfigurableActionConfigurator({
id: nanoid(),
propertyName: 'permissions',
label: 'Permissions',
inputType: 'permissions',
parentId: securityTabId,
jsSetting: true,
tooltip: 'Enter a list of permissions that should be associated with this component',
propertyName: "dblClickActionConfiguration",
parentId: 'root',
label: "On Double Click",
jsSetting: false,
readOnly: { _code: 'return getSettingValue(data?.readOnly);', _mode: 'code', _value: false } as any,
})
.addConfigurableActionConfigurator({
id: nanoid(),
propertyName: 'onRowSaveSuccessAction',
label: 'On Row Save Success',
parentId: crudTabId,
description: 'Custom business logic to be executed after successfull saving of new/updated row.',
hideLabel: true,
jsSetting: true,
})
.toJson()
]
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Duplicate tab ID for "events" and "security".
The 'events' tab reuses securityTabId, which can cause collisions or incorrect tab rendering. Each tab should have a unique id.

Below is a proposed fix:

-{
-  key: 'events',
-  title: 'Events',
-  id: securityTabId,
-  components: [
-    ...
-  ]
-}
+{
+  key: 'events',
+  title: 'Events',
+  id: nanoid(), // or a dedicated eventsTabId variable
+  components: [
+    ...
+  ]
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{
key: 'security',
title: 'Security',
key: 'events',
title: 'Events',
id: securityTabId,
components: [
...new DesignerToolbarSettings()
.addSettingsInput({
.addConfigurableActionConfigurator({
id: nanoid(),
propertyName: 'permissions',
label: 'Permissions',
inputType: 'permissions',
parentId: securityTabId,
jsSetting: true,
tooltip: 'Enter a list of permissions that should be associated with this component',
propertyName: "dblClickActionConfiguration",
parentId: 'root',
label: "On Double Click",
jsSetting: false,
readOnly: { _code: 'return getSettingValue(data?.readOnly);', _mode: 'code', _value: false } as any,
})
.addConfigurableActionConfigurator({
id: nanoid(),
propertyName: 'onRowSaveSuccessAction',
label: 'On Row Save Success',
parentId: crudTabId,
description: 'Custom business logic to be executed after successfull saving of new/updated row.',
hideLabel: true,
jsSetting: true,
})
.toJson()
]
}
{
key: 'events',
title: 'Events',
id: nanoid(), // or a dedicated eventsTabId variable
components: [
...new DesignerToolbarSettings()
.addConfigurableActionConfigurator({
id: nanoid(),
propertyName: "dblClickActionConfiguration",
parentId: 'root',
label: "On Double Click",
jsSetting: false,
readOnly: { _code: 'return getSettingValue(data?.readOnly);', _mode: 'code', _value: false } as any,
})
.addConfigurableActionConfigurator({
id: nanoid(),
propertyName: 'onRowSaveSuccessAction',
label: 'On Row Save Success',
parentId: crudTabId,
description: 'Custom business logic to be executed after successfull saving of new/updated row.',
hideLabel: true,
jsSetting: true,
})
.toJson()
]
}

@James-Baloyi James-Baloyi merged commit fb8234e into shesha-io:main Apr 4, 2025
1 of 4 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Sep 10, 2025
@coderabbitai coderabbitai bot mentioned this pull request Nov 24, 2025
@coderabbitai coderabbitai bot mentioned this pull request Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant