Skip to content

Conversation

@rameshmane7218
Copy link
Member

Change Summary

add tab key to query params

Change type

  • fix: (bug fix for the user, not a fix to a build script)

Test/ Verification

Provide summary of changes.

Additional information / screenshots (optional)

Anything for maintainers to be made aware of

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Oct 3, 2024
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 3, 2024

📝 Walkthrough

Walkthrough

The pull request introduces changes to two components: Social.vue and View.vue. In Social.vue, the event identifier for the Twitter icon has been corrected by removing an extra colon. In View.vue, the tab management logic has been significantly updated, replacing the previous event emission method with a reactive watch on the activeTab variable, which now integrates with the router to manage active tabs based on query parameters.

Changes

File Path Change Summary
packages/nc-gui/components/feed/Social.vue Updated Twitter event identifier from 'c:feed::twitter-open' to 'c:feed:twitter-open'.
packages/nc-gui/components/feed/View.vue Removed updateTab method; implemented reactive watch on activeTab and updated routing logic.

Possibly related PRs

  • fix: product feed fixes #9579: The changes in this PR involve modifications to the Twitter integration, specifically in handling errors and reload functionality, which is directly related to the event identifier change for the Twitter icon in the main PR.

Suggested labels

🐛 Type: Bug, 👓 Scope : View, lgtm

Suggested reviewers

  • DarkPhoenix2704
  • dstala

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 the 🐛 Type: Bug Something is broken or incorrect unexpectedly. label Oct 3, 2024
@DarkPhoenix2704 DarkPhoenix2704 self-assigned this Oct 3, 2024
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Oct 3, 2024
@DarkPhoenix2704 DarkPhoenix2704 merged commit b04fc14 into develop Oct 3, 2024
@DarkPhoenix2704 DarkPhoenix2704 deleted the nc-fix/style branch October 3, 2024 09:31
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: 2

🧹 Outside diff range and nitpick comments (3)
packages/nc-gui/components/feed/Social.vue (1)

Line range hint 3-38: Suggestion: Use a computed property for social icons

While the current implementation is functional, consider using a computed property for the socialIcons array. This approach can improve readability and maintainability, especially if the list of social icons grows or needs to be dynamically generated in the future.

Here's a suggested refactor:

 <script setup lang="ts">
+import { computed } from 'vue'
 const { $e } = useNuxtApp()
 
-const socialIcons = [
+const socialIcons = computed(() => [
   {
     name: '@nocodb',
     icon: iconMap.iconTwitter,
     link: 'https://twitter.com/nocodb',
     e: 'c:feed:twitter-open',
   },
   // ... other social icons ...
-]
+])
 
 const openUrl = (url: string, e: string) => {
   $e(e)
   window.open(url, '_blank')
 }
 </script>

This change allows for easier future modifications and potentially dynamic generation of the social icons list.

packages/nc-gui/components/feed/View.vue (2)

56-57: Use useRoute for cleaner access to the current route

In the onMounted hook, accessing the current route via router.currentRoute.value is functional but not the most idiomatic approach in the Composition API.

Consider using useRoute to access the current route more cleanly:

+const route = useRoute()
...
-const tab = router.currentRoute.value.query.tab as string
+const tab = route.query.tab as string

Don't forget to import useRoute:

+import { useRouter, useRoute } from 'vue-router'

71-71: Simplify duplicate class bindings in template

Both the GeneralIcon and span elements have similar :class bindings based on activeTab === tab.key. This duplication can make the template harder to maintain.

Consider extracting the common logic into a computed property or a method to reduce duplication:

<!-- Define a method or computed property -->
<script setup lang="ts">
...
const isActiveTab = (key: string) => activeTab === key
...
</script>

<!-- Use in template -->
<GeneralIcon
  :class="{
    'text-brand-500': isActiveTab(tab.key),
    'text-gray-600': !isActiveTab(tab.key),
  }"
  :icon="tab.icon as any"
/>
<span
  :class="{
    'text-brand-500 font-medium': isActiveTab(tab.key),
    'text-gray-700': !isActiveTab(tab.key),
  }"
  class="text-sm"
>
  {{ tab.title }}
</span>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c60b897 and 71d52bc.

📒 Files selected for processing (2)
  • packages/nc-gui/components/feed/Social.vue (1 hunks)
  • packages/nc-gui/components/feed/View.vue (2 hunks)

watch(activeTab, (val) => {
$e('c:nocodb:feed', { tab: val })
router.push({ query: { tab: val } })
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Preserve existing query parameters when updating the route

The call to router.push({ query: { tab: val } }) replaces all existing query parameters with the new tab parameter. This may unintentionally remove other query parameters that are important for navigation or state.

Consider merging the new tab parameter with the existing query parameters to prevent loss of data:

-router.push({ query: { tab: val } })
+router.push({ 
+  query: { 
+    ...router.currentRoute.value.query, 
+    tab: val 
+  } 
+})
📝 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
router.push({ query: { tab: val } })
router.push({
query: {
...router.currentRoute.value.query,
tab: val
}
})

const updateTab = (key: string) => {
$e(`c:nocodb:feed, tab:${key}`)
}
const router = useRouter()
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add missing import for useRouter

The useRouter function is used on line 49 but is not imported. This will result in a ReferenceError at runtime.

Please add the following import statement at the top of your script:

+import { useRouter } from 'vue-router'
📝 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
const router = useRouter()
import { useRouter } from 'vue-router'
const router = useRouter()

@coderabbitai coderabbitai bot mentioned this pull request Nov 25, 2024
1 task
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 size:S This PR changes 10-29 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.

3 participants