mirror of
https://github.com/bunny-lab-io/Borealis.git
synced 2025-10-27 07:21:58 -06:00
Fix assembly variable loading paths
This commit is contained in:
@@ -362,9 +362,18 @@ export default function CreateJob({ onCancel, onCreated, initialJob = null }) {
|
||||
const fetchAssemblyDoc = useCallback(async (type, rawPath) => {
|
||||
const normalizedPath = normalizeComponentPath(type, rawPath);
|
||||
if (!normalizedPath) return { doc: null, normalizedPath: "" };
|
||||
const trimmed = normalizedPath.replace(/\\/g, "/").replace(/^\/+/, "").trim();
|
||||
if (!trimmed) return { doc: null, normalizedPath: "" };
|
||||
let requestPath = trimmed;
|
||||
if (type === "script" && requestPath.toLowerCase().startsWith("scripts/")) {
|
||||
requestPath = requestPath.slice("Scripts/".length);
|
||||
} else if (type === "ansible" && requestPath.toLowerCase().startsWith("ansible_playbooks/")) {
|
||||
requestPath = requestPath.slice("Ansible_Playbooks/".length);
|
||||
}
|
||||
if (!requestPath) return { doc: null, normalizedPath };
|
||||
try {
|
||||
const island = type === "ansible" ? "ansible" : "scripts";
|
||||
const resp = await fetch(`/api/assembly/load?island=${island}&path=${encodeURIComponent(normalizedPath)}`);
|
||||
const resp = await fetch(`/api/assembly/load?island=${island}&path=${encodeURIComponent(requestPath)}`);
|
||||
if (!resp.ok) {
|
||||
return { doc: null, normalizedPath };
|
||||
}
|
||||
|
||||
@@ -200,9 +200,20 @@ export default function QuickJob({ open, onClose, hostnames = [] }) {
|
||||
setVariableStatus({ loading: true, error: "" });
|
||||
try {
|
||||
const island = mode === "ansible" ? "ansible" : "scripts";
|
||||
const relPath = island === "scripts"
|
||||
? (selectedPath.startsWith("Scripts/") ? selectedPath : `Scripts/${selectedPath}`)
|
||||
: selectedPath;
|
||||
const trimmed = (selectedPath || "").replace(/\\/g, "/").replace(/^\/+/, "").trim();
|
||||
if (!trimmed) {
|
||||
setVariables([]);
|
||||
setVariableValues({});
|
||||
setVariableErrors({});
|
||||
setVariableStatus({ loading: false, error: "" });
|
||||
return;
|
||||
}
|
||||
let relPath = trimmed;
|
||||
if (island === "scripts" && relPath.toLowerCase().startsWith("scripts/")) {
|
||||
relPath = relPath.slice("Scripts/".length);
|
||||
} else if (island === "ansible" && relPath.toLowerCase().startsWith("ansible_playbooks/")) {
|
||||
relPath = relPath.slice("Ansible_Playbooks/".length);
|
||||
}
|
||||
const resp = await fetch(`/api/assembly/load?island=${island}&path=${encodeURIComponent(relPath)}`);
|
||||
if (!resp.ok) throw new Error(`Failed to load assembly (HTTP ${resp.status})`);
|
||||
const data = await resp.json();
|
||||
|
||||
Reference in New Issue
Block a user