mirror of
https://github.com/hanzoai/insights.git
synced 2026-11-02 14:32:45 +00:00
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.
118 lines
4.9 KiB
TypeScript
118 lines
4.9 KiB
TypeScript
import { useActions } from 'kea'
|
|
|
|
import { IconArrowRight, IconPencil, IconPlus, IconTrash } from '@hanzo/icons'
|
|
import { Dialog } from '@hanzo/elements'
|
|
|
|
import { moveToLogic } from 'lib/components/FileSystem/MoveTo/moveToLogic'
|
|
import { Field } from 'lib/elements/Field'
|
|
import { Input } from 'lib/elements/Input'
|
|
import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'
|
|
import { DropdownMenuItem } from 'lib/ui/DropdownMenu/DropdownMenu'
|
|
|
|
import { splitPath } from '~/layout/panel-layout/ProjectTree/utils'
|
|
import { FileSystemEntry } from '~/queries/schema/schema-general'
|
|
|
|
import { dashboardsFileSystemLogic } from '../logics/dashboardsFileSystemLogic'
|
|
|
|
interface DashboardsTreeFolderMenuProps {
|
|
// The folder this menu acts on; '' is the tree root ("All dashboards"), which only offers New folder.
|
|
path: string
|
|
// The folder's FileSystem row. Absent for folders inferred purely from a dashboard's path (no row, no
|
|
// id) — those can't be moved/renamed/deleted, so only New subfolder is shown.
|
|
entry?: FileSystemEntry
|
|
}
|
|
|
|
function openNameDialog(title: string, initialName: string, onSubmit: (name: string) => void): void {
|
|
// Guard against a fast double-click submitting twice before the dialog closes — the create/rename
|
|
// actions are fire-and-forget, so without this a double-click yields a duplicate folder / repeated rename.
|
|
let submitted = false
|
|
Dialog.openForm({
|
|
title,
|
|
initialValues: { folderName: initialName },
|
|
content: (
|
|
<Field name="folderName">
|
|
<Input placeholder="Enter a folder name" autoFocus />
|
|
</Field>
|
|
),
|
|
errors: { folderName: (name) => (!name?.trim() ? 'You must enter a folder name' : undefined) },
|
|
onSubmit: ({ folderName }) => {
|
|
if (submitted) {
|
|
return
|
|
}
|
|
submitted = true
|
|
onSubmit(folderName)
|
|
},
|
|
})
|
|
}
|
|
|
|
// Folder context menu for the tree arm — reuses the same move/rename/delete/create operations the sidebar
|
|
// tree uses (via dashboardsFileSystemLogic, which delegates to projectTreeDataLogic), but renders a scoped
|
|
// surface instead of the sidebar's full menu. Rendered through Tree's itemSideAction (hover ellipsis).
|
|
export function DashboardsTreeFolderMenu({ path, entry }: DashboardsTreeFolderMenuProps): JSX.Element {
|
|
const { createFolder, renameFolder, deleteFolder } = useActions(dashboardsFileSystemLogic)
|
|
const { openMoveToModal } = useActions(moveToLogic)
|
|
const isRoot = path === ''
|
|
const label = splitPath(path).at(-1) ?? path
|
|
|
|
return (
|
|
<>
|
|
<DropdownMenuItem
|
|
asChild
|
|
onClick={(e) => {
|
|
e.stopPropagation()
|
|
openNameDialog(isRoot ? 'New folder' : 'New subfolder', '', (name) => createFolder(name, path))
|
|
}}
|
|
data-attr="dashboards-tree-new-folder"
|
|
>
|
|
<ButtonPrimitive menuItem>
|
|
<IconPlus className="size-4 text-tertiary" />
|
|
{isRoot ? 'New folder' : 'New subfolder'}
|
|
</ButtonPrimitive>
|
|
</DropdownMenuItem>
|
|
{entry && (
|
|
<>
|
|
<DropdownMenuItem
|
|
asChild
|
|
onClick={(e) => {
|
|
e.stopPropagation()
|
|
openNameDialog('Rename folder', label, (name) => renameFolder(entry, name))
|
|
}}
|
|
data-attr="dashboards-tree-rename-folder"
|
|
>
|
|
<ButtonPrimitive menuItem>
|
|
<IconPencil className="size-4 text-tertiary" />
|
|
Rename
|
|
</ButtonPrimitive>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem
|
|
asChild
|
|
onClick={(e) => {
|
|
e.stopPropagation()
|
|
openMoveToModal([entry])
|
|
}}
|
|
data-attr="dashboards-tree-move-folder"
|
|
>
|
|
<ButtonPrimitive menuItem>
|
|
<IconArrowRight className="size-4 text-tertiary" />
|
|
Move to...
|
|
</ButtonPrimitive>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem
|
|
asChild
|
|
onClick={(e) => {
|
|
e.stopPropagation()
|
|
deleteFolder(entry)
|
|
}}
|
|
data-attr="dashboards-tree-delete-folder"
|
|
>
|
|
<ButtonPrimitive menuItem>
|
|
<IconTrash className="size-4 text-danger" />
|
|
Delete
|
|
</ButtonPrimitive>
|
|
</DropdownMenuItem>
|
|
</>
|
|
)}
|
|
</>
|
|
)
|
|
}
|