1- /* eslint-disable ember/no-computed-properties-in-native-classes */
2- import { action , computed , set } from '@ember/object' ;
1+ import { action } from '@ember/object' ;
32import { service } from '@ember/service' ;
4- import { readOnly , alias } from '@ember/object/computed' ;
53import Controller from '@ember/controller' ;
6- import { A } from '@ember/array' ;
74import values from 'lodash.values' ;
85import groupBy from 'lodash.groupby' ;
96import semverCompare from 'semver-compare' ;
@@ -25,35 +22,30 @@ export default class ProjectVersionController extends Controller {
2522 @service router ;
2623 @service ( 'project' ) projectService ;
2724
28- @alias ( 'filterData.sideNav.showPrivate' )
29- showPrivateClasses ;
25+ get showPrivateClasses ( ) {
26+ return this . filterData . showPrivateClasses ;
27+ }
3028
31- @computed ( 'model' )
3229 get classesIDs ( ) {
3330 return this . getRelationshipIDs ( 'classes' ) ;
3431 }
3532
36- @computed ( 'model' )
3733 get publicClassesIDs ( ) {
3834 return this . getRelationshipIDs ( 'public-classes' ) ;
3935 }
4036
41- @computed ( 'model' )
4237 get namespaceIDs ( ) {
4338 return this . getRelationshipIDs ( 'namespaces' ) ;
4439 }
4540
46- @computed ( 'model' )
4741 get publicNamespaceIDs ( ) {
4842 return this . getRelationshipIDs ( 'public-namespaces' ) ;
4943 }
5044
51- @computed ( 'model.id' )
5245 get moduleIDs ( ) {
5346 return this . getModuleRelationships ( this . model . id , 'modules' ) ;
5447 }
5548
56- @computed ( 'model.id' )
5749 get publicModuleIDs ( ) {
5850 return this . getModuleRelationships ( this . model . id , 'public-modules' ) ;
5951 }
@@ -73,30 +65,25 @@ export default class ProjectVersionController extends Controller {
7365 getRelationshipIDs ( relationship ) {
7466 const projectId = this . model . project . id ;
7567 const classes = this . model . hasMany ( relationship ) ;
76- const sorted = A ( classes . ids ( ) ) . sort ( ) ;
68+ const sorted = Array . from ( classes . ids ( ) ) . sort ( ) ;
7769 //ids come in as ember-2.16.0-@ember/object/promise-proxy-mixin or ember-4.12.0-alpha.23-@ember/object/promise-proxy-mixin
7870 //so we remove the project name and version (including pre-release) to get the class name
79- return A ( sorted )
80- . toArray ( )
81- . map ( ( id ) => {
82- // Remove project name prefix
83- const withoutProject = id . replace ( `${ projectId } -` , '' ) ;
84- // Remove version (e.g., 2.16.0 or 4.12.0-alpha.23) and the following dash
85- return withoutProject . replace ( / ^ \d + \. \d + \. \d + (?: - [ a - z ] + \. \d + ) ? - / i, '' ) ;
86- } ) ;
71+ return sorted . map ( ( id ) => {
72+ // Remove project name prefix
73+ const withoutProject = id . replace ( `${ projectId } -` , '' ) ;
74+ // Remove version (e.g., 2.16.0 or 4.12.0-alpha.23) and the following dash
75+ return withoutProject . replace ( / ^ \d + \. \d + \. \d + (?: - [ a - z ] + \. \d + ) ? - / i, '' ) ;
76+ } ) ;
8777 }
8878
89- @computed ( 'showPrivateClasses' , 'classesIDs' , 'publicClassesIDs' )
9079 get shownClassesIDs ( ) {
9180 return this . showPrivateClasses ? this . classesIDs : this . publicClassesIDs ;
9281 }
9382
94- @computed ( 'showPrivateClasses' , 'moduleIDs' , 'publicModuleIDs' )
9583 get shownModuleIDs ( ) {
9684 return this . showPrivateClasses ? this . moduleIDs : this . publicModuleIDs ;
9785 }
9886
99- @computed ( 'showPrivateClasses' , 'namespaceIDs' , 'publicNamespaceIDs' )
10087 get shownNamespaceIDs ( ) {
10188 return this . showPrivateClasses
10289 ? this . namespaceIDs
@@ -120,20 +107,21 @@ export default class ProjectVersionController extends Controller {
120107 return values ( groupedVersions ) . map ( ( groupedVersion ) => groupedVersion [ 0 ] ) ;
121108 }
122109
123- @alias ( 'project.urlVersion' )
124- urlVersion ;
110+ get urlVersion ( ) {
111+ return this . projectService . getUrlVersion ( ) ;
112+ }
125113
126- @computed ( 'projectVersions.[]' , 'model.version' )
127114 get selectedProjectVersion ( ) {
128115 return this . projectVersions . filter ( ( pV ) => pV . id === this . model . version ) [ 0 ] ;
129116 }
130117
131- @readOnly ( 'model.project.id' )
132- activeProject ;
118+ get activeProject ( ) {
119+ return this . model . project . id ;
120+ }
133121
134122 @action
135123 togglePrivateClasses ( ) {
136- set ( this , 'showPrivateClasses' , ! this . showPrivateClasses ) ;
124+ this . filterData . togglePrivateClasses ( ) ;
137125 }
138126
139127 @action
0 commit comments