Skip to content

Commit

Permalink
Merge pull request #8520 from ever-co/stage
Browse files Browse the repository at this point in the history
Stage
  • Loading branch information
evereq authored Nov 5, 2024
2 parents eadc3d5 + 475da61 commit 1744954
Show file tree
Hide file tree
Showing 38 changed files with 933 additions and 331 deletions.
34 changes: 4 additions & 30 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,7 @@ jobs:
key: yarn-packages-sonarqube-root-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn
- persist_to_workspace:
root: /tmp/workspace/sonarqube-root
paths:
- '*'

build-monorepo-root:
<<: *defaults
machine:
Expand All @@ -131,10 +128,7 @@ jobs:
key: yarn-packages-monorepo-root-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn
- persist_to_workspace:
root: /tmp/workspace/monorepo-root
paths:
- '*'

build-desktop:
<<: *defaults
machine:
Expand Down Expand Up @@ -165,10 +159,7 @@ jobs:
key: yarn-packages-desktop-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn
- persist_to_workspace:
root: /tmp/workspace/desktop
paths:
- '*'

build-api:
<<: *defaults
machine:
Expand Down Expand Up @@ -203,10 +194,7 @@ jobs:
key: yarn-packages-api-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn
- persist_to_workspace:
root: /tmp/workspace/api
paths:
- '*'

build-web:
<<: *defaults
machine:
Expand Down Expand Up @@ -241,10 +229,6 @@ jobs:
key: yarn-packages-web-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn
- persist_to_workspace:
root: /tmp/workspace/web
paths:
- '*'

test-e2e:
<<: *defaults
Expand Down Expand Up @@ -289,11 +273,6 @@ jobs:
name: Kill API Background Process
command: pgrep node &> /dev/null && killall -w node || true

- persist_to_workspace:
root: /tmp/workspace/test-e2e
paths:
- '*'

pulumi_deploy:
<<: *defaults
machine:
Expand Down Expand Up @@ -333,11 +312,6 @@ jobs:
paths:
- ~/.cache/yarn

- persist_to_workspace:
root: /tmp/workspace/pulumi
paths:
- '*'

workflows:
version: 2
build:
Expand Down
3 changes: 2 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@
"randomcolor",
"underscore.string",
"slugify",
"eva-icons"
"eva-icons",
"localforage"
]
},
"configurations": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,68 +74,63 @@ export class EditEmployeeOtherSettingsComponent implements OnInit, OnDestroy {
}

