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

convert app component to standalone. #24398

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
122 changes: 61 additions & 61 deletions generators/angular/__snapshots__/generator.spec.mts.snap

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions generators/angular/cleanup.mts
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,10 @@ export default function cleanupOldFilesTask(this: CoreGenerator, { application }
this.removeFile(`${application.clientSrcDir}app/admin/tracker/tracker.module.ts`);
this.removeFile(`${application.clientSrcDir}app/account/account.module.ts`);
}
if (this.isJhipsterVersionLessThan('8.0.1')) {
this.removeFile(`${application.clientSrcDir}app/layouts/main/main.module.ts`);
this.removeFile(`${application.clientSrcDir}app/admin/admin-routing.module.ts`);
this.removeFile(`${application.clientSrcDir}app/app.module.ts`);
this.removeFile(`${application.clientSrcDir}app/entities/entity-routing.module.ts`);
}
}
7 changes: 3 additions & 4 deletions generators/angular/files-angular.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const files = {
},
{
...clientApplicationTemplatesBlock(),
templates: ['app.module.ts', 'app-routing.module.ts', 'app.constants.ts', 'app-page-title-strategy.ts'],
templates: ['app.config.ts', 'app.component.ts', 'app.routes.ts', 'app.constants.ts', 'app-page-title-strategy.ts'],
},
],
microfrontend: [
Expand All @@ -76,7 +76,7 @@ export const files = {
templates: [
// entities
'entities/entity-navbar-items.ts',
'entities/entity-routing.module.ts',
'entities/entity.routes.ts',
// home module
'home/home.component.ts',
'home/home.component.html',
Expand All @@ -86,7 +86,6 @@ export const files = {
'layouts/profiles/profile-info.model.ts',
'layouts/main/main.component.ts',
'layouts/main/main.component.html',
'layouts/main/main.module.ts',
'layouts/navbar/navbar-item.model.d.ts',
'layouts/navbar/navbar.component.ts',
'layouts/navbar/navbar.component.html',
Expand Down Expand Up @@ -172,7 +171,7 @@ export const files = {
condition: generator => !generator.applicationTypeMicroservice,
...clientApplicationTemplatesBlock(),
templates: [
'admin/admin-routing.module.ts',
'admin/admin.routes.ts',
'admin/docs/docs.component.ts',
'admin/docs/docs.component.html',
'admin/docs/docs.component.scss',
Expand Down
18 changes: 2 additions & 16 deletions generators/angular/generator.mts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default class AngularGenerator extends BaseApplicationGenerator {

source.addAdminRoute = (args: Omit<Parameters<typeof addRoute>[0], 'needle'>) =>
this.editFile(
`${application.srcMainWebapp}app/admin/admin-routing.module.ts`,
`${application.srcMainWebapp}app/admin/admin.routes.ts`,
addRoute({
needle: 'add-admin-route',
...args,
Expand Down Expand Up @@ -238,20 +238,6 @@ export default class AngularGenerator extends BaseApplicationGenerator {
this.needleApi.clientAngular.addVendorSCSSStyle(style, comment);
}

/**
* @private
* Add a new admin in the TS modules file.
*
* @param {string} appName - Angular2 application name.
* @param {string} adminAngularName - The name of the new admin item.
* @param {string} adminFolderName - The name of the folder.
* @param {string} adminFileName - The name of the file.
* @param {boolean} enableTranslation - If translations are enabled or not.
*/
addAdminToModule(appName, adminAngularName, adminFolderName, adminFileName, enableTranslation) {
this.needleApi.clientAngular.addToAdminModule(appName, adminAngularName, adminFolderName, adminFileName, enableTranslation);
}

/**
* @private
* Add a new lazy loaded module to admin routing file.
Expand Down Expand Up @@ -313,7 +299,7 @@ export default class AngularGenerator extends BaseApplicationGenerator {
}

addEntitiesToModule({ application, entities }: { application: CommonClientServerApplication; entities: Entity[] }) {
const filePath = `${application.clientSrcDir}app/entities/entity-routing.module.ts`;
const filePath = `${application.clientSrcDir}app/entities/entity.routes.ts`;
const ignoreNonExisting = chalk.yellow(`Route(s) not added to ${filePath}.`);
const addRouteCallback = addEntitiesRoute({ application, entities });
this.editFile(filePath, { ignoreNonExisting }, addRouteCallback);
Expand Down
42 changes: 21 additions & 21 deletions generators/angular/generator.spec.mts
Original file line number Diff line number Diff line change
Expand Up @@ -135,28 +135,28 @@ describe(`generator - ${clientFramework}`, () => {
const assertion = (...args) =>
generateAdminUi ? runResult.assertFileContent(...args) : runResult.assertNoFileContent(...args);
assertion(
`${clientSrcDir}app/admin/admin-routing.module.ts`,
`${clientSrcDir}app/admin/admin.routes.ts`,
`
{
path: 'configuration',
loadComponent: () => import('./configuration/configuration.component'),
title: 'configuration.title',
},
{
path: 'health',
loadComponent: () => import('./health/health.component'),
title: 'health.title',
},
{
path: 'logs',
loadComponent: () => import('./logs/logs.component'),
title: 'logs.title',
},
{
path: 'metrics',
loadComponent: () => import('./metrics/metrics.component'),
title: 'metrics.title',
},
{
path: 'configuration',
loadComponent: () => import('./configuration/configuration.component'),
title: 'configuration.title',
},
{
path: 'health',
loadComponent: () => import('./health/health.component'),
title: 'health.title',
},
{
path: 'logs',
loadComponent: () => import('./logs/logs.component'),
title: 'logs.title',
},
{
path: 'metrics',
loadComponent: () => import('./metrics/metrics.component'),
title: 'metrics.title',
},
`,
);
});
Expand Down
22 changes: 2 additions & 20 deletions generators/angular/needle-api/needle-client-angular.mts
Original file line number Diff line number Diff line change
Expand Up @@ -38,31 +38,13 @@ export default class extends needleClientBase {
}

addModule(appName, angularName, folderName, fileName, enableTranslation) {
const modulePath = `${this.clientSrcDir}app/app.module.ts`;
const modulePath = `${this.clientSrcDir}app/app.config.ts`;
const importNeedle = 'jhipster-needle-angular-add-module-import';
const moduleNeedle = 'jhipster-needle-angular-add-module';

this._genericAddModule(appName, angularName, folderName, fileName, enableTranslation, ANGULAR, modulePath, importNeedle, moduleNeedle);
}

addToAdminModule(appName, adminAngularName, adminFolderName, adminFileName, enableTranslation) {
const adminModulePath = `${this.clientSrcDir}app/admin/admin-routing.module.ts`;
const importNeedle = 'jhipster-needle-add-admin-module-import';
const moduleNeedle = 'jhipster-needle-add-admin-module';

this._genericAddModule(
appName,
adminAngularName,
adminFolderName,
adminFileName,
enableTranslation,
ANGULAR,
adminModulePath,
importNeedle,
moduleNeedle,
);
}

_genericAddModule(
appName,
angularName,
Expand Down Expand Up @@ -193,7 +175,7 @@ export default class extends needleClientBase {
}

addAdminRoute(route, modulePath, moduleName, pageTitle) {
const adminModulePath = `${this.clientSrcDir}app/admin/admin-routing.module.ts`;
const adminModulePath = `${this.clientSrcDir}app/admin/admin.routes.ts`;
this._addRoute(route, modulePath, moduleName, 'jhipster-needle-add-admin-route', adminModulePath, pageTitle);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ will generate few files:
```
create <%= clientSrcDir %>app/my-component/my-component.component.html
create <%= clientSrcDir %>app/my-component/my-component.component.ts
update <%= clientSrcDir %>app/app.module.ts
update <%= clientSrcDir %>app/app.config.ts
```

<&_ } -&>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<%#
Copyright 2013-2023 the original author or authors from the JHipster project.

This file is part of the JHipster project, see https://www.jhipster.tech/
for more information.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-%>
import { Routes } from '@angular/router';
/* jhipster-needle-add-admin-module-import - JHipster will add admin modules imports here */

const routes: Routes = [
<%_ if (generateUserManagement) { _%>
{
path: 'user-management',
loadChildren: () => import('./user-management/user-management.route'),
title: 'userManagement.home.title',
},
<%_ } _%>
{
path: 'docs',
loadComponent: () => import('./docs/docs.component'),
title: 'global.menu.admin.apidocs',
},
<%_ if (withAdminUi) { _%>
{
path: 'configuration',
loadComponent: () => import('./configuration/configuration.component'),
title: 'configuration.title',
},
{
path: 'health',
loadComponent: () => import('./health/health.component'),
title: 'health.title',
},
{
path: 'logs',
loadComponent: () => import('./logs/logs.component'),
title: 'logs.title',
},
{
path: 'metrics',
loadComponent: () => import('./metrics/metrics.component'),
title: 'metrics.title',
},
<%_ } _%>
<%_ if (applicationTypeGateway && serviceDiscoveryAny) { _%>
{
path: 'gateway',
loadComponent: () => import('./gateway/gateway.component'),
title: 'gateway.title',
},
<%_ } _%>
<%_ if (communicationSpringWebsocket) { _%>
{
path: 'tracker',
loadComponent: () => import('./tracker/tracker.component'),
title: 'tracker.title',
},
<%_ } _%>
/* jhipster-needle-add-admin-route - JHipster will add admin routes here */
];

export default routes;
Loading