-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OPIK-350] [Prompts Library][FE] Prompts details: Experiments tab (#621)
- Loading branch information
1 parent
20b9e11
commit f53a671
Showing
16 changed files
with
449 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
apps/opik-frontend/src/components/pages/ExperimentsShared/useExpandingConfig.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { useEffect, useMemo, useRef, useState } from "react"; | ||
import { ExpandedState } from "@tanstack/react-table"; | ||
import { GROUPING_COLUMN } from "@/hooks/useGroupedExperimentsList"; | ||
|
||
export type UseExpandingConfigProps = { | ||
groupIds: string[]; | ||
}; | ||
|
||
export const useExpandingConfig = ({ groupIds }: UseExpandingConfigProps) => { | ||
const openGroupsRef = useRef<Record<string, boolean>>({}); | ||
const [expanded, setExpanded] = useState<ExpandedState>({}); | ||
|
||
useEffect(() => { | ||
const updateForExpandedState: Record<string, boolean> = {}; | ||
groupIds.forEach((groupId) => { | ||
const id = `${GROUPING_COLUMN}:${groupId}`; | ||
if (!openGroupsRef.current[id]) { | ||
openGroupsRef.current[id] = true; | ||
updateForExpandedState[id] = true; | ||
} | ||
}); | ||
|
||
if (Object.keys(updateForExpandedState).length) { | ||
setExpanded((state) => { | ||
if (state === true) return state; | ||
return { | ||
...state, | ||
...updateForExpandedState, | ||
}; | ||
}); | ||
} | ||
}, [groupIds]); | ||
|
||
return useMemo( | ||
() => ({ | ||
autoResetExpanded: false, | ||
expanded, | ||
setExpanded, | ||
}), | ||
[expanded, setExpanded], | ||
); | ||
}; |
Oops, something went wrong.