Skip to content

Commit 1fd97c1

Browse files
feat:temporary Github deployment
Signed-off-by: Amol Sontakke <[email protected]>
1 parent 9e3475f commit 1fd97c1

File tree

4 files changed

+44
-33
lines changed

4 files changed

+44
-33
lines changed

src/app/core/services/cla-contributor.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {Injectable, isDevMode} from '@angular/core';
55
import {HttpClient} from '@angular/common/http';
66
import {Observable, Subject} from 'rxjs';
77
import {Project, ProjectModel} from '../models/project';
8-
import {UpdateUserModel, UserFromSessionModel, UserFromTokenModel, UserModel} from '../models/user';
8+
import {UpdateUserModel, UserFromTokenModel, UserModel} from '../models/user';
99
import {AlertService} from 'src/app/shared/services/alert.service';
1010
import {ActiveSignatureModel} from '../models/active-signature';
1111
import {IndividualRequestSignatureModel} from '../models/individual-request-signature';
@@ -60,9 +60,9 @@ export class ClaContributorService {
6060
return this.httpClient.get<UserFromTokenModel>(url);
6161
}
6262

63-
getUserFromSession(): Observable<UserFromSessionModel> {
63+
getUserFromSession(): Observable<any> {
6464
const url = this.getV2Endpoint('/v2/user-from-session');
65-
return this.httpClient.get<UserFromSessionModel>(url);
65+
return this.httpClient.get<any>(url);
6666
}
6767

6868
updateUser(data: any): Observable<UpdateUserModel> {

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: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ export class ClaDashboardComponent implements OnInit {
6161
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.');
6262
return false;
6363
}
64-
if (!this.hasError) {
64+
if (!this.hasError && this.userId) {
6565
const url = '/corporate-dashboard/' + this.projectId + '/' + this.userId;
6666
this.router.navigate([url]);
67+
}else {
68+
this.alertService.error('Unable to fetch user ID.');
6769
}
6870
}
6971

@@ -72,12 +74,18 @@ export class ClaDashboardComponent implements OnInit {
7274
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.');
7375
return false;
7476
}
75-
if (!this.hasError) {
77+
if (!this.hasError && this.userId) {
7678
const url = '/individual-dashboard/' + this.projectId + '/' + this.userId;
7779
this.router.navigate([url]);
80+
}else {
81+
this.alertService.error('Unable to fetch user ID.');
7882
}
7983
}
8084

85+
setUserId(userId: string) {
86+
this.userId = userId;
87+
}
88+
8189
onAPILoad(APIType: string) {
8290
if (APIType === 'Project') {
8391
this.project = JSON.parse(this.storageService.getItem(AppSettings.PROJECT));

src/app/shared/components/project-title/project-title.component.ts

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,39 @@
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, OnInit, Input, EventEmitter, Output, ViewChild, TemplateRef } 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 } 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';
1112

1213
@Component({
1314
selector: 'app-project-title',
1415
templateUrl: './project-title.component.html',
1516
styleUrls: ['./project-title.component.scss']
1617
})
1718
export class ProjectTitleComponent implements OnInit {
19+
@ViewChild('warningModal') warningModal: TemplateRef<any>;
20+
1821
@Input() projectId: string;
1922
@Input() userId: string;
2023
@Output() errorEmitter: EventEmitter<any> = new EventEmitter<any>();
2124
@Output() successEmitter: EventEmitter<any> = new EventEmitter<any>();
25+
@Output() setUserIdEmitter: EventEmitter<any> = new EventEmitter<any>();
2226

27+
message: string;
28+
redirectUrl: string;
2329
project = new ProjectModel();
2430
user = new UserFromTokenModel();
2531
userFromSession = new UserFromSessionModel();
2632
constructor(
2733
private alertService: AlertService,
2834
private storageService: StorageService,
2935
private claContributorService: ClaContributorService,
36+
private modalService: NgbModal
3037
) { }
3138

3239
ngOnInit(): void {
@@ -49,34 +56,32 @@ export class ProjectTitleComponent implements OnInit {
4956
}
5057

5158
getProject() {
52-
if (this.projectId) {
53-
this.claContributorService.getProject(this.projectId).subscribe(
54-
(response) => {
55-
this.project = response;
56-
this.storageService.setItem(AppSettings.PROJECT_NAME, this.project.project_name);
57-
this.storageService.setItem(AppSettings.PROJECT_ID, this.projectId);
58-
this.storageService.setItem(AppSettings.PROJECT, this.project);
59-
this.successEmitter.emit('Project');
60-
},
61-
(exception) => {
62-
this.errorEmitter.emit(true);
63-
this.claContributorService.handleError(exception);
64-
}
65-
);
66-
} else {
67-
this.errorEmitter.emit(true);
68-
this.alertService.error('Invalid project id in URL');
69-
}
59+
console.log(this.projectId)
60+
this.claContributorService.getProject(this.projectId).subscribe(
61+
(response) => {
62+
this.project = response;
63+
this.storageService.setItem(AppSettings.PROJECT_NAME, this.project.project_name);
64+
this.storageService.setItem(AppSettings.PROJECT_ID, this.projectId);
65+
this.storageService.setItem(AppSettings.PROJECT, this.project);
66+
this.successEmitter.emit('Project');
67+
},
68+
(exception) => {
69+
this.errorEmitter.emit(true);
70+
this.claContributorService.handleError(exception);
71+
}
72+
);
7073
}
7174

7275

7376
getUser() {
7477
this.claContributorService.getUserFromToken().subscribe(
7578
(response) => {
79+
console.log('getUserFromToken response ==>', response)
7680
this.user = response;
7781
this.storageService.setItem(AppSettings.USER_ID, this.user.userID);
7882
this.storageService.setItem(AppSettings.USER, this.user);
7983
this.successEmitter.emit('User');
84+
this.setUserIdEmitter.emit(this.user.userID);
8085
},
8186
() => {
8287
// If user is not found in token, get user from session
@@ -87,8 +92,8 @@ export class ProjectTitleComponent implements OnInit {
8792

8893
getUserFromSession() {
8994
this.claContributorService.getUserFromSession().subscribe(
90-
(response) => {
91-
console.log(response)
95+
(response: any) => {
96+
console.log('getUserFromSession response ==>', response)
9297
this.userFromSession = response;
9398
this.storageService.setItem(AppSettings.USER_ID, this.userFromSession.user_id);
9499
this.storageService.setItem(AppSettings.USER, {
@@ -104,11 +109,9 @@ export class ProjectTitleComponent implements OnInit {
104109
this.successEmitter.emit('User');
105110
},
106111
(exception) => {
107-
console.log(exception)
108-
// window.open('https://github.com/login/oauth/authorize?response_type=code&client_id=38f6d46ff92b7ed04071&redirect_uri=https%3A%2F%2Fapi.lfcla.dev.platform.linuxfoundation.org%2Fv2%2Fgithub%2Finstallation&scope=user%3Aemail&state=4CSOmSBNwx8Oi5liEEi5wEyKy3IkWQ', '_self');
112+
console.log('getUserFromSession exception ==>', exception)
109113
this.errorEmitter.emit(true);
110-
// this.alertService.error('An error occurred while retrieving the GitHub user from the session. '+
111-
// 'To use this feature, you must be logged in to your GitHub account and your browser must be set to accept cookies.');
114+
this.alertService.error('An error occurred while retrieving the GitHub user from the session.');
112115
this.claContributorService.handleError(exception);
113116
}
114117
);

0 commit comments

Comments
 (0)