migrate resource (resource migration 3/3)#72
migrate resource (resource migration 3/3)#72interim17 wants to merge 10 commits intomigrate-resources-1from
Conversation
…/idea-board into migrate-resources
| concerns: post.frontmatter.concerns || "", | ||
| dataset: { | ||
| ...post.frontmatter.materialsAndMethods?.dataset?.frontmatter, | ||
| ...post.frontmatter.resources.find((r) => r.type === "dataset"), |
There was a problem hiding this comment.
This file has an outdated approach to typing and querying, but it's not essential to do more than patch in this PR.
src/components/IdeaRoll.tsx
Outdated
| resources { | ||
| ...ResourceFields |
There was a problem hiding this comment.
Using fragments defined in src/graphql/fragments
| export const RESOURCE_TYPES = { | ||
| SOFTWARE_TOOL: "softwareTool", | ||
| DATASET: "dataset", | ||
| PROTOCOL_LINK: "protocolLink", | ||
| PROTOCOL_FILE: "protocolFile", | ||
| CELL_LINE: "cellLine", | ||
| } as const; | ||
|
|
||
| export type ResourceType = (typeof RESOURCE_TYPES)[keyof typeof RESOURCE_TYPES]; |
There was a problem hiding this comment.
There are places in both gatsby and decap where the frameworks limit our ability to use constants (in query filters for example) but trying to use them everywhere else that we can to keep things aligned.
| {!!softwareResources?.nodes.length && ( | ||
| <> | ||
| <h2>Software</h2> | ||
| <ul> | ||
| {softwareResources.nodes.map((node) => ( | ||
| <li key={node.slug}> | ||
| <Link to={node.slug}>{node.name}</Link> | ||
| {node.description && ( | ||
| <p>{node.description}</p> | ||
| )} | ||
| </li> | ||
| ))} | ||
| </ul> | ||
| </> | ||
| )} |
There was a problem hiding this comment.
Bucketed resources using filtered queries + fragmentes below with a basic render here. A demonstration/proof of concept, not styled.
…/idea-board into migrate-resources
There was a problem hiding this comment.
Pull request overview
Migrates “Materials and Methods” content from legacy dataset/software collections into the unified resources collection, updating CMS config, Gatsby schema/resolvers, GraphQL fragments, and UI consumers.
Changes:
- Remove legacy
materialsAndMethods,dataset, andsoftwarecontent/types/templates; add newresourcemarkdown entries. - Update Gatsby schema/custom resolvers and GraphQL fragments/constants to query typed resources.
- Refactor idea templates/components (IdeaPost, IdeaRoll, MaterialsAndMethods) to consume
resources.
Reviewed changes
Copilot reviewed 37 out of 37 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| static/admin/config.yml | Removes legacy Materials & Methods / dataset / software CMS fields and collections; keeps resources relation fields. |
| src/utils/formattingUtils.tsx | Adds NameWithLink helper for consistent name/link rendering. |
| src/types/index.ts | Removes legacy MaterialsAndMethods-derived types; adjusts Figure type derivation. |
| src/templates/idea-post.tsx | Stops querying legacy materialsAndMethods; passes resources into MaterialsAndMethods UI. |
| src/templates/dataset.tsx | Removes legacy dataset template page. |
| src/pages/software/timelapse-feature-explorer.md | Removes legacy software markdown entry. |
| src/pages/software/simularium.md | Removes legacy software markdown entry. |
| src/pages/resource/timelapse-feature-explorer.md | Adds resource entry (software tool) in new location/format. |
| src/pages/resource/simularium.md | Adds resource entry (software tool) in new location/format. |
| src/pages/resource/released-nucmorph-data-included-pre-calculated-pcs.md | Adds resource entry (dataset) in new location/format. |
| src/pages/resource/released-emt-dataset.md | Adds resource entry (dataset) in new location/format. |
| src/pages/resource/index.tsx | Refactors resources index into type-grouped sections with filtered queries. |
| src/pages/resource/emc.md | Adds resource entry (dataset) in new location/format. |
| src/pages/resource/aics-67.md | Adds resource entry (cell line) in new location/format. |
| src/pages/resource/aics-42.md | Adds resource entry (cell line) in new location/format. |
| src/pages/resource/actin-compression-simulation-dataset.md | Adds resource entry (dataset) with detailed description content. |
| src/pages/resource/60x-timelapse-images-of-tagged-lines-after-emt-sandwich-dataset.md | Adds resource entry (dataset) in new location/format. |
| src/pages/ideas/dev-example.md | Updates idea frontmatter to reference resources instead of legacy Materials & Methods block. |
| src/pages/ideas/2026-02-06-compare-actin-filament-compression-between-different-fiber-scale-simulators.md | Updates idea frontmatter to reference resources. |
| src/pages/ideas/2025-10-29-relate-cell-cell-junction-remodeling-to-migration-onset.md | Updates idea frontmatter to reference resources. |
| src/pages/ideas/2025-10-24-how-do-the-number-and-size-of-holes-in-the-basement-membrane-change-with-time-during-emt-induction.md | Updates idea frontmatter to reference resources. |
| src/pages/dataset/released-nucmorph-data-included-pre-calculated-pcs.md | Removes legacy dataset markdown entry. |
| src/pages/dataset/released-emt-dataset.md | Removes legacy dataset markdown entry. |
| src/pages/dataset/emc.md | Removes legacy dataset markdown entry. |
| src/pages/dataset/actin-compression-simulation-dataset.md | Removes legacy dataset markdown entry (migrated into resources). |
| src/graphql/fragments.ts | Splits resource fragments by resource type and composes a ResourceFields fragment. |
| src/constants/resourceTypes.ts | Adds centralized RESOURCE_TYPES constants + ResourceType union type. |
| src/components/ResourcesComponent.tsx | Removes placeholder component now that MaterialsAndMethods consumes resources. |
| src/components/MaterialsAndMethods.tsx | Refactors to derive datasets/software/protocols/cell lines from resources list. |
| src/components/IdeaRoll.tsx | Updates list item dataset display to read from resources instead of legacy Materials & Methods. |
| src/cms/widgets/VariableResourceWidget/constants.ts | Switches resource type values to use centralized RESOURCE_TYPES. |
| gatsby/utils/test/gatsby-resolver-utils.test.js | Updates tests to use RESOURCES_TEMPLATE_KEY constant. |
| gatsby/utils/gatsby-resolver-utils.js | Removes legacy software-tool resolver; keeps slug + resource query helpers. |
| gatsby/schema/base.gql | Removes materialsAndMethods from schema; adds file to Resource. |
| gatsby/constants.js | Removes dataset/software path constants; adds template-key constants for data-only pages. |
| gatsby-node.js | Removes legacy Materials & Methods schema/resolvers; ensures resources resolver links to Resource nodes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
src/pages/resource/index.tsx
Outdated
| if (!site) { | ||
| return ( | ||
| <Layout> | ||
| <p>Data not found.</p> | ||
| </Layout> | ||
| ); |
There was a problem hiding this comment.
Layout is referenced in the !site guard but isn’t imported in this module, which will cause a compile/runtime error. Import Layout (likely from ../../components/Layout) or remove the wrapper and render the fallback without it (and ideally keep the wrapper consistent with the normal render path).
| <ul> | ||
| {protocols.map((item, index) => ( | ||
| <li key={index}> | ||
| <a | ||
| href={item.protocol} | ||
| target="_blank" | ||
| rel="noreferrer" | ||
| > | ||
| {item.protocol.split("/").pop()} | ||
| </a> | ||
| <NameWithLink name={item.name} link={item.link} /> | ||
| </li> |
There was a problem hiding this comment.
Protocol resources of type protocolFile store the file path in the file field (see schema and CMS widget), but this renderer only links using item.link. As a result, protocol-file resources will render as plain text with no usable link. Consider using item.link ?? item.file (and optionally display the filename) when rendering protocol items.
There was a problem hiding this comment.
This is being left as TODO
src/utils/formattingUtils.tsx
Outdated
| <a href={link} target="_blank" rel="noreferrer"> | ||
| {name} |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 24 out of 24 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| </div> | ||
| )} | ||
| {!!resources?.length && ( | ||
| <ResourcesComponent resources={[...resources]} /> | ||
| )} | ||
| <MaterialsAndMethodsComponent {...materialsAndMethods} /> | ||
| <MaterialsAndMethodsComponent resources={[...resources]} /> | ||
| {tags && tags.length ? <div>{getTagList(tags)}</div> : null} |
There was a problem hiding this comment.
IdeaPostTemplate spreads resources ([...resources]) before passing to MaterialsAndMethodsComponent. This will throw at runtime if resources is ever undefined (e.g., the Decap CMS preview (IdeaPostPreview) calls IdeaPostTemplate without providing resources). Consider defaulting resources to an empty array in the template/component props, or passing resources ?? [] without spreading.
| {datasets.map((dataset, index) => ( | ||
| <div key={index}> |
There was a problem hiding this comment.
Using the array index as the React key (key={index}) can cause incorrect UI updates when the list order changes. Since resources have stable identifiers (e.g., slug), prefer a stable unique key like dataset.slug.
| {datasets.map((dataset, index) => ( | |
| <div key={index}> | |
| {datasets.map((dataset) => ( | |
| <div key={dataset.slug}> |
| {protocols.map((item, index) => ( | ||
| <li key={index}> | ||
| <a | ||
| href={item.protocol} | ||
| target="_blank" | ||
| rel="noreferrer" | ||
| > | ||
| {item.protocol.split("/").pop()} | ||
| </a> | ||
| <NameWithLink name={item.name} link={item.link} /> | ||
| </li> |
There was a problem hiding this comment.
Using the array index as the React key (key={index}) can cause incorrect UI updates when the list order changes. Since resources have stable identifiers (e.g., slug), prefer a stable unique key like item.slug.
| {cellLines.map((item, index) => ( | ||
| <li key={index}>{getCellLineRender(item)}</li> | ||
| <li key={index}> | ||
| <NameWithLink name={item.name} link={item.link} /> | ||
| </li> | ||
| ))} |
There was a problem hiding this comment.
Using the array index as the React key (key={index}) can cause incorrect UI updates when the list order changes. Since resources have stable identifiers (e.g., slug), prefer a stable unique key like item.slug.
| {softwareTools.map((tool, index) => ( | ||
| <div key={index}> | ||
| <p> | ||
| <strong>Name: </strong> |
There was a problem hiding this comment.
Using the array index as the React key (key={index}) can cause incorrect UI updates when the list order changes. Since resources have stable identifiers (e.g., slug), prefer a stable unique key like tool.slug.
| dataset: { | ||
| ...post.frontmatter.materialsAndMethods?.dataset?.frontmatter, | ||
| ...post.frontmatter.resources.find((r) => r.type === "dataset"), | ||
| }, |
There was a problem hiding this comment.
resources.find((r) => r.type === "dataset") hard-codes the resource type string. Since the codebase already defines RESOURCE_TYPES.DATASET, using the constant here will prevent drift if the underlying type values ever change.
There was a problem hiding this comment.
Love the cleanup here! moving them to their designate collection simplifies things a lot
…ea-board into migrate-resources
Problem
Closes #40
We love a negative code line PR.
Final PR in this series.
Solution
Mostly we are removing the old code and markdown from how we used to handle resources.
Change summary: