fix(editor): Show claim free ai credits modal on credentials (#19241)

Co-authored-by: konstantintieber <konstantin.tieber@n8n.io>
This commit is contained in:
Benjamin Schroth
2025-09-08 15:38:52 +02:00
committed by GitHub
parent 3c57dc488a
commit cf356e77b3
3 changed files with 57 additions and 1 deletions

View File

@@ -11,6 +11,12 @@ import { computed, ref } from 'vue';
import { OPEN_AI_API_CREDENTIAL_TYPE } from 'n8n-workflow';
import { N8nCallout, N8nText } from '@n8n/design-system';
type Props = {
credentialTypeName?: string;
};
const props = defineProps<Props>();
const LANGCHAIN_NODES_PREFIX = '@n8n/n8n-nodes-langchain.';
const N8N_NODES_PREFIX = '@n8n/n8n-nodes.';
@@ -42,6 +48,10 @@ const userHasOpenAiCredentialAlready = computed(
).length,
);
const isEditingOpenAiCredential = computed(
() => props.credentialTypeName && props.credentialTypeName === OPEN_AI_API_CREDENTIAL_TYPE,
);
const userHasClaimedAiCreditsAlready = computed(
() => !!usersStore.currentUser?.settings?.userClaimedAiCredits,
);
@@ -55,7 +65,7 @@ const activeNodeHasOpenAiApiCredential = computed(
const userCanClaimOpenAiCredits = computed(() => {
return (
settingsStore.isAiCreditsEnabled &&
activeNodeHasOpenAiApiCredential.value &&
(activeNodeHasOpenAiApiCredential.value || isEditingOpenAiCredential.value) &&
!userHasOpenAiCredentialAlready.value &&
!userHasClaimedAiCreditsAlready.value
);