mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-05 07:30:11 +00:00
fix: Hide delete button for input assets in OSS and fix cloud download (#6697)
## Summary Fix delete button visibility for input assets in OSS environment and resolve 404 error when downloading assets in cloud. ## Changes ### 1. Improved Delete Button Visibility Logic - **Problem**: In OSS environment, input files are sourced from local folders and cannot be deleted - **Solution**: Added `shouldShowDeleteButton` computed property to conditionally hide delete buttons - **Impact**: - Input tab + Cloud: Delete button shown ✅ - Input tab + OSS: Delete button hidden ❌ - Output tab (all environments): Delete button shown ✅ ### 2. Fixed Cloud Download 404 Error - **Problem**: Downloading files from imported tab in cloud returned 404 error for `/api/view` endpoint - **Root Cause**: In cloud environment, files are stored in external storage (e.g., GCS) and `/api/view` endpoint is not available - **Solution**: - Cloud: Use `preview_url` directly for downloads - OSS/localhost: Continue using `/api/view` endpoint as before - Applied the same logic to both single and bulk download operations ## Test Plan - [ ] Verify delete button is hidden in input tab on OSS environment - [ ] Verify delete button is shown in input tab on cloud environment - [ ] Verify file downloads work correctly in cloud for both input and output tabs - [ ] Verify file downloads work correctly in OSS for output tab 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -82,7 +82,7 @@
|
||||
:selected="isSelected(item.id)"
|
||||
:show-output-count="shouldShowOutputCount(item)"
|
||||
:output-count="getOutputCount(item)"
|
||||
:show-delete-button="!isInFolderView"
|
||||
:show-delete-button="shouldShowDeleteButton"
|
||||
@click="handleAssetSelect(item)"
|
||||
@zoom="handleZoomClick(item)"
|
||||
@output-count-click="enterFolderView(item)"
|
||||
@@ -94,7 +94,7 @@
|
||||
</template>
|
||||
<template #footer>
|
||||
<div
|
||||
v-if="hasSelection && activeTab === 'output'"
|
||||
v-if="hasSelection"
|
||||
class="flex h-18 w-full items-center justify-between px-4"
|
||||
>
|
||||
<div>
|
||||
@@ -122,7 +122,7 @@
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<IconTextButton
|
||||
v-if="!isInFolderView"
|
||||
v-if="shouldShowDeleteButton"
|
||||
:label="$t('mediaAsset.selection.deleteSelected')"
|
||||
type="secondary"
|
||||
icon-position="right"
|
||||
@@ -174,6 +174,7 @@ import { useMediaAssetActions } from '@/platform/assets/composables/useMediaAsse
|
||||
import { useMediaAssetFiltering } from '@/platform/assets/composables/useMediaAssetFiltering'
|
||||
import { getOutputAssetMetadata } from '@/platform/assets/schemas/assetMetadataSchema'
|
||||
import type { AssetItem } from '@/platform/assets/schemas/assetSchema'
|
||||
import { isCloud } from '@/platform/distribution/types'
|
||||
import { ResultItemImpl } from '@/stores/queueStore'
|
||||
import { formatDuration, getMediaTypeFromFilename } from '@/utils/formatUtil'
|
||||
|
||||
@@ -184,6 +185,13 @@ const folderPromptId = ref<string | null>(null)
|
||||
const folderExecutionTime = ref<number | undefined>(undefined)
|
||||
const isInFolderView = computed(() => folderPromptId.value !== null)
|
||||
|
||||
// Determine if delete button should be shown
|
||||
// Hide delete button when in input tab and not in cloud (OSS mode - files are from local folders)
|
||||
const shouldShowDeleteButton = computed(() => {
|
||||
if (activeTab.value === 'input' && !isCloud) return false
|
||||
return true
|
||||
})
|
||||
|
||||
const getOutputCount = (item: AssetItem): number => {
|
||||
const count = item.user_metadata?.outputCount
|
||||
return typeof count === 'number' && count > 0 ? count : 0
|
||||
|
||||
@@ -25,11 +25,19 @@ export function useMediaAssetActions() {
|
||||
if (!asset) return
|
||||
|
||||
try {
|
||||
const assetType = asset.tags?.[0] || 'output'
|
||||
const filename = asset.name
|
||||
const downloadUrl = api.apiURL(
|
||||
`/view?filename=${encodeURIComponent(filename)}&type=${assetType}`
|
||||
)
|
||||
let downloadUrl: string
|
||||
|
||||
// In cloud, use preview_url directly (from cloud storage)
|
||||
// In OSS/localhost, use the /view endpoint
|
||||
if (isCloud && asset.src) {
|
||||
downloadUrl = asset.src
|
||||
} else {
|
||||
const assetType = asset.tags?.[0] || 'output'
|
||||
downloadUrl = api.apiURL(
|
||||
`/view?filename=${encodeURIComponent(filename)}&type=${assetType}`
|
||||
)
|
||||
}
|
||||
|
||||
downloadFile(downloadUrl, filename)
|
||||
|
||||
@@ -58,11 +66,19 @@ export function useMediaAssetActions() {
|
||||
|
||||
try {
|
||||
assets.forEach((asset) => {
|
||||
const assetType = asset.tags?.[0] || 'output'
|
||||
const filename = asset.name
|
||||
const downloadUrl = api.apiURL(
|
||||
`/view?filename=${encodeURIComponent(filename)}&type=${assetType}`
|
||||
)
|
||||
let downloadUrl: string
|
||||
|
||||
// In cloud, use preview_url directly (from GCS or other cloud storage)
|
||||
// In OSS/localhost, use the /view endpoint
|
||||
if (isCloud && asset.preview_url) {
|
||||
downloadUrl = asset.preview_url
|
||||
} else {
|
||||
const assetType = asset.tags?.[0] || 'output'
|
||||
downloadUrl = api.apiURL(
|
||||
`/view?filename=${encodeURIComponent(filename)}&type=${assetType}`
|
||||
)
|
||||
}
|
||||
downloadFile(downloadUrl, filename)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user