feat(core): Only fetch credentials available in user's personal project on Chat (no-changelog) (#22465)

This commit is contained in:
Jaakko Husso 2025-11-28 16:24:24 +02:00 committed by GitHub
parent 9f2efb75aa
commit 58a0e4da2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 12 deletions

View File

@ -86,9 +86,11 @@ onMounted(async () => {
if (!settingsStore.isChatFeatureEnabled) {
return;
}
await fetchSettings();
await credentialsStore.fetchAllCredentials();
await credentialsStore.fetchCredentialTypes(false);
await Promise.all([
fetchSettings(),
credentialsStore.fetchAllCredentials(),
credentialsStore.fetchCredentialTypes(false),
]);
});
</script>
<template>

View File

@ -1,6 +1,5 @@
import { LOCAL_STORAGE_CHAT_HUB_CREDENTIALS } from '@/app/constants';
import { useSettingsStore } from '@/app/stores/settings.store';
import { hasPermission } from '@/app/utils/rbac/permissions';
import { credentialsMapSchema, type CredentialsMap } from '@/features/ai/chatHub/chat.types';
import { useProjectsStore } from '@/features/collaboration/projects/projects.store';
import { useCredentialsStore } from '@/features/credentials/credentials.store';
@ -102,16 +101,9 @@ export function useChatCredentials(userId: string) {
() => projectStore.personalProject,
async (personalProject) => {
if (personalProject) {
const hasGlobalCredentialRead = hasPermission(['rbac'], {
rbac: { scope: 'credential:read' },
});
await Promise.all([
credentialsStore.fetchCredentialTypes(false),
// For non-owner users only fetch credentials from personal project.
hasGlobalCredentialRead
? credentialsStore.fetchAllCredentials()
: credentialsStore.fetchAllCredentials(personalProject.id),
credentialsStore.fetchAllCredentialsForWorkflow({ projectId: personalProject.id }),
]);
isInitialized.value = true;