Should be merged once https://github.com/twentyhq/twenty/pull/16206 has been released + command run to prod In this PR - Remove usage of viewGroup.fieldMetadataId, both in BE and FE states. - But we still need to properly populate it until we fully remove viewGroup.fieldMetadataId from db and ORM entity (upcoming 3rd PR out of 3). fieldMetadataId was removed from CoreViewGroup type and CreateViewGroupInput and is determined BE-side based on the associated view's mainGroupByFieldMetadataId. **I expect this means a downtime on viewGroup creation, until both FE and BE are deployed and cache is flushed.** This seems acceptable to me as it only regards viewGroup creation. - this information is replaced by view.mainGroupByFieldMetadataID - Handle view group creation, update and deletion in the BE as a side-effect of a view creation, update or deletion. Optimistic effects are still used - Add validation at view creation or update regarding mainGroupByFieldMetadata Left to do in 3rd PR - Remove viewGroup.fieldMetadataId from db and ORM entity - Restore feature allowing to update an existing grouped view's group by field (already OK on BE side but need to rebuild FE optimistic)
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import { createOneCoreView } from 'test/integration/metadata/suites/view/utils/create-one-core-view.util';
|
|
|
|
import { type CreateViewInput } from 'src/engine/metadata-modules/view/dtos/inputs/create-view.input';
|
|
import { type ViewEntity } from 'src/engine/metadata-modules/view/entities/view.entity';
|
|
|
|
import { createViewData } from './view-data-factory.util';
|
|
|
|
export const createTestViewWithGraphQL = async (
|
|
overrides: Partial<ViewEntity> = {},
|
|
): Promise<ViewEntity> => {
|
|
const viewData = createViewData(overrides);
|
|
const input: CreateViewInput = {
|
|
name: viewData.name,
|
|
objectMetadataId: viewData.objectMetadataId as string,
|
|
icon: viewData.icon,
|
|
type: viewData.type,
|
|
position: viewData.position,
|
|
mainGroupByFieldMetadataId:
|
|
viewData.mainGroupByFieldMetadataId ?? undefined,
|
|
isCompact: viewData.isCompact,
|
|
openRecordIn: viewData.openRecordIn,
|
|
visibility: viewData.visibility,
|
|
};
|
|
|
|
const { data, errors } = await createOneCoreView({
|
|
input,
|
|
expectToFail: false,
|
|
});
|
|
|
|
if (errors) {
|
|
throw new Error(`Failed to create test view: ${JSON.stringify(errors)}`);
|
|
}
|
|
|
|
if (!data) {
|
|
throw new Error('No data returned from createTestViewWithGraphQL');
|
|
}
|
|
|
|
return data.createCoreView;
|
|
};
|