[feat] call AssetBrowserModal for whitelisted widgets

This commit is contained in:
Arjan Singh
2025-09-17 15:06:16 -07:00
parent 4820d87d86
commit b67e4977d7
13 changed files with 504 additions and 54 deletions

View File

@@ -1,4 +1,6 @@
import AssetBrowserModal from '@/platform/assets/components/AssetBrowserModal.vue'
import type { AssetItem } from '@/platform/assets/schemas/assetSchema'
import { assetService } from '@/platform/assets/services/assetService'
import { useDialogStore } from '@/stores/dialogStore'
interface AssetBrowserDialogProps {
@@ -8,8 +10,11 @@ interface AssetBrowserDialogProps {
inputName: string
/** Current selected asset value */
currentValue?: string
/** Callback for when an asset is selected */
onAssetSelected?: (assetPath: string) => void
/**
* Callback for when an asset is selected
* @param {string} filename - The validated filename from user_metadata.filename
*/
onAssetSelected?: (filename: string) => void
}
export const useAssetBrowserDialog = () => {
@@ -20,7 +25,7 @@ export const useAssetBrowserDialog = () => {
dialogStore.closeDialog({ key: dialogKey })
}
function show(props: AssetBrowserDialogProps) {
async function show(props: AssetBrowserDialogProps) {
const handleAssetSelected = (assetPath: string) => {
props.onAssetSelected?.(assetPath)
hide() // Auto-close on selection
@@ -48,6 +53,14 @@ export const useAssetBrowserDialog = () => {
}
}
// Fetch assets for the specific node type, fallback to empty array on error
let assets: AssetItem[] = []
try {
assets = await assetService.getAssetsForNodeType(props.nodeType)
} catch (error) {
console.error('Failed to fetch assets for node type:', props.nodeType, error)
}
dialogStore.showDialog({
key: dialogKey,
component: AssetBrowserModal,
@@ -55,6 +68,7 @@ export const useAssetBrowserDialog = () => {
nodeType: props.nodeType,
inputName: props.inputName,
currentValue: props.currentValue,
assets,
onSelect: handleAssetSelected,
onClose: handleClose
},