mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-07-14 17:16:09 +00:00
feat(auth,ui): support github sign-in in the UI (#2545)
# What does this PR do? Uses NextAuth to add github sign in support. ## Test Plan Start server with auth configured as in https://github.com/meta-llama/llama-stack/pull/2509 https://github.com/user-attachments/assets/61ff7442-f601-4b39-8686-5d0afb3b45ac
This commit is contained in:
parent
c8bac888af
commit
daf660c4ea
23 changed files with 577 additions and 81 deletions
55
llama_stack/ui/hooks/use-infinite-scroll.ts
Normal file
55
llama_stack/ui/hooks/use-infinite-scroll.ts
Normal file
|
@ -0,0 +1,55 @@
|
|||
"use client";
|
||||
|
||||
import { useRef, useEffect } from "react";
|
||||
|
||||
interface UseInfiniteScrollOptions {
|
||||
/** Whether the feature is enabled (e.g., hasMore data) */
|
||||
enabled?: boolean;
|
||||
/** Threshold for intersection (0-1, how much of sentinel must be visible) */
|
||||
threshold?: number;
|
||||
/** Margin around root to trigger earlier (e.g., "100px" to load 100px before visible) */
|
||||
rootMargin?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom hook for infinite scroll using Intersection Observer
|
||||
*
|
||||
* @param onLoadMore - Callback to load more data
|
||||
* @param options - Configuration options
|
||||
* @returns ref to attach to sentinel element
|
||||
*/
|
||||
export function useInfiniteScroll(
|
||||
onLoadMore: (() => void) | undefined,
|
||||
options: UseInfiniteScrollOptions = {},
|
||||
) {
|
||||
const { enabled = true, threshold = 0.1, rootMargin = "100px" } = options;
|
||||
const sentinelRef = useRef<HTMLTableRowElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!onLoadMore || !enabled) return;
|
||||
|
||||
const observer = new IntersectionObserver(
|
||||
(entries) => {
|
||||
const [entry] = entries;
|
||||
if (entry.isIntersecting) {
|
||||
onLoadMore();
|
||||
}
|
||||
},
|
||||
{
|
||||
threshold,
|
||||
rootMargin,
|
||||
},
|
||||
);
|
||||
|
||||
const sentinel = sentinelRef.current;
|
||||
if (sentinel) {
|
||||
observer.observe(sentinel);
|
||||
}
|
||||
|
||||
return () => {
|
||||
observer.disconnect();
|
||||
};
|
||||
}, [onLoadMore, enabled, threshold, rootMargin]);
|
||||
|
||||
return sentinelRef;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue