Repository: jhipster/generator-jhipster (ts)

Issue:
URL are inconsistent between Angular and React
<!--
- Please follow the issue template below for bug reports.
- If you have a support request rather than a bug, please use [Stack Overflow](http://stackoverflow.com/questions/tagged/jhipster) with the JHipster tag.
- For bug reports it is mandatory to run the command `jhipster info` in your project's root folder, and paste the result here.
- Tickets opened without any of these pieces of information will be **closed** without any explanation.
-->

##### **Overview of the issue**

There are still some inconsistencies in URLs between Angular and React. 
For instance, for accessing the entity page:

-  in Angular with: http://localhost:8080/meal 
- in React    with: http://localhost:8080/entity/meal

<!-- Explain the bug, if an error is being thrown a stack trace helps -->

##### **Motivation for or Use Case**

Keep consistency between the different generators

<!-- Explain why this is a bug for you -->

##### **Reproduce the error**

<!-- For bug reports, an unambiguous set of steps to reproduce the error -->

##### **Related issues**

PR: #10188 
<!-- Has a similar issue been reported before? Please search both closed & open issues -->

##### **Suggest a Fix**

Either put the `entity` prefix in Angular, or remove it in React (and Vue.js). I can make a PR once a decision is taken.

<!-- If you can't fix the bug yourself, perhaps you can point to what might be
  causing the problem (line of code or commit) -->

##### **JHipster Version(s)**
6.2.0 (on master)

<!--
Which version of JHipster are you using, is it a regression?
-->

##### **JHipster configuration**

To reproduce, you can use the following JDLs: 

For react
```
application {
  config {
    databaseType sql
    devDatabaseType h2Disk
    enableHibernateCache true
    enableSwaggerCodegen false
    enableTranslation true
    jhiPrefix jhi
    languages [en]
    messageBroker false
    nativeLanguage en
    packageName com.mycompany.myapp
    packageFolder com/mycompany/myapp
    prodDatabaseType mysql
    searchEngine false
    serviceDiscoveryType false
    skipClient false
    skipServer false
    testFrameworks []
    websocket false
    promptValues [object Object]
    jhipsterVersion 6.2.0
    applicationType monolith
    baseName jhipster
    serverPort 8080
    authenticationType jwt
    cacheProvider ehcache
    buildTool maven
    jwtSecretKey NGQxYTAzMmZhZjM0ZjBkYmM4ZGQwOGJjNzZiYzYzZDRjMWY4NjVlOGYwMDdmYTExOTA0ZGQ1NDU4MWViYjE3Y2FiYmU5OGJkNTYwMGFiYjY5YzA5MjI4NDdiZTU2ZDE1M2NkZTIzYjY4YjhiNDcyNGY4MDc0MmIzOTNiZTA0NGY=
    useSass true
    clientPackageManager npm
    clientFramework react
    clientTheme none
    clientThemeVariant 
    entitySuffix 
    dtoSuffix DTO
    otherModules 
    blueprints 
    skipUserManagement false
  }

  entities Meal
}

entity Meal {
  name String
}
```

For Angular
```
application {
  config {
    databaseType sql
    devDatabaseType h2Disk
    enableHibernateCache true
    enableSwaggerCodegen false
    enableTranslation true
    jhiPrefix jhi
    languages [en]
    messageBroker false
    nativeLanguage en
    packageName com.mycompany.myapp
    packageFolder com/mycompany/myapp
    prodDatabaseType mysql
    searchEngine false
    serviceDiscoveryType false
    skipClient false
    skipServer false
    testFrameworks []
    websocket false
    promptValues [object Object]
    jhipsterVersion 6.2.0
    applicationType monolith
    baseName jhipster
    serverPort 8080
    authenticationType jwt
    cacheProvider ehcache
    buildTool maven
    jwtSecretKey Y2QxMmUzMjYyYTdjNzY5Yjk3MGYyN2ZhN2RmNWY1MWU1NDVlZDFhYzg0MzE5ZTNhZWQyZjI1OTliOGUxZDM1MThiODhmNDZmZGNiZTBiYzJiYTY1NzJlMTk2YmVjMGFkMDZlMDhjMTMwZDBmOGYyM2E5ZjBkODFjZDI3MWE2NWI=
    useSass true
    clientPackageManager npm
    clientFramework angularX
    clientTheme none
    clientThemeVariant 
    entitySuffix 
    dtoSuffix DTO
    otherModules 
    blueprints 
    skipUserManagement false
  }

  entities Meal
}

entity Meal {
  name String
}
```

##### **Browsers and Operating System**

<!-- What OS are you on? is this a problem with all browsers or only IE8? -->

-   [x] Checking this box is mandatory (this is just to show you read everything)

<!-- Love JHipster? Please consider supporting our collective:
👉  https://opencollective.com/generator-jhipster/donate -->


Pull request description:
Fix urls inconsistencies with entities
Proposition to fix #10301 (I added the `entity/` prefix in Angular routes for entities)

Edit: following @vishal423 suggestion, I removed the entity/ prefix in React routes

-   Please make sure the below checklist is followed for Pull Requests.

-   [ ] [Travis tests](https://travis-ci.org/jhipster/generator-jhipster/pull_requests) are green
-   [ ] Tests are added where necessary
-   [ ] Documentation is added/updated where necessary
-   [ ] Coding Rules & Commit Guidelines as per our [CONTRIBUTING.md document](https://github.com/jhipster/generator-jhipster/blob/master/CONTRIBUTING.md) are followed

<!--
Please also reference the issue number in a commit message to [automatically close the related Github issue](https://help.github.com/articles/closing-issues-via-commit-messages/)

Note: It is also possible to add `[skip ci]` to your commit message to skip Travis tests
-->


Patch:
diff --git a/generators/client/needle-api/needle-client-react.js b/generators/client/needle-api/needle-client-react.js
index 3c31e27635..eb61b33411 100644
--- a/generators/client/needle-api/needle-client-react.js
+++ b/generators/client/needle-api/needle-client-react.js
@@ -35,7 +35,7 @@ module.exports = class extends needleClientBase {
         const entityMenuPath = `${CLIENT_MAIN_SRC_DIR}app/shared/layout/menus/entities.tsx`;
         const entityEntry =
             // prettier-ignore
-            this.generator.stripMargin(`|<MenuItem icon="asterisk" to="/entity/${routerName}">
+            this.generator.stripMargin(`|<MenuItem icon="asterisk" to="/${routerName}">
                         |      ${enableTranslation ? `<Translate contentKey="global.menu.entities.${entityTranslationKeyMenu}" />` : `${_.startCase(routerName)}`}
                         |    </MenuItem>`);
         const rewriteFileModel = this.generateFileModel(entityMenuPath, 'jhipster-needle-add-entity-to-menu', entityEntry);
@@ -62,7 +62,7 @@ module.exports = class extends needleClientBase {
         const indexAddRoutePathRewriteFileModel = this.generateFileModel(
             indexModulePath,
             'jhipster-needle-add-route-path',
-            this.generator.stripMargin(`|<ErrorBoundaryRoute path={\`\${match.url}/${entityFileName}\`} component={${entityName}} />`)
+            this.generator.stripMargin(`|<ErrorBoundaryRoute path={\`\${match.url}${entityFileName}\`} component={${entityName}} />`)
         );
         this.addBlockContentToFile(indexAddRoutePathRewriteFileModel, errorMessage(indexModulePath));
 
diff --git a/generators/client/templates/react/src/main/webapp/app/routes.tsx.ejs b/generators/client/templates/react/src/main/webapp/app/routes.tsx.ejs
index bac18991d6..8b72362b13 100644
--- a/generators/client/templates/react/src/main/webapp/app/routes.tsx.ejs
+++ b/generators/client/templates/react/src/main/webapp/app/routes.tsx.ejs
@@ -66,8 +66,8 @@ const Routes = () => (
     <%_ if (!skipUserManagement) { _%>
       <PrivateRoute path="/account" component={Account} hasAnyAuthorities={[AUTHORITIES.ADMIN, AUTHORITIES.USER]}/>
     <%_ } _%>
-      <PrivateRoute path="/entity" component={Entities} hasAnyAuthorities={[AUTHORITIES.USER]}/>
       <ErrorBoundaryRoute path="/" exact component={Home}/>
+      <PrivateRoute path="/" component={Entities} hasAnyAuthorities={[AUTHORITIES.USER]}/>
       <ErrorBoundaryRoute component={PageNotFound} />
     </Switch>
   </div>
diff --git a/generators/entity-client/templates/react/src/main/webapp/app/entities/entity-detail.tsx.ejs b/generators/entity-client/templates/react/src/main/webapp/app/entities/entity-detail.tsx.ejs
index 577b65ca7a..40e4495bb0 100644
--- a/generators/entity-client/templates/react/src/main/webapp/app/entities/entity-detail.tsx.ejs
+++ b/generators/entity-client/templates/react/src/main/webapp/app/entities/entity-detail.tsx.ejs
@@ -167,11 +167,11 @@ export class <%= entityReactName %>Detail extends React.Component<I<%= entityRea
               <%_ } _%>
             <%_ } _%>
             </dl>
-          <Button tag={Link} to="/entity/<%= entityFileName %>" replace color="info">
+          <Button tag={Link} to="/<%= entityFileName %>" replace color="info">
             <FontAwesomeIcon icon="arrow-left" /> <span className="d-none d-md-inline" ><Translate contentKey="entity.action.back">Back</Translate></span>
           </Button>&nbsp;
           <%_ if (!readOnly) { _%>
-          <Button tag={Link} to={`/entity/<%= entityFileName %>/${<%=entityInstance %>Entity.id}/edit`} replace color="primary">
+          <Button tag={Link} to={`/<%= entityFileName %>/${<%=entityInstance %>Entity.id}/edit`} replace color="primary">
             <FontAwesomeIcon icon="pencil-alt" /> <span className="d-none d-md-inline"><Translate contentKey="entity.action.edit">Edit</Translate></span>
           </Button>
           <%_ } _%>
diff --git a/generators/entity-client/templates/react/src/main/webapp/app/entities/entity-update.tsx.ejs b/generators/entity-client/templates/react/src/main/webapp/app/entities/entity-update.tsx.ejs
index 7c469ee774..fb2fb55f42 100644
--- a/generators/entity-client/templates/react/src/main/webapp/app/entities/entity-update.tsx.ejs
+++ b/generators/entity-client/templates/react/src/main/webapp/app/entities/entity-update.tsx.ejs
@@ -209,7 +209,7 @@ export class <%= entityReactName %>Update extends React.Component<I<%= entityRea
   }
 
   handleClose = () => {
-    this.props.history.push('/entity/<%= entityFileName %>');
+    this.props.history.push('/<%= entityFileName %>');
   }
 
   render() {
@@ -570,7 +570,7 @@ export class <%= entityReactName %>Update extends React.Component<I<%= entityRea
             </AvGroup>
             <%_ } _%>
           <%_ }) _%>
-            <Button tag={Link} id="cancel-save" to="/entity/<%= entityFileName %>" replace color="info">
+            <Button tag={Link} id="cancel-save" to="/<%= entityFileName %>" replace color="info">
               <FontAwesomeIcon icon="arrow-left" />&nbsp;
               <span className="d-none d-md-inline" ><Translate contentKey="entity.action.back">Back</Translate></span>
             </Button>


Test patch:
diff --git a/generators/client/templates/react/src/test/javascript/e2e/page-objects/navbar-page.ts.ejs b/generators/client/templates/react/src/test/javascript/e2e/page-objects/navbar-page.ts.ejs
index 096df45ca4..d9a693bdad 100644
--- a/generators/client/templates/react/src/test/javascript/e2e/page-objects/navbar-page.ts.ejs
+++ b/generators/client/templates/react/src/test/javascript/e2e/page-objects/navbar-page.ts.ejs
@@ -84,7 +84,7 @@ export default class NavBarPage extends BasePage {
   }
 
   async clickOnEntity(entityName: string) {
-    await this.selector.$(`.dropdown-item[href="/entity/${entityName}"]`).click();
+    await this.selector.$(`.dropdown-item[href="/${entityName}"]`).click();
   }
 
   async autoSignIn() {
diff --git a/test/needle-api/needle-client-react.spec.js b/test/needle-api/needle-client-react.spec.js
index b5ebc336a7..2cb66bd328 100644
--- a/test/needle-api/needle-client-react.spec.js
+++ b/test/needle-api/needle-client-react.spec.js
@@ -92,7 +92,7 @@ describe('needle API React: JHipster client generator with blueprint', () => {
     it('Assert entity is added to menu', () => {
         assert.fileContent(
             `${CLIENT_MAIN_SRC_DIR}app/shared/layout/menus/entities.tsx`,
-            '<MenuItem icon="asterisk" to="/entity/routerName">\n      Router Name\n    </MenuItem>'
+            '<MenuItem icon="asterisk" to="/routerName">\n      Router Name\n    </MenuItem>'
         );
     });
 
@@ -101,7 +101,7 @@ describe('needle API React: JHipster client generator with blueprint', () => {
         const indexReducerPath = `${CLIENT_MAIN_SRC_DIR}app/shared/reducers/index.ts`;
 
         assert.fileContent(indexModulePath, "import entityName from './entityFolderName';");
-        assert.fileContent(indexModulePath, '<ErrorBoundaryRoute path={`${match.url}/entityFileName`} component={entityName} />'); // eslint-disable-line
+        assert.fileContent(indexModulePath, '<ErrorBoundaryRoute path={`${match.url}entityFileName`} component={entityName} />'); // eslint-disable-line
 
         assert.fileContent(
             indexReducerPath,