Add basic UI support for invalid handles in Web UI (#40045)
This commit is contained in:
1 parent
d303a23f7f
commit
e21dc88ce9
11 files changed
+163
-50
No files matched your search
@@ -226,6 +226,10 @@ const redesignMessages = defineMessages({
|
||||
id: 'account.menu.open_original_page',
|
||||
defaultMessage: 'View on {domain}',
|
||||
},
|
||||
openOriginalPageInvalid: {
|
||||
id: 'account.menu.open_original_page_no_domain',
|
||||
defaultMessage: 'View on original server',
|
||||
},
|
||||
removeFollower: {
|
||||
id: 'account.menu.remove_follower',
|
||||
defaultMessage: 'Remove follower',
|
||||
@@ -270,32 +274,37 @@ function getMenuItems({
|
||||
// Open on remote page.
|
||||
if (isRemote) {
|
||||
items.push({
|
||||
text: intl.formatMessage(redesignMessages.openOriginalPage, {
|
||||
domain: remoteDomain,
|
||||
}),
|
||||
text: account.invalid_handle
|
||||
? intl.formatMessage(redesignMessages.openOriginalPageInvalid)
|
||||
: intl.formatMessage(redesignMessages.openOriginalPage, {
|
||||
domain: remoteDomain,
|
||||
}),
|
||||
href: account.url,
|
||||
});
|
||||
}
|
||||
|
||||
// Mention and direct message options
|
||||
if (signedIn && !account.suspended) {
|
||||
items.push(
|
||||
null,
|
||||
{
|
||||
text: intl.formatMessage(redesignMessages.mention),
|
||||
action: () => {
|
||||
dispatch(mentionCompose(account));
|
||||
if (account.invalid_handle) items.push(null);
|
||||
else {
|
||||
items.push(
|
||||
null,
|
||||
{
|
||||
text: intl.formatMessage(redesignMessages.mention),
|
||||
action: () => {
|
||||
dispatch(mentionCompose(account));
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
text: intl.formatMessage(redesignMessages.direct),
|
||||
action: () => {
|
||||
dispatch(directCompose(account));
|
||||
{
|
||||
text: intl.formatMessage(redesignMessages.direct),
|
||||
action: () => {
|
||||
dispatch(directCompose(account));
|
||||
},
|
||||
},
|
||||
},
|
||||
null,
|
||||
);
|
||||
null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!signedIn) {
|
||||
@@ -484,7 +493,7 @@ function getMenuItems({
|
||||
});
|
||||
}
|
||||
|
||||
if (remoteDomain) {
|
||||
if (remoteDomain && !account.invalid_handle) {
|
||||
items.push(null, {
|
||||
text: intl.formatMessage(
|
||||
relationship?.domain_blocking
|
||||
@@ -524,6 +533,7 @@ function getMenuItems({
|
||||
}
|
||||
if (
|
||||
remoteDomain &&
|
||||
!account.invalid_handle &&
|
||||
(permissions & PERMISSION_MANAGE_FEDERATION) ===
|
||||
PERMISSION_MANAGE_FEDERATION
|
||||
) {
|
||||
|
||||
@@ -62,17 +62,84 @@ export const AccountName: FC<{ accountId: string }> = ({ accountId }) => {
|
||||
{relationship?.followed_by && <FollowsYouBadge />}
|
||||
</div>
|
||||
|
||||
<AccountNameHelp
|
||||
username={username}
|
||||
domain={domain}
|
||||
isSelf={account.id === me}
|
||||
/>
|
||||
{account.invalid_handle ? (
|
||||
<InvalidAccountHelp />
|
||||
) : (
|
||||
<AccountNameHelp
|
||||
username={username}
|
||||
domain={domain}
|
||||
isSelf={account.id === me}
|
||||
/>
|
||||
)}
|
||||
|
||||
<AccountBadges accountId={accountId} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const InvalidAccountHelp: FC = () => {
|
||||
const accessibilityId = useId();
|
||||
const intl = useIntl();
|
||||
const [open, setOpen] = useState(false);
|
||||
const [triggerElement, setTriggerElement] =
|
||||
useState<HTMLButtonElement | null>(null);
|
||||
|
||||
const handleClick = useCallback(() => {
|
||||
setOpen((prev) => !prev);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<button
|
||||
type='button'
|
||||
ref={setTriggerElement}
|
||||
className={classNames(classes.handleHelpButton)}
|
||||
onClick={handleClick}
|
||||
aria-expanded={open}
|
||||
aria-controls={accessibilityId}
|
||||
>
|
||||
<FormattedMessage
|
||||
id='account.hame.invalid_handle'
|
||||
defaultMessage='Handle unavailable'
|
||||
/>
|
||||
|
||||
<Icon
|
||||
id='help'
|
||||
icon={HelpIcon}
|
||||
aria-label={intl.formatMessage(messages.nameInfo)}
|
||||
/>
|
||||
</button>
|
||||
|
||||
<Popover
|
||||
isOpen={open}
|
||||
reference={triggerElement}
|
||||
onClose={handleClick}
|
||||
offset={5}
|
||||
>
|
||||
{({ props }) => (
|
||||
<div
|
||||
{...props}
|
||||
role='region'
|
||||
id={accessibilityId}
|
||||
className={classNames('dropdown-animation', classes.handleHelp)}
|
||||
>
|
||||
<FormattedMessage
|
||||
id='account.name.help.invalid_header'
|
||||
defaultMessage="This user's handle is being updated"
|
||||
tagName='h3'
|
||||
/>
|
||||
<FormattedMessage
|
||||
id='account.name.help.invalid_explanation'
|
||||
defaultMessage='This can happen when a user changes username, and is generally temporary. If this persists, it may be because of an unavailable server or some misconfiguration on their end.'
|
||||
tagName='p'
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</Popover>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const AccountNameHelp: FC<{
|
||||
username: string;
|
||||
domain: string;
|
||||
|
||||
@@ -142,7 +142,8 @@
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
> ol {
|
||||
> ol,
|
||||
> p {
|
||||
margin: 12px 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user