fix: Hide cred setup button from canvas (no-changelog) (#8255)
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, onBeforeUnmount, watch } from 'vue';
|
||||
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';
|
||||
import { doesNodeHaveAllCredentialsFilled } from '@/utils/nodes/nodeTransforms';
|
||||
|
||||
const workflowsStore = useWorkflowsStore();
|
||||
const nodeTypesStore = useNodeTypesStore();
|
||||
@@ -14,15 +14,41 @@ 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) {
|
||||
const isTemplateSetupCompleted = computed(() => {
|
||||
return !!workflowsStore.workflow?.meta?.templateCredsSetupCompleted;
|
||||
});
|
||||
|
||||
const allCredentialsFilled = computed(() => {
|
||||
if (isTemplateSetupCompleted.value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const nodes = workflowsStore.getNodes();
|
||||
if (!nodes.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const nodes = workflowsStore.workflow?.nodes ?? [];
|
||||
return nodes.some((node) => doesNodeHaveCredentialsToFill(nodeTypesStore, node));
|
||||
return nodes.every((node) => doesNodeHaveAllCredentialsFilled(nodeTypesStore, node));
|
||||
});
|
||||
|
||||
const showButton = computed(() => {
|
||||
const isFeatureEnabled = posthogStore.isFeatureEnabled(TEMPLATE_CREDENTIAL_SETUP_EXPERIMENT);
|
||||
const isCreatedFromTemplate = !!workflowsStore.workflow?.meta?.templateId;
|
||||
if (!isFeatureEnabled || !isCreatedFromTemplate || isTemplateSetupCompleted.value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !allCredentialsFilled.value;
|
||||
});
|
||||
|
||||
const unsubscribe = watch(allCredentialsFilled, (newValue) => {
|
||||
if (newValue) {
|
||||
workflowsStore.addToWorkflowMetadata({
|
||||
templateCredsSetupCompleted: true,
|
||||
});
|
||||
|
||||
unsubscribe();
|
||||
}
|
||||
});
|
||||
|
||||
const handleClick = () => {
|
||||
|
||||
Reference in New Issue
Block a user