mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-23 08:00:45 +00:00
R/W/RW selection and changes node pos in flow
This commit is contained in:
@@ -8,15 +8,17 @@
|
||||
import ExploreAssetButton, {
|
||||
assetCanBeExplored
|
||||
} from '../../../routes/(root)/(logged)/assets/ExploreAssetButton.svelte'
|
||||
import { formatAsset, type Asset, type AssetWithAccessType } from './lib'
|
||||
import { assetEq, formatAsset, type Asset, type AssetWithAccessType } from './lib'
|
||||
import DbManagerDrawer from '../DBManagerDrawer.svelte'
|
||||
import { untrack } from 'svelte'
|
||||
import { ResourceService } from '$lib/gen'
|
||||
import { ResourceService, type AssetUsageAccessType } from '$lib/gen'
|
||||
import { workspaceStore } from '$lib/stores'
|
||||
import Button from '../common/button/Button.svelte'
|
||||
import Tooltip from '../meltComponents/Tooltip.svelte'
|
||||
import ResourceEditorDrawer from '../ResourceEditorDrawer.svelte'
|
||||
import type { Placement } from '@floating-ui/core'
|
||||
import Select from '../select/Select.svelte'
|
||||
import { safeSelectItems } from '../select/utils.svelte'
|
||||
|
||||
let {
|
||||
assets,
|
||||
@@ -25,8 +27,10 @@
|
||||
noBtnText = false,
|
||||
popoverPlacement = 'bottom-end',
|
||||
disableLiTooltip = false,
|
||||
accessTypeOverrides,
|
||||
onHoverLi,
|
||||
liSubtitle
|
||||
liSubtitle,
|
||||
onAccessTypeChanged
|
||||
}: {
|
||||
assets: AssetWithAccessType[]
|
||||
enableChangeAnimation?: boolean
|
||||
@@ -34,8 +38,10 @@
|
||||
noBtnText?: boolean
|
||||
popoverPlacement?: Placement
|
||||
disableLiTooltip?: boolean
|
||||
accessTypeOverrides?: AssetWithAccessType[]
|
||||
onHoverLi?: (asset: Asset, eventType: 'enter' | 'leave') => void
|
||||
liSubtitle?: (asset: Asset) => string
|
||||
onAccessTypeChanged?: (asset: AssetWithAccessType, accessType: AssetUsageAccessType) => void
|
||||
} = $props()
|
||||
|
||||
let prevAssets = $state<typeof assets>([])
|
||||
@@ -155,6 +161,20 @@
|
||||
_resourceMetadata={{ resource_type: resourceDataCache[asset.path] }}
|
||||
/>
|
||||
{/if}
|
||||
{#if onAccessTypeChanged}
|
||||
<Select
|
||||
disablePortal
|
||||
items={safeSelectItems(['r', 'w', 'rw'])}
|
||||
bind:value={
|
||||
() =>
|
||||
accessTypeOverrides?.find((a) => assetEq(a, asset))?.access_type ??
|
||||
asset.access_type,
|
||||
(a) => {
|
||||
a && onAccessTypeChanged?.(asset, a)
|
||||
}
|
||||
}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
</li>
|
||||
{/each}
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
import { getStepHistoryLoaderContext } from '$lib/components/stepHistoryLoader.svelte'
|
||||
import AssetsDropdownButton from '$lib/components/assets/AssetsDropdownButton.svelte'
|
||||
import { inferAssets } from '$lib/infer'
|
||||
import { assetEq } from '$lib/components/assets/lib'
|
||||
|
||||
const {
|
||||
selectedId,
|
||||
@@ -415,7 +416,23 @@
|
||||
{#key flowModule.id}
|
||||
<div class="absolute top-2 right-4 z-10 flex flex-row gap-2">
|
||||
{#if assets.value?.length}
|
||||
<AssetsDropdownButton assets={assets.value} />
|
||||
<AssetsDropdownButton
|
||||
assets={assets.value}
|
||||
accessTypeOverrides={flowModule.value.asset_access_type_overrides}
|
||||
onAccessTypeChanged={async (asset, access_type) => {
|
||||
if (flowModule.value.type !== 'rawscript') return
|
||||
flowModule.value.asset_access_type_overrides =
|
||||
flowModule.value.asset_access_type_overrides?.filter(
|
||||
(a) => !assetEq(a, asset)
|
||||
)
|
||||
flowModule.value.asset_access_type_overrides ??= []
|
||||
await tick()
|
||||
flowModule.value.asset_access_type_overrides.push({
|
||||
...asset,
|
||||
access_type
|
||||
})
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
<Editor
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
READ_ASSET_Y_OFFSET,
|
||||
WRITE_ASSET_Y_OFFSET
|
||||
} from '../flows/utils'
|
||||
import { formatAsset } from '../assets/lib'
|
||||
import { assetEq, formatAsset } from '../assets/lib'
|
||||
|
||||
let useDataflow: Writable<boolean | undefined> = writable<boolean | undefined>(false)
|
||||
|
||||
@@ -741,10 +741,16 @@
|
||||
{#if mod.value.type === 'rawscript'}
|
||||
{@const v = mod.value}
|
||||
<OnChange
|
||||
key={v.content}
|
||||
key={[v.content, v.asset_access_type_overrides]}
|
||||
runFirstEffect
|
||||
onChange={() =>
|
||||
inferAssets(v.language, v.content).then((assets) => {
|
||||
for (const override of v.asset_access_type_overrides ?? []) {
|
||||
assets = assets.map((asset) => {
|
||||
if (assetEq(asset, override)) return { ...asset, access_type: override.access_type }
|
||||
return asset
|
||||
})
|
||||
}
|
||||
if (assetsMap && !deepEqual(assetsMap[mod.id], assets)) assetsMap[mod.id] = assets
|
||||
})}
|
||||
/>
|
||||
|
||||
+23
-1
@@ -100,7 +100,7 @@ components:
|
||||
type: string
|
||||
required:
|
||||
- expr
|
||||
|
||||
|
||||
FlowModule:
|
||||
type: object
|
||||
properties:
|
||||
@@ -270,6 +270,28 @@ components:
|
||||
type: string
|
||||
is_trigger:
|
||||
type: boolean
|
||||
asset_access_type_overrides:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
required:
|
||||
- path
|
||||
- kind
|
||||
- access_type
|
||||
properties:
|
||||
path:
|
||||
type: string
|
||||
kind:
|
||||
type: string
|
||||
enum:
|
||||
- s3object
|
||||
- resource
|
||||
access_type:
|
||||
type: string
|
||||
enum:
|
||||
- r
|
||||
- w
|
||||
- rw
|
||||
required:
|
||||
- type
|
||||
- content
|
||||
|
||||
Reference in New Issue
Block a user