Files
insights/products/session_summaries/frontend/sessionGroupSummariesTableLogic.ts
zeekay 1b367e2b62 chore: rebase the tree onto upstream master
The tree was a debranded snapshot of upstream taken around 2026-02-20, and
upstream has moved about five months since. This replaces it with upstream
master, mechanically re-derived: bin/debrand does the rename, and the
pipeline and squashed migrations are restored from the shipped tree.

Not a merge. The previous import replaced the tree wholesale in a single
commit, so there is no shared content history to merge against. Reproducing
the rename on the new tree is what actually converges.

What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints,
compose files, LLM.md, and insights/migrations. The squashed initial
migration is load-bearing — the live database records it by name, so
upstream's ~918 individual migrations cannot come back.

Nine products are dropped as unreferenced. Twenty-one more that we do not run
are kept anyway because the core app still imports them; unpicking those is a
refactor and does not belong in a rebase.

This base does not build yet, and the reasons are not in the rename:
upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against
our 4.2, and the dependency manifests still name upstream packages that we
republish under our own names. Those are decisions, not renames.
2026-08-01 15:44:40 -07:00

222 lines
7.5 KiB
TypeScript

import { MakeLogicType, actions, kea, listeners, path, reducers, selectors } from 'kea'
import { loaders } from 'kea-loaders'
import { PaginationManual, Sorting } from '@hanzo/elements'
import api, { CountedPaginatedResponse } from 'lib/api'
import { objectClean } from 'lib/utils/objects'
import { Breadcrumb } from '~/types'
import { SessionGroupSummaryListItemType } from './types'
export interface SessionGroupSummariesListFilters {
search: string
createdBy: string | null
}
export const DEFAULT_FILTERS: SessionGroupSummariesListFilters = {
search: '',
createdBy: null,
}
const RESULTS_PER_PAGE = 50
const DEFAULT_SORTING: Sorting = { columnKey: '-created_at', order: 1 }
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface sessionGroupSummariesTableLogicValues {
breadcrumbs: Breadcrumb[]
filters: SessionGroupSummariesListFilters
page: number
pagination: PaginationManual
sessionGroupSummaries: SessionGroupSummaryListItemType[]
sessionGroupSummariesResponse: CountedPaginatedResponse<SessionGroupSummaryListItemType> | null
sessionGroupSummariesResponseLoading: boolean
tableSorting: Sorting
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface sessionGroupSummariesTableLogicActions {
deleteSessionGroupSummary: (id: string) => {
id: string
}
deleteSessionGroupSummaryFailure: (
error: string,
errorObject?: any
) => {
error: string
errorObject?: any
}
deleteSessionGroupSummarySuccess: (
sessionGroupSummariesResponse: null,
payload?: {
id: string
}
) => {
sessionGroupSummariesResponse: null
payload?: {
id: string
}
}
loadSessionGroupSummaries: () => {
value: true
}
loadSessionGroupSummariesFailure: (
error: string,
errorObject?: any
) => {
error: string
errorObject?: any
}
loadSessionGroupSummariesSuccess: (
sessionGroupSummariesResponse: CountedPaginatedResponse<SessionGroupSummaryListItemType>,
payload?: {
value: true
}
) => {
sessionGroupSummariesResponse: CountedPaginatedResponse<SessionGroupSummaryListItemType>
payload?: {
value: true
}
}
setFilters: (filters: Partial<SessionGroupSummariesListFilters>) => {
filters: Partial<SessionGroupSummariesListFilters>
}
setPage: (page: number) => {
page: number
}
tableSortingChanged: (sorting: Sorting | null) => {
sorting: Sorting | null
}
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface sessionGroupSummariesTableLogicMeta {
__keaTypeGenInternalSelectorTypes: {
sessionGroupSummaries: (
sessionGroupSummariesResponse: CountedPaginatedResponse<SessionGroupSummaryListItemType> | null
) => SessionGroupSummaryListItemType[]
pagination: (
page: number,
sessionGroupSummariesResponse: CountedPaginatedResponse<SessionGroupSummaryListItemType> | null
) => PaginationManual
}
}
export type sessionGroupSummariesTableLogicType = MakeLogicType<
sessionGroupSummariesTableLogicValues,
sessionGroupSummariesTableLogicActions,
Record<string, any>,
sessionGroupSummariesTableLogicMeta
>
export const sessionGroupSummariesTableLogic = kea<sessionGroupSummariesTableLogicType>([
path(['products', 'session_summaries', 'frontend', 'sessionGroupSummariesTableLogic']),
actions({
loadSessionGroupSummaries: true, // Takes no parameters, load by default
setFilters: (filters: Partial<SessionGroupSummariesListFilters>) => ({ filters }),
tableSortingChanged: (sorting: Sorting | null) => ({
sorting,
}),
setPage: (page: number) => ({ page }),
deleteSessionGroupSummary: (id: string) => ({ id }),
}),
reducers({
filters: [
DEFAULT_FILTERS,
{
setFilters: (state, { filters }) =>
objectClean({
...state,
...filters,
}),
},
],
page: [
1,
{
setPage: (_, { page }) => page,
setFilters: () => 1,
tableSortingChanged: () => 1,
},
],
tableSorting: [
DEFAULT_SORTING,
{ persist: true },
{
tableSortingChanged: (_, { sorting }) => sorting || DEFAULT_SORTING,
},
],
}),
loaders(({ values }) => ({
sessionGroupSummariesResponse: [
null as CountedPaginatedResponse<SessionGroupSummaryListItemType> | null,
{
loadSessionGroupSummaries: async (_, breakpoint) => {
await breakpoint(100)
const createdByForQuery =
values.filters?.createdBy === DEFAULT_FILTERS.createdBy ? undefined : values.filters?.createdBy
const sortKey = values.tableSorting.columnKey || '-created_at'
const res = await api.sessionGroupSummaries.list({
created_by: createdByForQuery ?? undefined,
search: values.filters?.search || undefined,
order: sortKey,
limit: RESULTS_PER_PAGE,
offset: (values.page - 1) * RESULTS_PER_PAGE,
})
breakpoint()
return res
},
deleteSessionGroupSummary: async ({ id }) => {
await api.sessionGroupSummaries.delete(id)
return null
},
},
],
})),
listeners(({ actions }) => ({
setFilters: () => actions.loadSessionGroupSummaries(),
tableSortingChanged: () => actions.loadSessionGroupSummaries(),
setPage: () => actions.loadSessionGroupSummaries(),
deleteSessionGroupSummarySuccess: () => actions.loadSessionGroupSummaries(),
})),
selectors(({ actions }) => ({
sessionGroupSummaries: [
(s) => [s.sessionGroupSummariesResponse],
(
sessionGroupSummariesResponse: CountedPaginatedResponse<SessionGroupSummaryListItemType> | null
): SessionGroupSummaryListItemType[] => {
return sessionGroupSummariesResponse?.results || []
},
],
pagination: [
(s) => [s.page, s.sessionGroupSummariesResponse],
(
page: number,
sessionGroupSummariesResponse: CountedPaginatedResponse<SessionGroupSummaryListItemType> | null
): PaginationManual => {
return {
controlled: true,
pageSize: RESULTS_PER_PAGE,
currentPage: page,
entryCount: sessionGroupSummariesResponse?.count ?? 0,
onBackward: () => actions.setPage(page - 1),
onForward: () => actions.setPage(page + 1),
}
},
],
})),
selectors({
breadcrumbs: [
() => [],
(): Breadcrumb[] => [
{
key: 'session-group-summaries',
name: 'Session summaries',
iconType: 'insight/script',
},
],
],
}),
])