-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
[HOLD for payment 2024-01-18] [$500] Add markdown syntax for creating a new task #32864
Comments
Job added to Upwork: https://www.upwork.com/jobs/~013d0a874d62f021b7 |
Triggered auto assignment to @bfitzexpensify ( |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @Ollyws ( |
ProposalPlease re-state the problem that we are trying to solve in this issue.Add markdown syntax for creating a new task What is the root cause of that problem?New feature What changes do you think we should make in order to solve the problem?At function const allPersonalDetails = usePersonalDetails();
const onSubmitComment = useCallback(
(text) => {
const taskRegex = /^\[\](?:\s+@([^\s@]+@[\w.-]+))?\s+(.+)/;
const match = text.match(taskRegex);
if (match) {
const email = match[1] ? match[1].trim() : undefined; // Email might be undefined if not captured
const title = match[2];
let assignee = {};
if (email) {
assignee = _.find(_.values(allPersonalDetails), (p) => p.login === email) || {};
}
Task.createTaskAndNavigate(getReportID(route), title, '', assignee.login, assignee.accountID, assignee.assigneeChatReport, report.policyID);
} else {
Report.addComment(getReportID(route), text);
}
// We need to scroll to the bottom of the list after the comment is added
const refID = setTimeout(() => {
flatListRef.current.scrollToOffset({animated: false, offset: 0});
}, 10);
return () => clearTimeout(refID);
},
[route],
); POC 32864_POC.mp4What alternative solutions did you explore? (Optional) |
ProposalPlease re-state the problem that we are trying to solve in this issue.Add markdown syntax for creating a new task What is the root cause of that problem?This is a new feature What changes do you think we should make in order to solve the problem?To start, we would modify const submitForm = useCallback(
(e) => {
if (e) {
e.preventDefault();
}
const newComment = composerRef.current.prepareCommentAndResetComposer();
if (!newComment) {
return;
}
const Taskregex = /^\[\]\s*(.+)/;
const match = newComment.match(Taskregex);
if (match && match[1]) {
const TaskDetails = match[1];
return onTriggerTaskCreation(TaskDetails);
}
onSubmit(newComment);
},
[onSubmit],
); What we are doing is we first use a regex that will look for [] at the start of the newComment text and if there is, it will be saved in const onTriggerTaskCreation = useCallback((taskDetails) => {
const assigneeRegex = /@([\S]+)/;
const assigneeMatch = taskDetails.match(assigneeRegex);
const assignee = assigneeMatch ? assigneeMatch[1] : '';
let assigneeAccountID = 0;
let assigneeChatReport = null;
if (assignee) {
const assigneeDetails = Object.values(personalDetails).find(entry => entry.login === assignee) || {};
assigneeAccountID = assigneeDetails.accountID ?? 0;
assigneeChatReport = assigneeDetails.assigneeChatReport ?? Task.setAssigneeValue(assignee, assigneeAccountID);
}
const title = assignee
? taskDetails.replace(`@${assignee}`, '').trim() || "Untitled Task"
: taskDetails.trim();
Task.createTaskAndNavigate(
reportID,
title,
'',
assignee,
assigneeAccountID,
assigneeChatReport,
report.policyID,
);
}, []); The logic of the function works as follows: const onTriggerTaskCreation = useCallback((taskDetails) => {
const assigneeRegex = /@([\S]+)/;
const assigneeMatch = taskDetails.match(assigneeRegex);
const assignee = assigneeMatch ? assigneeMatch[1] : '';
let assigneeAccountID = 0;
let assigneeChatReport = null;
if (assignee) {
const assigneeDetails = Object.values(personalDetails).find(entry => entry.login === assignee) || {};
assigneeAccountID = assigneeDetails.accountID ?? 0;
assigneeChatReport = assigneeDetails.assigneeChatReport ?? Task.setAssigneeValue(assignee, assigneeAccountID);
}
}, []); In this part we are grabbing the first @ item and assign it to assignee, otherwise it will be empty since it's not required const title = assignee
? taskDetails.replace(`@${assignee}`, '').trim() || "Untitled Task"
: taskDetails.trim();
Task.createTaskAndNavigate(
reportID,
title,
'',
assignee,
assigneeAccountID,
assigneeChatReport,
report.policyID,
);
}, []); In this section we are assigning a title, the logic is that if there is an assignee, we will filter it out and assign the rest of the text as a title After that's taken care of we can call |
Can I clarify: Should the task be created when the text is typed into the composer, or when the message is submitted? |
I think we should handle create task at ReportScreen after composer submit a message to separate logic due to the business logic shouldn't handle inside composer |
@Ollyws I think it should be on submit because otherwise the task could be created before the user is ready to create it |
It should only be created once the message is submitted |
Triggered auto assignment to @iwiznia, see https://stackoverflow.com/c/expensify/questions/7972 for more details. |
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸 |
Yeah, apologies for the delay will review this one now. |
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.24-3 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue: If no regressions arise, payment will be issued on 2024-01-18. 🎊 For reference, here are some details about the assignees on this issue:
|
BugZero Checklist: The PR adding this new feature has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
|
Issue is ready for payment but no BZ is assigned. @anmurali you are the lucky winner! Please verify the payment summary looks correct and complete the checklist. Thanks! |
Regression Test Proposal
Do we agree 👍 or 👎 |
Looks good to me |
@anmurali can we close this then? |
Still awaiting payment on this one. |
@anmurali can you pay then? |
Paid @Ollyws now. |
We want to create some syntax that will create a task when the following message is added to the composer
[] @jack This is the task name
Should create a task in the current room that:
The assignee can be optional, in which case the command would look something like this
[] This is the task name
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @anmuraliThe text was updated successfully, but these errors were encountered: