-
+
-
+
-
+
- {!isDemo() && (
-
-
-
- )}
{testsets.length > 0 && (
@@ -155,10 +151,10 @@ export default function Testsets() {
columns={columns}
dataSource={testsets}
rowKey="_id"
- loading={isTestsetsLoading}
+ loading={isTestsetsLoading || isAppsLoading}
onRow={(record) => {
return {
- onClick: () => router.push(`/apps/${appId}/testsets/${record._id}`),
+ onClick: () => router.push(`/apps/testsets/${record._id}`),
}
}}
/>
diff --git a/agenta-web/src/pages/apps/[app_id]/testsets/new/api/index.tsx b/agenta-web/src/pages/apps/testsets/new/api/index.tsx
similarity index 94%
rename from agenta-web/src/pages/apps/[app_id]/testsets/new/api/index.tsx
rename to agenta-web/src/pages/apps/testsets/new/api/index.tsx
index 829788c3e..b25197315 100644
--- a/agenta-web/src/pages/apps/[app_id]/testsets/new/api/index.tsx
+++ b/agenta-web/src/pages/apps/testsets/new/api/index.tsx
@@ -8,9 +8,9 @@ import pythonCodeUpload from "@/code_snippets/testsets/create_with_upload/python
import cURLCodeUpload from "@/code_snippets/testsets/create_with_upload/curl"
import tsCodeUpload from "@/code_snippets/testsets/create_with_upload/typescript"
import {Typography} from "antd"
-import {useRouter} from "next/router"
import {createUseStyles} from "react-jss"
import {getAgentaApiUrl} from "@/lib/helpers/utils"
+import { useAppsData } from "@/contexts/app.context"
const useStyles = createUseStyles({
title: {
@@ -20,8 +20,8 @@ const useStyles = createUseStyles({
export default function NewTestsetWithAPI() {
const classes = useStyles()
- const router = useRouter()
- const appId = router.query.app_id as string
+ const {apps} = useAppsData()
+ const appId = apps[0]?.app_id
const uploadURI = `${getAgentaApiUrl()}/api/testsets/upload`
const jsonURI = `${getAgentaApiUrl()}/api/testsets/${appId}`
diff --git a/agenta-web/src/pages/apps/[app_id]/testsets/new/manual/index.tsx b/agenta-web/src/pages/apps/testsets/new/manual/index.tsx
similarity index 100%
rename from agenta-web/src/pages/apps/[app_id]/testsets/new/manual/index.tsx
rename to agenta-web/src/pages/apps/testsets/new/manual/index.tsx
diff --git a/agenta-web/src/pages/apps/[app_id]/testsets/new/upload/index.tsx b/agenta-web/src/pages/apps/testsets/new/upload/index.tsx
similarity index 96%
rename from agenta-web/src/pages/apps/[app_id]/testsets/new/upload/index.tsx
rename to agenta-web/src/pages/apps/testsets/new/upload/index.tsx
index 0b8ecb2f7..024f20140 100644
--- a/agenta-web/src/pages/apps/[app_id]/testsets/new/upload/index.tsx
+++ b/agenta-web/src/pages/apps/testsets/new/upload/index.tsx
@@ -8,6 +8,7 @@ import {isValidCSVFile, isValidJSONFile} from "@/lib/helpers/fileManipulations"
import {GenericObject} from "@/lib/Types"
import {globalErrorHandler} from "@/lib/helpers/errorHandler"
import {getAgentaApiUrl} from "@/lib/helpers/utils"
+import {useAppsData} from "@/contexts/app.context"
const useStyles = createUseStyles({
fileFormatBtn: {
@@ -29,12 +30,17 @@ const useStyles = createUseStyles({
export default function AddANewTestset() {
const classes = useStyles()
const router = useRouter()
- const appId = router.query.app_id as string
+ const {apps} = useAppsData()
+ const appId = apps[0]?.app_id
const [form] = Form.useForm()
const [uploadLoading, setUploadLoading] = useState(false)
const [uploadType, setUploadType] = useState<"JSON" | "CSV" | undefined>("CSV")
const onFinish = async (values: any) => {
+ if (!appId) {
+ message.warning("To view the test set, you first need to create an app.")
+ }
+
const {file} = values
const fileObj = file[0].originFileObj
const malformedFileError = `The file you uploaded is either malformed or is not a valid ${uploadType} file`
@@ -67,7 +73,7 @@ export default function AddANewTestset() {
_ignoreError: true,
})
form.resetFields()
- router.push(`/apps/${appId}/testsets`)
+ router.push(`/apps/testsets`)
} catch (e: any) {
if (
e?.response?.data?.detail?.find((item: GenericObject) =>
diff --git a/agenta-web/src/services/testsets/api/index.ts b/agenta-web/src/services/testsets/api/index.ts
index b4806ccc1..3853c2215 100644
--- a/agenta-web/src/services/testsets/api/index.ts
+++ b/agenta-web/src/services/testsets/api/index.ts
@@ -12,7 +12,7 @@ import {axiosFetcher} from "@/services/api"
export const useLoadTestsetsList = (appId: string) => {
const {data, error, mutate, isLoading} = useSWR(
- `${getAgentaApiUrl()}/api/testsets/?app_id=${appId}`,
+ () => (appId ? `${getAgentaApiUrl()}/api/testsets/?app_id=${appId}` : null),
axiosFetcher,
{revalidateOnFocus: false, shouldRetryOnError: false},
)