-
Notifications
You must be signed in to change notification settings - Fork 4.6k
[GIT-248] Refactor: Components consolidation core Components #9245
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
base: git-240/hooks-consolidation-core-hooks
Are you sure you want to change the base?
Changes from all commits
b1def93
c9561a7
9804225
fa572ac
2e282f4
625c26c
b18639e
d86a2ab
38c1a97
5a91581
613717a
1fce8ad
58c7185
b2ec91c
a82a626
351ffef
479b4db
d43a0dd
33228d6
e833d45
7c19095
be637fc
ca3db95
28ab84f
328d08b
c6bb6b9
551df1e
96448da
0a2788a
217fe32
bdc3b2a
4f21a80
0659fba
bc3cd8a
62bdc80
e364648
3a48eef
c1736d6
0df7221
66e5181
1789e66
00273d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,7 @@ import { useAppTheme } from "@/hooks/store/use-app-theme"; | |
| import { useUserPermissions } from "@/hooks/store/user"; | ||
| import { useWorkspaceNavigationPreferences } from "@/hooks/use-navigation-preferences"; | ||
| // plane-web imports | ||
| import { ExtendedSidebarItem } from "@/plane-web/components/workspace/sidebar/extended-sidebar-item"; | ||
| import { ExtendedSidebarItem } from "@/components/workspace/sidebar/extended-sidebar-item"; | ||
| import { ExtendedSidebarWrapper } from "./extended-sidebar-wrapper"; | ||
|
|
||
| export const ExtendedAppSidebar = observer(function ExtendedAppSidebar() { | ||
|
|
@@ -34,32 +34,37 @@ export const ExtendedAppSidebar = observer(function ExtendedAppSidebar() { | |
| const sortedNavigationItems = useMemo(() => { | ||
| const slug = workspaceSlug.toString(); | ||
|
|
||
| return WORKSPACE_SIDEBAR_DYNAMIC_NAVIGATION_ITEMS_LINKS.filter((item) => { | ||
| // Permission check | ||
| const hasPermission = allowPermissions(item.access, EUserPermissionsLevel.WORKSPACE, slug); | ||
|
|
||
| return hasPermission; | ||
| }) | ||
| .map((item) => { | ||
| const preference = currentWorkspaceNavigationPreferences?.[item.key]; | ||
| return { | ||
| ...item, | ||
| sort_order: preference?.sort_order ?? 0, | ||
| is_pinned: preference?.is_pinned ?? false, | ||
| }; | ||
| return ( | ||
| WORKSPACE_SIDEBAR_DYNAMIC_NAVIGATION_ITEMS_LINKS.filter((item) => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. React Doctor · This loops over your list twice because .filter().map() makes two passes, so do it in one pass with .reduce() or a for...of loop Fix → Combine There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. React Doctor · This loops over your list twice because .filter().map() makes two passes, so do it in one pass with .reduce() or a for...of loop Fix → Combine |
||
| // Permission check | ||
| const hasPermission = allowPermissions(item.access, EUserPermissionsLevel.WORKSPACE, slug); | ||
|
|
||
| return hasPermission; | ||
| }) | ||
| .sort((a, b) => { | ||
| // First sort by pinned status (pinned items first) | ||
| if (a.is_pinned !== b.is_pinned) { | ||
| return b.is_pinned ? 1 : -1; | ||
| } | ||
| // Then sort by sort_order within each group | ||
| return a.sort_order - b.sort_order; | ||
| }); | ||
| // oxlint-disable-next-line oxc/no-map-spread | ||
| .map((item) => { | ||
| const preference = currentWorkspaceNavigationPreferences?.[item.key]; | ||
| return { | ||
| ...item, | ||
| sort_order: preference?.sort_order ?? 0, | ||
| is_pinned: preference?.is_pinned ?? false, | ||
| }; | ||
| }) | ||
| // oxlint-disable-next-line unicorn/no-array-sort | ||
| .sort((a, b) => { | ||
| // First sort by pinned status (pinned items first) | ||
| if (a.is_pinned !== b.is_pinned) { | ||
| return b.is_pinned ? 1 : -1; | ||
| } | ||
| // Then sort by sort_order within each group | ||
| return a.sort_order - b.sort_order; | ||
| }) | ||
| ); | ||
| }, [workspaceSlug, currentWorkspaceNavigationPreferences, allowPermissions]); | ||
|
|
||
| const sortedNavigationItemsKeys = sortedNavigationItems.map((item) => item.key); | ||
|
|
||
| // oxlint-disable-next-line unicorn/consistent-function-scoping | ||
| const orderNavigationItem = ( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. React Doctor ·
Fix → Move the function above the component, at the top of the file. It doesn't use local state, so rebuilding it each update is wasted work. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. React Doctor ·
Fix → Move the function above the component, at the top of the file. It doesn't use local state, so rebuilding it each update is wasted work. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. React Doctor ·
Fix → Move the function above the component, at the top of the file. It doesn't use local state, so rebuilding it each update is wasted work. |
||
| sourceIndex: number, | ||
| destinationIndex: number, | ||
|
|
||
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.
React Doctor ·
react-doctor/js-combine-iterations(warning)This loops over your list twice because .filter().map() makes two passes, so do it in one pass with .reduce() or a for...of loop
Fix → Combine
.map().filter()style chains into one pass with.reduce()or afor...ofloop, so you only loop over the list onceDocs