fix(ai): hide AI actions for users without ai.read (#5749)

This commit is contained in:
Yash Kumar
2026-10-23 00:37:49 +05:30
committed by GitHub
parent b38a7fb4fd
commit c7b0570bc6
2 changed files with 8 additions and 0 deletions
@@ -40,6 +40,7 @@ export function AnalyzeLogs({ logs, context }: Props) {
const [open, setOpen] = useState(false);
const [aiId, setAiId] = useState<string>("");
const [copied, setCopied] = useState(false);
const { data: permissions } = api.user.getPermissions.useQuery();
const { data: providers } = api.ai.getEnabledProviders.useQuery(undefined, {
enabled: open,
});
@@ -51,6 +52,8 @@ export function AnalyzeLogs({ logs, context }: Props) {
},
});
if (!permissions?.ai.read) return null;
const handleAnalyze = () => {
if (!aiId || logs.length === 0) return;
@@ -1,4 +1,5 @@
import { TemplateGenerator } from "@/components/dashboard/project/ai/template-generator";
import { api } from "@/utils/api";
interface Props {
environmentId: string;
@@ -6,5 +7,9 @@ interface Props {
}
export const AddAiAssistant = ({ environmentId }: Props) => {
const { data: permissions } = api.user.getPermissions.useQuery();
if (!permissions?.ai.read) return null;
return <TemplateGenerator environmentId={environmentId} />;
};