Skip to content

migrate resource (resource migration 3/3)#72

Open
interim17 wants to merge 10 commits intomigrate-resources-1from
migrate-resources
Open

migrate resource (resource migration 3/3)#72
interim17 wants to merge 10 commits intomigrate-resources-1from
migrate-resources

Conversation

@interim17
Copy link
Contributor

@interim17 interim17 commented Mar 11, 2026

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:

  • removal of markdown and data for software, datasets, etc in the old system
  • removal of schema typing, resolvers, etc for `MaterialsAndMethods
  • updated Materials and Methods component that consumes the new data
  • updated draft resource index page (proof of concept)

concerns: post.frontmatter.concerns || "",
dataset: {
...post.frontmatter.materialsAndMethods?.dataset?.frontmatter,
...post.frontmatter.resources.find((r) => r.type === "dataset"),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file has an outdated approach to typing and querying, but it's not essential to do more than patch in this PR.

Comment on lines +179 to +180
resources {
...ResourceFields
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using fragments defined in src/graphql/fragments

@interim17 interim17 changed the title Migrate resources migrate resource (resource migration 2/3) Mar 11, 2026
Comment on lines +1 to +9
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];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment on lines +34 to +48
{!!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>
</>
)}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bucketed resources using filtered queries + fragmentes below with a basic render here. A demonstration/proof of concept, not styled.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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, and software content/types/templates; add new resource markdown 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.

Comment on lines +20 to +25
if (!site) {
return (
<Layout>
<p>Data not found.</p>
</Layout>
);
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
Comment on lines 69 to 73
<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>
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is being left as TODO

Comment on lines +12 to +13
<a href={link} target="_blank" rel="noreferrer">
{name}

This comment was marked as resolved.

@interim17 interim17 changed the title migrate resource (resource migration 2/3) migrate resource (resource migration 2/2) Mar 11, 2026
@interim17 interim17 marked this pull request as ready for review March 11, 2026 18:14
@interim17 interim17 marked this pull request as draft March 11, 2026 18:37
@interim17 interim17 changed the base branch from feature/resource-query to migrate-resources-1 March 11, 2026 18:44
@interim17 interim17 changed the title migrate resource (resource migration 2/2) migrate resource (resource migration 3/3) Mar 11, 2026
@interim17 interim17 requested a review from Copilot March 11, 2026 18:50
@interim17 interim17 marked this pull request as ready for review March 11, 2026 18:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment on lines 141 to 144
</div>
)}
{!!resources?.length && (
<ResourcesComponent resources={[...resources]} />
)}
<MaterialsAndMethodsComponent {...materialsAndMethods} />
<MaterialsAndMethodsComponent resources={[...resources]} />
{tags && tags.length ? <div>{getTagList(tags)}</div> : null}
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +40 to +41
{datasets.map((dataset, index) => (
<div key={index}>
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
{datasets.map((dataset, index) => (
<div key={index}>
{datasets.map((dataset) => (
<div key={dataset.slug}>

Copilot uses AI. Check for mistakes.
Comment on lines 71 to 74
{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>
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines 87 to 91
{cellLines.map((item, index) => (
<li key={index}>{getCellLineRender(item)}</li>
<li key={index}>
<NameWithLink name={item.name} link={item.link} />
</li>
))}
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +103 to +106
{softwareTools.map((tool, index) => (
<div key={index}>
<p>
<strong>Name: </strong>
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines 53 to 55
dataset: {
...post.frontmatter.materialsAndMethods?.dataset?.frontmatter,
...post.frontmatter.resources.find((r) => r.type === "dataset"),
},
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Copy link

@rugeli rugeli left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link

Choose a reason for hiding this comment

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

Love the cleanup here! moving them to their designate collection simplifies things a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants