Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4d09ae2
feat(navigation): add pinning for sidebar menu items
ku5ic Oct 6, 2025
51ad1b8
refactor(nav): rename pinnableItems to pinnableStates
ku5ic Oct 6, 2025
e5e8221
Merge branch 'next' into ku5ic/feature/WEB-5364/menu_items_pinning_fu…
ku5ic Oct 6, 2025
d5cd259
feat(ui): show pin icon on hover and when pinned
ku5ic Oct 6, 2025
96560d4
feat(ui): simplify pinnable menu item icon logic
ku5ic Oct 7, 2025
84e474c
feat(admin-ui): improve pinned menu items rendering logic
ku5ic Oct 7, 2025
b226ce6
feat(menu): add pinnable option to settings menus
ku5ic Oct 7, 2025
5fce21d
feat(admin-ui): persist pinned menu order in localStorage
ku5ic Oct 7, 2025
fca3d7b
feat(admin-ui): add "Webiny" group to pinned menu items
ku5ic Oct 7, 2025
af06162
Merge branch 'next' into ku5ic/feature/WEB-5364/menu_items_pinning_fu…
ku5ic Oct 8, 2025
cd8d10f
feat(admin-ui): show parent icon for pinned menu items
ku5ic Oct 8, 2025
d7534b2
refactor(navigation): move icon prop to menu element
ku5ic Oct 8, 2025
f24413f
fix(admin-ui): handle possible undefined menu element
ku5ic Oct 8, 2025
10eae03
feat(ui): hide pinned menu items when sidebar is collapsed
ku5ic Oct 8, 2025
cd33be0
refactor(navigation): rename PINNED_KEY to pinnedKey
ku5ic Oct 9, 2025
224d0e7
fix(admin-ui): improve pinned menu sorting logic
ku5ic Oct 9, 2025
a961df9
refactor(nav): optimize pinned menu items memoization
ku5ic Oct 9, 2025
d52be94
feat(ui): rename sidebar state from pinned to expanded
ku5ic Oct 9, 2025
c0b74cb
refactor(navigation): rename pinnedKey to createPinnedKey
ku5ic Oct 9, 2025
d47da02
Merge branch 'next' into ku5ic/feature/WEB-5364/menu_items_pinning_fu…
ku5ic Oct 9, 2025
83eea6c
refactor(nav): simplify pinned menu rendering logic
ku5ic Oct 9, 2025
bfb5d62
refactor(properties): remove unused pinnable prop
ku5ic Oct 10, 2025
cbd66a4
fix(admin-ui): simplify icon rendering for pinned menu items
ku5ic Oct 10, 2025
0bcc609
feat(ui): show pin icon on menu item hover
ku5ic Oct 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/app-admin-ui/src/Navigation/PinnableMenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type PinnableMenuItemProps = {
* @param name - The unique name of the menu item.
* @returns The localStorage key string for the pinned state.
*/
export const PINNED_KEY = (name: string) => `navigation/${name}/pinned`;
export const pinnedKey = (name: string) => `navigation/${name}/pinned`;
Copy link
Contributor

Choose a reason for hiding this comment

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

const key = createPinnedKey(whatever)


/**
* The localStorage key for the order of pinned menu items.
Expand Down Expand Up @@ -61,7 +61,7 @@ const parseOrder = (order: unknown): string[] => {
* @note The pinned state and order are persisted in localStorage.
*/
const usePinnedMenuItem = (name: string) => {
const pinKey = PINNED_KEY(name);
const pinKey = pinnedKey(name);
const pinOrder = useLocalStorageValue(PINNED_ORDER_KEY);
const isPinned = useLocalStorageValue(pinKey);
const { set, remove } = useLocalStorage();
Expand Down
20 changes: 14 additions & 6 deletions packages/app-admin-ui/src/Navigation/PinnedMenuItems.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useMemo } from "react";
import { AdminConfig, useLocalStorageValues, useLocalStorageValue } from "@webiny/app-admin";
import { PINNED_KEY, PINNED_ORDER_KEY, PinnableMenuItem } from "./PinnableMenuItem.js";
import { pinnedKey, PINNED_ORDER_KEY, PinnableMenuItem } from "./PinnableMenuItem.js";
import type { MenuConfig } from "@webiny/app-admin/config/AdminConfig/Menu.js";
import { useSidebar } from "@webiny/admin-ui";

Expand Down Expand Up @@ -60,7 +60,7 @@ const getPinnableMenus = (menuItems: PinnedMenuItemsProps["menuItems"]) =>
* @returns Array of local storage key strings.
*/
const getPinnableKeys = (menus: PinnedMenuItemsProps["menuItems"]) =>
menus.map(({ name }) => PINNED_KEY(name));
menus.map(({ name }) => pinnedKey(name));

/**
* Parses the pinned order from a raw local storage value.
Expand Down Expand Up @@ -98,8 +98,16 @@ const getSortedPinnedItems = (
pinnedStates: Record<string, boolean>,
pinnedOrder: string[]
) => {
const pinned = menus.filter(({ name }) => pinnedStates[PINNED_KEY(name)]);
return pinned.sort((a, b) => pinnedOrder.indexOf(a.name) - pinnedOrder.indexOf(b.name));
const pinned = menus.filter(({ name }) => pinnedStates[pinnedKey(name)]);

return pinned.sort((a, b) => {
const aIdx = pinnedOrder.indexOf(a.name);
const bIdx = pinnedOrder.indexOf(b.name);
return (
(aIdx === -1 ? Number.MAX_SAFE_INTEGER : aIdx) -
(bIdx === -1 ? Number.MAX_SAFE_INTEGER : bIdx)
);
});
};

/**
Expand All @@ -115,8 +123,8 @@ const getSortedPinnedItems = (
* <PinnedMenuItems menuItems={menus} />
*/
export const PinnedMenuItems = ({ menuItems }: PinnedMenuItemsProps) => {
const pinnableMenus = useMemo(() => getPinnableMenus(menuItems), [menuItems]);
const pinnableKeys = useMemo(() => getPinnableKeys(pinnableMenus), [pinnableMenus]);
const pinnableMenus = getPinnableMenus(menuItems);
const pinnableKeys = getPinnableKeys(pinnableMenus);
const pinnedStates = useLocalStorageValues(pinnableKeys);
const rawPinnedOrder = useLocalStorageValue(PINNED_ORDER_KEY);
const pinnedOrder = useMemo(() => parsePinnedOrder(rawPinnedOrder), [rawPinnedOrder]);
Expand Down
Loading