Skip to content

The open alternative to Salesforce, designed for AI.

2.2 KB
Raw Blame
import {
  Field,
  Float,
  HideField,
  ObjectType,
  registerEnumType,
} from '@nestjs/graphql';
import { PageLayoutTabLayoutMode } from 'twenty-shared/types';

import { type AuthoredOverrides } from 'src/engine/metadata-modules/overrides/types/authored-overrides.type';
import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';
import { type PageLayoutTabOverrides } from 'src/engine/metadata-modules/page-layout-tab/entities/page-layout-tab.entity';
import { PageLayoutWidgetDTO } from 'src/engine/metadata-modules/page-layout-widget/dtos/page-layout-widget.dto';

registerEnumType(PageLayoutTabLayoutMode, {
  name: 'PageLayoutTabLayoutMode',
  valuesMap: {
    CANVAS: {
      deprecationReason:
        'Use VERTICAL_LIST with TAB_VIEWPORT widget height behavior.',
    },
  },
});

@ObjectType('PageLayoutTab')
export class PageLayoutTabDTO {
  @Field(() => UUIDScalarType)
  id: string;

  @Field(() => UUIDScalarType, { nullable: false })
  universalIdentifier: string;

  @Field({ nullable: false })
  isSystemSideEffect: boolean;

  @Field(() => UUIDScalarType, { nullable: false })
  applicationId: string;

  @Field({ nullable: false })
  title: string;

  @Field(() => Float, { nullable: false, defaultValue: 0 })
  position: number;

  @Field(() => UUIDScalarType, { nullable: false })
  pageLayoutId: string;

  @Field(() => [PageLayoutWidgetDTO], { nullable: true })
  widgets?: PageLayoutWidgetDTO[] | null;

  @Field(() => String, { nullable: true })
  icon?: string | null;

  @Field(() => PageLayoutTabLayoutMode, {
    nullable: true, // Not nullable in the database, but we need to make it nullable here until the frontend consumes the new type
    defaultValue: PageLayoutTabLayoutMode.GRID,
  })
  layoutMode: PageLayoutTabLayoutMode;

  @Field()
  createdAt: Date;

  @Field()
  updatedAt: Date;

  @Field(() => Boolean, { nullable: false })
  isActive: boolean;

  @Field(() => Date, { nullable: true })
  deletedAt?: Date | null;

  @Field(() => Boolean, {
    nullable: true,
    deprecationReason: 'isOverridden is deprecated',
  })
  isOverridden?: boolean;

  @HideField()
  overrides?: AuthoredOverrides<PageLayoutTabOverrides> | null;
}