Skip to content
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

Feature/refactor example default #3816

Merged
merged 11 commits into from Oct 8, 2022

Conversation

swarajsaaj
Copy link
Contributor

Fill default values for properties on application of patch/modules

Fix #3480

@codecov
Copy link

codecov bot commented Oct 5, 2022

Codecov Report

Base: 100.00% // Head: 100.00% // No change to project coverage 👍

Coverage data is based on head (b521f1e) compared to base (788f170).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff              @@
##                main     #3816    +/-   ##
============================================
  Coverage     100.00%   100.00%            
- Complexity      2094      2158    +64     
============================================
  Files            545       565    +20     
  Lines           8935      9264   +329     
  Branches         175       179     +4     
============================================
+ Hits            8935      9264   +329     
Impacted Files Coverage Δ
...p/module/secondary/RestModulePropertyDefinition.ts 100.00% <ø> (ø)
...tructure/primary/CodespaceModuleConfiguration.java 100.00% <100.00%> (ø)
...omain/properties/JHipsterPropertyDefaultValue.java 100.00% <100.00%> (ø)
...ain/resource/JHipsterModulePropertyDefinition.java 100.00% <100.00%> (ø)
...structure/primary/OpenApiModulesConfiguration.java 100.00% <100.00%> (ø)
.../primary/RestJHipsterModulePropertyDefinition.java 100.00% <100.00%> (ø)
...rc/main/webapp/app/module/primary/PropertyValue.ts 100.00% <100.00%> (ø)
...pp/module/primary/landscape/Landscape.component.ts 100.00% <100.00%> (ø)
...le/primary/modules-patch/ModulesPatch.component.ts 100.00% <100.00%> (ø)
src/main/webapp/app/common/domain/Optional.ts 100.00% <0.00%> (ø)
... and 108 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -117,8 +113,8 @@ public Optional<JHipsterPropertyDescription> description() {
return description;
}

public Optional<JHipsterPropertyExample> example() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Need to keep it deprecated at least for 1 version. See JHipsterModuleReplacements.JHipsterModuleReplacementsBuilder.in for deprecation example.

Doing that since it can be used in custom JHLite instances

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DamnClin Sorry I am not really getting this one, what do you mean by "custom JHLite instances" here and how would they be affected by this change?
Is it for JHLite being used as a dependency in other project? Not sure how it affects generated apps.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep. You have a module called custom-jhlite that generate instances allowing organization to build there own module. In this we have dependencies to JHLite so we need to give them some time to adapt to new apis

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, i have kept the example in here and builder as deprecated.

case 'BOOLEAN':
updateProperty(createProperty(property.key, Boolean(property.defaultValue)));
break;
default:
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can avoid default and have code not compiling without all values by putting that in a dedicated method. see modeClass in Landscape.component.ts for an example

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I would rather do a common util method in PropertyValue.ts for use in both Landscape and PathModule

@@ -205,6 +205,21 @@ export default defineComponent({
const applyModule = (module: string): void => {
operationInProgress.value = true;

selectedModuleProperties().forEach(property => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks a lot like a duplication :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

:), would reuse the common method from PropertyValue.ts for casting logic.

Reduce redundancy and move to common castValue method

Fix jhipster#3480
Added deprecated example method in property definition and builder

Fix jhipster#3480
public Optional<JHipsterPropertyExample> example() {
return example;
if (defaultValue.isPresent()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

defaultValue.map(value -> JHipsterPropertyExample.of(value.get()));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I see it has to be flatMap , else it would return Optional<Optional<JhipsterPropertyExample>>, so:-

defaultValue.flatMap(value -> JHipsterPropertyExample.of(value.get()));

DamnClin
DamnClin previously approved these changes Oct 8, 2022
@swarajsaaj
Copy link
Contributor Author

Had to add a test case for deprecated method, my assumption was its ignored from Codecov.

@DamnClin
Copy link
Collaborator

DamnClin commented Oct 8, 2022

Good job here. cc @pascalgrimaud I think this deserve a Bounty :)

@DamnClin DamnClin merged commit 15a1595 into jhipster:main Oct 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Default value for module properties
3 participants