Skip to content

Commit

Permalink
Merge pull request #6985 from ever-co/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
evereq authored Oct 13, 2023
2 parents cfce682 + c9bee0d commit f571215
Show file tree
Hide file tree
Showing 34 changed files with 532 additions and 275 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Subject, of } from 'rxjs';
import { catchError, finalize, map, tap } from 'rxjs/operators';
import { Observable } from 'rxjs/internal/Observable';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { IGithubRepository, IGithubRepositoryResponse, IIntegrationTenant, IOrganization } from '@gauzy/contracts';
import { HttpStatus, IGithubRepository, IGithubRepositoryResponse, IIntegrationTenant, IOrganization } from '@gauzy/contracts';
import { ErrorHandlingService, GithubService, Store } from './../../../../@core/services';

@UntilDestroy({ checkProperties: true })
Expand Down Expand Up @@ -124,6 +124,11 @@ export class RepositorySelectorComponent implements AfterViewInit, OnInit, OnDes
organizationId,
tenantId
}).pipe(
tap((response: IGithubRepositoryResponse) => {
if (response['status'] == HttpStatus.INTERNAL_SERVER_ERROR) {
throw new Error(`${response['message']}`);
}
}),
map(({ repositories }: IGithubRepositoryResponse) => repositories),
// Update component state with fetched repositories
tap((repositories: IGithubRepository[]) => {
Expand Down
10 changes: 5 additions & 5 deletions apps/gauzy/src/app/@shared/pipes/hash-number.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { Pipe, PipeTransform } from '@angular/core';
name: 'hash'
})
export class HashNumberPipe implements PipeTransform {
transform(value: number): string {
if (typeof value === 'number') {
return '#' + value;
} else {
return value; // Return an empty string for non-numeric values
transform(value: number | string): string {
if (value) {
const numericValue = isNaN(Number(value)) ? value : Number(value);
return '#' + numericValue;
}
return ''; // Return an empty string for non-numeric or falsy values
}
}
18 changes: 18 additions & 0 deletions apps/gauzy/src/app/@theme/styles/_overrides.scss
Original file line number Diff line number Diff line change
Expand Up @@ -690,3 +690,21 @@ nb-option-list.fit-content {
width: fit-content !important;
min-width: var(--select-min-width);
}

/* Apply style on spinner */
.sync-container {
.sync {
cursor: pointer;
&.spin {
animation: rotate 1s linear infinite;
}
}
@keyframes rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,18 @@ <h5>{{ 'INTEGRATIONS.GITHUB_PAGE.NAME' | translate }}</h5>
<nb-card-body>
<ng-template [ngIf]="integration$ | async">
<div class="mb-3">
<button [disabled]="selectedIssues.length == 0" nbButton status="primary" class="mr-2" (click)="syncIssues()">
<nb-icon class="mr-1" icon="edit-outline"></nb-icon>
{{ 'BUTTONS.SYNC' | translate }}
<button
[disabled]="selectedIssues.length == 0"
nbButton
status="primary"
class="mr-2"
debounceClick
(throttledClick)="syncIssues()"
>
<div class="sync-container">
<nb-icon class="sync" icon="sync-outline" [ngClass]="{ 'spin' : syncing }"></nb-icon>
{{ (syncing ? 'BUTTONS.SYNCING' : 'BUTTONS.SYNC') | translate }}
</div>
</button>
</div>
<div class="issues-container">
Expand All @@ -31,6 +40,7 @@ <h5>{{ 'INTEGRATIONS.GITHUB_PAGE.NAME' | translate }}</h5>
[source]="issues$ | async"
(userRowSelect)="selectIssues($event)"
style="cursor: pointer;"
#issuesTable
></ng2-smart-table>
</div>
</ng-template>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { AfterViewInit, Component, OnInit } from '@angular/core';
import { AfterViewInit, Component, OnInit, ViewChild } from '@angular/core';
import { TitleCasePipe } from '@angular/common';
import { ActivatedRoute, Data } from '@angular/router';
import { debounceTime, firstValueFrom, of } from 'rxjs';
import { debounceTime, finalize, firstValueFrom, of } from 'rxjs';
import { Observable } from 'rxjs/internal/Observable';
import { catchError, filter, map, switchMap, tap } from 'rxjs/operators';
import { TranslateService } from '@ngx-translate/core';
import { NbDialogService, NbMenuItem, NbMenuService } from '@nebular/theme';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { Ng2SmartTableComponent } from 'ng2-smart-table';
import {
IEntitySettingToSync,
IGithubIssue,
Expand Down Expand Up @@ -45,6 +46,7 @@ import { GithubSettingsDialogComponent } from '../settings-dialog/settings-dialo
export class GithubViewComponent extends TranslationBaseComponent implements AfterViewInit, OnInit {
public parsedInt = parsedInt;

public syncing: boolean = false;
public loading: boolean = false;
public user: IUser = this._store.user;
public organization: IOrganization = this._store.selectedOrganization;
Expand All @@ -59,6 +61,18 @@ export class GithubViewComponent extends TranslationBaseComponent implements Aft
public issues: IGithubIssue[] = [];
public selectedIssues: IGithubIssue[] = [];

/**
* Sets up a property 'issuesTable' to reference an instance of 'Ng2SmartTableComponent'
* when the child component with the template reference variable 'issuesTable' is rendered.
* This allows interaction with the child component from the parent component.
*/
private _issuesTable: Ng2SmartTableComponent;
@ViewChild('issuesTable') set content(content: Ng2SmartTableComponent) {
if (content) {
this._issuesTable = content;
}
}

constructor(
public readonly _translateService: TranslateService,
private readonly _activatedRoute: ActivatedRoute,
Expand Down Expand Up @@ -349,6 +363,12 @@ export class GithubViewComponent extends TranslationBaseComponent implements Aft
if (!this.organization || !this.repository) {
return;
}
// Check if another synchronization is already in progress
if (this.syncing) {
return;
}

this.syncing = true;

const { id: organizationId, tenantId } = this.organization;
const { id: integrationId } = this.integration;
Expand All @@ -372,17 +392,19 @@ export class GithubViewComponent extends TranslationBaseComponent implements Aft
tap(() => {
this._toastrService.success(
this.getTranslation('INTEGRATIONS.GITHUB_PAGE.SYNCED_ISSUES', {
repository: this.repository.name
repository: this.repository.full_name
}),
this.getTranslation('TOASTR.TITLE.SUCCESS')
);
this.resetTableSelectedItems();
}),
catchError((error) => {
// Handle and log errors
console.error('Error while syncing GitHub issues & labels:', error.message);
this._errorHandlingService.handleError(error);
return of(null);
}),
finalize(() => this.syncing = false),
untilDestroyed(this) // Ensure subscription is cleaned up on component destroy
).subscribe();
} catch (error) {
Expand All @@ -393,4 +415,17 @@ export class GithubViewComponent extends TranslationBaseComponent implements Aft
this._errorHandlingService.handleError(error);
}
}

/**
* Clears selected items in the table component and resets the 'selectedIssues' array.
*/
resetTableSelectedItems() {
if (this._issuesTable && this._issuesTable.grid) {
// Deselect all items in the table
this._issuesTable.grid.dataSet.deselectAll();

// Clear the 'selectedIssues' array
this.selectedIssues = [];
}
}
}
2 changes: 2 additions & 0 deletions apps/gauzy/src/app/pages/integrations/github/github.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { GithubInstallationComponent } from './components/installation/installat
import { GithubViewComponent } from './components/view/view.component';
import { GithubSettingsDialogComponent } from './components/settings-dialog/settings-dialog.component';
import { RepositorySelectorModule } from '../../../@shared/integrations/github';
import { DirectivesModule } from '../../../@shared/directives/directives.module';

@NgModule({
declarations: [
Expand All @@ -42,6 +43,7 @@ import { RepositorySelectorModule } from '../../../@shared/integrations/github';
NgSelectModule,
GithubRoutingModule,
TranslateModule,
DirectivesModule,
BackNavigationModule,
RepositorySelectorModule
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@
.registration-form-group {
display: inline-flex;
flex-direction: column;

& #registrationDate {
width: 175px;
}
}

::ng-deep nb-select.shape-rectangle .select-button {
Expand Down Expand Up @@ -204,4 +200,4 @@
.main-form .actions {
margin-top: 20px;
}
}
}
39 changes: 21 additions & 18 deletions apps/gauzy/src/app/pages/tasks/components/task/task.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
} from '@gauzy/contracts';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { distinctUntilChange } from '@gauzy/common-angular';
import { HashNumberPipe } from './../../../../@shared/pipes';
import { DeleteConfirmationComponent } from '../../../../@shared/user/forms';
import { MyTaskDialogComponent } from './../my-task-dialog/my-task-dialog.component';
import { TeamTaskDialogComponent } from '../team-task-dialog/team-task-dialog.component';
Expand Down Expand Up @@ -57,10 +58,8 @@ import {
templateUrl: './task.component.html',
styleUrls: ['task.component.scss'],
})
export class TaskComponent
extends PaginationFilterBaseComponent
implements OnInit, OnDestroy
{
export class TaskComponent extends PaginationFilterBaseComponent implements OnInit, OnDestroy {

private _refresh$: Subject<boolean> = new Subject();
private _tasks: ITask[] = [];
settingsSmartTable: object;
Expand Down Expand Up @@ -96,7 +95,8 @@ export class TaskComponent
private readonly _store: Store,
private readonly route: ActivatedRoute,
private readonly httpClient: HttpClient,
private readonly _errorHandlingService: ErrorHandlingService
private readonly _errorHandlingService: ErrorHandlingService,
private readonly _hashNumberPipe: HashNumberPipe
) {
super(translateService);
this.initTasks();
Expand Down Expand Up @@ -182,6 +182,9 @@ export class TaskComponent
filterFunction: (prefix: string) => {
this.setFilter({ field: 'prefix', search: prefix });
},
valuePrepareFunction: (data: number) => {
return this._hashNumberPipe.transform(data);
}
},
description: {
title: this.getTranslation('TASKS_PAGE.TASKS_TITLE'),
Expand Down Expand Up @@ -447,20 +450,20 @@ export class TaskComponent
tenantId,
...(this.selectedProject && this.selectedProject.id
? {
...(this.viewMode === TaskListTypeEnum.SPRINT
? {
organizationSprintId: null,
}
: {}),
projectId: this.selectedProject.id,
}
...(this.viewMode === TaskListTypeEnum.SPRINT
? {
organizationSprintId: null,
}
: {}),
projectId: this.selectedProject.id,
}
: {}),
...(this.selectedEmployeeId
? {
members: {
id: this.selectedEmployeeId,
},
}
members: {
id: this.selectedEmployeeId,
},
}
: {}),
...(this.filters.where ? this.filters.where : {}),
},
Expand All @@ -473,7 +476,7 @@ export class TaskComponent
},
finalize: () => {
this.dataLayoutStyle ===
this.componentLayoutStyleEnum.CARDS_GRID
this.componentLayoutStyleEnum.CARDS_GRID
? this._tasks.push(...this.smartTableSource.getData())
: (this._tasks = this.smartTableSource.getData());
this.storeInstance.loadAllTasks(this._tasks);
Expand Down Expand Up @@ -760,5 +763,5 @@ export class TaskComponent
}
}

