Skip to content

Commit 16f139e

Browse files
authored
Feat: Google Integration (#102)
1 parent 4c32ea0 commit 16f139e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+7314
-6715
lines changed

.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
BACKEND_URL=http://localhost:8000
1+
BACKEND_URL=http://localhost:8000
2+
NEXT_PUBLIC_GOOGLE_CLIENT_ID=your-google-client-id.apps.googleusercontent.com

app/(main)/configurations/page.tsx

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ export default function ConfigLibraryPage() {
4545
Record<string, number>
4646
>({});
4747
const { sidebarCollapsed } = useApp();
48-
const { activeKey } = useAuth();
49-
const apiKey = activeKey?.key;
48+
const { activeKey, isAuthenticated } = useAuth();
49+
const apiKey = activeKey?.key ?? "";
5050
const [searchInput, setSearchInput] = useState("");
5151
const [debouncedQuery, setDebouncedQuery] = useState("");
5252
const [columnCount, setColumnCount] = useState(3);
@@ -100,11 +100,11 @@ export default function ConfigLibraryPage() {
100100

101101
useEffect(() => {
102102
const fetchEvaluationCounts = async () => {
103-
if (!activeKey) return;
103+
if (!isAuthenticated) return;
104104
try {
105105
const data = await apiFetch<EvalJob[] | { data: EvalJob[] }>(
106106
"/api/evaluations",
107-
activeKey.key,
107+
apiKey,
108108
);
109109
const jobs: EvalJob[] = Array.isArray(data) ? data : data.data || [];
110110
const counts: Record<string, number> = {};
@@ -129,7 +129,7 @@ export default function ConfigLibraryPage() {
129129
await existing;
130130
return;
131131
}
132-
if (!apiKey) return;
132+
if (!isAuthenticated) return;
133133

134134
const loadPromise = (async () => {
135135
const res = await apiFetch<{
@@ -144,15 +144,15 @@ export default function ConfigLibraryPage() {
144144
pendingVersionLoads.set(configId, loadPromise);
145145
await loadPromise;
146146
},
147-
[apiKey],
147+
[apiKey, isAuthenticated],
148148
);
149149

150150
const loadSingleVersion = useCallback(
151151
async (configId: string, version: number): Promise<SavedConfig | null> => {
152152
const key = `${configId}:${version}`;
153153
const existing = pendingSingleVersionLoads.get(key);
154154
if (existing) return existing;
155-
if (!apiKey) return null;
155+
if (!isAuthenticated) return null;
156156

157157
const configPublic =
158158
configs.find((c) => c.id === configId) ??
@@ -179,7 +179,7 @@ export default function ConfigLibraryPage() {
179179
pendingSingleVersionLoads.set(key, loadPromise);
180180
return loadPromise;
181181
},
182-
[apiKey, configs],
182+
[apiKey, configs, isAuthenticated],
183183
);
184184

185185
const handleCreateNew = () => {
@@ -277,17 +277,7 @@ export default function ConfigLibraryPage() {
277277
) : error ? (
278278
<div className="rounded-lg p-6 text-center bg-[#fef2f2] border border-[#fecaca]">
279279
<WarningTriangleIcon className="w-12 h-12 mx-auto mb-3 text-[#dc2626]" />
280-
<p className="text-sm font-medium text-[#dc2626]">{error}</p>
281-
<button
282-
onClick={() => router.push("/keystore")}
283-
className="mt-4 px-4 py-2 rounded-md text-sm font-medium transition-colors"
284-
style={{
285-
backgroundColor: colors.accent.primary,
286-
color: colors.bg.primary,
287-
}}
288-
>
289-
Go to Keystore
290-
</button>
280+
<p className="text-sm font-medium text-status-error">{error}</p>
291281
</div>
292282
) : configs.length === 0 ? (
293283
<div

app/(main)/configurations/prompt-editor/page.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function PromptEditorContent() {
3636
const toast = useToast();
3737
const searchParams = useSearchParams();
3838
const { sidebarCollapsed } = useApp();
39-
const { activeKey } = useAuth();
39+
const { activeKey, isAuthenticated } = useAuth();
4040
const urlConfigId = searchParams.get("config");
4141
const urlVersion = searchParams.get("version");
4242
const showHistory = searchParams.get("history") === "true";
@@ -253,9 +253,9 @@ function PromptEditorContent() {
253253
return;
254254
}
255255

256-
const apiKey = activeKey?.key;
257-
if (!apiKey) {
258-
toast.error("No API key found. Please add an API key in the Keystore.");
256+
const apiKey = activeKey?.key ?? "";
257+
if (!isAuthenticated) {
258+
toast.error("Please log in to save configurations.");
259259
return;
260260
}
261261

0 commit comments

Comments
 (0)