-
Notifications
You must be signed in to change notification settings - Fork 3
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
Migrate Files table to data grid #1438
Conversation
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.
Thank you for knocking out another Material Table instance. I'm running into some bugginess that I'm sure will be a quick fix 🙏 🙌
@@ -56,33 +51,225 @@ const useStyles = makeStyles((theme) => ({ | |||
}, | |||
downloadLink: { | |||
cursor: "pointer", | |||
overflow: "hidden", | |||
display: "block", | |||
textOverflow: "ellipsis", |
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.
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.
ah because this isnt a link, this is just text. If it's truncated or overflow hidden, then users wouldn't be able to read the entire path
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.
I'm seeing a different issue when I entered a really long fake G drive location.
Here is an example of the behavior that I see in staging with the same length network location - https://moped.austinmobility.io/moped/projects/1695?tab=files.
Edit: I also realized that it is the codeStyle
styles below that handle non-links and needs to be updated. I requested a change there instead of here.
preProcessEditCellProps: (params) => { | ||
const hasError = params.props.value.trim().length < 1; | ||
return { ...params.props, error: hasError }; | ||
}, |
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.
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.
it is the source, thanks for catching it -- the weird thing is that I see the bug locally, but I am not seeing it on the netlify deploy link, which is confusing the heck out of me
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.
Part of the cause for this error message was my own lazy code, but the other part is that in cases where someone uploaded a file, the file_url was always going to be null, which was always returning an error and preventing the record from being updated.
width: 150, | ||
valueGetter: (value) => fileTypes[value], | ||
renderEditCell: (props) => <ProjectFilesTypeSelect {...props} />, | ||
}, |
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.
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.
I broke this when I added the valueGetter to make sorting work
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.
I broke the select when I used valueGetter, valueFormatter changes the value only for rendering and doesn't affect the underlying value. which means you still cant sort. valueGetter affects the underlying value, which means we can sort alphabetically vs 1,2,3,4 but it was then passing the string to the select component instead of the file_type number.
So now its valueFormatter to render the file_type strings, and passing those strings into the data grid sort comparator, while keeping the original value so the select works.
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.
thanks for fixing and explaining the difference 🙏 I tested the select and the sorting, and I see no warning and the sort is working. 🚀
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.
ditto—great to have these details ironed out for the next MaterialTable that gets replaced ✅
handleCancelClick, | ||
handleEditClick, | ||
handleDeleteOpen, | ||
]); |
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.
love the memoized columns—looks great!!
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.
Yay - this is looking great! I tested locally, and I was able to create linked files and edit from within the table rows. I'm requesting one change based on what I was seeing with long network locations for files that are links.
@@ -682,7 +682,7 @@ export const PROJECT_FILE_ATTACHMENTS_UPDATE = gql` | |||
$fileId: Int! | |||
$fileName: String! | |||
$fileType: Int! | |||
$fileDescription: String! |
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.
🐛 squashed! 🙏
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.
nice to see this component growing up to handle validation! 🌱
@@ -56,33 +51,225 @@ const useStyles = makeStyles((theme) => ({ | |||
}, | |||
downloadLink: { | |||
cursor: "pointer", | |||
overflow: "hidden", | |||
display: "block", | |||
textOverflow: "ellipsis", |
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.
I'm seeing a different issue when I entered a really long fake G drive location.
Here is an example of the behavior that I see in staging with the same length network location - https://moped.austinmobility.io/moped/projects/1695?tab=files.
Edit: I also realized that it is the codeStyle
styles below that handle non-links and needs to be updated. I requested a change there instead of here.
width: 150, | ||
valueGetter: (value) => fileTypes[value], | ||
renderEditCell: (props) => <ProjectFilesTypeSelect {...props} />, | ||
}, |
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.
thanks for fixing and explaining the difference 🙏 I tested the select and the sorting, and I see no warning and the sort is working. 🚀
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.
Nice—it's working great! Two minor things that are not blocking my approval:
When I edit a row, sometimes the sort order changes after I save. That was tripping me up a bit because i thought my edits were not getting saved correctly. I'm not sure if this is a bug in prod, so I'll let y'all decide on it 👍
Also, I noticed the activity logs for my edits were missing a field or two—possibly audit fields? Anyway, it's probably not a new bug.
🚢
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.
Looks amazing! Thanks for updating the sort and handling the network locations wrapping too. So excited to have another table converted to DataGrid, and there are nice improvements in here too! It is going to make the next one even more straightforward. 🙌 🚢
fyi - i created this spin off issue to capture another small bug that is in production too. sorting the "File" column doesn't work quite as expected on uploaded files since they all have a common S3 path. Plenty of improvements in this PR so let's save for another day! Thank you again @chiaberry! 🎉 |
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.
tested locally and looks and functions great! thank you for upgrading this table with DataGrid and adding the increased functionality, validation and modal! being able to inline edit is so nice ✨ long file paths and urls render as expected:
a couple minor things we could maybe address in the future:
- is it possible to disable editing on the 'file' field when it is an actual file (as opposed to a url or file path) since you can't actually edit that field in that case?
- i know we've come across this before, but when i double click on the 'file' field when it is a url it tries to open the url rather than allowing me to edit the field
as far as default column widths, i think we could shrink the 'file size' field by at least half and give that extra space to the 'file' field, since file size will probably only ever be around 5-6 characters
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.
👍
@tillyw thank you for pointing out the file size column width could be smaller! |
Associated issues
cityofaustin/atd-data-tech#18176
and a bonus cityofaustin/atd-data-tech#17597
I copied the patterns laid out in the Funding Table refactor, using DataGrid instead of Material Table, memoizing the columns, implementing the row mode model that data grid needs etc.
preProcessEditCellProps
that checks the input and will sets the error parameter update The file_url field also depends on the file_key field, I added a function to validate against the different variations in data.["", "Funding", "Plans", "Estimates", "Other"]
.Testing
URL to test:
There arent too many projects with files in staging, but here is one:
https://deploy-preview-1438--atd-moped-main.netlify.app/moped/projects/1695?tab=files
or if you run locally with prod data, this is a good project with files
https://localhost:3000/moped/projects/437?tab=files
Steps to test:
Test creating a file (use a url or fake file name to avoid issues with the file upload process in staging/local)
Test editing a record. You can do this by clicking the pencil, or double clicking in an editable field (name, file, type, description)
Cancel your edits. Or save your edits!!
Try deleting a record. A confirmation modal pops up.
Test sorting on file type. it sorts ascending, descending and then unsorts.
Do you like the widths of the columns as they are defined now? You can resize now, but wondering if anything should be defined differently.
Ship list
- [ ] Product manager added to QA test script if applicable