Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

1.1 KB
Raw Blame
import type {
  ReviewsStatusFilterId,
  ReviewsStatusTabId,
} from '../reviews-types';

/** Only highlight a tab when the menu selection matches the whole preset. */
export function reviewsStatusTab(
  statuses: readonly string[]
): ReviewsStatusTabId | undefined {
  if (statuses.length === 0) return 'all';
  if (statuses.length === 1 && statuses[0] === 'open') return 'open';
  if (
    statuses.length === 2 &&
    statuses.includes('closed') &&
    statuses.includes('merged')
  ) {
    return 'closed';
  }
  return undefined;
}

/** Keep the combined Closed preset visible, but hide custom multi-selections. */
export const showReviewsStatusTabs = (statuses: readonly string[]) =>
  statuses.length <= 1 || reviewsStatusTab(statuses) !== undefined;

const STATUS_TAB_SELECTIONS: Record<
  ReviewsStatusTabId,
  ReviewsStatusFilterId[]
> = {
  open: ['open'],
  closed: ['closed', 'merged'],
  all: [],
};

/** Closed includes merged PRs, and All filters on no status; menu choices remain independently selectable. */
export const reviewsStatusTabSelection = (
  tab: ReviewsStatusTabId
): ReviewsStatusFilterId[] => [...STATUS_TAB_SELECTIONS[tab]];