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
Update event triggers for moped personnel and personnel roles #964
Changes from all commits
699783a
e97d537
5d9e5d4
1995e98
90bfa2e
7eb8551
a01f045
fe46559
28673dc
5343304
7750d0e
9b537a8
3fd5eca
a1cec5e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import PeopleOutlineIcon from "@material-ui/icons/PeopleOutline"; | ||
|
||
export const formatPersonnelActivity = (change, userList) => { | ||
let changeIcon = <PeopleOutlineIcon />; | ||
|
||
const changeData = change.record_data.event.data; | ||
|
||
// Adding a new person to project team | ||
if (change.description.length === 0) { | ||
return { | ||
changeIcon, | ||
changeText: [ | ||
{ text: "Added ", style: null }, | ||
{ text: userList[changeData.new.user_id], style: "boldText" }, | ||
{ text: " to the team", style: null }, | ||
], | ||
}; | ||
} | ||
|
||
if (change.description[0].field === "user_id") { | ||
return { | ||
changeIcon, | ||
changeText: [ | ||
{ text: "Replaced team member " }, | ||
{ text: userList[changeData.old.user_id], style: "boldText" }, | ||
{ text: " with ", style: null }, | ||
{ text: userList[changeData.new.user_id], style: "boldText" }, | ||
], | ||
}; | ||
} | ||
|
||
// remove a person from the team | ||
if (change.description[0].field === "is_deleted") { | ||
return { | ||
changeIcon, | ||
changeText: [ | ||
{ text: "Removed ", style: null }, | ||
{ text: userList[changeData.old.user_id], style: "boldText" }, | ||
{ text: " from the team", style: null }, | ||
], | ||
}; | ||
} | ||
|
||
// currently 'notes' is the only other editable field on this table | ||
return { | ||
changeIcon, | ||
changeText: [ | ||
{ text: "Updated team member notes for " }, | ||
{ text: userList[changeData.new.user_id], style: "boldText" }, | ||
], | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,7 +95,6 @@ export const formatProjectActivity = (change, lookupList) => { | |
], | ||
}; | ||
} | ||
console.log(changeData.new[changedField]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😬 |
||
|
||
// the update can be rendered as a string | ||
const changeValue = | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ const useStyles = makeStyles((theme) => ({ | |
indentText: { | ||
paddingLeft: "16px", | ||
display: "block", | ||
} | ||
}, | ||
})); | ||
|
||
/** | ||
|
@@ -26,7 +26,11 @@ const ProjectActivityEntry = ({ changeIcon, changeText }) => { | |
<Box display="flex" p={0}> | ||
<Box p={0}>{changeIcon}</Box> | ||
<Box p={0} flexGrow={1}> | ||
<Typography variant="body2" className={classes.entryText}> | ||
<Typography | ||
variant="body2" | ||
className={classes.entryText} | ||
component="span" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this fixes an invalid DOM nesting error There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thank you!!! |
||
> | ||
{ | ||
// maps through the array of objects and applies specified style to the text | ||
changeText.map((changeObject, index) => ( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,7 +114,7 @@ const ProjectSummaryProjectDescription = ({ | |
)} | ||
{!editMode && ( | ||
<ProjectSummaryLabel | ||
text={description || " - "} | ||
text={description.trim().length > 0 ? description : " - "} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is to fix a bug I found where if you save empty spaces as a project description, you can't edit the description again (ex: https://moped.austinmobility.io/moped/projects/1790) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thank you for fixing this! we have a snackoo to prevent users from saving an empty description in the first place. we require description on project create but not project edit. |
||
classes={classes} | ||
onClickEdit={() => setEditMode(true)} | ||
/> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moped_proj_personnel_roles
does not have a column for the project_id, so this is null. This also means that while we are tracking these activities, they will not show up in our activity log query since we query on project_idThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is great—thanks for getting the tracking in place.
i also want to point out that, because we don't have the project ID here, we cannot update the project's modified date through this mutation. that's frustrating because i think user's should be able to expect that any project edit will update the project's modified date. if we wanted to get clever, we could mutate the
moped_proj_personnel
record from here, which would then fire off another event which would mutate the parent project's modified date. that would require us adding some mutable field onmoped_proj_personnel
like anupdated_at
timestamp.just throwing it out there—i don't necessarily think this is a good idea. i believe we're also going to encounter this problem when we set up tracking for project features.