forked from mastodon/mastodon
-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #734 from kmycode/upstream-20240426
Upstream 20240426
- Loading branch information
Showing
22 changed files
with
390 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
app/javascript/mastodon/features/explore/components/card.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import PropTypes from 'prop-types'; | ||
import { useCallback } from 'react'; | ||
|
||
import { FormattedMessage, useIntl, defineMessages } from 'react-intl'; | ||
|
||
import { Link } from 'react-router-dom'; | ||
|
||
import { useDispatch, useSelector } from 'react-redux'; | ||
|
||
import CloseIcon from '@/material-icons/400-24px/close.svg?react'; | ||
import { followAccount, unfollowAccount } from 'mastodon/actions/accounts'; | ||
import { dismissSuggestion } from 'mastodon/actions/suggestions'; | ||
import { Avatar } from 'mastodon/components/avatar'; | ||
import { Button } from 'mastodon/components/button'; | ||
import { DisplayName } from 'mastodon/components/display_name'; | ||
import { IconButton } from 'mastodon/components/icon_button'; | ||
import { domain } from 'mastodon/initial_state'; | ||
|
||
const messages = defineMessages({ | ||
follow: { id: 'account.follow', defaultMessage: 'Follow' }, | ||
unfollow: { id: 'account.unfollow', defaultMessage: 'Unfollow' }, | ||
dismiss: { id: 'follow_suggestions.dismiss', defaultMessage: "Don't show again" }, | ||
}); | ||
|
||
export const Card = ({ id, source }) => { | ||
const intl = useIntl(); | ||
const account = useSelector(state => state.getIn(['accounts', id])); | ||
const relationship = useSelector(state => state.getIn(['relationships', id])); | ||
const dispatch = useDispatch(); | ||
const following = relationship?.get('following') ?? relationship?.get('requested'); | ||
|
||
const handleFollow = useCallback(() => { | ||
if (following) { | ||
dispatch(unfollowAccount(id)); | ||
} else { | ||
dispatch(followAccount(id)); | ||
} | ||
}, [id, following, dispatch]); | ||
|
||
const handleDismiss = useCallback(() => { | ||
dispatch(dismissSuggestion(id)); | ||
}, [id, dispatch]); | ||
|
||
let label; | ||
|
||
switch (source) { | ||
case 'friends_of_friends': | ||
label = <FormattedMessage id='follow_suggestions.friends_of_friends_longer' defaultMessage='Popular among people you follow' />; | ||
break; | ||
case 'similar_to_recently_followed': | ||
label = <FormattedMessage id='follow_suggestions.similar_to_recently_followed_longer' defaultMessage='Similar to profiles you recently followed' />; | ||
break; | ||
case 'featured': | ||
label = <FormattedMessage id='follow_suggestions.featured_longer' defaultMessage='Hand-picked by the {domain} team' values={{ domain }} />; | ||
break; | ||
case 'most_followed': | ||
label = <FormattedMessage id='follow_suggestions.popular_suggestion_longer' defaultMessage='Popular on {domain}' values={{ domain }} />; | ||
break; | ||
case 'most_interactions': | ||
label = <FormattedMessage id='follow_suggestions.popular_suggestion_longer' defaultMessage='Popular on {domain}' values={{ domain }} />; | ||
break; | ||
} | ||
|
||
return ( | ||
<div className='explore__suggestions__card'> | ||
<div className='explore__suggestions__card__source'> | ||
{label} | ||
</div> | ||
|
||
<div className='explore__suggestions__card__body'> | ||
<Link to={`/@${account.get('acct')}`}><Avatar account={account} size={48} /></Link> | ||
|
||
<div className='explore__suggestions__card__body__main'> | ||
<div className='explore__suggestions__card__body__main__name-button'> | ||
<Link className='explore__suggestions__card__body__main__name-button__name' to={`/@${account.get('acct')}`}><DisplayName account={account} /></Link> | ||
<IconButton iconComponent={CloseIcon} onClick={handleDismiss} title={intl.formatMessage(messages.dismiss)} /> | ||
<Button text={intl.formatMessage(following ? messages.unfollow : messages.follow)} secondary={following} onClick={handleFollow} /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
Card.propTypes = { | ||
id: PropTypes.string.isRequired, | ||
source: PropTypes.oneOf(['friends_of_friends', 'similar_to_recently_followed', 'featured', 'most_followed', 'most_interactions']), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
app/javascript/mastodon/features/notifications/components/moderation_warning.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; | ||
|
||
import WarningIcon from '@/material-icons/400-24px/warning-fill.svg?react'; | ||
import { Icon } from 'mastodon/components/icon'; | ||
|
||
// This needs to be kept in sync with app/models/account_warning.rb | ||
const messages = defineMessages({ | ||
none: { | ||
id: 'notification.moderation_warning.action_none', | ||
defaultMessage: 'Your account has received a moderation warning.', | ||
}, | ||
disable: { | ||
id: 'notification.moderation_warning.action_disable', | ||
defaultMessage: 'Your account has been disabled.', | ||
}, | ||
force_cw: { | ||
id: 'notification.moderation_warning.action_force_cw', | ||
defaultMessage: 'Some of your posts have been added content-warning text.', | ||
}, | ||
mark_statuses_as_sensitive: { | ||
id: 'notification.moderation_warning.action_mark_statuses_as_sensitive', | ||
defaultMessage: 'Some of your posts have been marked as sensitive.', | ||
}, | ||
delete_statuses: { | ||
id: 'notification.moderation_warning.action_delete_statuses', | ||
defaultMessage: 'Some of your posts have been removed.', | ||
}, | ||
sensitive: { | ||
id: 'notification.moderation_warning.action_sensitive', | ||
defaultMessage: 'Your posts will be marked as sensitive from now on.', | ||
}, | ||
silence: { | ||
id: 'notification.moderation_warning.action_silence', | ||
defaultMessage: 'Your account has been limited.', | ||
}, | ||
suspend: { | ||
id: 'notification.moderation_warning.action_suspend', | ||
defaultMessage: 'Your account has been suspended.', | ||
}, | ||
}); | ||
|
||
interface Props { | ||
action: | ||
| 'none' | ||
| 'disable' | ||
| 'force_cw' | ||
| 'mark_statuses_as_sensitive' | ||
| 'delete_statuses' | ||
| 'sensitive' | ||
| 'silence' | ||
| 'suspend'; | ||
id: string; | ||
hidden: boolean; | ||
} | ||
|
||
export const ModerationWarning: React.FC<Props> = ({ action, id, hidden }) => { | ||
const intl = useIntl(); | ||
|
||
if (hidden) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<a | ||
href={`/disputes/strikes/${id}`} | ||
target='_blank' | ||
rel='noopener noreferrer' | ||
className='notification__moderation-warning' | ||
> | ||
<Icon id='warning' icon={WarningIcon} /> | ||
|
||
<div className='notification__moderation-warning__content'> | ||
<p>{intl.formatMessage(messages[action])}</p> | ||
<span className='link-button'> | ||
<FormattedMessage | ||
id='notification.moderation-warning.learn_more' | ||
defaultMessage='Learn more' | ||
/> | ||
</span> | ||
</div> | ||
</a> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.