Merge branch 'dropdown-menu-links' into 'main'
Prefer to/href for DropdownMenuItems See merge request soapbox-pub/soapbox!3007
This commit is contained in:
commit
25350969fd
4 changed files with 10 additions and 22 deletions
|
@ -33,6 +33,7 @@ const DropdownMenuItem = ({ index, item, onClick }: IDropdownMenuItem) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
if (!item) return;
|
if (!item) return;
|
||||||
|
|
||||||
if (onClick) onClick();
|
if (onClick) onClick();
|
||||||
|
|
||||||
if (item.to) {
|
if (item.to) {
|
||||||
|
|
|
@ -211,10 +211,6 @@ const StatusActionBar: React.FC<IStatusActionBar> = ({
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleExternalClick = () => {
|
|
||||||
window.open(status.uri, '_blank');
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleReblogClick: React.EventHandler<React.MouseEvent> = e => {
|
const handleReblogClick: React.EventHandler<React.MouseEvent> = e => {
|
||||||
if (me) {
|
if (me) {
|
||||||
const modalReblog = () => dispatch(toggleReblog(status));
|
const modalReblog = () => dispatch(toggleReblog(status));
|
||||||
|
@ -336,10 +332,6 @@ const StatusActionBar: React.FC<IStatusActionBar> = ({
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleOpen: React.EventHandler<React.MouseEvent> = (e) => {
|
|
||||||
history.push(`/@${status.account.acct}/posts/${status.id}`);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleEmbed = () => {
|
const handleEmbed = () => {
|
||||||
dispatch(openModal('EMBED', {
|
dispatch(openModal('EMBED', {
|
||||||
url: status.url,
|
url: status.url,
|
||||||
|
@ -417,8 +409,8 @@ const StatusActionBar: React.FC<IStatusActionBar> = ({
|
||||||
if (expandable) {
|
if (expandable) {
|
||||||
menu.push({
|
menu.push({
|
||||||
text: intl.formatMessage(messages.open),
|
text: intl.formatMessage(messages.open),
|
||||||
action: handleOpen,
|
|
||||||
icon: require('@tabler/icons/outline/arrows-vertical.svg'),
|
icon: require('@tabler/icons/outline/arrows-vertical.svg'),
|
||||||
|
to: `/@${status.account.acct}/posts/${status.id}`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,8 +467,9 @@ const StatusActionBar: React.FC<IStatusActionBar> = ({
|
||||||
const { hostname: domain } = new URL(status.uri);
|
const { hostname: domain } = new URL(status.uri);
|
||||||
menu.push({
|
menu.push({
|
||||||
text: intl.formatMessage(messages.external, { domain }),
|
text: intl.formatMessage(messages.external, { domain }),
|
||||||
action: handleExternalClick,
|
|
||||||
icon: require('@tabler/icons/outline/external-link.svg'),
|
icon: require('@tabler/icons/outline/external-link.svg'),
|
||||||
|
href: status.uri,
|
||||||
|
target: '_blank',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -263,10 +263,6 @@ const Header: React.FC<IHeader> = ({ account }) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRssFeedClick = () => {
|
|
||||||
window.open(software === MASTODON ? `${account.url}.rss` : `${account.url}/feed.rss`, '_blank');
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleShare = () => {
|
const handleShare = () => {
|
||||||
navigator.share({
|
navigator.share({
|
||||||
text: `@${account.acct}`,
|
text: `@${account.acct}`,
|
||||||
|
@ -290,8 +286,9 @@ const Header: React.FC<IHeader> = ({ account }) => {
|
||||||
if (features.rssFeeds && account.local) {
|
if (features.rssFeeds && account.local) {
|
||||||
menu.push({
|
menu.push({
|
||||||
text: intl.formatMessage(messages.subscribeFeed),
|
text: intl.formatMessage(messages.subscribeFeed),
|
||||||
action: handleRssFeedClick,
|
|
||||||
icon: require('@tabler/icons/outline/rss.svg'),
|
icon: require('@tabler/icons/outline/rss.svg'),
|
||||||
|
href: software === MASTODON ? `${account.url}.rss` : `${account.url}/feed.rss`,
|
||||||
|
target: '_blank',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,10 +113,6 @@ const EventHeader: React.FC<IEventHeader> = ({ status }) => {
|
||||||
copy(uri);
|
copy(uri);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleExternalClick = () => {
|
|
||||||
window.open(status.uri, '_blank');
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleBookmarkClick = () => {
|
const handleBookmarkClick = () => {
|
||||||
dispatch(toggleBookmark(status));
|
dispatch(toggleBookmark(status));
|
||||||
};
|
};
|
||||||
|
@ -218,8 +214,9 @@ const EventHeader: React.FC<IEventHeader> = ({ status }) => {
|
||||||
if (features.federating && !account.local) {
|
if (features.federating && !account.local) {
|
||||||
menu.push({
|
menu.push({
|
||||||
text: intl.formatMessage(messages.external, { domain }),
|
text: intl.formatMessage(messages.external, { domain }),
|
||||||
action: handleExternalClick,
|
|
||||||
icon: require('@tabler/icons/outline/external-link.svg'),
|
icon: require('@tabler/icons/outline/external-link.svg'),
|
||||||
|
href: status.uri,
|
||||||
|
target: '_blank',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,8 +390,8 @@ const EventHeader: React.FC<IEventHeader> = ({ status }) => {
|
||||||
if (typeof menuItem?.text === 'undefined') {
|
if (typeof menuItem?.text === 'undefined') {
|
||||||
return <MenuDivider key={idx} />;
|
return <MenuDivider key={idx} />;
|
||||||
} else {
|
} else {
|
||||||
const Comp = (menuItem.action ? MenuItem : MenuLink) as any;
|
const Comp = (menuItem.href ? MenuLink : MenuItem) as any;
|
||||||
const itemProps = menuItem.action ? { onSelect: menuItem.action } : { to: menuItem.to, as: Link, target: menuItem.target || '_self' };
|
const itemProps = menuItem.href ? { href: menuItem.href, target: menuItem.target || '_self' } : { onSelect: menuItem.action };
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Comp key={idx} {...itemProps} className='group'>
|
<Comp key={idx} {...itemProps} className='group'>
|
||||||
|
|
Loading…
Reference in a new issue