8000 fix(nc-gui): allow user to submit form in locked view by rameshmane7218 · Pull Request #9705 · nocodb/nocodb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(nc-gui): allow user to submit form in locked view #9705

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 3 commits into from
Oct 24, 2024

Conversation

rameshmane7218
Copy link
Member

Change Summary

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 Oct 23, 2024
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Oct 23, 2024
Copy link
Contributor
coderabbitai bot commented Oct 23, 2024
📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes in this pull request primarily involve updates to the Form.vue, Fields.vue, and FormBranding.vue components. In Form.vue, the logic for form submission and validation has been streamlined by removing unnecessary checks and adding a watcher for the isLocked state. In Fields.vue, the status handling and visual feedback for fields have been improved, including changes to color coding. Additionally, FormBranding.vue has updated the link destination for a branding element. These modifications enhance the control flow, error handling, and user feedback across the components.

Changes

File Path Change Summary
packages/nc-gui/components/smartsheet/Form.vue Updated submitForm and clearForm methods; added watcher for isLocked; refined visibility logic.
packages/nc-gui/components/smartsheet/details/Fields.vue Changed status badge color; refined fieldStatus checks; improved field update handling and feedback.
packages/nc-gui/components/general/FormBranding.vue Updated click event handler to change link destination for branding element.

Possibly related PRs

Suggested labels

size:S, lgtm

Suggested reviewers

  • dstala
  • rameshmane7218

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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 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.

@dosubot dosubot bot added 🐛 Type: Bug Something is broken or incorrect unexpectedly. 👓 Scope : View Related to views labels Oct 23, 2024
8000
@rameshmane7218 rameshmane7218 requested a review from dstala October 23, 2024 11:30
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: 1

🧹 Outside diff range and nitpick comments (6)
packages/nc-gui/components/smartsheet/details/Fields.vue (3)

Line range hint 1170-1200: Consider enhancing field validation for virtual columns.

While the validation logic is comprehensive, consider these improvements for virtual columns:

  1. Add validation for circular references in LTAR relationships
  2. Validate that referenced tables and columns exist
  3. Add more specific error messages for each validation failure case
 if ((column.uidt === UITypes.Links || column.uidt === UITypes.LinkToAnotherRecord) && isNew) {
   if (
     (!column.childColumn || !column.childTable || !column.childId) &&
     (!column.custom?.ref_model_id || !column.custom?.ref_column_id)
   ) {
+    // Add specific error message for each missing field
+    const missingFields = []
+    if (!column.childColumn) missingFields.push('Child Column')
+    if (!column.childTable) missingFields.push('Child Table')
+    if (!column.childId) missingFields.push('Child ID')
+    return {
+      isValid: false,
+      error: `Missing required fields: ${missingFields.join(', ')}`
+    }
   }
+  // Add circular reference check
+  if (isCircularReference(column)) {
+    return {
+      isValid: false,
+      error: 'Circular reference detected in LTAR relationship'
+    }
+  }
   return false
 }

Line range hint 600-700: Consider adding batch operation support for better performance.

The current implementation processes operations individually. Consider these improvements:

  1. Add batch operation support for multiple field changes
  2. Implement operation history for audit purposes
  3. Add operation debouncing for better performance during rapid changes

Line range hint 1-50: Enhance accessibility support.

Consider implementing these accessibility improvements:

  1. Add ARIA labels for interactive elements
  2. Implement focus management for keyboard navigation
  3. Add screen reader announcements for operation status changes
packages/nc-gui/components/smartsheet/Form.vue (3)

313-313: Consider notifying the user when form submission is disallowed due to permissions

In the submitForm function, the check if (!isUIAllowed('dataInsert')) return prevents form submission for users without the 'dataInsert' permission. To enhance user experience, consider notifying the user that they lack the necessary permissions.

Apply this diff to inform the user:

