Skip to content

Comments

DRY-up conditional rendering in GeneRecordClasses#1581

Merged
bobular merged 2 commits intogene-page-open-all-sectionsfrom
copilot/sub-pr-1578
Jan 7, 2026
Merged

DRY-up conditional rendering in GeneRecordClasses#1581
bobular merged 2 commits intogene-page-open-all-sectionsfrom
copilot/sub-pr-1578

Conversation

Copy link
Contributor

Copilot AI commented Jan 7, 2026

Refactored RecordMainSection component to eliminate ~40 lines of duplicated JSX from if/else branches that differed only in one conditionally-rendered button.

Changes:

  • Consolidated common structure (collapse button, layout) into single render path
  • Moved environment-specific logic to inline conditional: {process.env.NODE_ENV !== 'production' && <TestingButton />}
  • Preserved behavior: production shows collapse button only; non-production shows both collapse and expand buttons

Before:

let segment;
if (process.env.NODE_ENV === 'production') {
  segment = (
    <React.Fragment>
      {/* ~30 lines of JSX */}
      <button>Collapse all sections</button>
    </React.Fragment>
  );
} else {
  segment = (
    <React.Fragment>
      {/* Same ~30 lines of JSX */}
      <button>Collapse all sections</button>
      <button>Open all sections for testing</button>
    </React.Fragment>
  );
}
return <div>{segment}</div>;

After:

return (
  <div>
    <React.Fragment>
      {/* ~30 lines of JSX once */}
      <button>Collapse all sections</button>
      {process.env.NODE_ENV !== 'production' && (
        <button>Open all sections for testing</button>
      )}
    </React.Fragment>
  </div>
);

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: bobular <308639+bobular@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor conditional rendering for gene page DRY-up conditional rendering in GeneRecordClasses Jan 7, 2026
Copilot AI requested a review from bobular January 7, 2026 15:48
@bobular bobular marked this pull request as ready for review January 7, 2026 15:50
@bobular bobular merged commit d932900 into gene-page-open-all-sections Jan 7, 2026
1 check passed
@bobular bobular deleted the copilot/sub-pr-1578 branch January 7, 2026 15:51
aurreco-uga added a commit that referenced this pull request Jan 9, 2026
* gene page: open all sections in non prod sites

* back to not prettied with commas

* DRY-up conditional rendering in GeneRecordClasses (#1581)

* Initial plan

* DRY-up conditional rendering based on NODE_ENV

Co-authored-by: bobular <308639+bobular@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: bobular <308639+bobular@users.noreply.github.com>

---------

Co-authored-by: Cristina Aurrecoechea <aurreco@palm.penn.apidb.org>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: bobular <308639+bobular@users.noreply.github.com>
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.

2 participants