Skip to content

Commit

Permalink
fix: views (#428)
Browse files Browse the repository at this point in the history
  • Loading branch information
hughcrt authored Jul 17, 2024
1 parent b8fcd30 commit 14c753a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
28 changes: 16 additions & 12 deletions packages/frontend/pages/logs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,15 @@ export default function Logs() {
clearOnDefault: true,
})

const { view, update: updateView, remove: removeView } = useView(viewId)

const serializedChecks = useMemo(() => {
if (view) {
return serializeLogic(view.data)
}
const checksWithType = editCheck(checks, "type", { type })
return serializeLogic(checksWithType)
}, [checks, type])

const { view, update: updateView, remove: removeView } = useView(viewId)
}, [checks, type, view])

const { evaluators } = useEvaluators()

Expand All @@ -255,7 +258,6 @@ export default function Logs() {
if (type === "llm" && Array.isArray(evaluators)) {
for (const evaluator of evaluators) {
const id = "enrichment-" + evaluator.id
console.log(id)

if (newColumns.llm.map(({ accessorKey }) => accessorKey).includes(id)) {
continue
Expand Down Expand Up @@ -367,15 +369,15 @@ export default function Logs() {

const newView = await insertView({
name: "New View",
data: checks,
data: editCheck(checks, "type", { type }),
columns: visibleColumns,
icon,
})

setViewId(newView.id)
} else {
await updateView({
data: checks,
data: editCheck(checks, "type", { type }),
columns: visibleColumns,
})

Expand Down Expand Up @@ -559,12 +561,14 @@ export default function Logs() {
</Menu>
</Group>
)}
<CheckPicker
minimal
value={checks}
onChange={setChecks}
restrictTo={(f) => CHECKS_BY_TYPE[type].includes(f.id)}
/>
{!view && (
<CheckPicker
minimal
value={checks}
onChange={setChecks}
restrictTo={(f) => CHECKS_BY_TYPE[type].includes(f.id)}
/>
)}
</Group>
{!!showSaveView && (
<Button
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/utils/dataHooks/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function useViews() {
}
}

export function useView(id?: string, initialData?: any) {
export function useView(id: string | null, initialData?: any) {
const { mutate: mutateViews } = useViews()

const {
Expand Down

0 comments on commit 14c753a

Please sign in to comment.