Remove viewGroup.fieldMetadataId (#16571)
Final step of https://github.com/orgs/twentyhq/projects/1/views/8?pane=issue&itemId=142348748&issue=twentyhq%7Ccore-team-issues%7C1965 Removing viewGroup.fieldMetadataId. It's already not used in FE anymore
This commit is contained in:
-210
@@ -1,210 +0,0 @@
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
|
||||
import { Command } from 'nest-commander';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { In, IsNull, Not, Repository } from 'typeorm';
|
||||
|
||||
import { ActiveOrSuspendedWorkspacesMigrationCommandRunner } from 'src/database/commands/command-runners/active-or-suspended-workspaces-migration.command-runner';
|
||||
import { MigrationCommandOptions } from 'src/database/commands/command-runners/migration.command-runner';
|
||||
import { RunOnWorkspaceArgs } from 'src/database/commands/command-runners/workspaces-migration.command-runner';
|
||||
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { DataSourceService } from 'src/engine/metadata-modules/data-source/data-source.service';
|
||||
import { ViewGroupEntity } from 'src/engine/metadata-modules/view-group/entities/view-group.entity';
|
||||
import { ViewEntity } from 'src/engine/metadata-modules/view/entities/view.entity';
|
||||
import { GlobalWorkspaceOrmManager } from 'src/engine/twenty-orm/global-workspace-datasource/global-workspace-orm.manager';
|
||||
|
||||
@Command({
|
||||
name: 'upgrade:1-13:backfill:view-main-group-by-field-metadata-id',
|
||||
description:
|
||||
'Backfill mainGroupByFieldMetadataId on views and clean up inconsistent viewGroups',
|
||||
})
|
||||
export class BackfillViewMainGroupByFieldMetadataIdCommand extends ActiveOrSuspendedWorkspacesMigrationCommandRunner {
|
||||
constructor(
|
||||
@InjectRepository(ViewEntity)
|
||||
private readonly viewRepository: Repository<ViewEntity>,
|
||||
@InjectRepository(ViewGroupEntity)
|
||||
private readonly viewGroupRepository: Repository<ViewGroupEntity>,
|
||||
@InjectRepository(WorkspaceEntity)
|
||||
protected readonly workspaceRepository: Repository<WorkspaceEntity>,
|
||||
protected readonly twentyORMGlobalManager: GlobalWorkspaceOrmManager,
|
||||
protected readonly dataSourceService: DataSourceService,
|
||||
) {
|
||||
super(workspaceRepository, twentyORMGlobalManager, dataSourceService);
|
||||
}
|
||||
|
||||
override async runOnWorkspace({
|
||||
workspaceId,
|
||||
options,
|
||||
}: RunOnWorkspaceArgs): Promise<void> {
|
||||
await this.backfillMainGroupByFieldMetadataId(workspaceId, options);
|
||||
await this.cleanupInconsistentViewGroups(workspaceId, options);
|
||||
}
|
||||
|
||||
private async backfillMainGroupByFieldMetadataId(
|
||||
workspaceId: string,
|
||||
options: MigrationCommandOptions,
|
||||
): Promise<void> {
|
||||
this.logger.log(
|
||||
`Starting backfill of mainGroupByFieldMetadataId for workspace ${workspaceId}...`,
|
||||
);
|
||||
|
||||
const viewsToBackfill = await this.viewRepository.find({
|
||||
where: {
|
||||
mainGroupByFieldMetadataId: IsNull(),
|
||||
workspaceId,
|
||||
},
|
||||
select: ['id', 'workspaceId'],
|
||||
});
|
||||
|
||||
this.logger.log(
|
||||
`Found ${viewsToBackfill.length} views with null mainGroupByFieldMetadataId`,
|
||||
);
|
||||
|
||||
let backfilledCount = 0;
|
||||
let inconsistentViewsCount = 0;
|
||||
|
||||
for (const view of viewsToBackfill) {
|
||||
const nonDeletedViewGroups = await this.viewGroupRepository.find({
|
||||
where: {
|
||||
viewId: view.id,
|
||||
deletedAt: IsNull(),
|
||||
workspaceId,
|
||||
},
|
||||
select: ['id', 'fieldMetadataId'],
|
||||
});
|
||||
|
||||
if (nonDeletedViewGroups.length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const uniqueFieldMetadataIds = [
|
||||
...new Set(nonDeletedViewGroups.map((vg) => vg.fieldMetadataId)),
|
||||
];
|
||||
|
||||
if (uniqueFieldMetadataIds.length === 1) {
|
||||
const fieldMetadataId = uniqueFieldMetadataIds[0];
|
||||
|
||||
if (options.dryRun) {
|
||||
this.logger.log(
|
||||
`[DRY RUN] Would backfill view ${view.id} (workspace ${view.workspaceId}) with fieldMetadataId ${fieldMetadataId}`,
|
||||
);
|
||||
} else {
|
||||
await this.viewRepository.update(
|
||||
{ id: view.id, workspaceId },
|
||||
{ mainGroupByFieldMetadataId: fieldMetadataId },
|
||||
);
|
||||
this.logger.log(
|
||||
`Backfilled view ${view.id} (workspace ${view.workspaceId}) with fieldMetadataId ${fieldMetadataId}`,
|
||||
);
|
||||
}
|
||||
backfilledCount++;
|
||||
} else {
|
||||
this.logger.error(
|
||||
`Inconsistency detected for view ${view.id} (workspace ${view.workspaceId}): found ${uniqueFieldMetadataIds.length} different fieldMetadataIds`,
|
||||
);
|
||||
|
||||
const fieldMetadataIdCounts = new Map<string, number>();
|
||||
|
||||
for (const vg of nonDeletedViewGroups) {
|
||||
const count = fieldMetadataIdCounts.get(vg.fieldMetadataId) || 0;
|
||||
|
||||
fieldMetadataIdCounts.set(vg.fieldMetadataId, count + 1);
|
||||
}
|
||||
|
||||
let mostNumerousFieldMetadataId = '';
|
||||
let maxCount = 0;
|
||||
|
||||
for (const [
|
||||
fieldMetadataId,
|
||||
count,
|
||||
] of fieldMetadataIdCounts.entries()) {
|
||||
if (count > maxCount) {
|
||||
maxCount = count;
|
||||
mostNumerousFieldMetadataId = fieldMetadataId;
|
||||
}
|
||||
}
|
||||
|
||||
if (options.dryRun) {
|
||||
this.logger.log(
|
||||
`[DRY RUN] Would backfill view ${view.id} (workspace ${view.workspaceId}) with fieldMetadataId ${mostNumerousFieldMetadataId} (most numerous, found ${maxCount} occurrences)`,
|
||||
);
|
||||
} else {
|
||||
await this.viewRepository.update(
|
||||
{ id: view.id },
|
||||
{ mainGroupByFieldMetadataId: mostNumerousFieldMetadataId },
|
||||
);
|
||||
this.logger.log(
|
||||
`Backfilled view ${view.id} (workspace ${view.workspaceId}) with fieldMetadataId ${mostNumerousFieldMetadataId} (most numerous, found ${maxCount} occurrences)`,
|
||||
);
|
||||
}
|
||||
backfilledCount++;
|
||||
inconsistentViewsCount++;
|
||||
}
|
||||
}
|
||||
|
||||
this.logger.log(
|
||||
`${options.dryRun ? '[DRY RUN] Would have ' : ''}Backfilled ${backfilledCount} views${inconsistentViewsCount > 0 ? ` (${inconsistentViewsCount} with inconsistencies)` : ''}`,
|
||||
);
|
||||
}
|
||||
|
||||
private async cleanupInconsistentViewGroups(
|
||||
workspaceId: string,
|
||||
options: MigrationCommandOptions,
|
||||
): Promise<void> {
|
||||
this.logger.log('Starting cleanup of inconsistent viewGroups...');
|
||||
|
||||
const viewsWithMainGroupBy = await this.viewRepository.find({
|
||||
where: {
|
||||
mainGroupByFieldMetadataId: Not(IsNull()),
|
||||
workspaceId,
|
||||
},
|
||||
select: ['id', 'mainGroupByFieldMetadataId'],
|
||||
});
|
||||
|
||||
this.logger.log(
|
||||
`Found ${viewsWithMainGroupBy.length} views with mainGroupByFieldMetadataId set`,
|
||||
);
|
||||
|
||||
let totalDeletedCount = 0;
|
||||
|
||||
for (const view of viewsWithMainGroupBy) {
|
||||
if (!isDefined(view.mainGroupByFieldMetadataId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const inconsistentViewGroups = await this.viewGroupRepository.find({
|
||||
where: {
|
||||
viewId: view.id,
|
||||
fieldMetadataId: Not(view.mainGroupByFieldMetadataId),
|
||||
workspaceId,
|
||||
},
|
||||
select: ['id'],
|
||||
});
|
||||
|
||||
if (inconsistentViewGroups.length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const viewGroupIds = inconsistentViewGroups.map((vg) => vg.id);
|
||||
|
||||
if (options.dryRun) {
|
||||
this.logger.log(
|
||||
`[DRY RUN] Would delete ${inconsistentViewGroups.length} viewGroups from view ${view.id}`,
|
||||
);
|
||||
} else {
|
||||
await this.viewGroupRepository.delete({
|
||||
id: In(viewGroupIds),
|
||||
workspaceId,
|
||||
});
|
||||
this.logger.log(
|
||||
`Deleted ${inconsistentViewGroups.length} viewGroups from view ${view.id}`,
|
||||
);
|
||||
}
|
||||
totalDeletedCount += inconsistentViewGroups.length;
|
||||
}
|
||||
|
||||
this.logger.log(
|
||||
`${options.dryRun ? '[DRY RUN] Would have ' : ''}Deleted ${totalDeletedCount} inconsistent viewGroups`,
|
||||
);
|
||||
}
|
||||
}
|
||||
-3
@@ -2,7 +2,6 @@ import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
|
||||
import { BackfillPageLayoutUniversalIdentifiersCommand } from 'src/database/commands/upgrade-version-command/1-13/1-13-backfill-page-layout-universal-identifiers.command';
|
||||
import { BackfillViewMainGroupByFieldMetadataIdCommand } from 'src/database/commands/upgrade-version-command/1-13/1-13-backfill-view-main-group-by-field-metadata-id.command';
|
||||
import { CleanEmptyStringNullInTextFieldsCommand } from 'src/database/commands/upgrade-version-command/1-13/1-13-clean-empty-string-null-in-text-fields.command';
|
||||
import { DeduplicateRoleTargetsCommand } from 'src/database/commands/upgrade-version-command/1-13/1-13-deduplicate-role-targets.command';
|
||||
import { MigrateStandardInvalidEntitiesCommand } from 'src/database/commands/upgrade-version-command/1-13/1-13-migrate-standard-invalid-entities.command';
|
||||
@@ -59,7 +58,6 @@ import { TimelineActivityWorkspaceEntity } from 'src/modules/timeline/standard-o
|
||||
],
|
||||
providers: [
|
||||
CleanEmptyStringNullInTextFieldsCommand,
|
||||
BackfillViewMainGroupByFieldMetadataIdCommand,
|
||||
BackfillPageLayoutUniversalIdentifiersCommand,
|
||||
DeduplicateRoleTargetsCommand,
|
||||
RenameIndexNameCommand,
|
||||
@@ -69,7 +67,6 @@ import { TimelineActivityWorkspaceEntity } from 'src/modules/timeline/standard-o
|
||||
],
|
||||
exports: [
|
||||
CleanEmptyStringNullInTextFieldsCommand,
|
||||
BackfillViewMainGroupByFieldMetadataIdCommand,
|
||||
BackfillPageLayoutUniversalIdentifiersCommand,
|
||||
DeduplicateRoleTargetsCommand,
|
||||
RenameIndexNameCommand,
|
||||
|
||||
-3
@@ -10,7 +10,6 @@ import {
|
||||
type VersionCommands,
|
||||
} from 'src/database/commands/command-runners/upgrade.command-runner';
|
||||
import { BackfillPageLayoutUniversalIdentifiersCommand } from 'src/database/commands/upgrade-version-command/1-13/1-13-backfill-page-layout-universal-identifiers.command';
|
||||
import { BackfillViewMainGroupByFieldMetadataIdCommand } from 'src/database/commands/upgrade-version-command/1-13/1-13-backfill-view-main-group-by-field-metadata-id.command';
|
||||
import { CleanEmptyStringNullInTextFieldsCommand } from 'src/database/commands/upgrade-version-command/1-13/1-13-clean-empty-string-null-in-text-fields.command';
|
||||
import { DeduplicateRoleTargetsCommand } from 'src/database/commands/upgrade-version-command/1-13/1-13-deduplicate-role-targets.command';
|
||||
import { MigrateStandardInvalidEntitiesCommand } from 'src/database/commands/upgrade-version-command/1-13/1-13-migrate-standard-invalid-entities.command';
|
||||
@@ -43,7 +42,6 @@ export class UpgradeCommand extends UpgradeCommandRunner {
|
||||
protected readonly updateRoleTargetsUniqueConstraintMigrationCommand: UpdateRoleTargetsUniqueConstraintMigrationCommand,
|
||||
protected readonly backfillPageLayoutUniversalIdentifiersCommand: BackfillPageLayoutUniversalIdentifiersCommand,
|
||||
protected readonly migrateStandardInvalidEntitiesCommand: MigrateStandardInvalidEntitiesCommand,
|
||||
protected readonly backfillViewMainGroupByFieldMetadataIdCommand: BackfillViewMainGroupByFieldMetadataIdCommand,
|
||||
protected readonly cleanEmptyStringNullInTextFieldsCommand: CleanEmptyStringNullInTextFieldsCommand,
|
||||
protected readonly renameIndexNameCommand: RenameIndexNameCommand,
|
||||
|
||||
@@ -66,7 +64,6 @@ export class UpgradeCommand extends UpgradeCommandRunner {
|
||||
this.updateRoleTargetsUniqueConstraintMigrationCommand,
|
||||
this.backfillPageLayoutUniversalIdentifiersCommand,
|
||||
this.migrateStandardInvalidEntitiesCommand,
|
||||
this.backfillViewMainGroupByFieldMetadataIdCommand,
|
||||
this.cleanEmptyStringNullInTextFieldsCommand,
|
||||
this.renameIndexNameCommand,
|
||||
];
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import { type MigrationInterface, type QueryRunner } from 'typeorm';
|
||||
|
||||
export class RemoveFieldMetadataIdInViewGroup1765808791153
|
||||
implements MigrationInterface
|
||||
{
|
||||
name = 'RemoveFieldMetadataIdInViewGroup1765808791153';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."viewGroup" DROP CONSTRAINT "FK_b3aa7ec58cdd9e83729f2232591"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."viewGroup" DROP COLUMN "fieldMetadataId"`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."viewGroup" ADD "fieldMetadataId" uuid`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."viewGroup" ADD CONSTRAINT "FK_b3aa7ec58cdd9e83729f2232591" FOREIGN KEY ("fieldMetadataId") REFERENCES "core"."fieldMetadata"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
||||
);
|
||||
}
|
||||
}
|
||||
-1
@@ -26,7 +26,6 @@ describe('getConflictingFields', () => {
|
||||
universalIdentifier: overrides.id,
|
||||
viewFieldIds: [],
|
||||
viewFilterIds: [],
|
||||
viewGroupIds: [],
|
||||
kanbanAggregateOperationViewIds: [],
|
||||
calendarViewIds: [],
|
||||
applicationId: null,
|
||||
|
||||
-4
@@ -26,7 +26,6 @@ const mockFieldMetadatas: FlatFieldMetadata[] = [
|
||||
universalIdentifier: 'name-id',
|
||||
viewFieldIds: [],
|
||||
viewFilterIds: [],
|
||||
viewGroupIds: [],
|
||||
kanbanAggregateOperationViewIds: [],
|
||||
calendarViewIds: [],
|
||||
applicationId: null,
|
||||
@@ -48,7 +47,6 @@ const mockFieldMetadatas: FlatFieldMetadata[] = [
|
||||
universalIdentifier: 'emails-id',
|
||||
viewFieldIds: [],
|
||||
viewFilterIds: [],
|
||||
viewGroupIds: [],
|
||||
kanbanAggregateOperationViewIds: [],
|
||||
calendarViewIds: [],
|
||||
applicationId: null,
|
||||
@@ -71,7 +69,6 @@ const mockFieldMetadatas: FlatFieldMetadata[] = [
|
||||
universalIdentifier: 'linkedinLink-id',
|
||||
viewFieldIds: [],
|
||||
viewFilterIds: [],
|
||||
viewGroupIds: [],
|
||||
kanbanAggregateOperationViewIds: [],
|
||||
calendarViewIds: [],
|
||||
applicationId: null,
|
||||
@@ -90,7 +87,6 @@ const mockFieldMetadatas: FlatFieldMetadata[] = [
|
||||
universalIdentifier: 'jobTitle-id',
|
||||
viewFieldIds: [],
|
||||
viewFilterIds: [],
|
||||
viewGroupIds: [],
|
||||
kanbanAggregateOperationViewIds: [],
|
||||
calendarViewIds: [],
|
||||
applicationId: null,
|
||||
|
||||
-1
@@ -32,7 +32,6 @@ describe('buildColumnsToSelect', () => {
|
||||
universalIdentifier: overrides.id,
|
||||
viewFieldIds: [],
|
||||
viewFilterIds: [],
|
||||
viewGroupIds: [],
|
||||
kanbanAggregateOperationViewIds: [],
|
||||
calendarViewIds: [],
|
||||
applicationId: null,
|
||||
|
||||
-1
@@ -23,7 +23,6 @@ describe('getAllSelectableFields', () => {
|
||||
universalIdentifier: overrides.id,
|
||||
viewFieldIds: [],
|
||||
viewFilterIds: [],
|
||||
viewGroupIds: [],
|
||||
kanbanAggregateOperationViewIds: [],
|
||||
calendarViewIds: [],
|
||||
applicationId: null,
|
||||
|
||||
-1
@@ -27,7 +27,6 @@ describe('computeCursorArgFilter', () => {
|
||||
universalIdentifier: overrides.id,
|
||||
viewFieldIds: [],
|
||||
viewFilterIds: [],
|
||||
viewGroupIds: [],
|
||||
kanbanAggregateOperationViewIds: [],
|
||||
calendarViewIds: [],
|
||||
applicationId: null,
|
||||
|
||||
-4
@@ -30,7 +30,6 @@ import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadat
|
||||
import { FieldPermissionEntity } from 'src/engine/metadata-modules/object-permission/field-permission/field-permission.entity';
|
||||
import { ViewFieldEntity } from 'src/engine/metadata-modules/view-field/entities/view-field.entity';
|
||||
import { ViewFilterEntity } from 'src/engine/metadata-modules/view-filter/entities/view-filter.entity';
|
||||
import { ViewGroupEntity } from 'src/engine/metadata-modules/view-group/entities/view-group.entity';
|
||||
import { ViewEntity } from 'src/engine/metadata-modules/view/entities/view.entity';
|
||||
|
||||
@Entity('fieldMetadata')
|
||||
@@ -201,9 +200,6 @@ export class FieldMetadataEntity<
|
||||
@OneToMany(() => ViewFilterEntity, (viewFilter) => viewFilter.fieldMetadata)
|
||||
viewFilters: Relation<ViewFilterEntity[]>;
|
||||
|
||||
@OneToMany(() => ViewGroupEntity, (viewGroup) => viewGroup.fieldMetadata)
|
||||
viewGroups: Relation<ViewGroupEntity[]>;
|
||||
|
||||
@OneToMany(
|
||||
() => ViewEntity,
|
||||
(view) => view.kanbanAggregateOperationFieldMetadata,
|
||||
|
||||
-1
@@ -15,7 +15,6 @@ export const FIELD_METADATA_RELATION_PROPERTIES = [
|
||||
'kanbanAggregateOperationViews',
|
||||
'calendarViews',
|
||||
'mainGroupByFieldMetadataViews',
|
||||
'viewGroups',
|
||||
] as const satisfies (keyof FieldMetadataEntity)[];
|
||||
|
||||
export type FieldMetadataEntityRelationProperties =
|
||||
|
||||
-1
@@ -79,7 +79,6 @@ export const recomputeViewGroupsOnEnumFlatFieldMetadataIsNullableUpdate = ({
|
||||
deletedAt: null,
|
||||
viewId,
|
||||
applicationId: toFlatFieldMetadata.applicationId,
|
||||
fieldMetadataId: fromFlatFieldMetadata.id,
|
||||
});
|
||||
} else if (isDefined(emptyValueFlatViewGroup)) {
|
||||
sideEffectResult.flatViewGroupsToDelete.push(emptyValueFlatViewGroup);
|
||||
|
||||
-1
@@ -4,5 +4,4 @@ export const FLAT_VIEW_GROUP_EDITABLE_PROPERTIES = [
|
||||
'isVisible',
|
||||
'fieldValue',
|
||||
'position',
|
||||
'fieldMetadataId',
|
||||
] as const satisfies (keyof FlatViewGroup)[];
|
||||
|
||||
-1
@@ -58,7 +58,6 @@ export const computeFlatViewGroupsOnViewCreate = ({
|
||||
|
||||
flatViewGroups.push({
|
||||
id: emptyGroupId,
|
||||
fieldMetadataId: mainGroupByFieldMetadata.id,
|
||||
viewId: flatViewToCreateId,
|
||||
workspaceId: mainGroupByFieldMetadata.workspaceId,
|
||||
createdAt,
|
||||
|
||||
-3
@@ -8,12 +8,10 @@ export const fromCreateViewGroupInputToFlatViewGroupToCreate = ({
|
||||
createViewGroupInput: rawCreateViewGroupInput,
|
||||
workspaceId,
|
||||
workspaceCustomApplicationId,
|
||||
mainGroupByFieldMetadataId,
|
||||
}: {
|
||||
createViewGroupInput: CreateViewGroupInput;
|
||||
workspaceId: string;
|
||||
workspaceCustomApplicationId: string;
|
||||
mainGroupByFieldMetadataId: string;
|
||||
}): FlatViewGroup => {
|
||||
const { viewId, ...createViewGroupInput } =
|
||||
trimAndRemoveDuplicatedWhitespacesFromObjectStringProperties(
|
||||
@@ -26,7 +24,6 @@ export const fromCreateViewGroupInputToFlatViewGroupToCreate = ({
|
||||
|
||||
return {
|
||||
id: viewGroupId,
|
||||
fieldMetadataId: mainGroupByFieldMetadataId, // Mandatory because non-nullable until we completely remove it
|
||||
viewId,
|
||||
workspaceId,
|
||||
createdAt: createdAt,
|
||||
|
||||
-10
@@ -14,7 +14,6 @@ import {
|
||||
import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/interfaces/syncable-entity.interface';
|
||||
|
||||
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
||||
import { ViewEntity } from 'src/engine/metadata-modules/view/entities/view.entity';
|
||||
|
||||
@Entity({ name: 'viewGroup', schema: 'core' })
|
||||
@@ -29,15 +28,6 @@ export class ViewGroupEntity
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@Column({ nullable: false, type: 'uuid' })
|
||||
fieldMetadataId: string;
|
||||
|
||||
@ManyToOne(() => FieldMetadataEntity, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'fieldMetadataId' })
|
||||
fieldMetadata: Relation<FieldMetadataEntity>;
|
||||
|
||||
@Column({ nullable: false, default: true })
|
||||
isVisible: boolean;
|
||||
|
||||
|
||||
-1
@@ -101,7 +101,6 @@ export class ViewGroupService {
|
||||
createViewGroupInput,
|
||||
workspaceId,
|
||||
workspaceCustomApplicationId: workspaceCustomFlatApplication.id,
|
||||
mainGroupByFieldMetadataId,
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
-9
@@ -23,7 +23,6 @@ describe('computeRelationConnectQueryConfigs', () => {
|
||||
universalIdentifier: 'person-id-field-id',
|
||||
viewFieldIds: [],
|
||||
viewFilterIds: [],
|
||||
viewGroupIds: [],
|
||||
kanbanAggregateOperationViewIds: [],
|
||||
calendarViewIds: [],
|
||||
applicationId: null,
|
||||
@@ -41,7 +40,6 @@ describe('computeRelationConnectQueryConfigs', () => {
|
||||
universalIdentifier: 'person-name-field-id',
|
||||
viewFieldIds: [],
|
||||
viewFilterIds: [],
|
||||
viewGroupIds: [],
|
||||
kanbanAggregateOperationViewIds: [],
|
||||
calendarViewIds: [],
|
||||
applicationId: null,
|
||||
@@ -59,7 +57,6 @@ describe('computeRelationConnectQueryConfigs', () => {
|
||||
universalIdentifier: 'person-company-1-field-id',
|
||||
viewFieldIds: [],
|
||||
viewFilterIds: [],
|
||||
viewGroupIds: [],
|
||||
kanbanAggregateOperationViewIds: [],
|
||||
calendarViewIds: [],
|
||||
applicationId: null,
|
||||
@@ -83,7 +80,6 @@ describe('computeRelationConnectQueryConfigs', () => {
|
||||
universalIdentifier: 'person-company-2-field-id',
|
||||
viewFieldIds: [],
|
||||
viewFilterIds: [],
|
||||
viewGroupIds: [],
|
||||
kanbanAggregateOperationViewIds: [],
|
||||
calendarViewIds: [],
|
||||
applicationId: null,
|
||||
@@ -110,7 +106,6 @@ describe('computeRelationConnectQueryConfigs', () => {
|
||||
universalIdentifier: 'company-id-field-id',
|
||||
viewFieldIds: [],
|
||||
viewFilterIds: [],
|
||||
viewGroupIds: [],
|
||||
kanbanAggregateOperationViewIds: [],
|
||||
calendarViewIds: [],
|
||||
applicationId: null,
|
||||
@@ -128,7 +123,6 @@ describe('computeRelationConnectQueryConfigs', () => {
|
||||
universalIdentifier: 'company-name-field-id',
|
||||
viewFieldIds: [],
|
||||
viewFilterIds: [],
|
||||
viewGroupIds: [],
|
||||
kanbanAggregateOperationViewIds: [],
|
||||
calendarViewIds: [],
|
||||
applicationId: null,
|
||||
@@ -146,7 +140,6 @@ describe('computeRelationConnectQueryConfigs', () => {
|
||||
universalIdentifier: 'company-description-field-id',
|
||||
viewFieldIds: [],
|
||||
viewFilterIds: [],
|
||||
viewGroupIds: [],
|
||||
kanbanAggregateOperationViewIds: [],
|
||||
calendarViewIds: [],
|
||||
applicationId: null,
|
||||
@@ -164,7 +157,6 @@ describe('computeRelationConnectQueryConfigs', () => {
|
||||
universalIdentifier: 'company-domain-name-field-id',
|
||||
viewFieldIds: [],
|
||||
viewFilterIds: [],
|
||||
viewGroupIds: [],
|
||||
kanbanAggregateOperationViewIds: [],
|
||||
calendarViewIds: [],
|
||||
applicationId: null,
|
||||
@@ -182,7 +174,6 @@ describe('computeRelationConnectQueryConfigs', () => {
|
||||
universalIdentifier: 'company-address-field-id',
|
||||
viewFieldIds: [],
|
||||
viewFilterIds: [],
|
||||
viewGroupIds: [],
|
||||
kanbanAggregateOperationViewIds: [],
|
||||
calendarViewIds: [],
|
||||
applicationId: null,
|
||||
|
||||
-1
@@ -60,7 +60,6 @@ describe('getFieldMetadataIdToColumnNamesMap', () => {
|
||||
universalIdentifier: id,
|
||||
viewFieldIds: [],
|
||||
viewFilterIds: [],
|
||||
viewGroupIds: [],
|
||||
kanbanAggregateOperationViewIds: [],
|
||||
calendarViewIds: [],
|
||||
mainGroupByFieldMetadataViewIds: [],
|
||||
|
||||
-5
@@ -14,7 +14,6 @@ export const computeStandardOpportunityViewGroups = (
|
||||
context: {
|
||||
viewName: 'byStage',
|
||||
viewGroupName: 'new',
|
||||
fieldName: 'stage',
|
||||
isVisible: true,
|
||||
fieldValue: 'NEW',
|
||||
position: 0,
|
||||
@@ -26,7 +25,6 @@ export const computeStandardOpportunityViewGroups = (
|
||||
context: {
|
||||
viewName: 'byStage',
|
||||
viewGroupName: 'screening',
|
||||
fieldName: 'stage',
|
||||
isVisible: true,
|
||||
fieldValue: 'SCREENING',
|
||||
position: 1,
|
||||
@@ -38,7 +36,6 @@ export const computeStandardOpportunityViewGroups = (
|
||||
context: {
|
||||
viewName: 'byStage',
|
||||
viewGroupName: 'meeting',
|
||||
fieldName: 'stage',
|
||||
isVisible: true,
|
||||
fieldValue: 'MEETING',
|
||||
position: 2,
|
||||
@@ -50,7 +47,6 @@ export const computeStandardOpportunityViewGroups = (
|
||||
context: {
|
||||
viewName: 'byStage',
|
||||
viewGroupName: 'proposal',
|
||||
fieldName: 'stage',
|
||||
isVisible: true,
|
||||
fieldValue: 'PROPOSAL',
|
||||
position: 3,
|
||||
@@ -62,7 +58,6 @@ export const computeStandardOpportunityViewGroups = (
|
||||
context: {
|
||||
viewName: 'byStage',
|
||||
viewGroupName: 'customer',
|
||||
fieldName: 'stage',
|
||||
isVisible: true,
|
||||
fieldValue: 'CUSTOMER',
|
||||
position: 4,
|
||||
|
||||
-7
@@ -14,7 +14,6 @@ export const computeStandardTaskViewGroups = (
|
||||
context: {
|
||||
viewName: 'assignedToMe',
|
||||
viewGroupName: 'todo',
|
||||
fieldName: 'status',
|
||||
isVisible: true,
|
||||
fieldValue: 'TODO',
|
||||
position: 0,
|
||||
@@ -26,7 +25,6 @@ export const computeStandardTaskViewGroups = (
|
||||
context: {
|
||||
viewName: 'assignedToMe',
|
||||
viewGroupName: 'inProgress',
|
||||
fieldName: 'status',
|
||||
isVisible: true,
|
||||
fieldValue: 'IN_PROGRESS',
|
||||
position: 1,
|
||||
@@ -38,7 +36,6 @@ export const computeStandardTaskViewGroups = (
|
||||
context: {
|
||||
viewName: 'assignedToMe',
|
||||
viewGroupName: 'done',
|
||||
fieldName: 'status',
|
||||
isVisible: true,
|
||||
fieldValue: 'DONE',
|
||||
position: 2,
|
||||
@@ -50,7 +47,6 @@ export const computeStandardTaskViewGroups = (
|
||||
context: {
|
||||
viewName: 'assignedToMe',
|
||||
viewGroupName: 'empty',
|
||||
fieldName: 'status',
|
||||
isVisible: true,
|
||||
fieldValue: '',
|
||||
position: 3,
|
||||
@@ -62,7 +58,6 @@ export const computeStandardTaskViewGroups = (
|
||||
context: {
|
||||
viewName: 'byStatus',
|
||||
viewGroupName: 'todo',
|
||||
fieldName: 'status',
|
||||
isVisible: true,
|
||||
fieldValue: 'TODO',
|
||||
position: 0,
|
||||
@@ -74,7 +69,6 @@ export const computeStandardTaskViewGroups = (
|
||||
context: {
|
||||
viewName: 'byStatus',
|
||||
viewGroupName: 'inProgress',
|
||||
fieldName: 'status',
|
||||
isVisible: true,
|
||||
fieldValue: 'IN_PROGRESS',
|
||||
position: 1,
|
||||
@@ -86,7 +80,6 @@ export const computeStandardTaskViewGroups = (
|
||||
context: {
|
||||
viewName: 'byStatus',
|
||||
viewGroupName: 'done',
|
||||
fieldName: 'status',
|
||||
isVisible: true,
|
||||
fieldValue: 'DONE',
|
||||
position: 2,
|
||||
|
||||
+2
-13
@@ -3,19 +3,17 @@ import { v4 } from 'uuid';
|
||||
|
||||
import { type FlatViewGroup } from 'src/engine/metadata-modules/flat-view-group/types/flat-view-group.type';
|
||||
import { STANDARD_OBJECTS } from 'src/engine/workspace-manager/twenty-standard-application/constants/standard-object.constant';
|
||||
import { type AllStandardObjectFieldName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-field-name.type';
|
||||
import { type AllStandardObjectName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-name.type';
|
||||
import { type AllStandardObjectViewGroupName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-view-group-name.type';
|
||||
import { type AllStandardObjectViewName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-object-view-name.type';
|
||||
import { type StandardBuilderArgs } from 'src/engine/workspace-manager/twenty-standard-application/types/metadata-standard-buillder-args.type';
|
||||
|
||||
export type CreateStandardViewGroupOptions<
|
||||
type CreateStandardViewGroupOptions<
|
||||
O extends AllStandardObjectName,
|
||||
V extends AllStandardObjectViewName<O>,
|
||||
> = {
|
||||
viewName: V;
|
||||
viewGroupName: AllStandardObjectViewGroupName<O, V>;
|
||||
fieldName: AllStandardObjectFieldName<O>;
|
||||
isVisible: boolean;
|
||||
fieldValue: string;
|
||||
position: number;
|
||||
@@ -35,14 +33,7 @@ export const createStandardViewGroupFlatMetadata = <
|
||||
>({
|
||||
workspaceId,
|
||||
objectName,
|
||||
context: {
|
||||
viewName,
|
||||
viewGroupName,
|
||||
fieldName,
|
||||
isVisible,
|
||||
fieldValue,
|
||||
position,
|
||||
},
|
||||
context: { viewName, viewGroupName, isVisible, fieldValue, position },
|
||||
standardObjectMetadataRelatedEntityIds,
|
||||
twentyStandardApplicationId,
|
||||
now,
|
||||
@@ -66,8 +57,6 @@ export const createStandardViewGroupFlatMetadata = <
|
||||
workspaceId,
|
||||
viewId:
|
||||
standardObjectMetadataRelatedEntityIds[objectName].views[viewName].id,
|
||||
fieldMetadataId:
|
||||
standardObjectMetadataRelatedEntityIds[objectName].fields[fieldName].id,
|
||||
isVisible,
|
||||
fieldValue,
|
||||
position,
|
||||
|
||||
@@ -24,7 +24,6 @@ export const getMockFieldMetadataEntity = <
|
||||
mainGroupByFieldMetadataViews: [],
|
||||
viewFilters: [],
|
||||
viewFields: [],
|
||||
viewGroups: [],
|
||||
kanbanAggregateOperationViews: [],
|
||||
morphId: null,
|
||||
fieldPermissions: [],
|
||||
|
||||
Reference in New Issue
Block a user