feat: Enable cred setup for workflows created from templates (no-changelog) (#8240)
## Summary Enable users to open credential setup for workflows that have been created from templates if they skip it. Next steps (will be their own PRs): - Add telemetry events - Add e2e test - Hide the button when user sets up all the credentials - Change the feature flag to a new one ## Related tickets and issues https://linear.app/n8n/issue/ADO-1637/feature-support-template-credential-setup-for-http-request-nodes-that
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<script lang="ts" setup>
|
||||
import { useI18n } from '@/composables/useI18n';
|
||||
import { SETUP_CREDENTIALS_MODAL_KEY, TEMPLATE_CREDENTIAL_SETUP_EXPERIMENT } from '@/constants';
|
||||
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
|
||||
import { usePostHog } from '@/stores/posthog.store';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
import { doesNodeHaveCredentialsToFill } from '@/utils/nodes/nodeTransforms';
|
||||
import { computed, onBeforeUnmount } from 'vue';
|
||||
|
||||
const workflowsStore = useWorkflowsStore();
|
||||
const nodeTypesStore = useNodeTypesStore();
|
||||
const uiStore = useUIStore();
|
||||
const posthogStore = usePostHog();
|
||||
const i18n = useI18n();
|
||||
|
||||
const showButton = computed(() => {
|
||||
const isFeatureEnabled = posthogStore.isFeatureEnabled(TEMPLATE_CREDENTIAL_SETUP_EXPERIMENT);
|
||||
const isCreatedFromTemplate = !!workflowsStore.workflow?.meta?.templateId;
|
||||
if (!isFeatureEnabled || !isCreatedFromTemplate) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const nodes = workflowsStore.workflow?.nodes ?? [];
|
||||
return nodes.some((node) => doesNodeHaveCredentialsToFill(nodeTypesStore, node));
|
||||
});
|
||||
|
||||
const handleClick = () => {
|
||||
uiStore.openModal(SETUP_CREDENTIALS_MODAL_KEY);
|
||||
};
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
uiStore.closeModal(SETUP_CREDENTIALS_MODAL_KEY);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<n8n-button
|
||||
v-if="showButton"
|
||||
:label="i18n.baseText('nodeView.setupTemplate')"
|
||||
size="large"
|
||||
@click="handleClick()"
|
||||
/>
|
||||
</template>
|
||||
Reference in New Issue
Block a user