Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

chore(batch-action): make `entitlement` prop optional (#5884)

marliessophie70e0b036e5b4
diff --git a/web/src/features/entitlements/hooks.ts b/web/src/features/entitlements/hooks.ts
index ea82dd99ed..5317f9a026 100644
--- a/web/src/features/entitlements/hooks.ts
+++ b/web/src/features/entitlements/hooks.ts
@@ -50,6 +50,18 @@ export const useEntitlements = (): Entitlement[] => {
return availableEntitlements;
};
+/**
+ * Hook to check if the current organization or self-hosted instance has a specific entitlement.
+ * If the entitlement is not provided, it will return true.
+ */
+export const useOptionalEntitlement = (entitlement?: Entitlement): boolean => {
+ const entitlements = useEntitlements();
+ const session = useSession();
+ if (session.data?.user?.admin) return true;
+ if (!entitlement) return true;
+ return entitlements.includes(entitlement);
+};
+
/**
* Hook to check if the current organization or self-hosted instance has a specific entitlement.
*/
diff --git a/web/src/features/table/components/TableActionDialog.tsx b/web/src/features/table/components/TableActionDialog.tsx
index 774ce39d6f..8f7d8d9202 100644
--- a/web/src/features/table/components/TableActionDialog.tsx
+++ b/web/src/features/table/components/TableActionDialog.tsx
@@ -24,7 +24,7 @@ import { type TableAction } from "@/src/features/table/types";
import { TableActionTargetOptions } from "@/src/features/table/components/TableActionTargetOptions";
import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
import { ActionButton } from "@/src/components/ActionButton";
-import { useHasEntitlement } from "@/src/features/entitlements/hooks";
+import { useOptionalEntitlement } from "@/src/features/entitlements/hooks";
import { useSelectAll } from "@/src/features/table/hooks/useSelectAll";
import { type BatchExportTableName } from "@langfuse/shared";
import { api } from "@/src/utils/api";
@@ -50,7 +50,7 @@ export function TableActionDialog({
scope: action.accessCheck.scope,
});
const { setSelectAll } = useSelectAll(projectId, tableName);
- const hasEntitlement = useHasEntitlement(action.accessCheck.entitlement);
+ const hasEntitlement = useOptionalEntitlement(action.accessCheck.entitlement);
const form = useForm({ defaultValues: { targetId: "" } });
const isInProgress = api.table.getIsBatchActionInProgress.useQuery(
diff --git a/web/src/features/table/components/TableActionTargetOptions.tsx b/web/src/features/table/components/TableActionTargetOptions.tsx
index 13bb5aea03..e55a54c1ec 100644
--- a/web/src/features/table/components/TableActionTargetOptions.tsx
+++ b/web/src/features/table/components/TableActionTargetOptions.tsx
@@ -1,5 +1,5 @@
import { SelectItem } from "@/src/components/ui/select";
-import { useHasEntitlement } from "@/src/features/entitlements/hooks";
+import { useOptionalEntitlement } from "@/src/features/entitlements/hooks";
import { targetOptionsQueryMap } from "@/src/features/table/components/targetOptionsQueryMap";
import { type TableAction } from "@/src/features/table/types";
import { useSession } from "next-auth/react";
@@ -12,7 +12,7 @@ export function TableActionTargetOptions({
projectId: string;
}) {
const session = useSession();
- const hasEntitlement = useHasEntitlement(action.accessCheck.entitlement);
+ const hasEntitlement = useOptionalEntitlement(action.accessCheck.entitlement);
const useTargetOptionsQuery =
targetOptionsQueryMap[action.id as keyof typeof targetOptionsQueryMap];
diff --git a/web/src/features/table/types.ts b/web/src/features/table/types.ts
index 5bb0190324..a80a49ef33 100644
--- a/web/src/features/table/types.ts
+++ b/web/src/features/table/types.ts
@@ -10,7 +10,7 @@ type BaseTableAction = {
icon?: ReactElement;
accessCheck: {
scope: ProjectScope;
- entitlement: Entitlement;
+ entitlement?: Entitlement;
};
};