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:
yyh
2026-01-30 15:32:49 +08:00
parent abe2b37e3a
commit 60b4b10622
2 changed files with 7 additions and 4 deletions

View File

@ -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>
)
}

View File

@ -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" />