Skip to content

refactor(react-components): Change type of uniqueId and buttonType in the entire code #5249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 1, 2025

Conversation

nilscognite
Copy link
Contributor

@nilscognite nilscognite commented Jul 31, 2025

Type of change

Refactor

Description 📝

  1. Now, the uniqueId is made from Guid (before it was made from a counter)
  2. Let buttonType return ByttonType type instead of string
  3. Move ButtonType and UniqueId to architecture/utility/types.ts

How has this been tested? 🔍

I relay on the unit tests

Checklist ☑️

  • I am happy with this implementation.
  • I have performed a self-review of my own code.
  • I have added unit and visuals tests to prove that my feature works to the best of my ability.
  • I have added documentation to new and changed elements; both public and internally shared ones
  • I have refactored the code for testability, readability and extendibility to the best of my ability.
  • I have listed the JIRA tasks covering remaining work or tech debt related to this PR in the description.

@nilscognite nilscognite changed the title refactor(react-components): Change type of uniqueId and buttonType all code refactor(react-components): Change type of uniqueId and buttonType in the entire code Jul 31, 2025
Copy link

codecov bot commented Jul 31, 2025

Codecov Report

❌ Patch coverage is 97.36842% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 63.85%. Comparing base (d7b7631) to head (f0617f7).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...nts/src/components/Architecture/CommandButtons.tsx 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5249      +/-   ##
==========================================
- Coverage   63.85%   63.85%   -0.01%     
==========================================
  Files        1170     1171       +1     
  Lines       82508    82503       -5     
  Branches     7404     7401       -3     
==========================================
- Hits        52685    52680       -5     
  Misses      29682    29682              
  Partials      141      141              
Files with missing lines Coverage Δ
...ents/src/architecture/base/commands/BaseCommand.ts 94.61% <100.00%> (-0.05%) ⬇️
...base/concreteCommands/DeleteDomainObjectCommand.ts 100.00% <100.00%> (ø)
...rc/architecture/base/domainObjects/DomainObject.ts 89.35% <100.00%> (-0.02%) ⬇️
...chitecture/base/renderTarget/RevealRenderTarget.ts 61.70% <100.00%> (ø)
...mponents/src/architecture/base/undo/Transaction.ts 84.00% <ø> (ø)
...mponents/src/architecture/base/undo/UndoManager.ts 76.74% <100.00%> (ø)
...omponents/src/architecture/base/utilities/types.ts 100.00% <100.00%> (ø)
...tion360/DeleteSelectedImage360AnnotationCommand.ts 100.00% <100.00%> (ø)
...e/annotations/commands/AnnotationsDeleteCommand.ts 33.33% <100.00%> (ø)
...ure/concrete/clipping/commands/ApplyClipCommand.ts 27.77% <100.00%> (ø)
... and 11 more
🚀 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.

return this._uniqueId;
}

public set uniqueId(value: number) {
protected set uniqueId(value: UniqueId) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to protected. This should be used with care, so it is better


export type UniqueId = string;

export function generateUniqueId(): UniqueId {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added this so it is done in the same way for both cases where I use UniqueId

@@ -0,0 +1,7 @@
export type ButtonType = 'ghost' | 'ghost-destructive' | 'primary';

export type UniqueId = string;
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 add readability in the code.

return getKey(child);
}

function getKey(command: BaseCommand): string {
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 not needed anymore

@@ -27,11 +27,6 @@ export function getTooltipPlacement(toolbarPlacement: PlacementType): PlacementT
}
}

export function getButtonType(command: BaseCommand): ButtonType {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not needed anymore

Copy link
Contributor

@christjt christjt left a comment

Choose a reason for hiding this comment

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

risk review ok

@nilscognite nilscognite merged commit 2637647 into master Aug 1, 2025
16 checks passed
@nilscognite nilscognite deleted the np/uniqueId branch August 1, 2025 07:36
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