Skip to content

Commit 31f883f

Browse files
committed
feat(web): unarchive or delete all threads in the archive scope
1 parent 47e1963 commit 31f883f

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

‎apps/web/src/components/settings/ArchivedThreadsPanel.tsx‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ export function ArchivedThreadsPanel() {
138138
})();
139139

140140
type ArchivedThread = (typeof archivedGroups)[number]["threads"][number];
141+
const archivedThreads = archivedGroups.flatMap((group) => group.threads);
141142

142143
const reportFailure = (result: AtomCommandResult<unknown, unknown> | null, title: string) => {
143144
if (result?._tag !== "Failure" || isAtomCommandInterrupted(result)) return;
@@ -229,6 +230,34 @@ export function ArchivedThreadsPanel() {
229230

230231
return (
231232
<SettingsPageContainer>
233+
{archivedThreads.length > 0 ? (
234+
<div className="flex flex-wrap items-center justify-between gap-x-4 gap-y-2 px-3 sm:px-4">
235+
<p className="text-sm text-muted-foreground">
236+
{archivedThreads.length} archived thread{archivedThreads.length === 1 ? "" : "s"}
237+
</p>
238+
<div className="flex items-center gap-2">
239+
{ARCHIVE_ACTIONS.map(({ action, label, Icon }) => (
240+
<Button
241+
key={action}
242+
type="button"
243+
variant={action === "delete" ? "destructive-outline" : "outline"}
244+
size="sm"
245+
disabled={pendingKeys.size > 0}
246+
onClick={() =>
247+
void handleBulkAction(
248+
action,
249+
archivedThreads,
250+
archivedGroups.length === 1 ? ` in ${archivedGroups[0]!.title}` : "",
251+
)
252+
}
253+
>
254+
<Icon />
255+
<span>{label} all</span>
256+
</Button>
257+
))}
258+
</div>
259+
</div>
260+
) : null}
232261
{archivedGroups.length === 0 ? (
233262
<SettingsSection
234263
id={isLoadingArchive ? undefined : searchableSetting("archive").id}

‎apps/web/src/components/settings/SettingsPanels.archive.browser.test.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ function openContextMenu(container: HTMLElement) {
155155
}
156156

157157
it.each([
158+
["Unarchive all", "unarchiveThreads"],
159+
["Delete all", "deleteArchivedThreads"],
158160
["Unarchive all in project", "unarchiveThreads"],
159161
["Delete all in project", "deleteArchivedThreads"],
160162
] as const)(

0 commit comments

Comments
 (0)