Skip to content

Commit 9eeba56

Browse files
reverted old flow
Signed-off-by: Amol Sontakke <[email protected]>
2 parents 8792bc7 + a2b1561 commit 9eeba56

File tree

5 files changed

+81
-75
lines changed

5 files changed

+81
-75
lines changed

src/app/app.component.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// SPDX-License-Identifier: MIT
33

44
import { Component } from '@angular/core';
5-
import { LfxHeaderService } from './shared/services/lfx-header.service';
65
import { environment } from 'src/environments/environment';
76

87
@Component({
@@ -15,8 +14,6 @@ export class AppComponent {
1514
hasExpanded: boolean;
1615
links: any[];
1716

18-
constructor(private lfxHeaderService: LfxHeaderService) {}
19-
2017
onToggled() {
2118
this.hasExpanded = !this.hasExpanded;
2219
}

src/app/core/models/user.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,6 @@ export class UserModel {
1919
version: string;
2020
}
2121

22-
23-
export class UpdateUserModel {
24-
companyID: string;
25-
dateCreated: Date;
26-
dateModified: Date;
27-
emails?: any;
28-
githubID: string;
29-
githubUsername: string;
30-
lfEmail: string;
31-
lfUsername: string;
32-
userID: string;
33-
username: string;
34-
version: string;
35-
}
36-
3722
export class UserFromTokenModel {
3823
dateCreated: string
3924
dateModified: string
@@ -63,4 +48,18 @@ export class UserFromTokenModel {
6348
user_ldap_id: any
6449
user_name: string
6550
version: string
66-
}
51+
}
52+
53+
export class UpdateUserModel {
54+
companyID: string;
55+
dateCreated: Date;
56+
dateModified: Date;
57+
emails?: any;
58+
githubID: string;
59+
githubUsername: string;
60+
lfEmail: string;
61+
lfUsername: string;
62+
userID: string;
63+
username: string;
64+
version: string;
65+
}

src/app/modules/dashboard/container/cla-dashboard/cla-dashboard.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- Copyright The Linux Foundation and each contributor to CommunityBridge.
22
SPDX-License-Identifier: MIT -->
33

4-
<app-project-title [projectId]="projectId" [userId]="userId" (successEmitter)="onAPILoad($event)"
4+
<app-project-title [projectId]="projectId" [userId]="userId" (successEmitter)="onAPILoad($event)" (setUserIdEmitter)="setUserId($event)"
55
(errorEmitter)="hasErrorPresent($event)"></app-project-title>
66

77
<div class="container-fluid dashboard-container">
@@ -55,15 +55,15 @@
5555
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
5656
<ng-container>
5757
<app-dashboard-contributor-buttons [type]="corporateContributor"
58-
[hasEnabled]="project.project_ccla_enabled"
58+
[hasEnabled]="project.project_ccla_enabled && !hasError"
5959
(proceedBtnEmitter)="onClickCorporateProceed()">
6060
</app-dashboard-contributor-buttons>
6161
</ng-container>
6262
</div>
6363
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
6464
<ng-container>
6565
<app-dashboard-contributor-buttons [type]="individualContributor"
66-
[hasEnabled]="project.project_icla_enabled"
66+
[hasEnabled]="project.project_icla_enabled && !hasError"
6767
(proceedBtnEmitter)="onClickIndividualProceed()">
6868
</app-dashboard-contributor-buttons>
6969
</ng-container>

src/app/modules/dashboard/container/cla-dashboard/cla-dashboard.component.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export class ClaDashboardComponent implements OnInit {
3838
this.userId = this.route.snapshot.paramMap.get('userId');
3939
const redirect = this.route.snapshot.queryParamMap.get('redirect');
4040
this.storageService.setItem(AppSettings.REDIRECT, redirect);
41+
console.log('projectId'+this.projectId)
42+
console.log('userId'+this.userId)
4143
this.hasErrorPresent();
4244
}
4345

@@ -61,9 +63,11 @@ export class ClaDashboardComponent implements OnInit {
6163
this.alertService.error('The Corporate CLA option is not enabled for this project. Please contact to your administrator to enable the Corporate CLA option for this project.');
6264
return false;
6365
}
64-
if (!this.hasError) {
66+
if (!this.hasError && this.userId) {
6567
const url = '/corporate-dashboard/' + this.projectId + '/' + this.userId;
6668
this.router.navigate([url]);
69+
}else {
70+
this.alertService.error('Unable to fetch user ID.');
6771
}
6872
}
6973

@@ -72,12 +76,18 @@ export class ClaDashboardComponent implements OnInit {
7276
this.alertService.error('The Individual CLA option is not enabled for this project. Please to your administrator to enable the Individual CLA option for this project.');
7377
return false;
7478
}
75-
if (!this.hasError) {
79+
if (!this.hasError && this.userId) {
7680
const url = '/individual-dashboard/' + this.projectId + '/' + this.userId;
7781
this.router.navigate([url]);
82+
}else {
83+
this.alertService.error('Unable to fetch user ID.');
7884
}
7985
}
8086

87+
setUserId(userId: string) {
88+
this.userId = userId;
89+
}
90+
8191
onAPILoad(APIType: string) {
8292
if (APIType === 'Project') {
8393
this.project = JSON.parse(this.storageService.getItem(AppSettings.PROJECT));
Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
11
// Copyright The Linux Foundation and each contributor to CommunityBridge.
22
// SPDX-License-Identifier: MIT
33

4-
import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core';
4+
import { Component, Input, EventEmitter, Output, ViewChild, TemplateRef, OnInit } from '@angular/core';
55
import { AlertService } from '../../services/alert.service';
66
import { ClaContributorService } from 'src/app/core/services/cla-contributor.service';
77
import { ProjectModel } from 'src/app/core/models/project';
88
import { UserFromSessionModel, UserFromTokenModel, UserModel } from 'src/app/core/models/user';
99
import { StorageService } from '../../services/storage.service';
1010
import { AppSettings } from 'src/app/config/app-settings';
11+
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
12+
import { Router } from '@angular/router';
1113

1214
@Component({
1315
selector: 'app-project-title',
1416
templateUrl: './project-title.component.html',
1517
styleUrls: ['./project-title.component.scss']
1618
})
1719
export class ProjectTitleComponent implements OnInit {
20+
@ViewChild('warningModal') warningModal: TemplateRef<any>;
21+
1822
@Input() projectId: string;
1923
@Input() userId: string;
2024
@Output() errorEmitter: EventEmitter<any> = new EventEmitter<any>();
2125
@Output() successEmitter: EventEmitter<any> = new EventEmitter<any>();
2226
@Output() setUserIdEmitter: EventEmitter<any> = new EventEmitter<any>();
2327

28+
message: string;
29+
redirectUrl: string;
2430
project = new ProjectModel();
2531
userFromToken = new UserFromTokenModel();
2632
user = new UserModel();
@@ -29,7 +35,10 @@ export class ProjectTitleComponent implements OnInit {
2935
private alertService: AlertService,
3036
private storageService: StorageService,
3137
private claContributorService: ClaContributorService,
32-
) { }
38+
private router: Router
39+
) {
40+
41+
}
3342

3443
ngOnInit(): void {
3544
const hasGerrit = JSON.parse(this.storageService.getItem(AppSettings.HAS_GERRIT));
@@ -41,38 +50,32 @@ export class ProjectTitleComponent implements OnInit {
4150
}
4251

4352
validateGithubFlow() {
53+
console.log('validateGithubFlow'+this.projectId)
4454
if (this.projectId ) {
4555
this.getProject();
4656
if (this.userId) {
57+
// get user from user id
4758
this.getUser();
4859
} else {
60+
// get user from token if user id is not present in url
4961
this.getUserFromToken();
5062
}
5163
} else {
5264
this.errorEmitter.emit(true);
53-
this.alertService.error('Invalid project id and user id in URL');
65+
this.alertService.error('Invalid project id in URL');
5466
}
5567
}
5668

5769
getProject() {
58-
if (this.projectId) {
59-
this.claContributorService.getProject(this.projectId).subscribe(
60-
(response) => {
61-
this.project = response;
62-
this.storageService.setItem(AppSettings.PROJECT_NAME, this.project.project_name);
63-
this.storageService.setItem(AppSettings.PROJECT_ID, this.projectId);
64-
this.storageService.setItem(AppSettings.PROJECT, this.project);
65-
this.successEmitter.emit('Project');
66-
},
67-
(exception) => {
68-
this.errorEmitter.emit(true);
69-
this.claContributorService.handleError(exception);
70-
}
71-
);
72-
} else {
73-
this.errorEmitter.emit(true);
74-
this.alertService.error('Invalid project id in URL');
75-
}
70+
this.claContributorService.getProject(this.projectId).subscribe(
71+
(response) => {
72+
this.project = response;
73+
this.storageService.setItem(AppSettings.PROJECT_NAME, this.project.project_name);
74+
this.storageService.setItem(AppSettings.PROJECT_ID, this.projectId);
75+
this.storageService.setItem(AppSettings.PROJECT, this.project);
76+
this.successEmitter.emit('Project');
77+
}
78+
);
7679
}
7780

7881
getUser() {
@@ -105,6 +108,7 @@ export class ProjectTitleComponent implements OnInit {
105108
this.storageService.setItem(AppSettings.USER, this.userFromToken);
106109
this.successEmitter.emit('User');
107110
this.setUserIdEmitter.emit(this.userFromToken.userID);
111+
this.router.navigate(['/cla/project/' + this.projectId + '/user/' + this.userFromToken.userID]);
108112
},
109113
() => {
110114
// If user is not found in token, get user from session
@@ -113,34 +117,30 @@ export class ProjectTitleComponent implements OnInit {
113117
);
114118
}
115119

116-
getUserFromSession() {
117-
this.claContributorService.getUserFromSession().subscribe(
118-
(response: any) => {
119-
console.log('getUserFromSession response ==>', response)
120-
this.userFromSession = response;
121-
this.storageService.setItem(AppSettings.USER_ID, this.userFromSession.user_id);
122-
this.storageService.setItem(AppSettings.USER, {
123-
dateCreated: this.userFromSession.date_created,
124-
dateModified: this.userFromSession.date_modified,
125-
emails: this.userFromSession.user_emails,
126-
lfEmail: this.userFromSession.lf_email,
127-
lfUsername: this.userFromSession.lf_username,
128-
userID: this.userFromSession.user_id,
129-
username: this.userFromSession.user_name,
130-
version: this.userFromSession.version
131-
});
132-
this.successEmitter.emit('User');
133-
},
134-
(exception) => {
135-
console.log('getUserFromSession exception ==>', exception)
136-
this.errorEmitter.emit(true);
137-
this.alertService.error('An error occurred while retrieving the GitHub user from the session.');
138-
this.claContributorService.handleError(exception);
139-
}
140-
);
141-
}
142-
143-
144-
145-
120+
getUserFromSession() {
121+
this.claContributorService.getUserFromSession().subscribe(
122+
(response: any) => {
123+
console.log('getUserFromSession response ==>', response)
124+
this.userFromSession = response;
125+
this.storageService.setItem(AppSettings.USER_ID, this.userFromSession.user_id);
126+
this.storageService.setItem(AppSettings.USER, {
127+
dateCreated: this.userFromSession.date_created,
128+
dateModified: this.userFromSession.date_modified,
129+
emails: this.userFromSession.user_emails,
130+
lfEmail: this.userFromSession.lf_email,
131+
lfUsername: this.userFromSession.lf_username,
132+
userID: this.userFromSession.user_id,
133+
username: this.userFromSession.user_name,
134+
version: this.userFromSession.version
135+
});
136+
this.successEmitter.emit('User');
137+
},
138+
(exception) => {
139+
console.log('getUserFromSession exception ==>', exception)
140+
this.errorEmitter.emit(true);
141+
this.alertService.error('An error occurred while retrieving the GitHub user from the session.');
142+
this.claContributorService.handleError(exception);
143+
}
144+
);
145+
}
146146
}

0 commit comments

Comments
 (0)