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

fix: the system message when someone requests to join a workspace #51843

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3977,6 3977,7 @@ const translations = {
personalMessagePrompt: 'Message',
genericFailureMessage: 'An error occurred while inviting the member to the workspace. Please try again.',
inviteNoMembersError: 'Please select at least one member to invite.',
joinRequest: ({user, workspaceName}: {user: string; workspaceName: string}) => `${user} requested to join ${workspaceName}`,
},
distanceRates: {
oopsNotSoFast: 'Oops! Not so fast...',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4023,6 4023,7 @@ const translations = {
personalMessagePrompt: 'Mensaje',
inviteNoMembersError: 'Por favor, selecciona al menos un miembro a invitar.',
genericFailureMessage: 'Se ha producido un error al invitar al miembro al espacio de trabajo. Por favor, vuelva a intentarlo.',
joinRequest: ({user}: {user: string}) => `${user} solicitó unirse al espacio de trabajo`,
},
distanceRates: {
oopsNotSoFast: 'Ups! No tan rápido...',
Expand Down
2 changes: 2 additions & 0 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 644,8 @@ function getLastMessageTextForReport(report: OnyxEntry<Report>, lastActorDetails
lastMessageTextFromReport = ReportActionUtils.getExportIntegrationLastMessageText(lastReportAction);
} else if (lastReportAction?.actionName && ReportActionUtils.isOldDotReportAction(lastReportAction)) {
lastMessageTextFromReport = ReportActionUtils.getMessageOfOldDotReportAction(lastReportAction, false);
} else if (ReportActionUtils.isActionableJoinRequest(lastReportAction)) {
lastMessageTextFromReport = ReportUtils.getJoinRequestMessage(lastReportAction);
}

return lastMessageTextFromReport || (report?.lastMessageText ?? '');
Expand Down
12 changes: 12 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3967,6 3967,10 @@ function getReportName(
return getIOUUnapprovedMessage(parentReportAction);
}

if (ReportActionsUtils.isActionableJoinRequest(parentReportAction)) {
return getJoinRequestMessage(parentReportAction);
}

nkdengineer marked this conversation as resolved.
Show resolved Hide resolved
if (isChatThread(report)) {
if (!isEmptyObject(parentReportAction) && ReportActionsUtils.isTransactionThread(parentReportAction)) {
formattedName = getTransactionReportName(parentReportAction);
Expand Down Expand Up @@ -4766,6 4770,13 @@ function getIOUApprovedMessage(reportAction: ReportAction<typeof CONST.REPORT.AC
return Localize.translateLocal('iou.approvedAmount', {amount: getFormattedAmount(reportAction)});
}

function getJoinRequestMessage(reportAction: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_JOIN_REQUEST>) {
const policy = getPolicy(ReportActionsUtils.getOriginalMessage(reportAction)?.policyID);
const userDetail = PersonalDetailsUtils.getPersonalDetailByEmail(ReportActionsUtils.getOriginalMessage(reportAction)?.email ?? '');
const userName = userDetail?.firstName ? `${userDetail?.displayName} (${userDetail?.login})` : userDetail?.login ?? '';
return Localize.translateLocal('workspace.inviteMessage.joinRequest', {user: userName, workspaceName: policy?.name ?? ''});
}

/**
* We pass the reportID as older FORWARDED actions do not have the amount & currency stored in the message
* so we retrieve the amount from the report instead
Expand Down Expand Up @@ -8513,6 8524,7 @@ export {
getRejectedReportMessage,
getWorkspaceNameUpdatedMessage,
getReportAutomaticallySubmittedMessage,
getJoinRequestMessage,
getIOUSubmittedMessage,
getIcons,
getIconsForParticipants,
Expand Down
3 changes: 3 additions & 0 deletions src/pages/home/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 475,9 @@ const ContextMenuActions: ContextMenuAction[] = [
setClipboardMessage(ReportActionsUtils.getCardIssuedMessage(reportAction, true, report?.policyID, hasCard));
} else if (ReportActionsUtils.isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION)) {
setClipboardMessage(ReportActionsUtils.getRemovedConnectionMessage(reportAction));
} else if (ReportActionsUtils.isActionableJoinRequest(reportAction)) {
const displayMessage = ReportUtils.getJoinRequestMessage(reportAction);
Clipboard.setString(displayMessage);
} else if (content) {
setClipboardMessage(
content.replace(/(<mention-user>)(.*?)(<\/mention-user>)/gi, (match, openTag: string, innerContent: string, closeTag: string): string => {
Expand Down
12 changes: 12 additions & 0 deletions src/pages/home/report/ReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 695,18 @@ function ReportActionItem({
children = <ReportActionItemBasicMessage message={ReportActionsUtils.getPolicyChangeLogDeleteMemberMessage(action)} />;
} else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.REMOVED_FROM_APPROVAL_CHAIN)) {
children = <ReportActionItemBasicMessage message={ReportActionsUtils.getRemovedFromApprovalChainMessage(action)} />;
} else if (ReportActionsUtils.isActionableJoinRequest(action)) {
children = (
<View>
<ReportActionItemBasicMessage message={ReportUtils.getJoinRequestMessage(action)} />
{actionableItemButtons.length > 0 && (
<ActionableItemButtons
items={actionableItemButtons}
layout={ReportActionsUtils.isActionableTrackExpense(action) ? 'vertical' : 'horizontal'}
/>
)}
</View>
);
} else if (
ReportActionsUtils.isActionOfType(
action,
Expand Down
3 changes: 3 additions & 0 deletions src/types/onyx/OriginalMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 287,9 @@ type OriginalMessageJoinPolicyChangeLog = {

/** ID of the affected policy */
policyID: string;

/** Email of the requested user */
email?: string;
};

/** Model of `modified expense` report action */
Expand Down
Loading