Skip to content

Conversation

@dstala
Copy link
Member

@dstala dstala commented Mar 5, 2025

Change Summary

fix: Canvas throwing error in console
fix: Rollup not inheriting formula formatting options
Closes https://github.com/nocodb/nocohub/issues/4730
Closes #10712

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)

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 5, 2025

Warning

Rate limit exceeded

@o1lab has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 10 minutes and 24 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between a51beaf and cb87bc1.

📒 Files selected for processing (5)
  • packages/nc-gui/components/smartsheet/column/RollupOptions.vue (3 hunks)
  • packages/nc-gui/components/smartsheet/grid/canvas/cells/Rollup.ts (2 hunks)
  • packages/nc-gui/components/smartsheet/grid/canvas/composables/useCanvasRender.ts (2 hunks)
  • packages/nc-gui/components/smartsheet/grid/canvas/index.vue (1 hunks)
  • packages/nc-gui/components/smartsheet/grid/canvas/loaders/ImageLoader.ts (1 hunks)
📝 Walkthrough

Walkthrough

This pull request introduces changes to several components handling rollup columns and canvas rendering. In the rollup options component, a new computed property conditionally displays formatting options based on column type and metadata. The rollup cell renderer now builds its render properties conditionally when a formula-type column is detected, while other components update property access to use optional chaining. The image loader removes the cross-origin setting and calls its completion callback unconditionally, resulting in adjusted control flows.

Changes

File(s) Summary of Changes
packages/nc-gui/.../column/RollupOptions.vue Added new computed property enableFormattingOptions to conditionally render formatting options based on the rollup column’s type and metadata; added rfdc import for deep cloning.
packages/nc-gui/.../grid/canvas/cells/Rollup.ts Modified the creation of renderProps in the RollupCellRenderer by checking if the child column is of type Formula, parsing metadata, and updating references used in the rendering call.
packages/nc-gui/.../grid/canvas/composables/useCanvasRender.ts,
packages/nc-gui/.../grid/canvas/index.vue
Updated conditional checks by replacing meta.value.synced with meta.value?.synced to safely access properties and avoid runtime errors.
packages/nc-gui/.../grid/canvas/loaders/ImageLoader.ts Removed the crossOrigin assignment on the Image object and adjusted error handling to call the onSettled callback unconditionally after image load attempts.

Sequence Diagram(s)

sequenceDiagram
    participant Template as Template
    participant Computed as enableFormattingOptions
    participant Component as RollupOptions Component

    Template->>Component: Trigger render/update
    Component->>Computed: Evaluate computed property
    Computed->>Computed: Check if related column exists and inspect display type
    Computed-->>Component: Return true/false for formatting options
    Component->>Template: Render precision selection and locale switch conditionally
Loading
sequenceDiagram
    participant RCR as RollupCellRenderer
    participant Child as ChildColumn
    participant RP as RenderProps
    participant RC as renderCell

    RCR->>Child: Check if column type is Formula
    alt Is Formula
        RCR->>RP: Parse meta and update UIDT and additional metadata
    else Not Formula
        RCR->>RP: Initialize renderProps with default properties
    end
    RCR->>RC: Invoke renderCell with updated renderProps
Loading

Possibly related PRs

Suggested labels

🐛 Type: Bug, 👓 Scope : View, size:M, lgtm

Suggested reviewers

  • rameshmane7218

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 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/canvas/loaders/ImageLoader.ts (1)

138-138: Callback is now always triggered regardless of pending sprite count.

The onSettled() callback is now called unconditionally, removing the check for this.pendingSprites === 0. This ensures the callback is always triggered when an image load completes, regardless of other pending sprites.

Consider adding a comment explaining why the callback is now unconditionally invoked, as this represents a behavioral change from the previous implementation:

    } finally {
      this.pendingSprites--
-     this.onSettled?.()
+     // Always notify listeners when an image load attempt completes, regardless of pending sprites
+     this.onSettled?.()
    }
packages/nc-gui/utils/columnUtils.ts (1)

384-403: New utility function for determining number formatting availability.

This utility function improves formatting decisions for different column types, ensuring that number formatting is only applied to appropriate column/aggregation combinations.

The implementation correctly identifies restricted types and provides appropriate rules, but would benefit from documentation:

