-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add confirm trusted recipients dialog
Add a `ConfirmTrustedRecipientsDialog` component that allows the user to see contacts who need their identity to be confirmed and then confirm or reject those contacts `ConfirmTrustedRecipientsDialog` should receive confirmation related methods in `twoStepsConfirmationMethods` prop `ConfirmTrustedRecipientsDialog` can retrieve a list of contacts who need to be confirmed by calling `getRecipientsToBeConfirmed` from those props. It displays a loading spinner while this method is beeing processed `ConfirmTrustedRecipientsDialog` can display a custom dialog content when the users clic on the `verify` action. The custom dialog can be set by specifying a component in `recipientConfirmationDialogContent` prop From this custom dialog content the user can confirm the contact. Then `confirmRecipient` is called from those props From this custom dialog content the user can reject a contact. Then `rejectRecipient` is called from those props
- Loading branch information
Showing
5 changed files
with
86 additions
and
0 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
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
15 changes: 15 additions & 0 deletions
15
packages/cozy-sharing/src/ConfirmTrustedRecipientsDialog.jsx
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,15 @@ | ||
import React from 'react' | ||
|
||
import SharingContext from './context' | ||
import withLocales from './withLocales' | ||
import { default as DumbConfirmTrustedRecipientsDialog } from './components/ConfirmTrustedRecipientsDialog' | ||
|
||
export const ConfirmTrustedRecipientsDialog = withLocales( | ||
({ document, ...rest }) => ( | ||
<SharingContext.Consumer> | ||
{() => ( | ||
<DumbConfirmTrustedRecipientsDialog document={document} {...rest} /> | ||
)} | ||
</SharingContext.Consumer> | ||
) | ||
) |
60 changes: 60 additions & 0 deletions
60
packages/cozy-sharing/src/components/ConfirmTrustedRecipientsDialog.jsx
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,60 @@ | ||
import React from 'react' | ||
import { useI18n } from 'cozy-ui/transpiled/react/I18n' | ||
import Typography from 'cozy-ui/transpiled/react/Typography' | ||
|
||
import Recipient from './Recipient' | ||
|
||
import ShareDialogTwoStepsConfirmationContainer from './ShareDialogTwoStepsConfirmationContainer' | ||
|
||
/** | ||
* Displays the sharing interface that can be used when ConfirmTrustedRecipientsDialog is in sharing state | ||
*/ | ||
const SharingContent = ({ recipientsToBeConfirmed, verifyRecipient }) => { | ||
const { t } = useI18n() | ||
|
||
return ( | ||
<> | ||
<Typography variant="body1" className="u-mb-2"> | ||
{t(`ConfirmRecipientModal.intruction`)} | ||
</Typography> | ||
|
||
{recipientsToBeConfirmed.map(recipientConfirmationData => { | ||
return ( | ||
<Recipient | ||
{...recipientConfirmationData} | ||
key={`key_r_${recipientConfirmationData.id}`} | ||
isOwner={false} | ||
recipientConfirmationData={recipientConfirmationData} | ||
verifyRecipient={verifyRecipient} | ||
/> | ||
) | ||
})} | ||
</> | ||
) | ||
} | ||
|
||
/** | ||
* Displays the dialog's title that can be used when ConfirmTrustedRecipientsDialog is in sharing state | ||
*/ | ||
const SharingTitle = ({ recipientsToBeConfirmed }) => { | ||
const { t } = useI18n() | ||
|
||
const title = t(`ConfirmRecipientModal.title`, { | ||
smart_count: recipientsToBeConfirmed.length | ||
}) | ||
|
||
return title | ||
} | ||
|
||
const ConfirmTrustedRecipientsDialog = ({ ...props }) => { | ||
return ( | ||
<ShareDialogTwoStepsConfirmationContainer | ||
{...props} | ||
dialogContentOnShare={SharingContent} | ||
dialogActionsOnShare={null} | ||
dialogTitleOnShare={SharingTitle} | ||
/> | ||
) | ||
} | ||
|
||
export default ConfirmTrustedRecipientsDialog |
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