Skip to content

Commit

Permalink
fix: fixed consistency of idpUrls among all idpUrls .filter
Browse files Browse the repository at this point in the history
  • Loading branch information
urz9999 committed Apr 29, 2021
1 parent 5f7a988 commit 2472f83
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ export class AppComponent implements OnInit {
if (session.account.type === AccountType.AWS || session.account.type === AccountType.AWS_TRUSTER) {
if (session.account.parent === undefined) {
if (session.account.idpUrl === '' || session.account.idpUrl === null || session.account.idpUrl === undefined) {
session.account.idpUrl = workspace.idpUrl[0].id; // We force the first
session.account.idpUrl = workspace.idpUrl.filter(u => (u !== null && u !== undefined))[0].id; // We force the first
} else {
const found = workspace.idpUrl.filter(u => u.url === session.account.idpUrl)[0];
const found = workspace.idpUrl.filter(u => u && u.url === session.account.idpUrl)[0];
if (found) {
session.account.idpUrl = found.id;
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/federated-account.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class FederatedAccountService extends NativeService {

console.log('idpurl in workspace', workspace.idpUrl);

if (workspace.idpUrl.findIndex(i => i.id === idpUrl.id) === -1) {
if (workspace.idpUrl.findIndex(i => i && i.id === idpUrl.id) === -1) {
workspace.idpUrl.push(idpUrl);
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/services/workspace.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ export class WorkspaceService extends NativeService {
const workspace = this.configurationService.getDefaultWorkspaceSync();
let idpUrl;
if (session.account.parent === undefined) {
idpUrl = workspace.idpUrl.filter(u => u.id === session.account.idpUrl)[0].url;
idpUrl = workspace.idpUrl.filter(u => u && u.id === session.account.idpUrl)[0].url;
} else {
const parentSession = this.sessionService.getSession(session.account.parent);
idpUrl = workspace.idpUrl.filter(u => u.id === parentSession.account.idpUrl)[0].url;
idpUrl = workspace.idpUrl.filter(u => u && u.id === parentSession.account.idpUrl)[0].url;
}

// TODO: probably here will need to clean the partition area to force a windows refresh
Expand Down
2 changes: 2 additions & 0 deletions src/app/shared/profile-page/profile-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,15 @@ <h2 style="margin-top: 10px;">IdP URL list</h2>
</thead>
<tbody>
<ng-container *ngFor="let idpUrl of workspaceData.idpUrl">
<ng-container *ngIf="idpUrl">
<tr>
<td>{{idpUrl.url}}</td>
<td>
<button class="xs-btn" type="button" (click)="editIdpUrl(idpUrl.id);"><i class="fa fa-edit"></i></button>
<button class="xs-btn" type="button" (click)="deleteIdpUrl(idpUrl.id);"><i class="fa fa-trash"></i></button>
</td>
</tr>
</ng-container>
</ng-container>
</tbody>
</table>
Expand Down
6 changes: 3 additions & 3 deletions src/app/shared/profile-page/profile-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export class ProfilePageComponent extends AntiMemLeak implements OnInit {
}

manageIdpUrl(id) {
const idpUrl = this.workspaceData.idpUrl.findIndex(u => u.id === id);
const idpUrl = this.workspaceData.idpUrl.findIndex(u => u && u.id === id);
if (this.form.get('idpUrl').value !== '') {
if (idpUrl === -1) {
this.workspaceData.idpUrl.push({ id: uuid.v4(), url: this.form.get('idpUrl').value });
Expand All @@ -168,7 +168,7 @@ export class ProfilePageComponent extends AntiMemLeak implements OnInit {
}

editIdpUrl(id) {
const idpUrl = this.workspaceData.idpUrl.filter(u => u.id === id)[0];
const idpUrl = this.workspaceData.idpUrl.filter(u => u && u.id === id)[0];
this.idpUrlValue = idpUrl;
this.form.get('idpUrl').setValue(idpUrl.url);
this.editingIdpUrl = true;
Expand Down Expand Up @@ -197,7 +197,7 @@ export class ProfilePageComponent extends AntiMemLeak implements OnInit {
this.appService.confirmDialog(`Deleting this Idp url will also remove these sessions: <br><ul>${sessionsNames.join('')}</ul>Do you want to proceed?`, (res) => {
if (res !== constants.CONFIRM_CLOSED) {
this.appService.logger(`Removing idp url with id: ${id}`, LoggerLevel.INFO, this);
const idpUrl = this.workspaceData.idpUrl.findIndex(u => u.id === id);
const idpUrl = this.workspaceData.idpUrl.findIndex(u => u && u.id === id);
this.workspaceData.idpUrl.splice(idpUrl, 1);
this.configurationService.updateWorkspaceSync(this.workspaceData);
sessions.forEach(s => {
Expand Down

0 comments on commit 2472f83

Please sign in to comment.