mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 02:18:08 +08:00
fix(skill): disable template buttons during upload to prevent duplicates
Pass disabled/loading props to TemplateCard declaratively from loadingId state. All cards are disabled while any upload is in progress, and the active card shows a loading spinner. Remove the imperative pointer-events overlay in favor of native button disabled.
This commit is contained in:
@ -94,13 +94,12 @@ const SkillTemplatesSection = () => {
|
||||
<TemplateCard
|
||||
key={entry.id}
|
||||
template={entry}
|
||||
disabled={loadingId !== null}
|
||||
loading={loadingId === entry.id}
|
||||
onUse={handleUse}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
{loadingId
|
||||
? <div className="pointer-events-none fixed inset-0 z-50" />
|
||||
: null}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
@ -10,10 +10,12 @@ import Button from '@/app/components/base/button'
|
||||
|
||||
type TemplateCardProps = {
|
||||
template: SkillTemplateSummary
|
||||
disabled?: boolean
|
||||
loading?: boolean
|
||||
onUse: (template: SkillTemplateSummary) => void
|
||||
}
|
||||
|
||||
const TemplateCard = ({ template, onUse }: TemplateCardProps) => {
|
||||
const TemplateCard = ({ template, disabled, loading, onUse }: TemplateCardProps) => {
|
||||
const { t } = useTranslation('workflow')
|
||||
|
||||
return (
|
||||
@ -53,6 +55,8 @@ const TemplateCard = ({ template, onUse }: TemplateCardProps) => {
|
||||
variant="primary"
|
||||
size="medium"
|
||||
className="w-full"
|
||||
disabled={disabled}
|
||||
loading={loading}
|
||||
onClick={() => onUse(template)}
|
||||
>
|
||||
<RiAddLine className="mr-0.5 h-4 w-4" />
|
||||
|
||||
Reference in New Issue
Block a user