diff --git a/frontend/src/common/blocks/PostBlock.jsx b/frontend/src/common/blocks/PostBlock.jsx index c6ad20538..0464e46b9 100644 --- a/frontend/src/common/blocks/PostBlock.jsx +++ b/frontend/src/common/blocks/PostBlock.jsx @@ -9,12 +9,14 @@ import { SelectInput } from 'react-admin'; import { useLocation } from 'react-router-dom'; -import { Card, Box, Button, IconButton, CircularProgress, Backdrop } from '@mui/material'; +import { Card, Box, Button, IconButton, CircularProgress, Backdrop, Typography } from '@mui/material'; import { useTheme } from '@mui/material/styles'; import SendIcon from '@mui/icons-material/Send'; import InsertPhotoIcon from '@mui/icons-material/InsertPhoto'; import DeleteIcon from '@mui/icons-material/Delete'; import PublicIcon from '@mui/icons-material/Public'; +import LockPersonIcon from '@mui/icons-material/LockPerson'; +import AlternateEmailIcon from '@mui/icons-material/AlternateEmail'; import { useOutbox, OBJECT_TYPES, @@ -394,11 +396,12 @@ const PostBlock = ({ inReplyTo, mention }) => { )} - 0 ? 2 : 0} flexWrap="wrap"> + 0 ? 2 : 0} + flexWrap="wrap"> } + label={false} source="visibility" defaultValue="public" parse={(value) => value || 'public'} //if empty, fallback to public @@ -407,18 +410,29 @@ const PostBlock = ({ inReplyTo, mention }) => { { id: 'followers-only', name: translate('app.visibility.followersOnly') }, { id: 'mentions-only', name: translate('app.visibility.mentionsOnly') } ]} + optionText={(choice) => ( + + {choice.id === 'public' && } + {choice.id === 'followers-only' && } + {choice.id === 'mentions-only' && } + + {choice.name} + + + )} + optionValue="id" sx={{ + //hide the legend element in the fieldset to avoid empty space in the border + '& .MuiOutlinedInput-notchedOutline legend': { + display: 'none' + }, + //adjust height and margin to align with buttons + '& .MuiOutlinedInput-notchedOutline': { + mt: '3px' + }, '& .MuiInputBase-root': { height: '36px', - padding: '0 12px', - display: 'flex', - alignItems: 'center', - }, - '& .MuiSelect-select': { - display: 'flex', - alignItems: 'center', }, - minWidth: '150px', }} /> setShowDialog(false)}> + theme.zIndex.drawer + 1, + backgroundColor: 'rgba(0, 0, 0, 0.1)', + borderRadius: 1 + }} + open={isSubmitting} + > + +
{translate('app.action.sendDirectMessage')} ({ @@ -30,6 +31,7 @@ const useStyles = makeStyles(theme => ({ export default forwardRef((props, ref) => { const [selectedIndex, setSelectedIndex] = useState(0); const classes = useStyles(); + const translate = useTranslate(); const selectItem = index => { const item = props.items[index]; @@ -87,7 +89,7 @@ export default forwardRef((props, ref) => { )) ) : ( -
Aucun résultat
+
{translate('app.message.no_result')}
)} ); diff --git a/frontend/src/hooks/useMentions/useMentions.js b/frontend/src/hooks/useMentions/useMentions.js index cd23b8c9f..8bb6a91f9 100644 --- a/frontend/src/hooks/useMentions/useMentions.js +++ b/frontend/src/hooks/useMentions/useMentions.js @@ -1,7 +1,20 @@ import { useMemo } from 'react'; import renderMentions from './renderMentions'; +/** + * + * @param data The list of mentionable actors to be used in the mention suggestions. + * e.g. : { + * id: 'https://pod.provider/username', => the value that will be used in the "data-id" attribute of the generated link in the document + * label: '@username@pod.provider' => will be displayed in the document and stored in the "data-label" of the link + * } + * @returns {{items: (function({query: *}): *), render: ((function(): {onKeyDown(*): (boolean|*), onStart: function(*): void, onExit(): void, onUpdate(*): void})|*)}} + */ const useMentions = data => { + /** + * Filters suggestions using the end user query (what is typed after a "@" in the text field) + * @type {function({query: *}): *} + */ const items = useMemo( () => ({ query }) => data.filter(({ label }) => label.toLowerCase().includes(query.toLowerCase())).slice(0, 5) , [data]