Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 24 additions & 18 deletions nodes/_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,29 +67,35 @@ async function handleDatalinkAutoComplete(RED, req, res) {

// Try to get the node, but it might not exist yet if this is a new node
let node = RED.nodes.getNode(nodeId);
let seqeraConfigId = null;
let seqeraConfigId = req.query.seqeraConfig || req.body?.seqeraConfig;
let baseUrl = "https://api.cloud.seqera.io";
let workspaceId = null;
let credentials = null;

if (node && node.seqeraConfig) {
// Node exists and has config
// Node exists and has config - use deployed node's config
seqeraConfigId = node.seqeraConfig.id;
baseUrl = node.seqeraConfig.baseUrl || baseUrl;
workspaceId = node.seqeraConfig.workspaceId;
credentials = node.seqeraConfig.credentials;

// Check for workspace ID override in the node configuration
if (node.workspaceIdProp && node.workspaceIdPropType === "str" && node.workspaceIdProp.trim()) {
workspaceId = node.workspaceIdProp;
}
} else {
// Try to get config ID from request body or query params
seqeraConfigId = req.query.seqeraConfig || req.body?.seqeraConfig;
if (seqeraConfigId) {
const configNode = RED.nodes.getNode(seqeraConfigId);
if (configNode) {
baseUrl = configNode.baseUrl || baseUrl;
workspaceId = configNode.workspaceId;
}
} else if (seqeraConfigId) {
// Try to get deployed config node
const configNode = RED.nodes.getNode(seqeraConfigId);
if (configNode) {
baseUrl = configNode.baseUrl || baseUrl;
workspaceId = configNode.workspaceId;
credentials = configNode.credentials;
} else {
// Config node not deployed - use query params for baseUrl/workspaceId
// and look up saved credentials by config node ID
baseUrl = req.query.baseUrl || baseUrl;
workspaceId = req.query.workspaceId || null;
credentials = RED.nodes.getCredentials(seqeraConfigId);
}
}

Expand All @@ -102,16 +108,16 @@ async function handleDatalinkAutoComplete(RED, req, res) {
return res.json([]); // Return empty array instead of error for better UX
}

// Create a temporary node-like object for apiCall if we don't have a real node
const nodeForApi = node || {
seqeraConfig: RED.nodes.getNode(seqeraConfigId),
if (!credentials || !credentials.token) {
return res.json([]); // No credentials available
}

// Create a temporary node-like object for apiCall
const nodeForApi = {
seqeraConfig: { credentials },
warn: () => {}, // Dummy warn function
};

if (!nodeForApi.seqeraConfig) {
return res.json([]);
}

// Build the data-links API URL with search parameter
const params = new URLSearchParams({ workspaceId });
if (search) {
Expand Down
13 changes: 11 additions & 2 deletions nodes/datalink-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,25 @@
return;
}

// Get config node from editor (works for undeployed nodes)
const configNode = RED.nodes.node(seqeraConfigId);

const params = new URLSearchParams({
search: value,
seqeraConfig: seqeraConfigId,
});

// Add workspace ID override if configured
// Pass config values for undeployed nodes
if (configNode) {
if (configNode.baseUrl) params.append("baseUrl", configNode.baseUrl);
if (configNode.workspaceId) params.append("workspaceId", configNode.workspaceId);
}

// Add workspace ID override if configured (takes precedence)
const workspaceIdOverride = $("#node-input-workspaceId").typedInput("value");
const workspaceIdType = $("#node-input-workspaceId").typedInput("type");
if (workspaceIdType === "str" && workspaceIdOverride && workspaceIdOverride.trim()) {
params.append("workspaceId", workspaceIdOverride);
params.set("workspaceId", workspaceIdOverride);
}

$.ajax({
Expand Down
13 changes: 11 additions & 2 deletions nodes/datalink-poll.html
Original file line number Diff line number Diff line change
Expand Up @@ -231,16 +231,25 @@
return;
}

// Get config node from editor (works for undeployed nodes)
const configNode = RED.nodes.node(seqeraConfigId);

const params = new URLSearchParams({
search: value,
seqeraConfig: seqeraConfigId,
});

// Add workspace ID override if configured
// Pass config values for undeployed nodes
if (configNode) {
if (configNode.baseUrl) params.append("baseUrl", configNode.baseUrl);
if (configNode.workspaceId) params.append("workspaceId", configNode.workspaceId);
}

// Add workspace ID override if configured (takes precedence)
const workspaceIdOverride = $("#node-input-workspaceId").typedInput("value");
const workspaceIdType = $("#node-input-workspaceId").typedInput("type");
if (workspaceIdType === "str" && workspaceIdOverride && workspaceIdOverride.trim()) {
params.append("workspaceId", workspaceIdOverride);
params.set("workspaceId", workspaceIdOverride);
}

$.ajax({
Expand Down
13 changes: 11 additions & 2 deletions nodes/workflow-launch.html
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,25 @@
return;
}

// Get config node from editor (works for undeployed nodes)
const configNode = RED.nodes.node(seqeraConfigId);

const params = new URLSearchParams({
search: value,
seqeraConfig: seqeraConfigId,
});

// Add workspace ID override if configured
// Pass config values for undeployed nodes
if (configNode) {
if (configNode.baseUrl) params.append("baseUrl", configNode.baseUrl);
if (configNode.workspaceId) params.append("workspaceId", configNode.workspaceId);
}

// Add workspace ID override if configured (takes precedence)
const workspaceIdOverride = $("#node-input-workspaceId").typedInput("value");
const workspaceIdType = $("#node-input-workspaceId").typedInput("type");
if (workspaceIdType === "str" && workspaceIdOverride && workspaceIdOverride.trim()) {
params.append("workspaceId", workspaceIdOverride);
params.set("workspaceId", workspaceIdOverride);
}

$.ajax({
Expand Down
42 changes: 24 additions & 18 deletions nodes/workflow-launch.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,35 @@ module.exports = function (RED) {

// Try to get the node, but it might not exist yet if this is a new node
let node = RED.nodes.getNode(nodeId);
let seqeraConfigId = null;
let seqeraConfigId = req.query.seqeraConfig || req.body?.seqeraConfig;
let baseUrl = "https://api.cloud.seqera.io";
let workspaceId = null;
let credentials = null;

if (node && node.seqeraConfig) {
// Node exists and has config
// Node exists and has config - use deployed node's config
seqeraConfigId = node.seqeraConfig.id;
baseUrl = node.seqeraConfig.baseUrl || baseUrl;
workspaceId = node.seqeraConfig.workspaceId;
credentials = node.seqeraConfig.credentials;

// Check for workspace ID override in the node configuration
if (node.workspaceIdProp && node.workspaceIdPropType === "str" && node.workspaceIdProp.trim()) {
workspaceId = node.workspaceIdProp;
}
} else {
// Try to get config ID from request body or query params
seqeraConfigId = req.query.seqeraConfig || req.body?.seqeraConfig;
if (seqeraConfigId) {
const configNode = RED.nodes.getNode(seqeraConfigId);
if (configNode) {
baseUrl = configNode.baseUrl || baseUrl;
workspaceId = configNode.workspaceId;
}
} else if (seqeraConfigId) {
// Try to get deployed config node
const configNode = RED.nodes.getNode(seqeraConfigId);
if (configNode) {
baseUrl = configNode.baseUrl || baseUrl;
workspaceId = configNode.workspaceId;
credentials = configNode.credentials;
} else {
// Config node not deployed - use query params for baseUrl/workspaceId
// and look up saved credentials by config node ID
baseUrl = req.query.baseUrl || baseUrl;
workspaceId = req.query.workspaceId || null;
credentials = RED.nodes.getCredentials(seqeraConfigId);
}
}

Expand All @@ -42,16 +48,16 @@ module.exports = function (RED) {
return res.json([]); // Return empty array instead of error for better UX
}

// Create a temporary node-like object for apiCall if we don't have a real node
const nodeForApi = node || {
seqeraConfig: RED.nodes.getNode(seqeraConfigId),
if (!credentials || !credentials.token) {
return res.json([]); // No credentials available
}

// Create a temporary node-like object for apiCall
const nodeForApi = {
seqeraConfig: { credentials },
warn: () => {}, // Dummy warn function
};

if (!nodeForApi.seqeraConfig) {
return res.json([]);
}

const { apiCall } = require("./_utils");

// Build the pipelines API URL
Expand Down