| 2 | import Route from '@ember/routing/route'; |
| 3 | |
| 4 | export default class ClassRoute extends Route { |
| 5 | /** @type {import('@ember/routing/router-service').default} */ |
| 6 | @service |
| 7 | router; |
| 8 | |
| 9 | @service |
| 10 | legacyModuleMappings; |
| 11 | |
| 12 | model(params) { |
| 13 | let ret = { |
| 14 | mappings: this.legacyModuleMappings.buildMappings( |
| 15 | this.legacyModuleMappings.legacyMappings, |
| 16 | ), |
| 17 | className: params['class'].substr(0, params['class'].lastIndexOf('.')), |
| 18 | }; |
| 19 | return ret; |
| 20 | } |
| 21 | |
| 22 | redirect(model) { |
| 23 | let mappedInfo = this.legacyModuleMappings.getNewClassFromOld( |
| 24 | model.className, |
| 25 | model.mappings, |
| 26 | ); |
| 27 | if (!mappedInfo.error && model.className !== mappedInfo.newName) { |
| 28 | let { itemType, newName, newModule } = mappedInfo; |
| 29 | if (itemType === 'class') { |
| 30 | return this.router.transitionTo( |
| 31 | `project-version.classes.class`, |
| 32 | 'ember', |
| 33 | 'release', |
| 34 | newName, |
| 35 | ); |
| 36 | } else { |
| 37 | return this.router.transitionTo( |
| 38 | `project-version.functions.function`, |
| 39 | 'ember', |
| 40 | 'release', |
| 41 | newModule, |
| 42 | newName, |
| 43 | ); |
| 44 | } |
| 45 | } |
| 46 | return this.router.transitionTo('project-version', 'ember', 'release'); |
| 47 | } |
| 48 | } |
nothing calls this directly
no outgoing calls
no test coverage detected