mirror of
https://github.com/bunny-lab-io/Borealis.git
synced 2025-10-26 15:21:57 -06:00
Fixed Script Editor
This commit is contained in:
@@ -101,11 +101,13 @@ export default function ScriptEditor({ mode = "scripts", initialPath = "", onCon
|
|||||||
const [newType, setNewType] = useState(isAnsible ? "ansible" : "powershell");
|
const [newType, setNewType] = useState(isAnsible ? "ansible" : "powershell");
|
||||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||||
|
|
||||||
|
const island = useMemo(() => (isAnsible ? 'ansible' : 'scripts'), [isAnsible]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
if (!initialPath) return;
|
if (!initialPath) return;
|
||||||
try {
|
try {
|
||||||
const resp = await fetch(`${baseApi}/load?path=${encodeURIComponent(initialPath)}`);
|
const resp = await fetch(`/api/assembly/load?island=${encodeURIComponent(island)}&path=${encodeURIComponent(initialPath)}`);
|
||||||
if (resp.ok) {
|
if (resp.ok) {
|
||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
setCurrentPath(data.rel_path || initialPath);
|
setCurrentPath(data.rel_path || initialPath);
|
||||||
@@ -118,7 +120,7 @@ export default function ScriptEditor({ mode = "scripts", initialPath = "", onCon
|
|||||||
if (onConsumedInitialPath) onConsumedInitialPath();
|
if (onConsumedInitialPath) onConsumedInitialPath();
|
||||||
})();
|
})();
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [initialPath, baseApi]);
|
}, [initialPath, island]);
|
||||||
|
|
||||||
const saveFile = async () => {
|
const saveFile = async () => {
|
||||||
if (!currentPath && !fileName) {
|
if (!currentPath && !fileName) {
|
||||||
|
|||||||
Reference in New Issue
Block a user