diff --git a/backend/windmill-api/openapi.yaml b/backend/windmill-api/openapi.yaml index af4188c2a7..0b4e8a1839 100644 --- a/backend/windmill-api/openapi.yaml +++ b/backend/windmill-api/openapi.yaml @@ -4275,6 +4275,7 @@ components: - hash - path - summary + - description - content - created_by - created_at diff --git a/frontend/src/lib/components/Dropdown.svelte b/frontend/src/lib/components/Dropdown.svelte index f19f9a87ff..ab8fc29a39 100644 --- a/frontend/src/lib/components/Dropdown.svelte +++ b/frontend/src/lib/components/Dropdown.svelte @@ -36,16 +36,17 @@ dispatch('click', { item: item?.eventName }) } }} - class="block w-full whitespace-nowrap hover:drop-shadow-sm hover:bg-gray-50 hover:bg-opacity-30 px-4 py-2 text-sm text-gray-700 text-left {item.separatorTop - ? 'border-t' - : ''} {item.separatorBottom ? 'border-b' : ''} {item.type == 'delete' + class="block w-full whitespace-nowrap hover:drop-shadow-sm hover:bg-gray-50 hover:bg-opacity-30 + px-4 py-2 text-sm text-gray-700 text-left + {item.disabled ? 'bg-gray-100' : ''} + {item.separatorTop ? 'border-t' : ''} {item.separatorBottom ? 'border-b' : ''} {item.type == + 'delete' ? 'text-red-500' : ''}" role="menuitem" tabindex="-1" id="user-menu-item-{name}-{i}}" disabled={item.disabled} - class:disabled={item.disabled} > {#if item.icon} { folder = await FolderService.getFolder({ workspace: $workspaceStore!, name }) - can_write = folder.owners.includes('u/' + $userStore?.username) + can_write = + folder.owners.includes('u/' + $userStore?.username) || ($userStore?.is_admin ?? false) perms = Array.from( new Set( Object.entries(folder?.extra_perms ?? {}) @@ -216,7 +217,7 @@ (scripts/flows/apps/schedules/resources/variables) inside the folder - Admin An admin of a folder has read AND write access to all the elements inside the folders and can manage the permissions as well as add new admins + import { isOwner } from '$lib/utils' + import { createEventDispatcher } from 'svelte' + import { userStore, workspaceStore } from '$lib/stores' + import { Alert, Button, Drawer } from './common' + import DrawerContent from './common/drawer/DrawerContent.svelte' + import Path from './Path.svelte' + import { FlowService, ScriptService } from '$lib/gen' + + const dispatch = createEventDispatcher() + + type Kind = 'script' | 'resource' | 'schedule' | 'variable' | 'flow' | 'app' + + let kind: Kind + let initialPath: string = '' + let path: string = '' + + let drawer: Drawer + + let own = false + export async function openDrawer(initialPath_l: string, kind_l: Kind) { + kind = kind_l + initialPath = initialPath_l + drawer.openDrawer() + } + + $: $userStore && $workspaceStore && loadOwner() + + async function loadOwner() { + own = await isOwner(path, $userStore!, $workspaceStore!) + } + + async function updatePath() { + if (kind == 'flow') { + const flow = await FlowService.getFlowByPath({ + workspace: $workspaceStore!, + path: initialPath + }) + await FlowService.updateFlow({ + workspace: $workspaceStore!, + path: initialPath, + requestBody: { + path, + summary: flow.summary, + description: flow.description, + value: flow.value + } + }) + } else if (kind == 'script') { + const script = await ScriptService.getScriptByPath({ + workspace: $workspaceStore!, + path: initialPath + }) + await ScriptService.createScript({ + workspace: $workspaceStore!, + requestBody: { + ...script, + description: script.description ?? '', + lock: script.lock?.split('\n'), + parent_hash: script.hash, + path + } + }) + } + dispatch('update', path) + drawer.closeDrawer() + } + + + + +
+

Move {initialPath} to

+ {#if !own} + Since you do not own this item, you cannot move this item(you can however fork it!) + {/if} + + +
+
+ + diff --git a/frontend/src/lib/components/Path.svelte b/frontend/src/lib/components/Path.svelte index 37b7af8c77..33ad78bee7 100644 --- a/frontend/src/lib/components/Path.svelte +++ b/frontend/src/lib/components/Path.svelte @@ -350,7 +350,7 @@ > -
+