mirror of
https://github.com/stablyai/orca.git
synced 2026-10-23 16:03:49 +00:00
fix(mobile): remove close-tabs-to-right action
This commit is contained in:
@@ -16,7 +16,7 @@ type BulkCloseSheetDeps = {
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the long-press bulk-close entries (Close Others / Left / Right) shared
|
||||
* Builds the long-press bulk-close entries (Close Others / Left) shared
|
||||
* by every session tab sheet. Lives outside the session route to keep the
|
||||
* orchestration out of its max-lines budget; anchors are passed by tab id so
|
||||
* sheets never need the full tab object.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { selectBulkCloseTabs } from './mobile-tab-close-selection'
|
||||
import { BULK_TAB_CLOSE_ACTIONS, selectBulkCloseTabs } from './mobile-tab-close-selection'
|
||||
|
||||
const tab = (id: string, isDirty?: boolean, isPinned?: boolean) => ({
|
||||
id,
|
||||
@@ -10,6 +10,13 @@ const tab = (id: string, isDirty?: boolean, isPinned?: boolean) => ({
|
||||
describe('selectBulkCloseTabs', () => {
|
||||
const tabs = [tab('a'), tab('b'), tab('c'), tab('d')]
|
||||
|
||||
it('offers only close-others and close-left actions', () => {
|
||||
expect(BULK_TAB_CLOSE_ACTIONS).toEqual([
|
||||
{ mode: 'others', label: 'Close Other Tabs' },
|
||||
{ mode: 'left', label: 'Close Tabs to the Left' }
|
||||
])
|
||||
})
|
||||
|
||||
it('selects every tab except the anchor for mode "others"', () => {
|
||||
expect(selectBulkCloseTabs(tabs, 'b', 'others').map((t) => t.id)).toEqual(['a', 'c', 'd'])
|
||||
})
|
||||
@@ -18,13 +25,8 @@ describe('selectBulkCloseTabs', () => {
|
||||
expect(selectBulkCloseTabs(tabs, 'c', 'left').map((t) => t.id)).toEqual(['a', 'b'])
|
||||
})
|
||||
|
||||
it('selects tabs after the anchor for mode "right"', () => {
|
||||
expect(selectBulkCloseTabs(tabs, 'b', 'right').map((t) => t.id)).toEqual(['c', 'd'])
|
||||
})
|
||||
|
||||
it('returns empty when the anchor is at the edge', () => {
|
||||
it('returns empty when the anchor is at the left edge', () => {
|
||||
expect(selectBulkCloseTabs(tabs, 'a', 'left')).toEqual([])
|
||||
expect(selectBulkCloseTabs(tabs, 'd', 'right')).toEqual([])
|
||||
})
|
||||
|
||||
it('returns empty when the anchor is not in the list', () => {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
export type BulkTabCloseMode = 'others' | 'left' | 'right'
|
||||
export type BulkTabCloseMode = 'others' | 'left'
|
||||
|
||||
/** Long-press sheet entries, in display order. */
|
||||
export const BULK_TAB_CLOSE_ACTIONS: { mode: BulkTabCloseMode; label: string }[] = [
|
||||
{ mode: 'others', label: 'Close Other Tabs' },
|
||||
{ mode: 'left', label: 'Close Tabs to the Left' },
|
||||
{ mode: 'right', label: 'Close Tabs to the Right' }
|
||||
{ mode: 'left', label: 'Close Tabs to the Left' }
|
||||
]
|
||||
|
||||
type BulkClosableTab = {
|
||||
@@ -15,7 +14,7 @@ type BulkClosableTab = {
|
||||
|
||||
/**
|
||||
* Pick the tabs a long-press bulk close ("Close Other Tabs" / "Close Tabs to
|
||||
* the Left/Right") should target, in strip order relative to the pressed tab.
|
||||
* the Left") should target, in strip order relative to the pressed tab.
|
||||
* Dirty documents are skipped — mobile has no save prompt on close, so bulk
|
||||
* closing must never silently discard unsaved edits.
|
||||
*/
|
||||
@@ -31,8 +30,6 @@ export function selectBulkCloseTabs<T extends BulkClosableTab>(
|
||||
const candidates =
|
||||
mode === 'others'
|
||||
? tabs.filter((_, index) => index !== anchorIndex)
|
||||
: mode === 'left'
|
||||
? tabs.slice(0, anchorIndex)
|
||||
: tabs.slice(anchorIndex + 1)
|
||||
: tabs.slice(0, anchorIndex)
|
||||
return candidates.filter((tab) => tab.isDirty !== true && tab.isPinned !== true)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user