Skip to content

Commit

Permalink
fix: integration core route resolvers
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul-rocket committed Jul 20, 2024
1 parent fc741b0 commit f92cb2a
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { IntegrationEnum, PermissionsEnum } from '@gauzy/contracts';
import { PermissionsGuard } from '@gauzy/ui-core/core';
import { IntegrationResolver } from '../integration.resolver';
import { IntegrationResolver, PermissionsGuard } from '@gauzy/ui-core/core';
import { GauzyAIAuthorizationComponent } from './components/authorization/authorization.component';
import { GauzyAILayoutComponent } from './gauzy-ai.layout.component';
import { GauzyAIViewComponent } from './components/view/view.component';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { IntegrationEnum } from '@gauzy/contracts';
import { IntegrationResolver } from './../integration.resolver';
import { IntegrationEnum, PermissionsEnum } from '@gauzy/contracts';
import { IntegrationResolver, PermissionsGuard } from '@gauzy/ui-core/core';
import { GithubWizardComponent } from './components/wizard/wizard.component';
import { GithubInstallationComponent } from './components/installation/installation.component';
import { GithubComponent } from './github.component';
Expand All @@ -11,7 +11,12 @@ const routes: Routes = [
{
path: '',
component: GithubComponent,
canActivate: [PermissionsGuard],
data: {
permissions: {
only: [PermissionsEnum.INTEGRATION_ADD],
redirectTo: '/pages/dashboard'
},
integration: IntegrationEnum.GITHUB
},
resolve: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { IntegrationEnum, PermissionsEnum } from '@gauzy/contracts';
import { PermissionsGuard } from '@gauzy/ui-core/core';
import { IntegrationResolver, PermissionsGuard } from '@gauzy/ui-core/core';
import { SearchComponent } from './search/search.component';
import { IntegrationResolver } from '../../integrations/integration.resolver';

const routes: Routes = [
{
Expand Down
3 changes: 1 addition & 2 deletions apps/gauzy/src/app/pages/projects/projects-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { IntegrationEnum, PermissionsEnum } from '@gauzy/contracts';
import { PermissionsGuard } from '@gauzy/ui-core/core';
import { IntegrationResolver, PermissionsGuard } from '@gauzy/ui-core/core';
import { ProjectLayoutComponent } from './layout/layout.component';
import { ProjectResolver } from './project.resolver';
import { ProjectCreateMutationComponent } from './components/project-create/create.component';
import { ProjectEditMutationComponent } from './components/project-edit/edit.component';
import { ProjectListComponent } from './components/project-list/list.component';
import { IntegrationResolver } from '../integrations/integration.resolver';

const routes: Routes = [
{
Expand Down
2 changes: 2 additions & 0 deletions packages/plugins/job-search-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
"@angular/core": "^16.2.12"
},
"dependencies": {
"jest-preset-angular": "^13.1.4",
"tslib": "^2.6.2"
},
"devDependencies": {
"@types/jest": "^29.4.4",
"@types/node": "^20.14.9"
},
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/job-search-ui/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"outDir": "./dist/out-tsc",
"module": "commonjs",
"target": "es2016",
"types": ["jasmine", "jest", "node"]
"types": ["jest", "node"]
},
"files": ["src/test-setup.ts"],
"include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"]
Expand Down
1 change: 1 addition & 0 deletions packages/ui-core/src/lib/core/src/resolvers/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './employee-count.resolver';
export * from './user.resolver';
export * from './onboarding.resolver';
export * from './integration.resolver';
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ActivatedRouteSnapshot, Resolve, Router } from '@angular/router';
import { catchError, EMPTY, Observable, of } from 'rxjs';
import { IIntegrationTenant } from '@gauzy/contracts';
import { Store } from '@gauzy/ui-core/common';
import { IntegrationsService } from '@gauzy/ui-core/core';
import { IntegrationsService } from '../services';

@Injectable({
providedIn: 'root'
Expand All @@ -27,8 +27,11 @@ export class IntegrationResolver implements Resolve<Observable<IIntegrationTenan
*/
resolve(route: ActivatedRouteSnapshot): Observable<IIntegrationTenant | boolean> {
try {
const integration = route.data['integration'];
// Get Integration By Options
const name = route.data['integration'];
const relations = route.data['relations'] || [];

//Get Organization Details
const { id: organizationId, tenantId } = this._store.selectedOrganization;

if (!organizationId) {
Expand All @@ -39,7 +42,7 @@ export class IntegrationResolver implements Resolve<Observable<IIntegrationTenan
const integration$ = this._integrationsService.getIntegrationByOptions({
organizationId,
tenantId,
name: integration,
name,
relations
});

Expand Down

0 comments on commit f92cb2a

Please sign in to comment.