From 00402f1dfbb7b47875540178c204068ed045f386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Mon, 29 Apr 2024 18:59:16 +0200 Subject: [PATCH] Update Lists list UI, fix reply mentions modal overflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- src/components/account.tsx | 2 +- src/features/bookmarks/index.tsx | 4 +- src/features/list-timeline/index.tsx | 46 +++++++++++- .../lists/components/new-list-form.tsx | 2 +- src/features/lists/index.tsx | 74 +++++++------------ src/features/reply-mentions/account.tsx | 10 +-- 6 files changed, 74 insertions(+), 64 deletions(-) diff --git a/src/components/account.tsx b/src/components/account.tsx index 5751b2c3a..e458dd4a5 100644 --- a/src/components/account.tsx +++ b/src/components/account.tsx @@ -297,7 +297,7 @@ const Account = ({
- {withRelationship ? renderAction() : null} + {(withRelationship || action) ? renderAction() : null}
diff --git a/src/features/bookmarks/index.tsx b/src/features/bookmarks/index.tsx index 3522ede0a..2fdb5e7cf 100644 --- a/src/features/bookmarks/index.tsx +++ b/src/features/bookmarks/index.tsx @@ -103,9 +103,7 @@ const Bookmarks: React.FC = ({ params }) => { return ( - } + action={} transparent > diff --git a/src/features/list-timeline/index.tsx b/src/features/list-timeline/index.tsx index ec1e412dd..22ccb8d38 100644 --- a/src/features/list-timeline/index.tsx +++ b/src/features/list-timeline/index.tsx @@ -1,18 +1,28 @@ import React, { useEffect } from 'react'; -import { FormattedMessage } from 'react-intl'; +import { FormattedMessage, defineMessages, useIntl } from 'react-intl'; import { useParams } from 'react-router-dom'; -import { fetchList } from 'soapbox/actions/lists'; +import { deleteList, fetchList } from 'soapbox/actions/lists'; import { openModal } from 'soapbox/actions/modals'; import { expandListTimeline } from 'soapbox/actions/timelines'; import { useListStream } from 'soapbox/api/hooks'; +import DropdownMenu from 'soapbox/components/dropdown-menu'; import MissingIndicator from 'soapbox/components/missing-indicator'; import { Column, Button, Spinner } from 'soapbox/components/ui'; import { useAppDispatch, useAppSelector, useTheme } from 'soapbox/hooks'; import Timeline from '../ui/components/timeline'; +const messages = defineMessages({ + deleteHeading: { id: 'confirmations.delete_list.heading', defaultMessage: 'Delete list' }, + deleteMessage: { id: 'confirmations.delete_list.message', defaultMessage: 'Are you sure you want to permanently delete this list?' }, + deleteConfirm: { id: 'confirmations.delete_list.confirm', defaultMessage: 'Delete' }, + editList: { id: 'lists.edit', defaultMessage: 'Edit list' }, + deleteList: { id: 'lists.delete', defaultMessage: 'Delete list' }, +}); + const ListTimeline: React.FC = () => { + const intl = useIntl(); const dispatch = useAppDispatch(); const { id } = useParams<{ id: string }>(); const theme = useTheme(); @@ -35,6 +45,19 @@ const ListTimeline: React.FC = () => { dispatch(openModal('LIST_EDITOR', { listId: id })); }; + const handleDeleteClick = (e: React.MouseEvent | React.KeyboardEvent) => { + e.preventDefault(); + + dispatch(openModal('CONFIRM', { + heading: intl.formatMessage(messages.deleteHeading), + message: intl.formatMessage(messages.deleteMessage), + confirm: intl.formatMessage(messages.deleteConfirm), + onConfirm: () => { + dispatch(deleteList(id)); + }, + })); + }; + const title = list ? list.title : id; if (typeof list === 'undefined') { @@ -59,8 +82,25 @@ const ListTimeline: React.FC = () => { ); + const items = [ + { + text: intl.formatMessage(messages.editList), + action: handleEditClick, + icon: require('@tabler/icons/outline/edit.svg'), + }, + { + text: intl.formatMessage(messages.deleteList), + action: handleDeleteClick, + icon: require('@tabler/icons/outline/trash.svg'), + }, + ]; + return ( - + } + transparent + > { return (
- + + } + /> + ))} + + )} + ); }; diff --git a/src/features/reply-mentions/account.tsx b/src/features/reply-mentions/account.tsx index 335690cac..2d00d6af7 100644 --- a/src/features/reply-mentions/account.tsx +++ b/src/features/reply-mentions/account.tsx @@ -6,7 +6,6 @@ import { addToMentions, removeFromMentions } from 'soapbox/actions/compose'; import { useAccount } from 'soapbox/api/hooks'; import AccountComponent from 'soapbox/components/account'; import IconButton from 'soapbox/components/icon-button'; -import { HStack } from 'soapbox/components/ui'; import { useAppDispatch, useCompose } from 'soapbox/hooks'; const messages = defineMessages({ @@ -48,12 +47,9 @@ const Account: React.FC = ({ composeId, accountId, author }) => { } return ( - -
- -
- {!author && button} -
+
+ +
); };