diff --git a/backend/windmill-api/src/folders.rs b/backend/windmill-api/src/folders.rs index 7f27e4cc6a..4022cb4a0a 100644 --- a/backend/windmill-api/src/folders.rs +++ b/backend/windmill-api/src/folders.rs @@ -163,7 +163,7 @@ async fn create_folder( check_name_conflict(&mut tx, &w_id, &ng.name).await?; cache.invalidate(&w_id, token).await; let owner = username_to_permissioned_as(&authed.username); - let owners = &ng.owners.unwrap_or(vec![owner.clone()]); + let owners = &ng.owners.unwrap_or_else(|| vec![owner.clone()]); if let Some(extra_perms) = ng.extra_perms.clone() { for o in owners { diff --git a/frontend/src/lib/components/DeployWorkspace.svelte b/frontend/src/lib/components/DeployWorkspace.svelte index 6208376a3d..a1fa199454 100644 --- a/frontend/src/lib/components/DeployWorkspace.svelte +++ b/frontend/src/lib/components/DeployWorkspace.svelte @@ -4,6 +4,7 @@ import { AppService, FlowService, + FolderService, RawAppService, ResourceService, ScheduleService, @@ -66,19 +67,21 @@ seeTarget = false } - dependencies = (await getDependencies(kind, path)).map((x) => ({ + const allDeps = await getDependencies(kind, path) + for (const dep of allDeps) { + allAlreadyExists[computeStatusPath(dep.kind, dep.path)] = await checkAlreadyExists( + dep.kind, + dep.path + ) + } + dependencies = allDeps.map((x) => ({ ...x, include: - kind == 'variable' || - kind == 'resource' || - kind == 'resource_type' || - (x.kind != 'variable' && x.kind != 'resource' && x.kind != 'resource_type') + x.kind != 'variable' && + x.kind != 'resource' && + x.kind != 'resource_type' && + (x.kind != 'folder' || !allAlreadyExists[computeStatusPath(x.kind, x.path)]) })) - dependencies.forEach((x) => { - checkAlreadyExists(x.kind, x.path).then( - (y) => (allAlreadyExists[computeStatusPath(x.kind, x.path)] = y) - ) - }) } async function getDependencies( @@ -146,6 +149,14 @@ toProcess.push(...(await rec(kind, path))) processed.push({ kind, path }) } + let folders: string[] = [] + for (const p of processed) { + let split = p.path.split('/') + if (split.length > 2 && split[0] == 'f' && !folders.includes(split[1])) { + folders.push(split[1]) + processed.push({ kind: 'folder', path: split[1] }) + } + } processed.reverse() return processed } @@ -191,6 +202,17 @@ workspace: workspaceToDeployTo!, path: path }) + } else if (kind == 'folder') { + let exists = true + try { + await FolderService.getFolder({ + workspace: workspaceToDeployTo!, + name: path + }) + } catch (e) { + exists = false + } + return exists } else { throw new Error(`Unknown kind ${kind}`) } @@ -367,6 +389,15 @@ // path: path // } // }) + } else if (kind == 'folder') { + await FolderService.createFolder({ + workspace: workspaceToDeployTo!, + requestBody: { + name: path + } + }) + } else { + throw new Error(`Unknown kind ${kind}`) } allAlreadyExists[statusPath] = true @@ -453,6 +484,16 @@ // path: path // } // }) + } else if (kind == 'folder') { + const folder = await FolderService.getFolder({ + workspace: workspace, + name: path + }) + return { + name: folder.name + } + } else { + throw new Error(`Unknown kind ${kind}`) } } catch { return {} @@ -502,7 +543,7 @@