feat(web): show disabled reasons in tooltips when buttons are disabled (#2430)
* feat(web): show disabled reasons in tooltips when buttons are disabled - Add disabled reason tooltips for model card actions (set default, delete) - Add disabled reason tooltips for marketplace skill card install button - Add disabled reason display for chat input when disabled - Add internationalization support for all disabled reasons (en/zh) - Model card: Show specific reasons when set-default or delete buttons are disabled - Marketplace skill card: Show specific reasons when install button is disabled - Chat composer: Show reason text below input when input is disabled * fix: show disabled action reasons via tooltips * fix(web): restore accessible labels for model action tooltips
This commit is contained in:
5 files changed
+187
-46
No files matched your search
@@ -18,6 +18,11 @@ import {
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card"
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip"
|
||||
|
||||
export function MarketSkillCard({
|
||||
result,
|
||||
@@ -36,6 +41,17 @@ export function MarketSkillCard({
|
||||
}) {
|
||||
const { t } = useTranslation()
|
||||
|
||||
const installDisabledReason = (() => {
|
||||
if (installPending)
|
||||
return t("pages.agent.skills.marketplace_installDisabled.installing")
|
||||
if (result.installed)
|
||||
return t("pages.agent.skills.marketplace_installDisabled.installed")
|
||||
if (!canInstall)
|
||||
return t("pages.agent.skills.marketplace_installDisabled.cannotInstall")
|
||||
return t("pages.agent.skills.marketplace_install_action")
|
||||
})()
|
||||
const installDisabled = !canInstall || result.installed || installPending
|
||||
|
||||
return (
|
||||
<Card
|
||||
className="group border-border/40 bg-card/40 hover:border-border/80 hover:bg-card relative overflow-hidden transition-all hover:shadow-md"
|
||||
@@ -86,24 +102,34 @@ export function MarketSkillCard({
|
||||
) : null}
|
||||
</div>
|
||||
<div className="flex shrink-0 flex-col items-end gap-2">
|
||||
<Button
|
||||
size="sm"
|
||||
variant={result.installed ? "secondary" : "default"}
|
||||
className="shadow-sm transition-all"
|
||||
disabled={!canInstall || result.installed || installPending}
|
||||
onClick={onInstall}
|
||||
>
|
||||
{installPending ? (
|
||||
<IconLoader2 className="size-4 animate-spin" />
|
||||
) : result.installed ? (
|
||||
<IconCheck className="size-4" />
|
||||
) : (
|
||||
<IconPlus className="size-4" />
|
||||
)}
|
||||
{result.installed
|
||||
? t("pages.agent.skills.marketplace_installed")
|
||||
: t("pages.agent.skills.marketplace_install_action")}
|
||||
</Button>
|
||||
<Tooltip delayDuration={installDisabled ? 0 : 700}>
|
||||
<TooltipTrigger asChild>
|
||||
<span
|
||||
className={installDisabled ? "cursor-not-allowed" : undefined}
|
||||
tabIndex={installDisabled ? 0 : undefined}
|
||||
>
|
||||
<Button
|
||||
size="sm"
|
||||
variant={result.installed ? "secondary" : "default"}
|
||||
className="shadow-sm transition-all"
|
||||
disabled={installDisabled}
|
||||
onClick={onInstall}
|
||||
>
|
||||
{installPending ? (
|
||||
<IconLoader2 className="size-4 animate-spin" />
|
||||
) : result.installed ? (
|
||||
<IconCheck className="size-4" />
|
||||
) : (
|
||||
<IconPlus className="size-4" />
|
||||
)}
|
||||
{result.installed
|
||||
? t("pages.agent.skills.marketplace_installed")
|
||||
: t("pages.agent.skills.marketplace_install_action")}
|
||||
</Button>
|
||||
</span>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>{installDisabledReason}</TooltipContent>
|
||||
</Tooltip>
|
||||
{result.installed && installedSkill ? (
|
||||
<Button
|
||||
variant="outline"
|
||||
|
||||
Reference in new issue
Block a user