8000 Nc Fix/limit record in group by if it is external source by rameshmane7218 · Pull Request #11257 · nocodb/nocodb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Nc Fix/limit record in group by if it is external source #11257

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

Merged
merged 4 commits into from
Apr 30, 2025

Conversation

rameshmane7218
Copy link
Member

Change Summary

Provide summary of changes with issue number if any.

Change type

  • feat: (new feature for the user, not a new feature for build script)
  • fix: (bug fix for the user, not a fix to a build script)
  • docs: (changes to the documentation)
  • style: (formatting, missing semi colons, etc; no production code change)
  • refactor: (refactoring production code, eg. renaming a variable)
  • test: (adding missing tests, refactoring tests; no production code change)
  • chore: (updating grunt tasks etc; no production code change)

Test/ Verification

Provide summary of changes.

Additional information / screenshots (optional)

Anything for maintainers to be made aware of

@rameshmane7218 rameshmane7218 self-assigned this Apr 30, 2025
@rameshmane7218 rameshmane7218 requested a review from dstala April 30, 2025 08:58
Copy link
Contributor
coderabbitai bot commented Apr 30, 2025
📝 Walkthrough

Walkthrough

The changes introduce new logic to handle external source record visibility restrictions and refine UI behavior in the pagination and grid components. A new optional prop is added to the pagination component to adjust its offset based on grid mode. The expanded-form component now exposes a method to stop loading externally. The GroupByTable component implements a validation function to prevent loading more records than allowed for external sources, displaying an upgrade modal if the limit is exceeded. The Table and grid index components are updated to support these changes through new prop bindings and feature flag gating.

Changes

Files / Areas Changed Change Summary
Pagination.vue Added optional boolean prop isAddNewRecordGridMode. Updated conditional CSS class logic for pagination container's left offset based on this prop and group-by/add-record mode.
expanded-form/index.vue Added stopLoading function to set isLoading to false via nextTick. Exposed this function using defineExpose for external access.
grid/GroupByTable.vue Introduced expandedFormRef for referencing the expanded form. Added isExternalSource and showUpgradeToSeeMoreRecordsModal handling. Implemented validateExternalSourceRecordVisibility to block page loads beyond a threshold for external sources and trigger an upgrade modal. Integrated this validation into pagination and row navigation logic. Adjusted pagination boundary check.
grid/Table.vue Added :is-add-new-record-grid-mode="isAddNewRecordGridMode" prop binding to the LazySmartsheetPagination component in the template. No logic changes.
grid/index.vue Imported isExternalSource and blockExternalSourceRecordVisibility. Updated isCanvasGroupByTableEnabled computed property to disable the feature if external source record visibility is blocked. Added validateExternalSourceRecordVisibility function and integrated it into pagination controls. Added expandedFormRef ref to manage loading state.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant GroupByTable
    participant ExpandedForm
    participant UpgradeModal

    User->>GroupByTable: Request to change page or go to next row
    GroupByTable->>GroupByTable: validateExternalSourceRecordVisibility(page)
    alt Page limit exceeded and is external source
        GroupByTable->>UpgradeModal: showUpgradeToSeeMoreRecordsModal()
        GroupByTable->>ExpandedForm: stopLoading() (if applicable)
        Note right of GroupByTable: Abort page load
    else Page within limit
        GroupByTable->>GroupByTable: Proceed with page load
    end
Loading

Suggested reviewers

  • rameshmane7218
  • dstala

📜 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 ce24c41 and ceea7b6.

