11import { service } from '@ember/service' ;
22import Component from '@glimmer/component' ;
33import { dropTask } from 'ember-concurrency' ;
4- import { scheduleTask } from 'ember-lifeline' ;
54import { tracked } from 'tracked-built-ins' ;
65
76import { emptyChangeset } from 'outdated/utils' ;
@@ -10,7 +9,6 @@ import ProjectValidations from 'outdated/validations/project';
109export default class ProjectFormComponent extends Component {
1110 @service store ;
1211 @service router ;
13- @tracked maintainers ;
1412
1513 @service notification ;
1614
@@ -19,51 +17,23 @@ export default class ProjectFormComponent extends Component {
1917 this . args . project ?? this . store . createRecord ( 'project' ) ,
2018 ) ;
2119
22- constructor ( ...args ) {
23- super ( ...args ) ;
24- if ( this . args . project ) {
25- scheduleTask ( this , 'actions' , ( ) => {
26- this . maintainers = this . project . maintainers ;
27- this . project . users = this . project . maintainers . map ( ( m ) => m . user ) ;
28- this . project . primaryMaintainer = this . maintainers ?. find (
29- ( m ) => m . isPrimary ,
30- ) ?. user ;
31- } ) ;
32- }
33- }
34-
3520 saveProject = dropTask ( async ( ) => {
3621 try {
3722 if ( this . project . repoType === 'public' ) {
3823 this . project . accessToken = '' ;
3924 }
4025
26+ document
27+ . querySelectorAll ( '[data-source-form-submit-button]' )
28+ . forEach ( ( e ) => e . click ( ) ) ;
29+
4130 const project = await this . project . save ( {
4231 adapterOptions : {
4332 include :
44- 'versionedDependencies,versionedDependencies.releaseVersion,versionedDependencies.releaseVersion. dependency,maintainers,maintainers.user' ,
33+ 'sources,sources.versions,sources.versions.release-version,sources.versions.release-version. dependency,sources. maintainers,sources. maintainers.user' ,
4534 } ,
4635 } ) ;
4736
48- this . maintainers
49- ?. filter ( ( m ) => ! this . project . users ?. includes ( m . user ) )
50- . forEach ( ( m ) => m . destroyRecord ( ) ) ;
51- this . project . users ?. forEach ( ( user ) => {
52- const maintainer = this . maintainers ?. find ( ( m ) => m . user . id === user . id ) ;
53- if ( maintainer ) {
54- maintainer . isPrimary = user . id === this . primaryMaintainer . id ;
55- if ( maintainer . hasDirtyAttributes ) maintainer . save ( ) ;
56- } else {
57- this . store
58- . createRecord ( 'maintainer' , {
59- user,
60- project,
61- isPrimary : user === this . primaryMaintainer ,
62- } )
63- . save ( ) ;
64- }
65- } ) ;
66-
6737 this . router . transitionTo ( 'projects.detailed' , project . id ) ;
6838 this . project . accessToken = '' ;
6939 this . notification . success ( 'Successfully saved!' ) ;
@@ -73,19 +43,11 @@ export default class ProjectFormComponent extends Component {
7343 }
7444 } ) ;
7545
76- get primaryMaintainer ( ) {
77- return (
78- this . project . users ?. find (
79- ( u ) => u . id === this . project . primaryMaintainer ?. id ,
80- ) ?? this . project . users [ 0 ]
81- ) ;
46+ get repoTypes ( ) {
47+ return [ 'public' , 'access-token' ] ;
8248 }
8349
8450 get users ( ) {
8551 return this . store . peekAll ( 'user' ) ;
8652 }
87-
88- get repoTypes ( ) {
89- return [ 'public' , 'access-token' ] ;
90- }
9153}
0 commit comments