Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: introduce variations to fail to add users (WPB-2299) #15497

Merged
merged 1 commit into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -517,10 +517,10 @@
"extensionsGiphyMessage": "{{tag}} • via giphy.com",
"extensionsGiphyNoGifs": "Oops, no gifs",
"extensionsGiphyRandom": "Random",
"failedToAddParticipant": "[bold]{{name}}[/bold] could not be added to the group as the backend of [bold]{{domain}}[/bold] could not be reached.",
"failedToAddParticipantDetails": "[bold]{{name}}[/bold] could not be added to the group as the backend of [bold]{{domain}}[/bold] could not be reached.",
"failedToAddParticipants": "[bold]{{total}} participants[/bold] could not be added to the group.",
"failedToAddParticipantsDetails": "[bold]{{names}}[/bold] and [bold]{{name}}[/bold] could not be added to the group as the backend of [bold]{{domain}}[/bold] could not be reached.",
"failedToAddParticipantsPlural": "[bold]{{total}} participants[/bold] could not be added to the group.",
"failedToAddParticipantsPluralDetailsNonFullyConnectedGraph": "[bold]{{names}}[/bold] and [bold]{{name}}[/bold] could not be added to the group as their backends do not federate with each other.",
"failedToAddParticipantsPluralDetailsOfflineBackEnd": "[bold]{{names}}[/bold] and [bold]{{name}}[/bold] could not be added to the group as the backend of [bold]{{domain}}[/bold] could not be reached.",
"failedToAddParticipantSingularOfflineBackEnd": "[bold]{{name}}[/bold] could not be added to the group as the backend of [bold]{{domain}}[/bold] could not be reached.",
"featureConfigChangeModalApplock": "Mandatory app lock is now disabled. You do not need a passcode or biometric authentication when returning to the app.",
"featureConfigChangeModalApplockHeadline": "Team settings changed",
"featureConfigChangeModalAudioVideoDescriptionItemCameraDisabled": "Camera in calls is disabled",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,15 @@ import {useMessageFocusedTabIndex} from './util';

import {FailedToAddUsersMessage as FailedToAddUsersMessageEntity} from '../../../entity/message/FailedToAddUsersMessage';

export enum ErrorMessageType {
offlineBackEnd = 'OfflineBackEnd',
nonFullyConnectedGraph = 'NonFullyConnectedGraph',
}

export interface FailedToAddUsersMessageProps {
isMessageFocused: boolean;
message: FailedToAddUsersMessageEntity;
errorMessageType?: ErrorMessageType;
userState?: UserState;
}

Expand All @@ -49,6 +55,7 @@ const config = Config.getConfig();
const FailedToAddUsersMessage: React.FC<FailedToAddUsersMessageProps> = ({
isMessageFocused,
message,
errorMessageType = ErrorMessageType.offlineBackEnd,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The different error messages are not part of the scope of the September release.
The only error message displayed stays the same as offline back-end

userState = container.resolve(UserState),
}) => {
const messageFocusedTabIndex = useMessageFocusedTabIndex(isMessageFocused);
Expand Down Expand Up @@ -101,15 +108,28 @@ const FailedToAddUsersMessage: React.FC<FailedToAddUsersMessageProps> = ({
data-uie-name="element-message-failed-to-add-users"
data-uie-value={total <= 1 ? '1-user-not-added' : 'multi-users-not-added'}
>
<p
css={warning}
dangerouslySetInnerHTML={{
__html:
total <= 1
? t('failedToAddParticipant', {name: users[0].name(), domain: users[0].domain})
: t('failedToAddParticipants', {total: total.toString()}),
}}
/>
{total <= 1 && (
<p data-uie-name="1-user-not-added-details" data-uie-value={users[0].id}>
<span
css={warning}
dangerouslySetInnerHTML={{
__html: t(`failedToAddParticipantSingularOfflineBackEnd`, {
name: users[0].name(),
domain: users[0].domain,
}),
}}
/>
{learnMore}
</p>
)}
{total > 1 && (
<p
css={warning}
dangerouslySetInnerHTML={{
__html: t(`failedToAddParticipantsPlural`, {total: total.toString()}),
}}
/>
)}
Comment on lines +111 to +132
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be simplified to just total <= 1 ? () : (), no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could, I kept it the way @thisisamir98 did it.
Probably easier to read?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The result will be the same, I'm fine with it

</div>
<p className="message-body-actions">
<MessageTime
Expand All @@ -122,41 +142,29 @@ const FailedToAddUsersMessage: React.FC<FailedToAddUsersMessageProps> = ({
<div className="message-body">
{isOpen && (
<>
{total <= 1 && (
Comment on lines 143 to -125
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

condition isOpen is true when total > 1 so this will never happen

<p data-uie-name="1-user-not-added-details" data-uie-value={users[0].id}>
{Object.entries(groupedUsers).map(([domain, domainUsers]) => (
<p
key={domain}
data-uie-name="multi-user-not-added-details"
data-uie-value={domain}
style={{lineHeight: 'var(--line-height-sm)'}}
>
<span
css={warning}
dangerouslySetInnerHTML={{
__html: t('failedToAddParticipantDetails', {name: users[0].name(), domain: users[0].domain}),
__html: t(`failedToAddParticipantsPluralDetails${errorMessageType}`, {
name: domainUsers[domainUsers.length - 1].name(),
names:
domainUsers.length === 2
? domainUsers[0].name()
: domainUsers.map(user => user.name()).join(', '),
domain,
}),
}}
/>
{learnMore}
</p>
)}
{total > 1 &&
Object.entries(groupedUsers).map(([domain, domainUsers]) => (
<p
key={domain}
data-uie-name="multi-user-not-added-details"
data-uie-value={domain}
style={{lineHeight: 'var(--line-height-sm)'}}
>
<span
css={warning}
dangerouslySetInnerHTML={{
__html: t('failedToAddParticipantsDetails', {
name: domainUsers[domainUsers.length - 1].name(),
names:
domainUsers.length === 2
? domainUsers[0].name()
: domainUsers.map(user => user.name()).join(', '),
domain,
}),
}}
/>
{learnMore}
</p>
))}
))}
</>
)}
{total > 1 && (
Expand Down
Loading