/**
* Patches the form with employee data or default values if data is unavailable.
*
* @param employee
* @returns
* @param {IEmployee} employee - The employee object containing user data.
* @returns {void}
*/
private _patchFormValue(employee: IEmployee) {
if (!employee) {
return;
}
const { user } = employee;
private _patchFormValue(employee: IEmployee): void {
if (!employee) return;

const { user, upworkId, linkedInId, allowManualTime, allowDeleteTime, allowModifyTime, allowScreenshotCapture } = employee;
this.form.patchValue({
timeZone: user.timeZone || moment.tz.guess(), // set current timezone, if employee don't have any timezone
timeFormat: user.timeFormat,
upworkId: employee.upworkId,
linkedInId: employee.linkedInId,
allowManualTime: employee.allowManualTime,
allowDeleteTime: employee.allowDeleteTime,
allowModifyTime: employee.allowModifyTime,
allowScreenshotCapture: employee.allowScreenshotCapture
timeZone: user?.timeZone ?? moment.tz.guess(),
timeFormat: user?.timeFormat,
upworkId,
linkedInId,
allowManualTime,
allowDeleteTime,
allowModifyTime,
allowScreenshotCapture
});
this.form.updateValueAndValidity();
}

/**
* Handles the form submission, updating employee and user settings if valid.
*
* @param form
* @returns
* @param {NgForm} form - The form reference for submission.
* @returns {void}
*/
onSubmit(form: NgForm) {
if (form.invalid) {
return;
}
onSubmit(form: NgForm): void {
if (form.invalid) return;

const { organizationId, tenantId } = this.selectedEmployee;
const {
timeZone,
timeFormat,
upworkId,
linkedInId,
allowScreenshotCapture,
allowManualTime,
allowDeleteTime,
allowModifyTime,
allowDeleteTime
allowScreenshotCapture
} = this.form.value;

/** Update user fields */
this.employeeStore.userForm = {
timeZone,
timeFormat
};

/** Update employee fields */
this.employeeStore.employeeForm = {
this.employeeStore.updateUserForm({ timeZone, timeFormat });
this.employeeStore.updateEmployeeForm({
upworkId,
linkedInId,
organizationId,
tenantId,
allowManualTime,
allowModifyTime,
allowDeleteTime,
allowModifyTime,
allowScreenshotCapture
};
});
}


/**
*
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { IOrganization, IUserOrganizationCreateInput, RolesEnum } from '@gauzy/contracts';
import { IOrganization, IUserOrganizationCreateInput } from '@gauzy/contracts';
import { filter, tap, debounceTime } from 'rxjs/operators';
import { Subject, firstValueFrom } from 'rxjs';
import { TranslateService } from '@ngx-translate/core';
Expand Down Expand Up @@ -84,22 +84,25 @@ export class EditUserOrganizationsComponent extends TranslationBaseComponent imp

async remove(id: string) {
const { tenantId } = this.store.user;
const user = await this.usersService.getUserById(this.selectedUserId);
const { items } = await this.userOrganizationsService.getAll(['user', 'user.role'], { tenantId });
const { items } = await this.userOrganizationsService.getAll(['user', 'user.role'], {
tenantId,
userId: this.selectedUserId
});

let counter = 0;
let userName: string;

for (const orgUser of items) {
if (orgUser.isActive && (!orgUser.user.role || orgUser.user.role.name !== RolesEnum.EMPLOYEE)) {
this.userToRemove = orgUser;
userName = orgUser.user.firstName + ' ' + orgUser.user.lastName;
this.userToRemove = items.find((orgUser) => orgUser.organizationId === id && orgUser.isActive);

if (orgUser.organizationId === id) this.orgUserId = orgUser.id;
if (this.userToRemove.user.id === user.id) counter++;
}
if (!this.userToRemove?.user) {
this.toastrService.danger('User organization record not found');
return;
}

userName = [this.userToRemove.user.firstName, this.userToRemove.user.lastName].filter(Boolean).join(' ');
this.orgUserId = this.userToRemove.id;
counter = items.filter((orgUser) => orgUser.isActive).length;

if (counter - 1 < 1) {
this.dialogService
.open(DeleteConfirmationComponent, {
Expand Down
6 changes: 3 additions & 3 deletions apps/server-api/src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@
"node_modules/linebreak/src/classes.trie"
],
"targets": [
"node16-linux-x64",
"node16-mac-x64",
"node16-win-x64"
"node20-linux-x64",
"node20-mac-x64",
"node20-win-x64"
]
}
}
6 changes: 3 additions & 3 deletions apps/server/src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@
"node_modules/linebreak/src/classes.trie"
],
"targets": [
"node16-linux-x64",
"node16-mac-x64",
"node16-win-x64"
"node20-linux-x64",
"node20-mac-x64",
"node20-win-x64"
]
}
}
1 change: 1 addition & 0 deletions packages/contracts/src/base-entity.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,6 @@ export enum BaseEntityEnum {
OrganizationVendor = 'OrganizationVendor',
Task = 'Task',
TaskView = 'TaskView',
TaskLinkedIssue = 'TaskLinkedIssue',
User = 'User'
}
16 changes: 7 additions & 9 deletions packages/contracts/src/task-linked-issue.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IBasePerTenantAndOrganizationEntityModel } from './base-entity.model';
import { IBasePerTenantAndOrganizationEntityModel, ID } from './base-entity.model';
import { ITask } from './task.model';

export enum TaskRelatedIssuesRelationEnum {
Expand All @@ -8,23 +8,21 @@ export enum TaskRelatedIssuesRelationEnum {
CLONES = 4,
IS_DUPLICATED_BY = 5,
DUPLICATES = 6,
RELATES_TO = 7,
RELATES_TO = 7
}

export interface ITaskLinkedIssue
extends IBasePerTenantAndOrganizationEntityModel {
export interface ITaskLinkedIssue extends IBasePerTenantAndOrganizationEntityModel {
action: TaskRelatedIssuesRelationEnum;
taskFrom?: ITask;
taskFromId: ITask['id'];
taskFromId: ID;
taskTo?: ITask;
taskToId: ITask['id'];
taskToId: ID;
}

export interface ITaskLinkedIssueCreateInput extends ITaskLinkedIssue {}

export interface ITaskLinkedIssueUpdateInput
extends Partial<ITaskLinkedIssueCreateInput> {
id?: string;
export interface ITaskLinkedIssueUpdateInput extends Partial<ITaskLinkedIssueCreateInput> {
id?: ID;
}

export interface ILinkedIssueFindInput
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/activity-log/activity-log.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class ActivityLogService extends TenantAwareCrudService<ActivityLog> {
/**
* @description Create or Update Activity Log
* @template T
* @param {BaseEntityEnum} entityType - Entity type for whom creating activity log (E.g : Task, OrganizationProject, etc.)
* @param {BaseEntityEnum} entity - Entity type for whom creating activity log (E.g : Task, OrganizationProject, etc.)
* @param {string} entityName - Name or Title of the entity
* @param {ActorTypeEnum} actor - The actor type performing the action (User or System)
* @param {ID} organizationId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,14 @@ export class OrganizationProjectModuleService extends TenantAwareCrudService<Org
const tenantId = RequestContext.currentTenantId() || entity.tenantId;

try {
// Find Organization Project Module relations
const relations = this.typeOrmProjectModuleRepository.metadata.relations.map(
(relation) => relation.propertyName
);

// Retrieve existing module.
const existingProjectModule = await this.findOneByIdString(id, {
relations: {
members: true,
manager: true
}
relations
});

if (!existingProjectModule) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,14 @@ export class OrganizationProjectService extends TenantAwareCrudService<Organizat
const tenantId = RequestContext.currentTenantId() || input.tenantId;
const { memberIds = [], managerIds = [], organizationId } = input;

// Find Organization Project relations
const relations = this.typeOrmOrganizationProjectRepository.metadata.relations.map(
(relation) => relation.propertyName
);

let organizationProject = await super.findOneByIdString(id, {
where: { organizationId, tenantId }
where: { organizationId, tenantId },
relations
});

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,15 @@ export class OrganizationSprintService extends TenantAwareCrudService<Organizati
const { memberIds = [], managerIds = [], organizationId, projectId } = input;

try {
// Find Organization Sprint relations
const relations = this.typeOrmOrganizationSprintRepository.metadata.relations.map(
(relation) => relation.propertyName
);

// Search for existing Organization Sprint
const organizationSprint = await super.findOneByIdString(id, {
where: { organizationId, tenantId, projectId },
relations: {
members: true,
modules: true
}
relations
});

// Retrieve members and managers IDs
Expand Down
7 changes: 6 additions & 1 deletion packages/core/src/resource-link/resource-link.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,12 @@ export class ResourceLinkService extends TenantAwareCrudService<ResourceLink> {
*/
async update(id: ID, input: IResourceLinkUpdateInput): Promise<IResourceLink | UpdateResult> {
try {
const resourceLink = await this.findOneByIdString(id);
// Find Resource Link relations
const relations = this.typeOrmResourceLinkRepository.metadata.relations.map(
(relation) => relation.propertyName
);

const resourceLink = await this.findOneByIdString(id, { relations });

if (!resourceLink) {
throw new BadRequestException('Resource Link not found');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,11 @@ export class AutomationTaskSyncHandler implements ICommandHandler<AutomationTask
*/
async updateTask(id: ID, entity: ITaskUpdateInput): Promise<ITask> {
try {
// Find task relations
const relations = this.typeOrmTaskRepository.metadata.relations.map((relation) => relation.propertyName);

// Find the existing task by its ID
const existingTask = await this._taskService.findOneByIdString(id);
const existingTask = await this._taskService.findOneByIdString(id, { relations });
if (!existingTask) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { TaskLinkedIssueCreateHandler } from './task-linked-issue-create.handler';
import { TaskLinkedIssueUpdateHandler } from './task-linked-issue-update.handler';

export const CommandHandlers = [TaskLinkedIssueCreateHandler, TaskLinkedIssueUpdateHandler];
Loading

0 comments on commit 1744954

Please sign in to comment.