Skip to content

The open alternative to Salesforce, designed for AI.

795 B
Raw Blame
import { PRERENDERABLE_PAGE_LAYOUT_WIDGET_TYPES } from '@/page-layout/constants/PrerenderablePageLayoutWidgetTypes';
import { type PageLayoutTab } from '@/page-layout/types/PageLayoutTab';
import {
  PageLayoutTabLayoutMode,
  PageLayoutType,
} from '~/generated-metadata/graphql';

export const shouldPrerenderPageLayoutTab = ({
  tab,
  pageLayoutType,
}: {
  tab: PageLayoutTab;
  pageLayoutType: PageLayoutType;
}): boolean => {
  if (pageLayoutType !== PageLayoutType.RECORD_PAGE) {
    return false;
  }

  // Grid tabs size widgets from the container, which measures zero while hidden.
  if (tab.layoutMode !== PageLayoutTabLayoutMode.VERTICAL_LIST) {
    return false;
  }

  return tab.widgets.every((widget) =>
    PRERENDERABLE_PAGE_LAYOUT_WIDGET_TYPES.includes(widget.type),
  );
};