ngOnDestroy(): void {}
ngOnDestroy(): void { }
}
3 changes: 2 additions & 1 deletion apps/gauzy/src/assets/i18n/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -2083,7 +2083,8 @@
"ORG_TASK_VIEW": "عرض المهام",
"ORG_TASK_EDIT": "تحرير المهام",
"ORG_TASK_DELETE": "حذف المهام",
"ORG_TASK_SETTING": "إعدادات المهام"
"ORG_TASK_SETTING": "إعدادات المهام",
"ORG_MEMBER_LAST_LOG_VIEW": "عرض السجل الأخير"
},
"BILLING": "الفوترة",
"BUDGET": "ميزانية",
Expand Down
3 changes: 2 additions & 1 deletion apps/gauzy/src/assets/i18n/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -2042,7 +2042,8 @@
"ALLOW_MODIFY_TIME": "Allow Modify Time",
"ALLOW_MANUAL_TIME": "Allow Manual Time",
"DELETE_SCREENSHOTS": "Allow Delete Screenshot",
"ORG_TASK_SETTING": "Настройки на задачите"
"ORG_TASK_SETTING": "Настройки на задачите",
"ORG_MEMBER_LAST_LOG_VIEW": "Преглед на последния запис"
},
"BILLING": "Billing",
"BUDGET": "Budget",
Expand Down
3 changes: 2 additions & 1 deletion apps/gauzy/src/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -2083,7 +2083,8 @@
"ORG_TASK_VIEW": "Ansicht von Aufgaben",
"ORG_TASK_EDIT": "Aufgaben bearbeiten",
"ORG_TASK_DELETE": "Aufgaben löschen",
"ORG_TASK_SETTING": "Aufgabeeinstellungen"
"ORG_TASK_SETTING": "Aufgabeeinstellungen",
"ORG_MEMBER_LAST_LOG_VIEW": "Letztes Protokoll anzeigen"
},
"BILLING": "Rechnungsstellung",
"BUDGET": "Budget",
Expand Down
6 changes: 4 additions & 2 deletions apps/gauzy/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"REQUEST": "Request",
"HISTORY": "History",
"SYNC": "Sync",
"SYNCING": "Syncing...",
"UPDATE": "Update",
"AUTO_SYNC": "Auto sync",
"VIEW": "View",
Expand Down Expand Up @@ -1218,7 +1219,7 @@
"NAME": "GitHub",
"SELECT_REPOSITORY": "Select repository",
"SEARCH_REPOSITORY": "Type to search repository",
"SYNCED_ISSUES": "{{repository}} issues & labels synced successfully"
"SYNCED_ISSUES": "'{{repository}}' issues & labels synced successfully"
},
"COMING_SOON": "Coming soon",
"RE_INTEGRATE": "Re-integrate",
Expand Down Expand Up @@ -2099,7 +2100,8 @@
"ORG_TASK_DELETE": "Delete Tasks",
"ORG_TASK_SETTING": "Task Settings",
"IMPORT_ADD": "Ability to import your data",
"EXPORT_ADD": "Ability to export your data"
"EXPORT_ADD": "Ability to export your data",
"ORG_MEMBER_LAST_LOG_VIEW": "View Last Log"
},
"BILLING": "Billing",
"BUDGET": "Budget",
Expand Down
3 changes: 2 additions & 1 deletion apps/gauzy/src/assets/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -2085,7 +2085,8 @@
"ORG_TASK_VIEW": "Ver tareas",
"ORG_TASK_EDIT": "Editar tareas",
"ORG_TASK_DELETE": "Eliminar tareas",
"ORG_TASK_SETTING": "Configuración de tarea"
"ORG_TASK_SETTING": "Configuración de tarea",
"ORG_MEMBER_LAST_LOG_VIEW": "Ver último registro"
},
"BILLING": "Facturación",
"BUDGET": "Presupuesto",
Expand Down
3 changes: 2 additions & 1 deletion apps/gauzy/src/assets/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2084,7 +2084,8 @@
"ORG_TASK_VIEW": "Afficher les tâches",
"ORG_TASK_EDIT": "Modifier les tâches",
"ORG_TASK_DELETE": "Supprimer les tâches",
"ORG_TASK_SETTING": "Paramètres de tâche"
"ORG_TASK_SETTING": "Paramètres de tâche",
"ORG_MEMBER_LAST_LOG_VIEW": "Voir le dernier journal"
},
"BILLING": "Facturation",
"BUDGET": "Budget",
Expand Down
3 changes: 2 additions & 1 deletion apps/gauzy/src/assets/i18n/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -2042,7 +2042,8 @@
"ALLOW_MODIFY_TIME": "Allow Modify Time",
"ALLOW_MANUAL_TIME": "Allow Manual Time",
"DELETE_SCREENSHOTS": "Allow Delete Screenshot",
"ORG_TASK_SETTING": "Task Settings"
"ORG_TASK_SETTING": "Task Settings",
"ORG_MEMBER_LAST_LOG_VIEW": "צפה ביומן האחרון"
},
"BILLING": "Billing",
"BUDGET": "Budget",
Expand Down
Loading

0 comments on commit f571215

Please sign in to comment.