⛔ Files ignored due to path filters (1)
  • packages/nc-gui/lang/en.json is excluded by !**/*.json
📒 Files selected for processing (5)
  • packages/nc-gui/components/smartsheet/Pagination.vue (3 hunks)
  • packages/nc-gui/components/smartsheet/expanded-form/index.vue (1 hunks)
  • packages/nc-gui/components/smartsheet/grid/GroupByTable.vue (4 hunks)
  • packages/nc-gui/components/smartsheet/grid/Table.vue (1 hunks)
  • packages/nc-gui/components/smartsheet/grid/index.vue (5 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/nc-gui/components/smartsheet/expanded-form/index.vue
🚧 Files skipped from review as they are similar to previous changes (4)
  • packages/nc-gui/components/smartsheet/grid/Table.vue
  • packages/nc-gui/components/smartsheet/grid/GroupByTable.vue
  • packages/nc-gui/components/smartsheet/grid/index.vue
  • packages/nc-gui/components/smartsheet/Pagination.vue
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: pre-build-for-playwright / playwright
  • GitHub Check: unit-tests-pg
  • GitHub Check: unit-tests
  • GitHub Check: release-docker / buildx

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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 generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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
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: 0

🧹 Nitpick comments (2)
packages/nc-gui/components/smartsheet/grid/GroupByTable.vue (2)

238-247: Consider moving validation logic to a composable for reusability

The external source validation logic might be useful in other components. Consider extracting this function to a shared composable to promote reuse and maintain consistency across the application.

-const validateExternalSourceRecordVisibility = (page: number, callback?: () => void) => {
-  if (
-    (vGroup.value.paginationData?.pageSize ?? 10) * page > 100 &&
-    showUpgradeToSeeMoreRecordsModal({ isExternalSource: isExternalSource.value })
-  ) {
-    return true
-  }
-
-  callback?.()
-}

Create a new composable like useExternalSourceValidation.ts:

export function useExternalSourceValidation(paginationData, isExternalSource) {
  const { showUpgradeToSeeMoreRecordsModal } = useEeConfig()
  
  const validateRecordVisibility = (page: number, callback?: () => void) => {
    if (
      (paginationData?.pageSize ?? 10) * page > 100 &&
      showUpgradeToSeeMoreRecordsModal({ isExternalSource: isExternalSource.value })
    ) {
      return true
    }
    
    callback?.()
  }
  
  return {
    validateRecordVisibility
  }
}

Then import and use it in this component.


240-241: Magic number in validation logic

The code uses a hard-coded value of 100 as the record limit threshold. Consider extracting this to a constant or configuration value to make it more maintainable and easier to adjust if needed.

+const EXTERNAL_SOURCE_RECORD_LIMIT = 100
 
 const validateExternalSourceRecordVisibility = (page: number, callback?: () => void) => {
   if (
-    (vGroup.value.paginationData?.pageSize ?? 10) * page > 100 &&
+    (vGroup.value.paginationData?.pageSize ?? 10) * page > EXTERNAL_SOURCE_RECORD_LIMIT &&
     showUpgradeToSeeMoreRecordsModal({ isExternalSource: isExternalSource.value })
   ) {
     return true
   }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between be650df and e9591e3.

📒 Files selected for processing (5)
  • packages/nc-gui/components/smartsheet/Pagination.vue (3 hunks)
  • packages/nc-gui/components/smartsheet/expanded-form/index.vue (1 hunks)
  • packages/nc-gui/components/smartsheet/grid/GroupByTable.vue (4 hunks)
  • packages/nc-gui/components/smartsheet/grid/Table.vue (1 hunks)
  • packages/nc-gui/components/smartsheet/grid/index.vue (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: release-docker / buildx
  • GitHub Check: pre-build-for-playwright / playwright
  • GitHub Check: unit-tests
  • GitHub Check: unit-tests-pg
🔇 Additional comments (16)
packages/nc-gui/components/smartsheet/expanded-form/index.vue (2)

709-713: Proper handling of loading state through the component lifecycle.

This new stopLoading method provides a way to externally control the loading state of the expanded form, ensuring DOM updates are completed before changing the visibility state.


715-717: Exposing component functionality for external control.

Good practice to expose only the necessary methods through defineExpose. This allows parent components to manage the loading state of this component as needed.

packages/nc-gui/components/smartsheet/Pagination.vue (3)

17-17: Added prop for pagination positioning control.

The addition of this boolean prop enhances component flexibility by allowing the parent to control pagination positioning based on grid mode.


32-32: Reactive reference extraction for the new prop.

Correctly including the new prop in the reactive references to maintain reactivity throughout the component.


117-119: Refined pagination positioning for different grid modes.

This change improves the UI layout by specifying different left offset classes based on the grid mode. When in group-by view with an add-record slot:

  • Uses left-[159px] when in add-new-record grid mode
  • Uses left-[199px] otherwise

This ensures proper alignment of the pagination controls with other UI elements based on the context.

packages/nc-gui/components/smartsheet/grid/Table.vue (1)

2730-2730: Forwarding grid mode prop to pagination component.

Properly passes the isAddNewRecordGridMode state to the pagination component, ensuring consistent UI behavior between the grid and pagination components.

packages/nc-gui/components/smartsheet/grid/index.vue (3)

18-18: Added external source flag from smartsheet store.

This change allows checking whether the current data source is external, which is necessary for implementing the record visibility restriction logic.


24-25: Added external source record visibility restriction function.

Importing the blockExternalSourceRecordVisibility function from the EE config provides the mechanism to enforce visibility restrictions when needed.


210-212: Gating Canvas Group By Table feature for external sources.

This change enhances security by conditionally disabling the Canvas Group By Table feature when restrictions should be applied to external data sources. It's a key part of fixing the issue mentioned in the PR title about limiting records in group by operations for external sources.

packages/nc-gui/components/smartsheet/grid/GroupByTable.vue (7)

45-47: Added utility imports for external source validation

The addition of isExternalSource and showUpgradeToSeeMoreRecordsModal provides the necessary tools to implement record visibility restrictions for external data sources. This is a clean approach to feature gating based on source type.


53-53: New reference to expose expanded form methods

Adding expandedFormRef enables access to the expanded form component's methods, particularly stopLoading, which is used when external source validation fails.


238-247: Well-implemented validation for external source record limits

This function properly implements the business logic to restrict records in external sources:

  1. Checks if the requested page exceeds the 100 record threshold
  2. Shows an upgrade modal if needed
  3. Only calls the callback if validation passes

The conditional logic is clear and follows the "early return" pattern for failed validation.


253-253: Fix for pagination boundary condition

The modified condition correctly uses (pageSize ?? 10) - 1 instead of directly comparing with pageSize, fixing an off-by-one error in pagination boundary checks.


256-260: Integration of validation in navigation flow

The external source validation is well integrated into the navigation flow. If validation fails:

  1. The expanded form loading is stopped via stopLoading()
  2. The function returns early, preventing navigation to pages beyond the limit

This ensures a consistent user experience when limits are reached.


324-324: Validation wrapper for page change callback

The change-page prop now correctly wraps the original callback with validation, maintaining the same pattern used in goToNextRow. This ensures consistent validation across all pagination entry points.


355-355: Reference binding for expanded form component

Adding the ref binding to expandedFormRef correctly connects the template reference to the reactive reference declared earlier, enabling access to component methods like stopLoading.

Copy link
Contributor
github-actions bot commented Apr 30, 2025

Uffizzi Preview deployment-63298 was deleted.

@o1lab o1lab force-pushed the nc-fix/limit-record-in-group-by branch 3 times, most recently from 56fd565 to ce24c41 Compare April 30, 2025 10:26
@o1lab o1lab force-pushed the nc-fix/limit-record-in-group-by branch from ce24c41 to ceea7b6 Compare April 30, 2025 10:37
@rameshmane7218 rameshmane7218 merged commit 194f8e1 into develop Apr 30, 2025
20 of 22 checks passed
@rameshmane7218 rameshmane7218 deleted the nc-fix/limit-record-in-group-by branch April 30, 2025 11:32
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.

2 participants
0