Skip to content

Commit

Permalink
fix(web): make registration alert more compact
Browse files Browse the repository at this point in the history
By using a link instead of a button for the action since it is the right
component from a semantic point of view: it performs a navigation for
taking the user to another place.
  • Loading branch information
dgdavid committed Jan 28, 2025
1 parent 02752ce commit 8617f86
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions web/src/components/product/ProductRegistrationAlert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ import { _ } from "~/i18n";
import { sprintf } from "sprintf-js";
import { useIssues } from "~/queries/issues";

const LinkToRegistration = () => {
const LinkToRegistration = ({ text }: { text: string }) => {
const location = useLocation();

if (location.pathname === REGISTRATION.root) return;
if (location.pathname === REGISTRATION.root) return text;

return (
<Link to={REGISTRATION.root} variant="control">
{_("Register it now")}
<Link to={REGISTRATION.root} variant="link" isInline>
{text}
</Link>
);
};
Expand All @@ -53,9 +53,20 @@ export default function ProductRegistrationAlert() {
if (SUPPORTIVE_PATHS.includes(location.pathname)) return;
if (!registrationRequired) return;

const [textStart, text, textEnd] = sprintf(_("%s [must be registered]."), product.name).split(
/[[\]]/,
);

return (
<Alert variant="warning" title={sprintf(_("%s must be registered."), product.name)}>
<LinkToRegistration />
</Alert>
<Alert
variant="warning"
title={
<>
{textStart}
<LinkToRegistration text={text} />
{textEnd}
</>
}
/>
);
}

0 comments on commit 8617f86

Please sign in to comment.