Files
ServerKit/frontend/src/components/PagePrimaryButton.jsx
T
Juan Denis 9a8b116eda feat(ui): explain the remaining disabled buttons
Button: the disabledReason description now sits beside the button instead
of inside it, so the accessible name stays the label and the reason is only
the description. Controls test asserts both (text and icon buttons).

disabledReason added to: backup schedule Save, job progress Close, service
Settings attach domain (x2), DNS Add record, New service Connect GitHub,
shared variable groups (Create group, Add, Attach), .htaccess Convert,
deploy console prev/next match, DataTable sort direction, Cron job form,
Recipes Start, filter drawer Clear all, saved view Save, ChangeBar
Undo/Redo/Save, log viewer Refresh/Download, server Packages Uninstall,
grid Column menu (move left/right, clear filter), File manager Up, grid
Tools scope, grid view Create, OAuth Connect, DB table Next page, DB
console Export, DB import dump, Operations dock Continue, Notifications
Reset, integrity Baseline/Check, AI composer Send, Terminal journal
toolbar (remote), and the page primary action / phone header "+".
2026-11-10 20:26:35 -05:00

36 lines
1.5 KiB
React

import { useNavigate } from 'react-router-dom';
import { Plus } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { usePagePrimaryAction } from '../contexts/pagePrimaryAction.js';
// A page's primary create button: compact icon + short label on desktop (the
// full text rides in title/aria-label), and it registers the same action with
// the mobile header "+", which takes over at the width where this button hides
// (.sk-topbar__primary). Pass `to` instead of onClick to navigate.
// `iconOnly` drops the visible label, e.g. for pages with a tight icon bar.
// `disabledReason` (a prerequisite, not a pending request) is shown on both this
// button and the header "+".
export function PagePrimaryButton({ id, label, shortLabel, icon: Icon = Plus, onClick, to, disabled = false, disabledReason, iconOnly = false }) {
const navigate = useNavigate();
const run = to ? () => navigate(to) : onClick;
usePagePrimaryAction({ id, label, onClick: run, disabled, disabledReason });
return (
<Button
size={iconOnly ? 'icon' : 'sm'}
variant={iconOnly ? 'ghost' : 'default'}
className="sk-topbar__primary"
title={label}
aria-label={label}
disabled={disabled}
disabledReason={disabledReason}
onClick={run}
>
<Icon size={15} aria-hidden="true" />
{!iconOnly && (shortLabel || label)}
</Button>
);
}
export default PagePrimaryButton;