mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-30 00:19:35 +00:00
feat: add tab close menu actions (#24)
Co-authored-by: SuLe <sule@SuLedeMacBook-Air.local>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
export interface TabLike {
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface TabCloseState<T extends TabLike> {
|
||||
tabs: T[];
|
||||
activeTabId: string | null;
|
||||
}
|
||||
|
||||
export function closeOtherTabsState<T extends TabLike>(
|
||||
tabs: readonly T[],
|
||||
activeTabId: string | null,
|
||||
targetTabId: string,
|
||||
): TabCloseState<T> {
|
||||
const target = tabs.find((tab) => tab.id === targetTabId);
|
||||
if (!target) return { tabs: [...tabs], activeTabId };
|
||||
|
||||
return { tabs: [target], activeTabId: target.id };
|
||||
}
|
||||
|
||||
export function closeAllTabsState<T extends TabLike>(
|
||||
_tabs: readonly T[],
|
||||
_activeTabId: string | null,
|
||||
): TabCloseState<T> {
|
||||
return { tabs: [], activeTabId: null };
|
||||
}
|
||||
Reference in New Issue
Block a user