MCPcopy
hub / github.com/brimdata/zui / useTitleForm

Function useTitleForm

apps/zui/src/views/session-page/use-title-form.ts:9–31  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7import {create} from "src/domain/named-queries/handlers"
8
9export function useTitleForm() {
10 const active = useSelector(Current.getActiveQuery)
11 const api = useZuiApi()
12 const dispatch = useDispatch()
13
14 return {
15 onSubmit: (e: FormEvent<HTMLFormElement>) => {
16 e.preventDefault()
17 const input = e.currentTarget.elements.namedItem("query-name") as any
18 const name = input.value.trim() || ""
19
20 if (name.length) {
21 if (active.isSaved() && !active.isModified()) {
22 api.queries.rename(active.query.id, name)
23 } else {
24 create(name)
25 }
26 }
27 dispatch(Layout.hideTitleForm())
28 },
29 onReset: () => dispatch(Layout.hideTitleForm()),
30 }
31}

Callers 1

QueryTitleFunction · 0.90

Calls 6

useZuiApiFunction · 0.90
useDispatchFunction · 0.90
createFunction · 0.85
isSavedMethod · 0.80
renameMethod · 0.80
isModifiedMethod · 0.45

Tested by

no test coverage detected