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

Migrate Files table to data grid #1438

Merged
merged 26 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9b5dfb3
the data is rendering
chiaberry Sep 30, 2024
8eec112
add the toolbar and more of the edits
chiaberry Sep 30, 2024
3b32597
linting
chiaberry Sep 30, 2024
33891f7
delete a row
chiaberry Oct 1, 2024
5795234
able to edit a row
chiaberry Oct 1, 2024
4031490
validate input in data grid
chiaberry Oct 1, 2024
4c4effe
remove older props
chiaberry Oct 1, 2024
31a99ba
ability to edit the type select in data grid
chiaberry Oct 1, 2024
d27ceb9
looks like we dont need the field selector
chiaberry Oct 1, 2024
06ab1bc
remove the unneeded text field
chiaberry Oct 2, 2024
ed304bd
fix external link rendering
chiaberry Oct 3, 2024
924295e
add delete confirmation modal to files table
chiaberry Oct 3, 2024
5831ccb
tabbing seems to work without the handler
chiaberry Oct 3, 2024
bf5c6b8
update comment
chiaberry Oct 3, 2024
65f27a2
updating the value getter so the sort workds
chiaberry Oct 3, 2024
610c3c4
Merge branch 'main' into 18176-data-grid-files
chiaberry Oct 4, 2024
44b9852
check if value exists, dont try to trim null
chiaberry Oct 4, 2024
2c9623c
description is not required
chiaberry Oct 7, 2024
b2f79e3
fill width more or less of parent component
chiaberry Oct 7, 2024
19fdb86
clean up payload
chiaberry Oct 7, 2024
82c3335
use data grid sort comparator
chiaberry Oct 7, 2024
6348377
write a handler to validate file input
chiaberry Oct 7, 2024
1dc2d3b
break the words
chiaberry Oct 8, 2024
c0fbe1e
ignore the audit fields in in the files activity log
chiaberry Oct 8, 2024
d42a31a
order files by created at desc
chiaberry Oct 8, 2024
fd1ce13
give the file size column a size
chiaberry Oct 10, 2024
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
3 changes: 2 additions & 1 deletion moped-editor/src/queries/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,7 @@ export const PROJECT_ACTIVITY_LOG_DETAILS = gql`
export const PROJECT_FILE_ATTACHMENTS = gql`
query MopedProjectFiles($projectId: Int!) {
moped_project_files(
order_by: { created_at: desc }
where: { project_id: { _eq: $projectId }, is_deleted: { _eq: false } }
) {
project_file_id
Expand Down Expand Up @@ -682,7 +683,7 @@ export const PROJECT_FILE_ATTACHMENTS_UPDATE = gql`
$fileId: Int!
$fileName: String!
$fileType: Int!
$fileDescription: String!
Copy link
Collaborator

Choose a reason for hiding this comment

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

🐛 squashed! 🙏

$fileDescription: String
$fileUrl: String
) {
update_moped_project_files(
Expand Down
11 changes: 11 additions & 0 deletions moped-editor/src/utils/activityLogFormatters/mopedFilesActivity.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import AttachFileOutlined from "@mui/icons-material/AttachFileOutlined";
import { ProjectActivityLogTableMaps } from "../../views/projects/projectView/ProjectActivityLogTableMaps";

/** Fields which do not need to be rendered in the activity log */
const CHANGE_FIELDS_TO_IGNORE = [
"updated_by_user_id",
"created_by_user_id",
"created_at",
"updated_at",
];

export const formatFilesActivity = (change) => {
const entryMap = ProjectActivityLogTableMaps["moped_project_files"];

Expand Down Expand Up @@ -44,6 +52,9 @@ export const formatFilesActivity = (change) => {
// loop through fields to check for differences, push label onto changes Array
Object.keys(newRecord).forEach((field) => {
if (newRecord[field] !== oldRecord[field]) {
if (CHANGE_FIELDS_TO_IGNORE.includes(field)) {
return;
}
changes.push(entryMap.fields[field]?.label);
}
});
Expand Down
14 changes: 13 additions & 1 deletion moped-editor/src/views/projects/projectView/DataGridTextField.js
Copy link
Collaborator

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! 🌱

Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,19 @@ import { useGridApiContext } from "@mui/x-data-grid-pro";
* @param {Integer} id - Data Grid row id
* @param {String} value - field value
* @param {String} field - name of field
* @param {Boolean} hasFocus - does this field have focus
* @param {String} helperText - optional helper text
* @param {Boolean} error - toggles error style in textfield
* @return {JSX.Element}
*/
const DataGridTextField = ({ id, value, field, hasFocus }) => {
const DataGridTextField = ({
id,
value,
field,
hasFocus,
helperText,
error,
}) => {
const apiRef = useGridApiContext();
const ref = React.useRef(null);

Expand Down Expand Up @@ -38,6 +48,8 @@ const DataGridTextField = ({ id, value, field, hasFocus }) => {
type="text"
value={value ?? ""}
onChange={handleChange}
helperText={!!helperText && helperText}
error={error}
/>
);
};
Expand Down
Loading