-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[web] Warn the user when deleting a chat that has contained chats
Summary: Part of [ENG-4319](https://linear.app/comm/issue/ENG-4319/warn-the-user-when-deleting-a-chat-that-has-contained-chats). Before deletion, the user is warned about possible contained chats. For subchannel deletion, the modal looks like this: {F642476} When deleting a whole community, message changes: {F642488} When there are no contained chats, the confirmation modal does not pop up. Depends on D8526. Test Plan: This modal should pop up when deleting: - Non-empty community - Subchannel with threads Modal should not pop up when deleting: - Empty community - Empty subchannel - Thread Note: right now we don't support deleting subchannels when the parent channel is deleted. What I mean is this situation: -> Community --> Subchannel 1 ---> Subchannel 2 If we delete Subchannel 1, right now Subchannel 2 is not deleted, thus modal should not pop up. Reviewers: bartek, tomek, inka, michal, ashoat Reviewed By: ashoat Subscribers: ashoat, tomek Differential Revision: https://phab.comm.dev/D8530
- Loading branch information
Showing
4 changed files
with
128 additions
and
4 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
14 changes: 14 additions & 0 deletions
14
web/modals/threads/settings/thread-settings-delete-confirmation-modal.css
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,14 @@ | ||
.container { | ||
padding: 0 40px 32px; | ||
border-radius: 8px; | ||
color: var(--modal-fg); | ||
} | ||
.text { | ||
font-size: var(--xl-font-20); | ||
padding: 5px 0px 20px; | ||
} | ||
.buttonContainer { | ||
display: flex; | ||
justify-content: flex-end; | ||
gap: 24px; | ||
} |
54 changes: 54 additions & 0 deletions
54
web/modals/threads/settings/thread-settings-delete-confirmation-modal.react.js
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,54 @@ | ||
// @flow | ||
|
||
import * as React from 'react'; | ||
|
||
import { useModalContext } from 'lib/components/modal-provider.react.js'; | ||
import { getThreadsToDeleteText } from 'lib/shared/thread-utils.js'; | ||
import type { ThreadInfo } from 'lib/types/thread-types'; | ||
|
||
import css from './thread-settings-delete-confirmation-modal.css'; | ||
import Button from '../../../components/button.react.js'; | ||
import Modal from '../../modal.react.js'; | ||
|
||
type BaseProps = { | ||
+threadInfo: ThreadInfo, | ||
+onConfirmation: () => mixed, | ||
}; | ||
|
||
function ThreadDeleteConfirmationModal({ | ||
threadInfo, | ||
onConfirmation, | ||
}: BaseProps): React.Node { | ||
const { popModal } = useModalContext(); | ||
const threadsToDeleteText = React.useMemo( | ||
() => getThreadsToDeleteText(threadInfo), | ||
[threadInfo], | ||
); | ||
|
||
return ( | ||
<Modal | ||
size="large" | ||
name="Warning" | ||
icon="warning-circle" | ||
withCloseButton={false} | ||
onClose={popModal} | ||
> | ||
<div className={css.container}> | ||
<p className={css.text}> | ||
{threadsToDeleteText} will also be permanently deleted. Are you sure | ||
you want to continue? | ||
</p> | ||
<div className={css.buttonContainer}> | ||
<Button variant="outline" onClick={popModal}> | ||
No | ||
</Button> | ||
<Button variant="filled" onClick={onConfirmation} type="submit"> | ||
Yes | ||
</Button> | ||
</div> | ||
</div> | ||
</Modal> | ||
); | ||
} | ||
|
||
export default ThreadDeleteConfirmationModal; |
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