async function submitForm() {
  if (!isUIAllowed('dataInsert')) {
+   message.error(t('msg.error.permissionDenied'));
    return;
  }
  // ...

352-352: Consider notifying the user when form clearing is disallowed due to permissions

In the clearForm function, the check if (!isUIAllowed('dataInsert')) return prevents clearing the form for users without the 'dataInsert' permission. To improve user experience, consider informing the user that they lack the necessary permissions.

Apply this diff to notify the user:

async function clearForm() {
  if (!isUIAllowed('dataInsert')) {
+   message.error(t('msg.error.permissionDenied'));
    return;
  }
  // ...

1216-1216: Simplify the conditional expression

The condition !isLocked || (isLocked && element?.visible) can be simplified to !isLocked || element?.visible for better readability without changing the logic.

Apply this diff to simplify the condition:

- v-if="!isLocked || (isLocked && element?.visible)"
+ v-if="!isLocked || element?.visible"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ff866a6 and 101267b.

📒 Files selected for processing (2)
  • packages/nc-gui/components/smartsheet/Form.vue (17 hunks)
  • packages/nc-gui/components/smartsheet/details/Fields.vue (1 hunks)
🧰 Additional context used
🔇 Additional comments (4)
packages/nc-gui/components/smartsheet/details/Fields.vue (2)

1170-1170: LGTM! Improved color semantics for new field status.

The change from orange to green for new field status badges improves visual clarity and follows common UI patterns where green represents successful additions.


Line range hint 1-1500: Changes align with PR objectives.

The modifications to field state management and validation feedback support the PR's goal of improving form submission in locked view by providing better visual feedback and state management.

packages/nc-gui/components/smartsheet/Form.vue (2)

976-976: Verify the condition for disabling the tooltip

The :disabled attribute in <NcTooltip :disabled="isEeUI || isLocked"> disables the tooltip when isEeUI is true or isLocked is true. If the intention is to show the tooltip when the feature is not available (i.e., !isEeUI), consider revising the condition to ensure the tooltip behaves as expected.


2135-2141: LGTM!

The added CSS styles enhance the hover effect for the .nc-textarea-rich-editor class within the .editable class, improving user experience.

Comment on lines +800 to +807
watch(isLocked, (newValue) => {
if (newValue) {
activeRow.value = ''
}

clearForm()
})

Copy link
Contributor
@coderabbitai coderabbitai bot Oct 23, 2024

Choose a reason for hiding this comment

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

⚠️ Potential issue

Ensure form is only cleared when the form becomes locked

In the watcher for isLocked, the clearForm() function is called unconditionally whenever isLocked changes, regardless of its value. This may result in the form being cleared even when the form becomes unlocked, which could disrupt the user's input. Consider modifying the logic to call clearForm() only when isLocked changes to true.

Apply this diff to modify the logic:

watch(isLocked, (newValue) => {
  if (newValue) {
    activeRow.value = ''
+   clearForm()
  }
})
📝 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
watch(isLocked, (newValue) => {
if (newValue) {
activeRow.value = ''
}
clearForm()
})
watch(isLocked, (newValue) => {
if (newValue) {
activeRow.value = ''
clearForm()
}
})

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, thats what we wanted here

Copy link
Member Author

Choose a reason for hiding this comment

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

clearForm fucntion will reload the form

Copy link
Contributor

Choose a reason for hiding this comment

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

@rameshmane7218, glad to hear that! 😊

(_/)
( ^‿^)
c(")(")


If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!

Copy link
Contributor

Choose a reason for hiding this comment

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

@rameshmane7218, understood. Thank you for the clarification.

(^・ェ・^)


✏️ Learnings added
Learnt from: rameshmane7218
PR: nocodb/nocodb#9705
File: packages/nc-gui/components/smartsheet/Form.vue:800-807
Timestamp: 2024-10-24T06:00:55.861Z
Learning: The `clearForm()` function in `packages/nc-gui/components/smartsheet/Form.vue` reloads the form, and it is intended to be called unconditionally when `isLocked` changes.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Copy link
Contributor
github-actions bot commented Oct 23, 2024

Uffizzi Preview deployment-57548 was deleted.

@o1lab o1lab force-pushed the nc-fix/allow-user-to-submit-form-in-locked-view branch from 101267b to a940e73 Compare October 24, 2024 05:55
@o1lab o1lab force-pushed the nc-fix/allow-user-to-submit-form-in-locked-view branch from a940e73 to 5311c2a Compare October 24, 2024 06:40
Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reas 8000 on will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (3)
packages/nc-gui/components/general/FormBranding.vue (3)

6-6: LGTM! Consider security improvements for external link.

The URL change from GitHub to the product website is appropriate for branding. However, consider implementing proper security measures for external links.

Consider updating the template to use an anchor tag with security attributes:

-    @click="openLink('https://www.nocodb.com')"
+    <a
+      href="https://www.nocodb.com"
+      target="_blank"
+      rel="noopener noreferrer"
+      class="flex items-center gap-3"
+    >

Line range hint 4-10: Improve accessibility for branding element.

The current implementation using a div with click handler lacks proper keyboard navigation and accessibility attributes.

Consider these improvements:

-  <div
-    class="flex items-center gap-3 cursor-pointer text-gray-700 dark:text-slate-300"
-    @click="openLink('https://www.nocodb.com')"
-  >
+  <a
+    href="https://www.nocodb.com"
+    target="_blank"
+    rel="noopener noreferrer"
+    class="flex items-center gap-3 text-gray-700 dark:text-slate-300"
+    aria-label="Visit NocoDB website"
+  >
     <img src="~assets/img/brand/nocodb-logo.svg" alt="NocoDB" class="flex-none w-6 h-6" />
     <div class="text-sm">NocoDB Forms</div>
-  </div>
+  </a>

Missing import for openLink utility function

The verification shows that:

  1. openLink is used in the component to open nocodb.com link
  2. openLink is implemented in utils/urlUtils.ts
  3. There's no import statement in FormBranding.vue
  4. No global injection of this function was found

The component needs to import the openLink utility from ~/utils/urlUtils to use it.

🔗 Analysis chain

Line range hint 1-1: Verify the openLink implementation.

The component uses openLink but it's not defined in the setup script.

Let's verify the implementation:


Let me gather more context about the usage of openLink in the FormBranding.vue file.


Let me check if there's a composable or plugin that might be injecting the openLink function globally.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for openLink implementation
rg "openLink.*=" packages/nc-gui

Length of output: 231


Script:

#!/bin/bash
# Search for openLink usage in FormBranding.vue
rg "openLink" packages/nc-gui/components/general/FormBranding.vue -A 2

# Check if there's an import statement for openLink
rg "import.*openLink" packages/nc-gui/components/general/FormBranding.vue

# Let's also see the implementation from urlUtils.ts
cat packages/nc-gui/utils/urlUtils.ts

Length of output: 2591


Script:

#!/bin/bash
# Check for any plugin or composable that might provide openLink
rg -g "*.ts" -g "*.js" -g "*.vue" "provide.*openLink|app.config.globalProperties.*openLink" packages/nc-gui

# Check for any auto-imports configuration
fd "auto-?imports" packages/nc-gui -x cat {}

Length of output: 158

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between a940e73 and 5311c2a.

📒 Files selected for processing (3)
  • packages/nc-gui/components/general/FormBranding.vue (1 hunks)
  • packages/nc-gui/components/smartsheet/Form.vue (17 hunks)
  • packages/nc-gui/components/smartsheet/details/Fields.vue (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/nc-gui/components/smartsheet/Form.vue
  • packages/nc-gui/components/smartsheet/details/Fields.vue

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Oct 24, 2024
@dstala dstala merged commit 6f9ca7a into develop Oct 24, 2024
25 of 26 checks passed
@dstala dstala deleted the nc-fix/allow-user-to-submit-form-in-locked-view branch October 24, 2024 11:31
@coderabbitai coderabbitai bot mentioned this pull request Feb 28, 2025
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer 👓 Scope : View Related to views size:M This PR changes 30-99 lines, ignoring generated files. 🐛 Type: Bug Something is broken or incorrect unexpectedly.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0