+/**
+ * Determines if number formatting should be available based on column type and aggregation function
+ * 
+ * @param type - The UI type of the column
+ * @param aggregationFunction - The aggregation function being applied
+ * @returns Whether number formatting is available for this combination
+ */
const isNumberFormattingAvailable = (type: UITypes, aggregationFunction: string) => {
  const restrictedTypes = [
    UITypes.Year,
    UITypes.Time,
    UITypes.Date,
    UITypes.DateTime,
    UITypes.CreatedTime,
    UITypes.LastModifiedTime,
    UITypes.Currency,
    UITypes.Duration,
  ]

  // For restricted types, only allow formatting for 'count' and 'countDistinct'
  if (restrictedTypes.includes(type)) {
    return ['count', 'countDistinct'].includes(aggregationFunction)
  }

  // For all other types, always allow formatting
  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 14a3ded and 5723f97.

📒 Files selected for processing (6)
  • packages/nc-gui/components/smartsheet/column/RollupOptions.vue (4 hunks)
  • packages/nc-gui/components/smartsheet/grid/canvas/cells/Rollup.ts (2 hunks)
  • packages/nc-gui/components/smartsheet/grid/canvas/composables/useCanvasRender.ts (2 hunks)
  • packages/nc-gui/components/smartsheet/grid/canvas/index.vue (1 hunks)
  • packages/nc-gui/components/smartsheet/grid/canvas/loaders/ImageLoader.ts (1 hunks)
  • packages/nc-gui/utils/columnUtils.ts (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-pg
  • GitHub Check: unit-tests
🔇 Additional comments (15)
packages/nc-gui/components/smartsheet/grid/canvas/index.vue (1)

1132-1132: Added optional chaining improves code robustness.

The use of optional chaining (meta.value?.synced) prevents potential null or undefined reference errors when accessing the synced property.

packages/nc-gui/components/smartsheet/grid/canvas/loaders/ImageLoader.ts (1)

116-140:

❓ Verification inconclusive

Image loading no longer sets cross-origin attribute.

The removal of the img.crossOrigin = 'anonymous' setting means images are now loaded without the cross-origin attribute. This change might affect how cross-origin images are handled, potentially impacting security and rendering in certain scenarios.

Check if this change could lead to CORS issues for certain image sources:


🏁 Script executed:

#!/bin/bash
# Search for any references to handling cross-origin images or CORS issues in image loading

rg -i -A 3 -B 3 "crossOrigin|cors|cross.?origin" --type ts

Length of output: 15863


Attention: Potential CORS Impact on Image Loading

After verifying the codebase, the search confirms that while other parts of the project (e.g. in the Nuxt configuration) explicitly set the cross-origin attribute, the ImageLoader in question no longer applies img.crossOrigin = 'anonymous'. This removal means that images loaded via this function will not carry a cross-origin attribute, which could lead to CORS issues if images are fetched from domains that require it (especially if they later need to be drawn to a canvas or processed further).

  • Verify that images loaded by this loader are either from the same origin or are served with proper CORS headers.
  • If cross-origin images are a possibility, consider reintroducing the crossOrigin assignment or exposing a configuration option to handle such cases.
packages/nc-gui/components/smartsheet/grid/canvas/composables/useCanvasRender.ts (2)

226-235: Added optional chaining improves code robustness.

The use of optional chaining (meta.value?.synced) prevents potential null or undefined reference errors when accessing the synced property.


457-466: Added optional chaining improves code robustness.

The use of optional chaining (meta.value?.synced) prevents potential null or undefined reference errors when accessing the synced property.

packages/nc-gui/utils/columnUtils.ts (1)

420-420: Function correctly added to exports.

The new utility function has been properly added to the module exports.

packages/nc-gui/components/smartsheet/column/RollupOptions.vue (5)

13-13: Added rfdc import for deep cloning

Good addition of the rfdc (Really Fast Deep Clone) library which will be useful for creating deep copies of objects without modifying the originals.


19-19: Initialized clone function

The clone function is properly instantiated from the imported rfdc library, allowing for efficient deep cloning throughout the component.


211-227: Added computed property to conditionally display formatting options

The new enableFormattingOptions computed property correctly determines when number formatting options should be available based on the column type and rollup function. It handles formula columns properly by checking their display_type in metadata.

This enhances the UX by only showing relevant options to users based on their column selection.


341-341: Conditional rendering of precision selection

Good improvement to conditionally show the precision form item only when number formatting is applicable to the selected column type and rollup function.


365-365: Conditional rendering of locale string option

The locale string (thousands separator) option is now correctly shown only when applicable to the selected column type and rollup function, improving the user interface clarity.

packages/nc-gui/components/smartsheet/grid/canvas/cells/Rollup.ts (5)

27-28: Improved variable declaration for renderProps

Changed the variable declaration to allow for conditional assignment based on column type, which enables more sophisticated rendering logic to follow.


29-48: Enhanced formula column handling

Added specialized handling for formula columns that properly preserves the display type and metadata from the formula configuration. This ensures that formula-based rollup columns render correctly according to their intended display format rather than just their raw type.


50-58: Added fallback renderProps initialization

Good implementation of a fallback for non-formula columns that ensures renderProps is always properly initialized before use, preventing potential undefined errors.


60-60: Updated renderAsTextFun to use renderProps

Modified to reference the uidt from renderProps.column instead of directly from childColumn, ensuring that any type transformations from formula handling are respected when determining the render function.


70-70: Updated renderCell call to use renderProps

The renderCell call now correctly uses renderProps.column instead of childColumn, ensuring that all the column transformations (especially for formula columns) are respected during the actual rendering process.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2025

Uffizzi Preview deployment-61551 was deleted.

@o1lab o1lab force-pushed the nc-canvas-related-issues branch from 5723f97 to a51beaf Compare March 5, 2025 06:56
@o1lab o1lab force-pushed the nc-canvas-related-issues branch from a51beaf to cb87bc1 Compare March 5, 2025 07:10
@DarkPhoenix2704 DarkPhoenix2704 merged commit d041f7a into develop Mar 5, 2025
22 checks passed
@DarkPhoenix2704 DarkPhoenix2704 deleted the nc-canvas-related-issues branch March 5, 2025 07:41
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.

🐛 Bug: Images are not showed on grid view

4 participants