Skip to content

Commit

Permalink
connect private service projects to private nav (#1250)
Browse files Browse the repository at this point in the history
  • Loading branch information
horlah authored Dec 23, 2022
1 parent d44f86b commit 88e792a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export class CreateProjectComponent implements OnInit {
this.isCreatingProject = false;
this.projectForm.reset();
this.privateService.activeProjectDetails = response.data.group;
this.privateService.getProjects();
this.apiKey = response.data.api_key.key;
this.projectDetails = response.data.project;
if (projectFormModal) projectFormModal.style.overflowY = 'hidden';
Expand Down
5 changes: 2 additions & 3 deletions web/ui/dashboard/src/app/private/private.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

<nav class="ml-130px desktop:ml-20px transition-all duration-200">
<ul class="flex items-center">
<li *ngIf="!organisations?.length || !projects?.length">
<li *ngIf="!organisations?.length || !privateService.projects?.length">
<a routerLink="/get-started" routerLinkActive="bg-primary-500 text-primary-100 font-medium" class="py-8px px-16px mr-32px rounded-4px text-14 transition-all duration-200">Get Started</a>
</li>
<li *ngIf="organisations?.length && projects?.length">
<li *ngIf="organisations?.length && privateService.projects?.length">
<a routerLink="/projects" routerLinkActive="bg-primary-500 text-primary-100 font-medium" class="py-8px px-16px mr-32px rounded-4px text-14 transition-all duration-200">Projects</a>
</li>
<li *ngIf="organisations?.length">
Expand Down Expand Up @@ -62,7 +62,6 @@
</ul>
</div>


<div convoy-dropdown size="lg" #accountDropdown>
<button dropdownTrigger convoy-button color="grey" texture="light" size="sm" class="bg-grey-10 py-12px px-20px rounded-8px h-36px">
<img src="/assets/img/nav-bar-more-primary.svg" alt="more icon" />
Expand Down
9 changes: 3 additions & 6 deletions web/ui/dashboard/src/app/private/private.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { GROUP } from '../models/group.model';
import { ORGANIZATION_DATA } from '../models/organisation.model';
import { GeneralService } from '../services/general/general.service';
import { PrivateService } from './private.service';
Expand All @@ -20,12 +19,11 @@ export class PrivateComponent implements OnInit {
showVerifyEmailModal = false;
isEmailVerified = true;
apiURL = this.generalService.apiURL();
projects?: GROUP[];
organisations?: ORGANIZATION_DATA[];
userOrganization?: ORGANIZATION_DATA;
convoyVersion: string = '';

constructor(private generalService: GeneralService, private router: Router, private privateService: PrivateService) {}
constructor(private generalService: GeneralService, private router: Router, public privateService: PrivateService) {}

async ngOnInit() {
await Promise.all([this.getConfiguration(), this.getUserDetails(), this.getOrganizations()]);
Expand Down Expand Up @@ -66,8 +64,7 @@ export class PrivateComponent implements OnInit {
async getProjects() {
try {
const projectsResponse = await this.privateService.getProjects();
this.projects = projectsResponse.data;
if (this.projects?.length === 0) return this.router.navigateByUrl('/get-started');
if (projectsResponse.data?.length === 0) return this.router.navigateByUrl('/get-started');
return;
} catch (error) {
return error;
Expand Down
6 changes: 4 additions & 2 deletions web/ui/dashboard/src/app/private/private.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class PrivateService {
activeProjectDetails?: GROUP;
organisationDetails!: ORGANIZATION_DATA;
apiFlagResponse!: FLIPT_API_RESPONSE;
projects: GROUP[] = [];

constructor(private http: HttpService, private router: Router) {}

Expand Down Expand Up @@ -189,12 +190,13 @@ export class PrivateService {
getProjects(): Promise<HTTP_RESPONSE> {
return new Promise(async (resolve, reject) => {
try {
const groupsResponse = await this.http.request({
const projectsResponse = await this.http.request({
url: `${this.urlFactory('org')}/projects`,
method: 'get'
});

return resolve(groupsResponse);
this.projects = projectsResponse.data;
return resolve(projectsResponse);
} catch (error) {
return reject(error);
}
Expand Down

0 comments on commit 88e792a

Please sign in to comment.