From 71d6a1d383aa53a5c7ffc8362c704fe716ffbcd7 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Tue, 14 Jun 2022 10:09:32 -0700 Subject: [PATCH] Conversation details: Unblock option for groups, update unblock style --- _locales/en/messages.json | 22 +++++++ .../components/ConversationDetails.scss | 9 +++ .../ConversationDetailsActions.stories.tsx | 16 ++++- .../ConversationDetailsActions.tsx | 59 +++++++++++++++++-- .../ConversationDetailsIcon.tsx | 1 + 5 files changed, 101 insertions(+), 6 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 5c38a28d28f8..44c17596deec 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -5742,6 +5742,10 @@ "message": "Block group", "description": "This is a button to block a group" }, + "ConversationDetailsActions--unblock-group": { + "message": "Unblock group", + "description": "This is a button to unblock a group" + }, "ConversationDetailsActions--leave-group-must-choose-new-admin": { "message": "Before you leave, you must choose at least one new admin for this group.", "description": "Shown if, before leaving a group, you need to choose an admin" @@ -5758,6 +5762,16 @@ "message": "Leave", "description": "This is the modal button to confirm leaving a group" }, + "ConversationDetailsActions--unblock-group-modal-title": { + "message": "Unblock the \"$groupName$\" Group?", + "description": "This is the modal title for confirming unblock of a group", + "placeholders": { + "groupName": { + "content": "$1", + "example": "Our Conversation" + } + } + }, "ConversationDetailsActions--block-group-modal-title": { "message": "Block and Leave the \"$groupName$\" Group?", "description": "This is the modal title for confirming blocking a group", @@ -5776,6 +5790,14 @@ "message": "Block", "description": "This is the modal button to confirm blocking a group" }, + "ConversationDetailsActions--unblock-group-modal-content": { + "message": "Your contacts will be able add you to this group.", + "description": "This is the modal content for confirming unblock of a group" + }, + "ConversationDetailsActions--unblock-group-modal-confirm": { + "message": "Unblock", + "description": "This is the modal button to confirm unblock of a group" + }, "ConversationDetailsHeader--members": { "message": "$number$ members", "description": "This is the number of members in a group", diff --git a/stylesheets/components/ConversationDetails.scss b/stylesheets/components/ConversationDetails.scss index 4ca1c2bcff05..d0fe3dfa7438 100644 --- a/stylesheets/components/ConversationDetails.scss +++ b/stylesheets/components/ConversationDetails.scss @@ -123,6 +123,9 @@ &__block-group { color: $color-accent-red; } + &__unblock-group { + color: $color-accent-blue; + } &__tabs { display: flex; @@ -414,6 +417,12 @@ background-color: $color-accent-red; } } + &--unblock { + &::after { + -webkit-mask: url(../images/icons/v2/block-24.svg) no-repeat center; + background-color: $color-accent-blue; + } + } &--verify { &::after { diff --git a/ts/components/conversation/conversation-details/ConversationDetailsActions.stories.tsx b/ts/components/conversation/conversation-details/ConversationDetailsActions.stories.tsx index f0cead92ba8d..17a4999c8376 100644 --- a/ts/components/conversation/conversation-details/ConversationDetailsActions.stories.tsx +++ b/ts/components/conversation/conversation-details/ConversationDetailsActions.stories.tsx @@ -30,7 +30,7 @@ const createProps = (overrideProps: Partial = {}): Props => ({ onLeave: action('onLeave'), onUnblock: action('onUnblock'), i18n, - isBlocked: false, + isBlocked: isBoolean(overrideProps.isBlocked), isGroup: true, }); @@ -50,6 +50,20 @@ LeftTheGroup.story = { name: 'Left the group', }; +export const BlockedAndLeftTheGroup = (): JSX.Element => { + const props = createProps({ + left: true, + isBlocked: true, + conversationTitle: '😸 Cat Snaps', + }); + + return ; +}; + +BlockedAndLeftTheGroup.story = { + name: 'Blocked and left the group', +}; + export const CannotLeaveBecauseYouAreTheLastAdmin = (): JSX.Element => { const props = createProps({ cannotLeaveBecauseYouAreLastAdmin: true }); diff --git a/ts/components/conversation/conversation-details/ConversationDetailsActions.tsx b/ts/components/conversation/conversation-details/ConversationDetailsActions.tsx index b13d5fdff498..2b2b9b30a480 100644 --- a/ts/components/conversation/conversation-details/ConversationDetailsActions.tsx +++ b/ts/components/conversation/conversation-details/ConversationDetailsActions.tsx @@ -38,6 +38,7 @@ export const ConversationDetailsActions: React.ComponentType = ({ }) => { const [confirmLeave, gLeave] = useState(false); const [confirmGroupBlock, gGroupBlock] = useState(false); + const [confirmGroupUnblock, gGroupUnblock] = useState(false); const [confirmDirectBlock, gDirectBlock] = useState(false); const [confirmDirectUnblock, gDirectUnblock] = useState(false); @@ -82,7 +83,7 @@ export const ConversationDetailsActions: React.ComponentType = ({ } let blockNode: ReactNode; - if (isGroup) { + if (isGroup && !isBlocked) { blockNode = ( = ({ } /> ); + } else if (isGroup && isBlocked) { + blockNode = ( + gGroupUnblock(true)} + icon={ + + } + label={ +
+ {i18n('ConversationDetailsActions--unblock-group')} +
+ } + /> + ); } else { const label = isBlocked ? i18n('MessageRequests--unblock') @@ -108,9 +126,22 @@ export const ConversationDetailsActions: React.ComponentType = ({ (isBlocked ? gDirectUnblock(true) : gDirectBlock(true))} icon={ - + + } + label={ +
+ {label} +
} - label={
{label}
} /> ); } @@ -134,7 +165,6 @@ export const ConversationDetailsActions: React.ComponentType = ({ {leaveGroupNode} {blockNode} - {confirmLeave && ( = ({ {i18n('ConversationDetailsActions--block-group-modal-content')} )} + {confirmGroupUnblock && ( + gGroupUnblock(false)} + title={i18n('ConversationDetailsActions--unblock-group-modal-title', [ + conversationTitle, + ])} + > + {i18n('ConversationDetailsActions--unblock-group-modal-content')} + + )} {confirmDirectBlock && ( = ({ {i18n('MessageRequests--block-direct-confirm-body')} )} - {confirmDirectUnblock && (