-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Nc fix: add tab key to query params #9585
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
Conversation
📝 WalkthroughWalkthroughThe pull request introduces changes to two components: Changes
Possibly related PRs
Suggested labels
Suggested reviewers
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 iconsWhile the current implementation is functional, consider using a computed property for the
socialIconsarray. 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: UseuseRoutefor cleaner access to the current routeIn the
onMountedhook, accessing the current route viarouter.currentRoute.valueis functional but not the most idiomatic approach in the Composition API.Consider using
useRouteto access the current route more cleanly:+const route = useRoute() ... -const tab = router.currentRoute.value.query.tab as string +const tab = route.query.tab as stringDon't forget to import
useRoute:+import { useRouter, useRoute } from 'vue-router'
71-71: Simplify duplicate class bindings in templateBoth the
GeneralIconandspanelements have similar:classbindings based onactiveTab === 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>
| watch(activeTab, (val) => { | ||
| $e('c:nocodb:feed', { tab: val }) | ||
| router.push({ query: { tab: val } }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| 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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| const router = useRouter() | |
| import { useRouter } from 'vue-router' | |
| const router = useRouter() |
Change Summary
add tab key to query params
Change type
Test/ Verification
Provide summary of changes.
Additional information / screenshots (optional)
Anything for maintainers to be made aware of