fix: Hide cred setup button from canvas (no-changelog) (#8255)

This commit is contained in:
Tomi Turtiainen
2024-01-08 13:59:04 +02:00
committed by GitHub
parent 7899f7aca5
commit 8affdf680d
6 changed files with 88 additions and 8 deletions

View File

@@ -32,6 +32,9 @@ export function getNodeTypeDisplayableCredentials(
return displayableCredentials;
}
/**
* Checks if the given node has credentials that can be filled.
*/
export function doesNodeHaveCredentialsToFill(
nodeTypeProvider: NodeTypeProvider,
node: Pick<INodeUi, 'parameters' | 'type' | 'typeVersion'>,
@@ -40,3 +43,31 @@ export function doesNodeHaveCredentialsToFill(
return requiredCredentials.length > 0;
}
/**
* Does node has the given credential filled
*
* @param credentialName E.g. "telegramApi"
*/
export function hasNodeCredentialFilled(
node: Pick<INodeUi, 'credentials'>,
credentialName: string,
): boolean {
if (!node.credentials) {
return false;
}
return !!node.credentials[credentialName];
}
/**
* Checks if the given node has all credentials filled.
*/
export function doesNodeHaveAllCredentialsFilled(
nodeTypeProvider: NodeTypeProvider,
node: Pick<INodeUi, 'parameters' | 'type' | 'typeVersion' | 'credentials'>,
): boolean {
const requiredCredentials = getNodeTypeDisplayableCredentials(nodeTypeProvider, node);
return requiredCredentials.every((cred) => hasNodeCredentialFilled(node, cred.name));
}