From 9cd95bbcf170bb8178f1d46fc7639a10a9b26314 Mon Sep 17 00:00:00 2001 From: William Grant Date: Tue, 13 Jun 2023 16:42:50 +1000 Subject: [PATCH] fix: remove AdminLeaveClosedGroupDialog added new leave group dialog strings --- _locales/en/messages.json | 9 ++- .../dialog/AdminLeaveClosedGroupDialog.tsx | 61 ------------------- ts/components/dialog/ModalContainer.tsx | 6 -- ts/state/ducks/modalDialog.tsx | 7 --- ts/state/selectors/modal.ts | 6 -- ts/types/LocalizerKeys.ts | 5 ++ 6 files changed, 12 insertions(+), 82 deletions(-) delete mode 100644 ts/components/dialog/AdminLeaveClosedGroupDialog.tsx diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 2ec7a8a49..e485a3e75 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -102,7 +102,7 @@ "deleteMessages": "Delete Messages", "deleteMessagesConfirmation": "Permanently delete the messages in this conversation?", "deleteConversation": "Delete Conversation", - "deleteConversationConfirmation": "Are you sure you want to delete your conversation with $name$?", + "deleteConversationConfirmation": "Are you sure you want to delete your conversation with $name$?", "deleteConversationFailed": "Failed to leave the Conversation!", "leaving": "Leaving...", "deleted": "$count$ deleted", @@ -257,10 +257,14 @@ "banUserAndDeleteAll": "Ban and Delete All", "userBanned": "Banned successfully", "userBanFailed": "Ban failed!", + "leave": "Leave", "leaveGroup": "Leave Group", "leaveAndRemoveForEveryone": "Leave Group and Remove for Everyone", - "leaveGroupConfirmation": "Are you sure you want to leave $name$?", + "leaveGroupConfirmation": "Are you sure you want to leave $name$?", "leaveGroupConfirmationAdmin": "As you are the admin of this group, if you leave it it will be removed for every current members. Are you sure you want to leave this group?", + "leaveGroupConrirmationOnlyAdminLegacy": "Are you sure you want to leave $name$? This will deactivate the group for all members.", + "leaveGroupConfirmationOnlyAdmin": "You are the only admin in $name$", + "leaveGroupConfirmationOnlyAdminWarning": "Group settings and members cannot be changed without an admin", "leaveGroupFailed": "Failed to leave Group!", "leaveCommunity": "Leave Community", "leaveCommunityFailed": "Failed to leave Community!", @@ -326,6 +330,7 @@ "editProfileModalTitle": "Profile", "groupNamePlaceholder": "Group Name", "inviteContacts": "Invite Contacts", + "addModerator": "Add Admin", "addModerators": "Add Admins", "removeModerators": "Remove Admins", "addAsModerator": "Add as Admin", diff --git a/ts/components/dialog/AdminLeaveClosedGroupDialog.tsx b/ts/components/dialog/AdminLeaveClosedGroupDialog.tsx deleted file mode 100644 index d5e7a6f9b..000000000 --- a/ts/components/dialog/AdminLeaveClosedGroupDialog.tsx +++ /dev/null @@ -1,61 +0,0 @@ -import React, { useState } from 'react'; -import { useDispatch } from 'react-redux'; -import styled from 'styled-components'; -import { getConversationController } from '../../session/conversations'; -import { adminLeaveClosedGroup } from '../../state/ducks/modalDialog'; -import { SessionWrapperModal } from '../SessionWrapperModal'; -import { SessionButton, SessionButtonColor, SessionButtonType } from '../basic/SessionButton'; -import { SpacerLG } from '../basic/Text'; -import { SessionSpinner } from '../basic/SessionSpinner'; - -const StyledWarning = styled.p` - max-width: 500px; - line-height: 1.3333; -`; - -export const AdminLeaveClosedGroupDialog = (props: { conversationId: string }) => { - const dispatch = useDispatch(); - const convo = getConversationController().get(props.conversationId); - const [loading, setLoading] = useState(false); - const titleText = `${window.i18n('leaveGroup')} ${convo?.getRealSessionUsername() || ''}`; - - const closeDialog = () => { - dispatch(adminLeaveClosedGroup(null)); - }; - - const onClickOK = async () => { - if (loading) { - return; - } - setLoading(true); - // we know want to delete a closed group right after we've left it, so we can call the deleteContact which takes care of it all - await getConversationController().deleteClosedGroup(props.conversationId, { - fromSyncMessage: false, - sendLeaveMessage: true, - }); - setLoading(false); - closeDialog(); - }; - - return ( - - - {window.i18n('leaveGroupConfirmationAdmin')} - - -
- - -
-
- ); -}; diff --git a/ts/components/dialog/ModalContainer.tsx b/ts/components/dialog/ModalContainer.tsx index d54bbe7e8..9b4deb1cf 100644 --- a/ts/components/dialog/ModalContainer.tsx +++ b/ts/components/dialog/ModalContainer.tsx @@ -2,7 +2,6 @@ import React from 'react'; import { useSelector } from 'react-redux'; import { getAddModeratorsModal, - getAdminLeaveClosedGroupDialog, getBanOrUnbanUserModalState, getChangeNickNameDialog, getConfirmModal, @@ -19,7 +18,6 @@ import { getUpdateGroupNameModal, getUserDetailsModal, } from '../../state/selectors/modal'; -import { AdminLeaveClosedGroupDialog } from './AdminLeaveClosedGroupDialog'; import { InviteContactsDialog } from './InviteContactsDialog'; import { DeleteAccountModal } from './DeleteAccountModal'; import { EditProfileDialog } from './EditProfileDialog'; @@ -49,7 +47,6 @@ export const ModalContainer = () => { const editProfileModalState = useSelector(getEditProfileDialog); const onionPathModalState = useSelector(getOnionPathDialog); const recoveryPhraseModalState = useSelector(getRecoveryPhraseDialog); - const adminLeaveClosedGroupModalState = useSelector(getAdminLeaveClosedGroupDialog); const sessionPasswordModalState = useSelector(getSessionPasswordDialog); const deleteAccountModalState = useSelector(getDeleteAccountModalState); const banOrUnbanUserModalState = useSelector(getBanOrUnbanUserModalState); @@ -71,9 +68,6 @@ export const ModalContainer = () => { {editProfileModalState && } {onionPathModalState && } {recoveryPhraseModalState && } - {adminLeaveClosedGroupModalState && ( - - )} {sessionPasswordModalState && } {deleteAccountModalState && } {confirmModalState && } diff --git a/ts/state/ducks/modalDialog.tsx b/ts/state/ducks/modalDialog.tsx index ea8428b70..65677da89 100644 --- a/ts/state/ducks/modalDialog.tsx +++ b/ts/state/ducks/modalDialog.tsx @@ -15,7 +15,6 @@ export type RemoveModeratorsModalState = InviteContactModalState; export type UpdateGroupMembersModalState = InviteContactModalState; export type UpdateGroupNameModalState = InviteContactModalState; export type ChangeNickNameModalState = InviteContactModalState; -export type AdminLeaveClosedGroupModalState = InviteContactModalState; export type EditProfileModalState = {} | null; export type OnionPathModalState = EditProfileModalState; export type RecoveryPhraseModalState = EditProfileModalState; @@ -47,7 +46,6 @@ export type ModalState = { editProfileModal: EditProfileModalState; onionPathModal: OnionPathModalState; recoveryPhraseModal: RecoveryPhraseModalState; - adminLeaveClosedGroup: AdminLeaveClosedGroupModalState; sessionPasswordModal: SessionPasswordModalState; deleteAccountModal: DeleteAccountModalState; reactListModalState: ReactModalsState; @@ -67,7 +65,6 @@ export const initialModalState: ModalState = { editProfileModal: null, onionPathModal: null, recoveryPhraseModal: null, - adminLeaveClosedGroup: null, sessionPasswordModal: null, deleteAccountModal: null, reactListModalState: null, @@ -114,9 +111,6 @@ const ModalSlice = createSlice({ recoveryPhraseModal(state, action: PayloadAction) { return { ...state, recoveryPhraseModal: action.payload }; }, - adminLeaveClosedGroup(state, action: PayloadAction) { - return { ...state, adminLeaveClosedGroup: action.payload }; - }, sessionPassword(state, action: PayloadAction) { return { ...state, sessionPasswordModal: action.payload }; }, @@ -145,7 +139,6 @@ export const { editProfileModal, onionPathModal, recoveryPhraseModal, - adminLeaveClosedGroup, sessionPassword, updateDeleteAccountModal, updateBanOrUnbanUserModal, diff --git a/ts/state/selectors/modal.ts b/ts/state/selectors/modal.ts index f959bc243..0a47d25a8 100644 --- a/ts/state/selectors/modal.ts +++ b/ts/state/selectors/modal.ts @@ -3,7 +3,6 @@ import { createSelector } from '@reduxjs/toolkit'; import { StateType } from '../reducer'; import { AddModeratorsModalState, - AdminLeaveClosedGroupModalState, BanOrUnbanUserModalState, ChangeNickNameModalState, ConfirmModalState, @@ -85,11 +84,6 @@ export const getRecoveryPhraseDialog = createSelector( (state: ModalState): RecoveryPhraseModalState => state.recoveryPhraseModal ); -export const getAdminLeaveClosedGroupDialog = createSelector( - getModal, - (state: ModalState): AdminLeaveClosedGroupModalState => state.adminLeaveClosedGroup -); - export const getSessionPasswordDialog = createSelector( getModal, (state: ModalState): SessionPasswordModalState => state.sessionPasswordModal diff --git a/ts/types/LocalizerKeys.ts b/ts/types/LocalizerKeys.ts index 243495b5a..7d303ae08 100644 --- a/ts/types/LocalizerKeys.ts +++ b/ts/types/LocalizerKeys.ts @@ -257,10 +257,14 @@ export type LocalizerKeys = | 'banUserAndDeleteAll' | 'userBanned' | 'userBanFailed' + | 'leave' | 'leaveGroup' | 'leaveAndRemoveForEveryone' | 'leaveGroupConfirmation' | 'leaveGroupConfirmationAdmin' + | 'leaveGroupConrirmationOnlyAdminLegacy' + | 'leaveGroupConfirmationOnlyAdmin' + | 'leaveGroupConfirmationOnlyAdminWarning' | 'leaveGroupFailed' | 'leaveCommunity' | 'leaveCommunityFailed' @@ -326,6 +330,7 @@ export type LocalizerKeys = | 'editProfileModalTitle' | 'groupNamePlaceholder' | 'inviteContacts' + | 'addModerator' | 'addModerators' | 'removeModerators' | 'addAsModerator'