-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow user to copy-click the participants email addresses
* feat: let user to copy-click addresses on emails * chore: change the background of chip icon * chore: used the snackbar from ds
- Loading branch information
1 parent
de7f7c1
commit 86ccc03
Showing
6 changed files
with
212 additions
and
69 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 Zextras <https://www.zextras.com> | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
import { CreateSnackbarFn } from '@zextras/carbonio-design-system'; | ||
import { t } from '@zextras/carbonio-shell-ui'; | ||
|
||
import { mailToSharedFunction } from '../integrations/shared-functions'; | ||
import { Participant } from '../types'; | ||
|
||
export const copyEmailToClipboard = (email: string, createSnackbar: CreateSnackbarFn): void => { | ||
navigator.clipboard.writeText(email).then(() => { | ||
createSnackbar({ | ||
key: `clipboard-copy-success`, | ||
replace: true, | ||
type: 'success', | ||
hideButton: true, | ||
label: t('snackbar.email_copied_to_clipboard', 'Email copied to clipboard.'), | ||
autoHideTimeout: 3000 | ||
}); | ||
}); | ||
}; | ||
|
||
export const sendMsg = (contact: Participant): void => { | ||
mailToSharedFunction([contact]); | ||
}; |
89 changes: 89 additions & 0 deletions
89
src/views/app/detail-panel/preview/parts/contact-names-chips.tsx
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,89 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2022 Zextras <https://www.zextras.com> | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
import React, { FC, ReactElement, useContext } from 'react'; | ||
|
||
import { | ||
Row, | ||
Text, | ||
Chip, | ||
Container, | ||
SnackbarManagerContext | ||
} from '@zextras/carbonio-design-system'; | ||
import { t } from '@zextras/carbonio-shell-ui'; | ||
import { map } from 'lodash'; | ||
|
||
import type { Participant } from '../../../../../types'; | ||
import { | ||
copyEmailToClipboard, | ||
sendMsg | ||
} from '../../../../../ui-actions/participant-displayer-actions'; | ||
|
||
const ContactNameChip: FC<{ | ||
showOverflow?: boolean; | ||
contacts: Participant[]; | ||
label: string; | ||
}> = ({ contacts, label }): ReactElement => { | ||
const createSnackbar = useContext(SnackbarManagerContext); | ||
return ( | ||
<> | ||
<Row mainAlignment="flex-start"> | ||
<Text color="secondary" size="small" style={{ paddingRight: '0.25rem' }}> | ||
{label} | ||
</Text> | ||
</Row> | ||
<Row | ||
mainAlignment="flex-start" | ||
takeAvailableSpace | ||
height="fit" | ||
orientation="vertical" | ||
display="flex" | ||
wrap={'nowrap'} | ||
style={{ | ||
lineHeight: '1.125rem', | ||
flexDirection: 'row', | ||
overflow: 'hidden' | ||
}} | ||
> | ||
<Container | ||
orientation="horizontal" | ||
wrap="wrap" | ||
mainAlignment="flex-start" | ||
style={{ gap: '0.5rem' }} | ||
> | ||
{map(contacts, (contact) => ( | ||
<Chip | ||
label={contact.address} | ||
background="gray2" | ||
color="text" | ||
data-testid={'Chip'} | ||
actions={[ | ||
{ | ||
id: 'action1', | ||
label: t('message.send_email', 'Send e-mail'), | ||
type: 'button', | ||
icon: 'EmailOutline', | ||
background: 'gray3', | ||
onClick: () => sendMsg(contact) | ||
}, | ||
{ | ||
id: 'action2', | ||
label: t('message.copy', 'Copy'), | ||
type: 'button', | ||
icon: 'Copy', | ||
background: 'gray3', | ||
onClick: () => copyEmailToClipboard(contact.address, createSnackbar) | ||
} | ||
]} | ||
/> | ||
))} | ||
</Container> | ||
</Row> | ||
</> | ||
); | ||
}; | ||
|
||
export default ContactNameChip; |
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
Oops, something went wrong.