Skip to content

Commit d945617

Browse files
klopez4212npub13fn4ahfnvaa2qwylvegdgeajqs0mph6v4qsw4jcqnw4mjh3hzh2quuucm5
andauthored
feat(desktop): unify sidebar section actions into a per-section ⋮ menu (#1577)
Signed-off-by: npub13fn4ahfnvaa2qwylvegdgeajqs0mph6v4qsw4jcqnw4mjh3hzh2quuucm5 <8a675edd33677aa0389f6650d467b2041fb0df4ca820eacb009babb95e3715d4@sprout-oss.stage.blox.sqprod.co> Co-authored-by: npub13fn4ahfnvaa2qwylvegdgeajqs0mph6v4qsw4jcqnw4mjh3hzh2quuucm5 <8a675edd33677aa0389f6650d467b2041fb0df4ca820eacb009babb95e3715d4@sprout-oss.stage.blox.sqprod.co>
1 parent ed84a87 commit d945617

13 files changed

Lines changed: 724 additions & 507 deletions

‎desktop/src/features/sidebar/ui/AppSidebar.tsx‎

Lines changed: 29 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
// biome-ignore format: keep compact to stay within file size limit
2-
import { MessageCirclePlus } from "lucide-react";
3-
42
import * as React from "react";
53
import { FeatureGate } from "@/shared/features";
64
import { SidebarDndContext } from "@/features/sidebar/ui/SidebarDnd";
@@ -36,8 +34,9 @@ import { SidebarSection } from "@/features/sidebar/ui/SidebarSection";
3634
import {
3735
ChannelGroupSection,
3836
CustomChannelSection,
37+
SectionActionsMenu,
38+
SectionQuickAction,
3939
} from "@/features/sidebar/ui/CustomChannelSection";
40-
import { ChannelSortDropdown } from "@/features/sidebar/ui/ChannelSortDropdown";
4140
import { CreateChannelDialog } from "@/features/sidebar/ui/CreateChannelDialog";
4241
import { NewDirectMessageDialog } from "@/features/sidebar/ui/NewDirectMessageDialog";
4342
import { SidebarProfileCard } from "@/features/sidebar/ui/SidebarProfileCard";
@@ -47,10 +46,6 @@ import {
4746
SidebarLoadingContent,
4847
useSidebarLoadingShape,
4948
} from "@/features/sidebar/ui/sidebarLoadingSkeleton";
50-
import {
51-
SECTION_ACTION_VISIBILITY_CLASS,
52-
SECTION_ICON_BUTTON_CLASS,
53-
} from "@/features/sidebar/ui/sidebarSectionStyles";
5449
import { useDeferredModalOpen } from "@/shared/ui/deferredModalOpen";
5550
import { SidebarUpdateCard } from "@/features/settings/SidebarUpdateCard";
5651
import { useUpdaterContext } from "@/features/settings/hooks/UpdaterProvider";
@@ -592,24 +587,16 @@ export function AppSidebar({
592587
<>
593588
{starredChannels.length > 0 ? (
594589
<ChannelGroupSection
595-
createAriaLabel="Starred channels"
596590
hasUnread={starredChannels.some((c) =>
597591
unreadChannelIds.has(c.id),
598592
)}
599593
isCollapsed={collapsedGroups.starred}
600594
isActiveChannel={selectedView === "channel"}
601595
activeWorkingByChannelId={activeWorkingByChannelId}
602596
items={starredChannels}
603-
leadingHeaderAction={
604-
<ChannelSortDropdown
605-
groupLabel="starred channels"
606-
onSortModeChange={(mode) =>
607-
setSortModeFor("starred", mode)
608-
}
609-
sortMode={sortModeFor("starred")}
610-
testId="channel-sort-trigger-starred"
611-
/>
612-
}
597+
sortMode={sortModeFor("starred")}
598+
onSortModeChange={(mode) => setSortModeFor("starred", mode)}
599+
actionsTestId="section-actions-starred"
613600
listTestId="starred-list"
614601
onMarkAllRead={() => {
615602
for (const channel of starredChannels) {
@@ -661,21 +648,9 @@ export function AppSidebar({
661648
assignments={channelAssignments}
662649
isFirst={idx === 0}
663650
isLast={idx === channelSections.length - 1}
664-
leadingHeaderAction={
665-
<ChannelSortDropdown
666-
groupLabel={section.name}
667-
onSortModeChange={(mode) =>
668-
setSortModeFor(
669-
sectionSortGroupKey(section.id),
670-
mode,
671-
)
672-
}
673-
sortMode={sortModeFor(
674-
sectionSortGroupKey(section.id),
675-
)}
676-
testId={`channel-sort-trigger-section-${section.id}`}
677-
visibilityClassName=""
678-
/>
651+
sortMode={sortModeFor(sectionSortGroupKey(section.id))}
652+
onSortModeChange={(mode) =>
653+
setSortModeFor(sectionSortGroupKey(section.id), mode)
679654
}
680655
onToggleCollapsed={() =>
681656
toggleCollapsedSection(section.id)
@@ -707,27 +682,23 @@ export function AppSidebar({
707682
/>
708683
))}
709684
<ChannelGroupSection
710-
browseAriaLabel="Browse channels"
711-
createAriaLabel="Create a channel"
685+
browseLabel="Browse channels"
686+
createLabel="New channel"
712687
draggable
713688
hasUnread={unreadChannelIds.size > 0}
714689
isCollapsed={collapsedGroups.channels}
715690
isActiveChannel={selectedView === "channel"}
716691
activeWorkingByChannelId={activeWorkingByChannelId}
717692
items={sectionBuckets.unassigned}
718-
leadingHeaderAction={
719-
<ChannelSortDropdown
720-
groupLabel="channels"
721-
onSortModeChange={(mode) =>
722-
setSortModeFor("channels", mode)
723-
}
724-
sortMode={sortModeFor("channels")}
725-
testId="channel-sort-trigger-channels"
726-
/>
693+
sortMode={sortModeFor("channels")}
694+
onSortModeChange={(mode) =>
695+
setSortModeFor("channels", mode)
727696
}
697+
actionsTestId="section-actions-channels"
728698
listTestId="stream-list"
729699
onBrowseClick={onBrowseChannels}
730700
onCreateClick={() => openCreateDialog("stream")}
701+
showQuickCreate
731702
onMarkAllRead={onMarkAllChannelsRead}
732703
onMarkChannelRead={onMarkChannelRead}
733704
onMarkChannelUnread={onMarkChannelUnread}
@@ -753,22 +724,15 @@ export function AppSidebar({
753724
</SidebarDndContext>
754725
<FeatureGate feature="forum">
755726
<ChannelGroupSection
756-
createAriaLabel="Create a forum"
727+
createLabel="New forum"
757728
hasUnread={unreadChannelIds.size > 0}
758729
isCollapsed={collapsedGroups.forums}
759730
isActiveChannel={selectedView === "channel"}
760731
activeWorkingByChannelId={activeWorkingByChannelId}
761732
items={forumChannels}
762-
leadingHeaderAction={
763-
<ChannelSortDropdown
764-
groupLabel="forums"
765-
onSortModeChange={(mode) =>
766-
setSortModeFor("forums", mode)
767-
}
768-
sortMode={sortModeFor("forums")}
769-
testId="channel-sort-trigger-forums"
770-
/>
771-
}
733+
sortMode={sortModeFor("forums")}
734+
onSortModeChange={(mode) => setSortModeFor("forums", mode)}
735+
actionsTestId="section-actions-forums"
772736
listTestId="forum-list"
773737
onCreateClick={() => openCreateDialog("forum")}
774738
onMarkAllRead={onMarkAllChannelsRead}
@@ -788,25 +752,18 @@ export function AppSidebar({
788752
<SidebarSection
789753
action={
790754
<div className="absolute right-1 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5">
791-
<ChannelSortDropdown
792-
groupLabel="direct messages"
793-
onSortModeChange={(mode) => setSortModeFor("dms", mode)}
755+
<SectionQuickAction
756+
label="New message"
757+
onClick={() => setIsNewDmOpen(true)}
758+
testId="section-actions-dms-quick-create"
759+
/>
760+
<SectionActionsMenu
761+
sectionLabel="direct messages"
762+
testId="section-actions-dms"
763+
onNewMessage={() => setIsNewDmOpen(true)}
794764
sortMode={sortModeFor("dms")}
795-
testId="channel-sort-trigger-dms"
765+
onSortModeChange={(mode) => setSortModeFor("dms", mode)}
796766
/>
797-
<button
798-
aria-expanded={isNewDmOpen}
799-
aria-label="Compose new message"
800-
className={`${SECTION_ICON_BUTTON_CLASS} ${SECTION_ACTION_VISIBILITY_CLASS}`}
801-
data-testid="new-dm-trigger"
802-
onClick={() => {
803-
setIsNewDmOpen(true);
804-
}}
805-
title="Compose new message"
806-
type="button"
807-
>
808-
<MessageCirclePlus className="h-4 w-4" />
809-
</button>
810767
</div>
811768
}
812769
dmParticipantsByChannelId={dmParticipantsByChannelId}

0 commit comments

Comments
 (0)