Skip to content

Conversation

@kmcginnes
Copy link
Collaborator

@kmcginnes kmcginnes commented Jan 22, 2026

Description

This PR refactors entity count formatting from a static utility function into a custom hook that properly integrates with the translation system, enabling query-language-specific terminology.

New Hook: useEntityCountFormatter

Created a new hook that replaces the static formatEntityCounts utility with translation-aware formatting:

  • useFormattedEntityCounts(vertexCount, edgeCount) - Direct formatting hook for use in components
  • useEntityCountFormatterCallback() - Returns a callback function for use in mutations and async operations

Key improvements:

  • Integrates with the translation system to use query-language-specific terms (e.g., "relationships" for openCypher, "predicates" for SPARQL)
  • Maintains locale-aware number formatting (e.g., "1,000 nodes")
  • Handles singular/plural forms correctly
  • Comprehensive test coverage with 89 lines of tests

Updated Components

  • GraphViewerEmptyState - Now uses useFormattedEntityCounts hook
  • ImportGraphButton - Now uses useEntityCountFormatterCallback for mutation callbacks
  • useRestoreGraphSession - Now uses useEntityCountFormatterCallback for mutation callbacks

This change ensures that entity count messages throughout the application respect the active query language's terminology.

Validation

Gremlin

CleanShot 2026-01-22 at 15 55 23@2x

Cypher

CleanShot 2026-01-22 at 15 56 36@2x

SPARQL

CleanShot 2026-01-22 at 15 57 06@2x

Related Issues

Check List

  • I confirm that my contribution is made under the terms of the Apache 2.0
    license.
  • I have run pnpm checks to ensure code compiles and meets standards.
  • I have run pnpm test to check if all tests are passing.
  • I have covered new added functionality with unit tests if necessary.
  • I have added an entry in the Changelog.md.

@codecov
Copy link

codecov bot commented Jan 22, 2026

Codecov Report

❌ Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.78%. Comparing base (c5affc5) to head (46ce015).
⚠️ Report is 42 commits behind head on main.

Files with missing lines Patch % Lines
...ateProvider/graphSession/useRestoreGraphSession.ts 0.00% 0 Missing and 1 partial ⚠️
...orer/src/modules/GraphViewer/ImportGraphButton.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1477       +/-   ##
===========================================
+ Coverage   47.81%   62.78%   +14.97%     
===========================================
  Files         382      315       -67     
  Lines        8525     6530     -1995     
  Branches     3159     2271      -888     
===========================================
+ Hits         4076     4100       +24     
+ Misses       3070     1699     -1371     
+ Partials     1379      731      -648     
Flag Coverage Δ
unittests 62.78% <84.61%> (+14.97%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kmcginnes kmcginnes changed the title Format entity counts Refactor entity count formatting to support translations Jan 22, 2026
@kmcginnes kmcginnes marked this pull request as ready for review January 22, 2026 22:06
@kmcginnes kmcginnes merged commit 5e3fbcb into aws:main Jan 22, 2026
4 checks passed
@kmcginnes kmcginnes deleted the feature/labels-format-entity-counts branch January 22, 2026 22:12
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