Date formatting per workspace member settings (#6408)

Implement date formatting per workspace member settings

We'll need another round to maybe initialize all workspaces on the
default settings.

For now the default behavior is to take system settings if nothing is
found in DB.

---------

Co-authored-by: Weiko <corentin@twenty.com>
This commit is contained in:
Lucas Bordeau
2024-07-30 14:52:10 +02:00
committed by GitHub
parent 45ebb0b824
commit ccf4d1eeec
64 changed files with 1176 additions and 165 deletions

View File

@ -3,6 +3,10 @@ import { Field, ObjectType } from '@nestjs/graphql';
import { IDField } from '@ptc-org/nestjs-query-graphql';
import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';
import {
WorkspaceMemberDateFormatEnum,
WorkspaceMemberTimeFormatEnum,
} from 'src/modules/workspace-member/standard-objects/workspace-member.workspace-entity';
@ObjectType('FullName')
export class FullName {
@ -27,6 +31,15 @@ export class WorkspaceMember {
@Field({ nullable: true })
avatarUrl: string;
@Field({ nullable: false })
@Field({ nullable: true })
locale: string;
@Field({ nullable: true })
timeZone: string;
@Field(() => WorkspaceMemberDateFormatEnum, { nullable: true })
dateFormat: WorkspaceMemberDateFormatEnum;
@Field(() => WorkspaceMemberTimeFormatEnum, { nullable: true })
timeFormat: WorkspaceMemberTimeFormatEnum;
}

View File

@ -70,6 +70,9 @@ export class UserService extends TypeOrmQueryService<User> {
firstName: workspaceMembers[0].nameFirstName,
lastName: workspaceMembers[0].nameLastName,
};
userWorkspaceMember.timeZone = workspaceMembers[0].timeZone;
userWorkspaceMember.dateFormat = workspaceMembers[0].dateFormat;
userWorkspaceMember.timeFormat = workspaceMembers[0].timeFormat;
return userWorkspaceMember;
}

View File

@ -1,13 +1,13 @@
import { Logger } from '@nestjs/common';
import { Command, CommandRunner, Option } from 'nest-commander';
import chalk from 'chalk';
import { Command, CommandRunner, Option } from 'nest-commander';
import { WorkspaceHealthMode } from 'src/engine/workspace-manager/workspace-health/interfaces/workspace-health-options.interface';
import { WorkspaceHealthFixKind } from 'src/engine/workspace-manager/workspace-health/interfaces/workspace-health-fix-kind.interface';
import { WorkspaceHealthMode } from 'src/engine/workspace-manager/workspace-health/interfaces/workspace-health-options.interface';
import { WorkspaceHealthService } from 'src/engine/workspace-manager/workspace-health/workspace-health.service';
import { CommandLogger } from 'src/command/command-logger';
import { WorkspaceHealthService } from 'src/engine/workspace-manager/workspace-health/workspace-health.service';
interface WorkspaceHealthCommandOptions {
workspaceId: string;
@ -48,13 +48,20 @@ export class WorkspaceHealthCommand extends CommandRunner {
chalk.red(`Workspace is not healthy, found ${issues.length} issues`),
);
if (options.dryRun) {
await this.commandLogger.writeLog(
`workspace-health-issues-${options.workspaceId}`,
issues,
for (let issueIndex = 0; issueIndex < issues.length; issueIndex++) {
this.logger.log(
chalk.red(`Issue #${issueIndex + 1} : ${issues[issueIndex].message}`),
);
this.logger.log(chalk.yellow('Issues written to log'));
}
const logFilePath = await this.commandLogger.writeLog(
`workspace-health-issues-${options.workspaceId}`,
issues,
);
this.logger.log(
chalk.yellow(`Issues written to log at : ${logFilePath}`),
);
}
if (options.fix) {

View File

@ -369,6 +369,9 @@ export const WORKSPACE_MEMBER_STANDARD_FIELD_IDS = {
calendarEventParticipants: '20202020-0dbc-4841-9ce1-3e793b5b3512',
timelineActivities: '20202020-e15b-47b8-94fe-8200e3c66615',
auditLogs: '20202020-2f54-4739-a5e2-99563385e83d',
timeZone: '20202020-2d33-4c21-a86e-5943b050dd54',
dateFormat: '20202020-af13-4e11-b1e7-b8cf5ea13dc0',
timeFormat: '20202020-8acb-4cf8-a851-a6ed443c8d81',
};
export const CUSTOM_OBJECT_STANDARD_FIELD_IDS = {