mirror of
https://github.com/bunny-lab-io/Borealis.git
synced 2025-10-27 09:21:57 -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 fetchAssemblyDoc = useCallback(async (type, rawPath) => {
|
||||||
const normalizedPath = normalizeComponentPath(type, rawPath);
|
const normalizedPath = normalizeComponentPath(type, rawPath);
|
||||||
if (!normalizedPath) return { doc: null, normalizedPath: "" };
|
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 {
|
try {
|
||||||
const island = type === "ansible" ? "ansible" : "scripts";
|
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) {
|
if (!resp.ok) {
|
||||||
return { doc: null, normalizedPath };
|
return { doc: null, normalizedPath };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -200,9 +200,20 @@ export default function QuickJob({ open, onClose, hostnames = [] }) {
|
|||||||
setVariableStatus({ loading: true, error: "" });
|
setVariableStatus({ loading: true, error: "" });
|
||||||
try {
|
try {
|
||||||
const island = mode === "ansible" ? "ansible" : "scripts";
|
const island = mode === "ansible" ? "ansible" : "scripts";
|
||||||
const relPath = island === "scripts"
|
const trimmed = (selectedPath || "").replace(/\\/g, "/").replace(/^\/+/, "").trim();
|
||||||
? (selectedPath.startsWith("Scripts/") ? selectedPath : `Scripts/${selectedPath}`)
|
if (!trimmed) {
|
||||||
: selectedPath;
|
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)}`);
|
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})`);
|
if (!resp.ok) throw new Error(`Failed to load assembly (HTTP ${resp.status})`);
|
||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
|
|||||||
Reference in New Issue
Block a user