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

[CP Staging] fixes optimistc case and delay submission current user bad grammar #49482

Merged
merged 9 commits into from
Sep 19, 2024
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
17 changes: 14 additions & 3 deletions src/libs/NextStepUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,19 @@ Onyx.connect({
function parseMessage(messages: Message[] | undefined) {
let nextStepHTML = '';

messages?.forEach((part) => {
messages?.forEach((part, index) => {
const isEmail = Str.isValidEmail(part.text);
let tagType = part.type ?? 'span';
let content = Str.safeEscape(part.text);

const previousPart = messages[index - 1];
const nextPart = messages[index + 1];

if (currentUserEmail === part.text || part.clickToCopyText === currentUserEmail) {
tagType = 'strong';
content = 'You';
content = nextPart?.text === `'s` ? 'Your' : 'You';
} else if (part.text === `'s` && (previousPart?.text === currentUserEmail || previousPart?.clickToCopyText === currentUserEmail)) {
content = '';
} else if (isEmail) {
tagType = 'next-step-email';
content = EmailUtils.prefixMailSeparatorsWithBreakOpportunities(content);
Expand Down Expand Up @@ -116,6 +121,7 @@ function buildNextStep(report: OnyxEntry<Report>, predictedNextStatus: ValueOf<t
{
text: `${ownerDisplayName}`,
type: 'strong',
clickToCopyText: ownerAccountID === currentUserAccountID ? currentUserEmail : '',
},
{
text: ' to ',
Expand All @@ -136,7 +142,12 @@ function buildNextStep(report: OnyxEntry<Report>, predictedNextStatus: ValueOf<t
text: 'Waiting for ',
},
{
text: `${ownerDisplayName}'s`,
text: `${ownerDisplayName}`,
type: 'strong',
clickToCopyText: ownerAccountID === currentUserAccountID ? currentUserEmail : '',
},
{
text: `'s`,
type: 'strong',
},
{
Expand Down
49 changes: 42 additions & 7 deletions tests/unit/NextStepUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ describe('libs/NextStepUtils', () => {
text: 'Waiting for ',
},
{
text: `${currentUserEmail}'s`,
text: `${currentUserEmail}`,
clickToCopyText: `${currentUserEmail}`,
type: 'strong',
},
{
text: "'s",
type: 'strong',
},
{
Expand Down Expand Up @@ -143,7 +148,12 @@ describe('libs/NextStepUtils', () => {
text: 'Waiting for ',
},
{
text: `${currentUserEmail}'s`,
text: `${currentUserEmail}`,
clickToCopyText: `${currentUserEmail}`,
type: 'strong',
},
{
text: "'s",
type: 'strong',
},
{
Expand Down Expand Up @@ -173,7 +183,12 @@ describe('libs/NextStepUtils', () => {
text: 'Waiting for ',
},
{
text: `${currentUserEmail}'s`,
text: `${currentUserEmail}`,
clickToCopyText: `${currentUserEmail}`,
type: 'strong',
},
{
text: "'s",
type: 'strong',
},
{
Expand Down Expand Up @@ -203,7 +218,12 @@ describe('libs/NextStepUtils', () => {
text: 'Waiting for ',
},
{
text: `${currentUserEmail}'s`,
text: `${currentUserEmail}`,
clickToCopyText: `${currentUserEmail}`,
type: 'strong',
},
{
text: "'s",
type: 'strong',
},
{
Expand Down Expand Up @@ -234,7 +254,12 @@ describe('libs/NextStepUtils', () => {
text: 'Waiting for ',
},
{
text: `${currentUserEmail}'s`,
text: `${currentUserEmail}`,
clickToCopyText: `${currentUserEmail}`,
type: 'strong',
},
{
text: "'s",
type: 'strong',
},
{
Expand Down Expand Up @@ -267,7 +292,12 @@ describe('libs/NextStepUtils', () => {
text: 'Waiting for ',
},
{
text: `${currentUserEmail}'s`,
text: `${currentUserEmail}`,
clickToCopyText: `${currentUserEmail}`,
type: 'strong',
},
{
text: "'s",
type: 'strong',
},
{
Expand Down Expand Up @@ -298,7 +328,12 @@ describe('libs/NextStepUtils', () => {
text: 'Waiting for ',
},
{
text: `${currentUserEmail}'s`,
text: `${currentUserEmail}`,
clickToCopyText: `${currentUserEmail}`,
type: 'strong',
},
{
text: "'s",
type: 'strong',
},
{
Expand Down
Loading