Files
insights/products/endpoints/frontend/EndpointFromInsightModal.tsx
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

138 lines
5.6 KiB
TypeScript

import { useActions, useValues } from 'kea'
import { useMemo } from 'react'
import { Button } from 'lib/elements/Button'
import { Field } from 'lib/elements/Field'
import { Input } from 'lib/elements/Input'
import { Modal } from 'lib/elements/Modal'
import { Table } from 'lib/elements/Table'
import { TextArea } from 'lib/elements/TextArea'
import { Link } from 'lib/elements/Link'
import { slugify } from 'lib/utils/strings'
import { urls } from 'scenes/urls'
import { EndpointQueryNode, InsightsQLQuery } from '~/queries/schema/schema-general'
import { validateEndpointName } from './common'
import { endpointLogic } from './endpointLogic'
import { endpointsLogic } from './endpointsLogic'
export interface EndpointFromInsightModalProps {
insightQuery: InsightsQLQuery | EndpointQueryNode
insightShortId?: string
}
export function EndpointFromInsightModal({ insightQuery, insightShortId }: EndpointFromInsightModalProps): JSX.Element {
const { createEndpoint, setEndpointName, setEndpointDescription, closeCreateFromInsightModal } =
useActions(endpointLogic)
const { endpointName, endpointDescription, createFromInsightModalOpen, duplicateEndpoint } =
useValues(endpointLogic)
const { endpoints } = useValues(endpointsLogic)
const endpointsFromThisInsight = insightShortId
? endpoints.filter((endpoint) => endpoint.derived_from_insight === insightShortId)
: []
const slugifiedName = useMemo(() => (endpointName ? slugify(endpointName) : ''), [endpointName])
const nameValidationError = useMemo(() => validateEndpointName(endpointName?.trim() || ''), [endpointName])
const handleSubmit = (): void => {
if (nameValidationError) {
return
}
createEndpoint({
name: endpointName!.trim(),
description: endpointDescription?.trim() || undefined,
query: insightQuery,
derived_from_insight: insightShortId,
})
}
const handleClose = (): void => {
setEndpointName('')
setEndpointDescription('')
closeCreateFromInsightModal()
}
return (
<Modal isOpen={createFromInsightModalOpen} onClose={handleClose} width={600}>
<Modal.Header>
<h3>{duplicateEndpoint ? 'Duplicate insight-based endpoint' : 'Create endpoint from insight'}</h3>
</Modal.Header>
<Modal.Content>
<div className="space-y-4">
{duplicateEndpoint && (
<div className="text-sm text-secondary">
Duplicating <strong>{duplicateEndpoint.name}</strong>
</div>
)}
{endpointsFromThisInsight.length > 0 && (
<div>
<div className="text-muted mb-2">Endpoints already created from this insight:</div>
<Table
dataSource={endpointsFromThisInsight}
columns={[
{
title: 'Name',
key: 'name',
dataIndex: 'name',
render: (_, record) => (
<Link to={urls.endpoint(record.name)}>{record.name}</Link>
),
},
{
title: 'Description',
key: 'description',
dataIndex: 'description',
render: (_, record) =>
record.description || <span className="text-muted">—</span>,
},
]}
size="small"
embedded
/>
</div>
)}
<Field.Pure
label="Name"
error={endpointName?.trim() ? nameValidationError : undefined}
info={
endpointName && slugifiedName !== endpointName.trim()
? `Will be saved as: ${slugifiedName}`
: undefined
}
>
<Input
value={endpointName || ''}
onChange={setEndpointName}
placeholder="Enter endpoint name"
autoFocus
/>
</Field.Pure>
<Field.Pure label="Description">
<TextArea
value={endpointDescription || ''}
onChange={setEndpointDescription}
placeholder="Enter endpoint description (optional)"
rows={3}
/>
</Field.Pure>
</div>
</Modal.Content>
<Modal.Footer>
<div className="flex-1" />
<Button type="secondary" onClick={handleClose}>
Cancel
</Button>
<Button type="primary" onClick={handleSubmit} disabledReason={nameValidationError}>
Create endpoint
</Button>
</Modal.Footer>
</Modal>
)
}