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

17322 - shall generate pagination for the frontend even if gateway h… #17342

Merged
merged 3 commits into from
Dec 21, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion generators/entity/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,11 @@ class EntityGenerator extends BaseBlueprintGenerator {
}

this.entityConfig.name = this.entityConfig.name || context.name;
if (![SQL, MONGODB, COUCHBASE, NEO4J].includes(context.databaseType)) {
// disable pagination if there is not database, unless it is gateway project
mshima marked this conversation as resolved.
Show resolved Hide resolved
if (
![SQL, MONGODB, COUCHBASE, NEO4J].includes(context.databaseType) &&
(context.applicationType !== GATEWAY || !this.entityConfig.microserviceName)
) {
this.entityConfig.pagination = NO_PAGINATION;
}

Expand Down
21 changes: 21 additions & 0 deletions test/entity.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,9 @@ describe('JHipster generator for entity', () => {
it('generates search specific content for template', () => {
assert.fileContent(`${CLIENT_MAIN_SRC_DIR}app/entities/sampleMicroservice/bar/list/bar.component.html`, 'form name="searchForm"');
});
it('generates pagination specific content for template', () => {
assert.fileContent(`${CLIENT_MAIN_SRC_DIR}app/entities/sampleMicroservice/bar/list/bar.component.html`, 'ngb-pagination');
});
});

describe('with entity from microservice and custom client-root-folder', () => {
Expand Down Expand Up @@ -674,6 +677,24 @@ describe('JHipster generator for entity', () => {
assert.fileContent(`${CLIENT_MAIN_SRC_DIR}app/entities/sampleMicroservice/baz/baz.model.ts`, 'id?: string');
});
});

describe('without database and paginated entity', () => {
before(async () => {
await helpers
.run(require.resolve('../generators/entity'))
.doInDir(dir => {
fse.copySync(path.join(__dirname, '../test/templates/gateway-nodb'), dir);
})
.withPrompts({
useMicroserviceJson: true,
microservicePath: 'microservice1',
})
.withArguments(['foo']);
});
it('generates pagination specific content for the template', () => {
assert.fileContent(`${CLIENT_MAIN_SRC_DIR}app/entities/sampleMicroservice/foo/list/foo.component.html`, 'ngb-pagination');
});
});
});

describe('with creation timestamp', () => {
Expand Down
35 changes: 35 additions & 0 deletions test/templates/gateway-nodb/.yo-rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"generator-jhipster": {
"promptValues": {
"packageName": "com.mycompany.myapp",
"nativeLanguage": "en"
},
"jhipsterVersion": "5.3.0",
"applicationType": "gateway",
"baseName": "gway",
"packageName": "com.mycompany.myapp",
"packageFolder": "com/mycompany/myapp",
"serverPort": "8080",
"authenticationType": "jwt",
"cacheProvider": "hazelcast",
"enableHibernateCache": true,
"websocket": false,
"databaseType": "no",
"searchEngine": false,
"messageBroker": false,
"serviceDiscoveryType": "eureka",
"buildTool": "maven",
"enableSwaggerCodegen": false,
"jwtSecretKey": "MTBlZDY1OTk5Yjc2MjRkZDY3ZDkwZTE1ZWY1Nzg5MTQ0NWU0MjA4OTcxZDMyMTUzZTcxOGFhM2UwMWIyYjlkZmQ3OTljZTkwNThlYmViZDM0M2Y2OWFiM2JhNWY5ZDZkYzBhODg3ZDkwOGQyYmY1ZTFiYzFkNDhkNjhjZGFmNDE=",
"clientFramework": "angularX",
"clientPackageManager": "npm",
"testFrameworks": [],
"jhiPrefix": "jhi",
"enableTranslation": true,
"nativeLanguage": "en",
"languages": [
"en",
"es"
]
}
}
20 changes: 20 additions & 0 deletions test/templates/gateway-nodb/microservice1/.jhipster/Foo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "Foo",
"fields": [
{
"fieldName": "name",
"fieldType": "String"
}
],
"relationships": [],
"changelogDate": "20180905045309",
"entityTableName": "foo",
"dto": "mapstruct",
"pagination": "pagination",
"service": "serviceClass",
"jpaMetamodelFiltering": true,
"fluentMethods": true,
"clientRootFolder": "sampleMicroservice",
"applications": "*",
"microserviceName": "sampleMicroservice"
}