Add buttons for PR creation and material management features#19
Add buttons for PR creation and material management features#19likeajumprope merged 18 commits intoReproNim:mainfrom
Conversation
Add material: test course
Add material: test course
Edit material: Andy's brain book (ID: 58)
There was a problem hiding this comment.
Code Review
This pull request implements a workflow to manage training materials via GitHub issues, adding a Python script for processing submissions and updating the frontend with new "Add" and "Delete" capabilities. Key changes include the introduction of the AddMaterialDialog component, the addition of a project guide in CLAUDE.md, and the transition of the EditMaterialDialog to an issue-based submission model. Feedback points out a missing field in the issue processing script, code duplication between the dialog components, and the inclusion of future dates and test data in the YAML dataset.
| function formatAsYaml(material: ReproInventoryEntry): string { | ||
| const lines: string[] = []; | ||
|
|
||
| const addScalar = (key: string, value: string | number | boolean | undefined | null) => { | ||
| if (value !== undefined && value !== null && value !== "") { | ||
| lines.push(`${key}: ${value}`); | ||
| } | ||
| }; | ||
|
|
||
| const addList = (key: string, values: string[] | undefined | null) => { | ||
| if (values && values.length > 0) { | ||
| lines.push(`${key}:`); | ||
| values.forEach((v) => lines.push(` - ${v}`)); | ||
| } | ||
| }; | ||
|
|
||
| addScalar("id", material.id); | ||
| addList("tag_team", material.tag_team); | ||
| addScalar("course_name", material.course_name); | ||
| addScalar("url", material.url); | ||
| addList("level", material.level); | ||
| addList("platform", material.platform); | ||
| addList("keywords", material.keywords); | ||
| addScalar("course_length", material.course_length); | ||
| addList("instruction_medium", material.instruction_medium); | ||
| addList("delivery", material.delivery); | ||
| addList("language", material.language); | ||
| addList("programming_language", material.programming_language); | ||
| addList("neuroimaging_software", material.neuroimaging_software); | ||
| addList("imaging_modality", material.imaging_modality); | ||
| addScalar("open_dataset", material.open_dataset); | ||
| addScalar("last_updated", material.last_updated); | ||
| addScalar("functionality", material.functionality); | ||
| addScalar("assessment", material.assessment); | ||
| addList("prerequisite", material.prerequisite); | ||
| addList("source", material.source); | ||
| addScalar("review", material.review); | ||
| addScalar("exclude_from_repro_inventory", material.exclude_from_repro_inventory); | ||
| addScalar("alias_links", material.alias_links); | ||
| addScalar("notes", material.notes); | ||
| addList("quadrants", material.quadrants); | ||
|
|
||
| return lines.join("\n"); | ||
| } | ||
|
|
||
| function openGitHubIssue(material: ReproInventoryEntry) { | ||
| const yaml = formatAsYaml(material); | ||
| const title = `Edit material: ${material.course_name || "Unknown"} (ID: ${material.id})`; | ||
| const body = | ||
| `## Edit Training Material Request\n\n` + | ||
| `Please update entry **ID: ${material.id}** in \`model/reproinventory_data.yaml\` with the following:\n\n` + | ||
| `\`\`\`yaml\n${yaml}\n\`\`\``; | ||
| const url = `${GITHUB_REPO}/issues/new?labels=edit-material&title=${encodeURIComponent(title)}&body=${encodeURIComponent(body)}`; | ||
| window.open(url, "_blank"); | ||
| } |
There was a problem hiding this comment.
There's significant code duplication between this component and the new AddMaterialDialog.tsx. Both components share a large amount of form UI logic and state management, as well as the formatAsYaml and openGitHubIssue helper functions (with minor variations).
To improve maintainability and reduce redundancy, consider abstracting the common form elements and logic into a shared MaterialForm component. This shared component could then be used within both EditMaterialDialog and AddMaterialDialog.
| - id: 62 | ||
| course_name: test course | ||
| platform: | ||
| - Mac | ||
| instruction_medium: | ||
| - blog post | ||
| delivery: | ||
| - instructor | ||
| imaging_modality: | ||
| - Behavioral |
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This pull request introduces a GitHub Actions-based workflow for managing updates to the training materials dataset via GitHub issues, along with frontend changes to streamline the editing and addition of materials. The workflow automates the process of creating pull requests from labeled issues, and the frontend now directs edits and additions through GitHub issues rather than direct in-app mutation. Several data normalization improvements and minor dataset updates are also included.
Automated Dataset Management via GitHub Issues:
.github/workflows/create-pr-from-issue.ymlto automate creating pull requests when issues labelednew-material,edit-material, ordelete-materialare created. The workflow processes the issue, updates the YAML and JSON data files, and opens a PR with the changes..github/scripts/process_issue.py, a Python script that reads issue data, applies the requested changes (add, edit, delete) tomodel/reproinventory_data.yamlandfrontend/public/data/reproinventory_data.json, and ensures array fields are properly normalized.Frontend Integration with GitHub-based Editing:
EditMaterialDialog.tsxso that clicking "Submit via GitHub Issue" opens a pre-filled GitHub issue for editing the material, rather than saving changes directly in the app. Added YAML formatting and normalization utilities to support this. [1] [2] [3] [4]AddMaterialDialogcomponent intotraining-materials-browser.tsx, laying groundwork for similar GitHub-based addition of new materials. [1] [2]Data and Documentation Updates:
reproinventory_data.json, including ID fixes, field normalization, and new/updated entries. [1] [2] [3] [4] [5]CLAUDE.md, a detailed developer guide describing the project structure, tech stack, data model, and contribution guidelines.These changes collectively move the project toward a more robust, auditable, and collaborative workflow for managing its core dataset.