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

5710 add breadcrumbs to tasks lists #7757

Merged
merged 96 commits into from
Sep 22, 2022

Conversation

elvisdorkenoo
Copy link
Contributor

@elvisdorkenoo elvisdorkenoo commented Sep 1, 2022

Description

This PR adds a third line of text to tasks to display the additional contextual information.
This new line of text should display breadcrumbs showing where the person/place the task is about belongs to.
The functionality should match how we display breadcrumbs elsewhere on the app. Note that we are updating breadcrumbs across the app so that they do not list out the level the user themselves belongs to repetitively (i.e. CHW Janet will not see “CHW Janet’s Area” repeated all over the place, ticket #5697).
The text should be styled just like breadcrumbs elsewhere on the app (Noto Sans 14px).

#5710

Code review checklist

  • Readable: Concise, well named, follows the style guide, documented if necessary.
  • Documented: Configuration and user documentation on cht-docs
  • Tested: Unit and/or e2e where appropriate
  • Internationalised: All user facing text
  • Backwards compatible: Works with existing data and configuration or includes a migration. Any breaking changes documented in the release notes.

License

The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.

@jkuester
Copy link
Contributor

jkuester commented Sep 2, 2022

@elvisdorkenoo is this ready to review or is it waiting on #7732?

(Just not exactly sure what do to when assigned to a draft PR....) 😄

@elvisdorkenoo
Copy link
Contributor Author

elvisdorkenoo commented Sep 2, 2022

(Just not exactly sure what do to when assigned to a draft PR....) 😄

leave draft reviews 😅.
Sorry you are right, I should the assignment when Draft PR -> PR.
I would happily welcome some feedback, but :
it's not yet PR because I still have the fix broken unit tests and add new ones ; and the truth is I'm struggling at it.

@elvisdorkenoo elvisdorkenoo changed the base branch from master to 5697-update-breadcrumbs-displayed-levels September 2, 2022 17:55
…:medic/cht-core into 5710-add-breadcrumbs-to-tasks-lists
const hydratedTasks = await this.hydrateEmissions(taskDocs) || [];
const subjects = await this.getLineagesFromTaskDocs(hydratedTasks);
if (subjects?.size) {
for (const task of hydratedTasks) {
Copy link
Contributor

Choose a reason for hiding this comment

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

In theory the this.currentLevel promise should resolve immediately the following iterations and the performance impact of awaiting for every task shouldn't be big....

Another option is to await 1 time first and send over the currentLevel to the getTaskLineage, something like this:

... other code...

const subjects = await this.getLineagesFromTaskDocs(hydratedTasks);

if (subjects?.size) {
  const userLineageLevel = await this.currentLevel;
  hydratedTasks.forEach(task => task.lineage = this.getTaskLineage(subjects, task, userLineageLevel));
}
...continue code...

And the cleanAndRemoveCurrentLineage wont' be async anymore.

@jkuester @elvisdorkenoo what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I like the second option, it would make me passing over userLineageLevel parameter, but it's fine.

Copy link
Contributor

@jkuester jkuester left a comment

Choose a reason for hiding this comment

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

Looking good! Couple minor comments.

The big question I have left is the same one as the other PR regarding whether or not we need an e2e test for these breadcrumbs...

Comment on lines 198 to 200
if (!subjects?.size) {
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor, but this check is unnecessary since you have done it already above.

if (subjects?.size) {
const userLineageLevel = await this.currentLevel;
for (const task of hydratedTasks) {
task.lineage = await this.getTaskLineage(subjects, task, userLineageLevel);
Copy link
Contributor

Choose a reason for hiding this comment

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

Pretty sure we don't need to await this call.

Copy link
Contributor

@latin-panda latin-panda Sep 15, 2022

Choose a reason for hiding this comment

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

and you can use for each as in the sample here.
Also please remove the async in cleanAndRemoveCurrentLineage since you don't need it anymore

const dueDate = moment(emission.dueDate, 'YYYY-MM-DD');
emission.date = new Date(dueDate.valueOf());
emission.overdue = dueDate.isBefore(moment());
emission.owner = taskDoc.owner;

emission.forId = taskDoc.forId ? taskDoc.forId : taskDoc.owner;
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure that we are not going to inadvertently trigger some additional logic by setting the forId to owner?

I am not sure exactly what the difference is between the two fields anyway, but I am a little worried that this could have unintended consequences...

Copy link
Contributor

Choose a reason for hiding this comment

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

@elvisdorkenoo - To play safe, you can:

  • Line 135 has emission.owner already defined and available.
  • Line 136 - Add emission.forId and don't default it to task.owner because it's already expose in emission.owner.
  • In your getLineagesFromTaskDocs check for both properties: const ids = [...new Set(taskDocs.map(task => task.forId || task.owner))];

Copy link
Contributor Author

Choose a reason for hiding this comment

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

task => task.forId || task.owner is actually what I've before changing it this way when I got the confirmation that when it's set, task.forId always equals task.owner. But yeah let's play it safe.

@latin-panda
Copy link
Contributor

@elvisdorkenoo is it ready for review again?

@latin-panda
Copy link
Contributor

@elvisdorkenoo Looks like the e2e is failing consistently in the same place, can you please have a look?

@elvisdorkenoo
Copy link
Contributor Author

@elvisdorkenoo Looks like the e2e is failing consistently in the same place, can you please have a look?

I tried to take a look, even reverted my changes, it is also failing when I run that e2e locally, it looks mostly a timeout issue.

Copy link
Contributor

@jkuester jkuester left a comment

Choose a reason for hiding this comment

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

Just want to say that this looks good (pending the build issues being fixed).

New e2e tests will be added for this functionality as a part of #7806

Copy link
Contributor

@latin-panda latin-panda left a comment

Choose a reason for hiding this comment

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

LGTM!

@elvisdorkenoo elvisdorkenoo changed the base branch from 5697-update-breadcrumbs-displayed-levels to master September 22, 2022 12:03
@elvisdorkenoo elvisdorkenoo merged commit e0ef002 into master Sep 22, 2022
latin-panda pushed a commit that referenced this pull request Oct 6, 2022
This commit adds a third line of text to tasks to display the additional contextual information.
This new line of text should display breadcrumbs showing where the person/place the task is about belongs to.
The functionality should match how we display breadcrumbs elsewhere on the app.
@elvisdorkenoo elvisdorkenoo mentioned this pull request Nov 4, 2022
5 tasks
@craig-landry craig-landry mentioned this pull request Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants