mattrguerra/meridian-ops-boardmainPrivate on GitHub, published here in full

ninety-teams.ts

Language TypeScript2.4 KB60 lines

config/ninety-teams.ts

  1. /**
  2. * Ninety teams, and which of them carry restricted work.
  3. *
  4. * As read from the directory (`pnpm smoke` prints it):
  5. *
  6. * Leadership Team 3daec27fdbd4c3a983e95864 12 open to-dos
  7. * Operations Team 20b8a35b8edd3ed30b2d8f30 2
  8. * All Hands eb3d8bb215506d3263d47cac 19
  9. * (no team) 3
  10. *
  11. * The rule: Leadership Team to-dos are visible only to the people cleared for
  12. * them (`seesLeadership` in the roster). Everything in All Hands stays visible
  13. * to everyone, so the whole team can see where the company stands. That is a
  14. * confidentiality boundary, so it is written down in one place rather than
  15. * inferred from a team name at three call sites.
  16. *
  17. * Matched by id first. A team gets renamed the same way a person does, and the
  18. * whole reason `ninetyId` exists on the roster is that display names in Ninety
  19. * drift. A rename here would not merely mislabel something; it would silently
  20. * unrestrict it.
  21. */
  22. /** Ninety team id -> display name. */
  23. export const NINETY_TEAMS: Record<string, string> = {
  24. '3daec27fdbd4c3a983e95864': 'Leadership Team',
  25. '20b8a35b8edd3ed30b2d8f30': 'Operations Team',
  26. 'eb3d8bb215506d3263d47cac': 'All Hands',
  27. }
  28. export const LEADERSHIP_TEAM_ID = '3daec27fdbd4c3a983e95864'
  29. /** Kept only so a rename is recognisable; the id is what decides. */
  30. const LEADERSHIP_NAMES = new Set(['leadership team', 'leadership'])
  31. /**
  32. * Whether a to-do is restricted to the leadership-cleared readers.
  33. *
  34. * Untagged counts as restricted. Some to-dos carry no team at all, and an item
  35. * with no team could be anything. Failing open would mean a Leadership to-do
  36. * that lost its tag becomes readable by everyone, silently. Failing closed hides at most a
  37. * few All Hands items, and `untaggedTodoCount()` exists so that is stated on the
  38. * page rather than absorbed.
  39. */
  40. export function isRestrictedTeam(
  41. teamId: string | null | undefined,
  42. teamName?: string | null,
  43. ): boolean {
  44. if (!teamId) return true
  45. if (teamId === LEADERSHIP_TEAM_ID) return true
  46. // An id this file has never seen is also unknown work. Same reasoning.
  47. if (!(teamId in NINETY_TEAMS)) return true
  48. return LEADERSHIP_NAMES.has((teamName ?? '').trim().toLowerCase())
  49. }
  50. /** How many to-dos are restricted only because nothing says which team they are in. */
  51. export function untaggedTodoCount(
  52. todos: { teamId: string | null | undefined }[],
  53. ): number {
  54. return todos.filter((t) => !t.teamId).length
  55. }