Restore "Fix "Create profile" page not supporting dark mode (#8110)" & Fix string defaultValues during sync-metadata (#9220)
Restoring https://github.com/twentyhq/twenty/pull/9185 Also fixing sync-metadata with test values in jsonb ## Test sync-metadata on existing workspaces should replace colorSchema in both metadata and workspaceMember tables
This commit is contained in:
@ -5,16 +5,16 @@ import { TypeOrmQueryService } from '@ptc-org/nestjs-query-typeorm';
|
|||||||
import { Repository } from 'typeorm';
|
import { Repository } from 'typeorm';
|
||||||
|
|
||||||
import { TypeORMService } from 'src/database/typeorm/typeorm.service';
|
import { TypeORMService } from 'src/database/typeorm/typeorm.service';
|
||||||
|
import { DatabaseEventAction } from 'src/engine/api/graphql/graphql-query-runner/enums/database-event-action';
|
||||||
|
import { USER_SIGNUP_EVENT_NAME } from 'src/engine/api/graphql/workspace-query-runner/constants/user-signup-event-name.constants';
|
||||||
import { UserWorkspace } from 'src/engine/core-modules/user-workspace/user-workspace.entity';
|
import { UserWorkspace } from 'src/engine/core-modules/user-workspace/user-workspace.entity';
|
||||||
import { User } from 'src/engine/core-modules/user/user.entity';
|
import { User } from 'src/engine/core-modules/user/user.entity';
|
||||||
import { WorkspaceInvitationService } from 'src/engine/core-modules/workspace-invitation/services/workspace-invitation.service';
|
import { WorkspaceInvitationService } from 'src/engine/core-modules/workspace-invitation/services/workspace-invitation.service';
|
||||||
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
|
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||||
import { DataSourceService } from 'src/engine/metadata-modules/data-source/data-source.service';
|
import { DataSourceService } from 'src/engine/metadata-modules/data-source/data-source.service';
|
||||||
|
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||||
import { WorkspaceEventEmitter } from 'src/engine/workspace-event-emitter/workspace-event-emitter';
|
import { WorkspaceEventEmitter } from 'src/engine/workspace-event-emitter/workspace-event-emitter';
|
||||||
import { assert } from 'src/utils/assert';
|
import { assert } from 'src/utils/assert';
|
||||||
import { DatabaseEventAction } from 'src/engine/api/graphql/graphql-query-runner/enums/database-event-action';
|
|
||||||
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
|
||||||
import { USER_SIGNUP_EVENT_NAME } from 'src/engine/api/graphql/workspace-query-runner/constants/user-signup-event-name.constants';
|
|
||||||
|
|
||||||
export class UserWorkspaceService extends TypeOrmQueryService<UserWorkspace> {
|
export class UserWorkspaceService extends TypeOrmQueryService<UserWorkspace> {
|
||||||
constructor(
|
constructor(
|
||||||
@ -59,7 +59,7 @@ export class UserWorkspaceService extends TypeOrmQueryService<UserWorkspace> {
|
|||||||
await workspaceDataSource?.query(
|
await workspaceDataSource?.query(
|
||||||
`INSERT INTO ${dataSourceMetadata.schema}."workspaceMember"
|
`INSERT INTO ${dataSourceMetadata.schema}."workspaceMember"
|
||||||
("nameFirstName", "nameLastName", "colorScheme", "userId", "userEmail", "avatarUrl")
|
("nameFirstName", "nameLastName", "colorScheme", "userId", "userEmail", "avatarUrl")
|
||||||
VALUES ($1, $2, 'Light', $3, $4, $5)`,
|
VALUES ($1, $2, 'System', $3, $4, $5)`,
|
||||||
[
|
[
|
||||||
user.firstName,
|
user.firstName,
|
||||||
user.lastName,
|
user.lastName,
|
||||||
|
|||||||
@ -193,7 +193,7 @@ export class WorkspaceFieldComparator {
|
|||||||
if (
|
if (
|
||||||
(fieldPropertiesToStringify as readonly string[]).includes(property)
|
(fieldPropertiesToStringify as readonly string[]).includes(property)
|
||||||
) {
|
) {
|
||||||
fieldPropertiesToUpdateMap[id][property] = JSON.parse(
|
fieldPropertiesToUpdateMap[id][property] = this.parseJSONOrString(
|
||||||
difference.value,
|
difference.value,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -233,4 +233,16 @@ export class WorkspaceFieldComparator {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private parseJSONOrString(value: string | null): string | object | null {
|
||||||
|
if (value === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return JSON.parse(value);
|
||||||
|
} catch {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -98,7 +98,7 @@ export class WorkspaceMemberWorkspaceEntity extends BaseWorkspaceEntity {
|
|||||||
label: 'Color Scheme',
|
label: 'Color Scheme',
|
||||||
description: 'Preferred color scheme',
|
description: 'Preferred color scheme',
|
||||||
icon: 'IconColorSwatch',
|
icon: 'IconColorSwatch',
|
||||||
defaultValue: "'Light'",
|
defaultValue: "'System'",
|
||||||
})
|
})
|
||||||
colorScheme: string;
|
colorScheme: string;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user