Move is active to fe (#19649)
## Context Moving isActive filtering to the frontend for page layout tabs and widgets, hiding inactive entities from the UI while keeping them in state for future reactivation Next we will implement deactivated standard tab re-activation during tab creation (cc @Devessier) <img width="234" height="303" alt="📋 Menu (Slots)" src="https://github.com/user-attachments/assets/17a25ac6-55e2-4778-b7f0-e7554ed69704" />
This commit is contained in:
@@ -11,6 +11,7 @@ describe('addWidgetToTab', () => {
|
||||
const mockWidget: PageLayoutWidget = {
|
||||
__typename: 'PageLayoutWidget',
|
||||
id: 'widget-1',
|
||||
isActive: true,
|
||||
pageLayoutTabId: 'tab-1',
|
||||
title: 'Test Widget',
|
||||
type: WidgetType.GRAPH,
|
||||
@@ -31,6 +32,7 @@ describe('addWidgetToTab', () => {
|
||||
{
|
||||
id: 'tab-1',
|
||||
applicationId: '',
|
||||
isActive: true,
|
||||
title: 'Tab 1',
|
||||
position: 0,
|
||||
pageLayoutId: 'layout-1',
|
||||
@@ -42,6 +44,7 @@ describe('addWidgetToTab', () => {
|
||||
{
|
||||
id: 'tab-2',
|
||||
applicationId: '',
|
||||
isActive: true,
|
||||
title: 'Tab 2',
|
||||
position: 1,
|
||||
pageLayoutId: 'layout-1',
|
||||
|
||||
+2
@@ -12,6 +12,7 @@ describe('convertLayoutsToWidgets', () => {
|
||||
const mockWidgets: PageLayoutWidget[] = [
|
||||
{
|
||||
id: 'widget-1',
|
||||
isActive: true,
|
||||
pageLayoutTabId: 'tab-1',
|
||||
title: 'Widget 1',
|
||||
type: WidgetType.GRAPH,
|
||||
@@ -34,6 +35,7 @@ describe('convertLayoutsToWidgets', () => {
|
||||
},
|
||||
{
|
||||
id: 'widget-2',
|
||||
isActive: true,
|
||||
pageLayoutTabId: 'tab-1',
|
||||
title: 'Widget 2',
|
||||
type: WidgetType.GRAPH,
|
||||
|
||||
+5
@@ -20,6 +20,7 @@ describe('convertPageLayoutToTabLayouts', () => {
|
||||
{
|
||||
id: 'tab-1',
|
||||
applicationId: '',
|
||||
isActive: true,
|
||||
title: 'Tab 1',
|
||||
position: 0,
|
||||
pageLayoutId: 'page-layout-1',
|
||||
@@ -27,6 +28,7 @@ describe('convertPageLayoutToTabLayouts', () => {
|
||||
{
|
||||
__typename: 'PageLayoutWidget',
|
||||
id: 'widget-1',
|
||||
isActive: true,
|
||||
pageLayoutTabId: 'tab-1',
|
||||
title: 'Widget 1',
|
||||
type: WidgetType.GRAPH,
|
||||
@@ -45,6 +47,7 @@ describe('convertPageLayoutToTabLayouts', () => {
|
||||
{
|
||||
__typename: 'PageLayoutWidget',
|
||||
id: 'widget-2',
|
||||
isActive: true,
|
||||
pageLayoutTabId: 'tab-1',
|
||||
title: 'Widget 2',
|
||||
type: WidgetType.GRAPH,
|
||||
@@ -99,6 +102,7 @@ describe('convertPageLayoutToTabLayouts', () => {
|
||||
{
|
||||
id: 'tab-1',
|
||||
applicationId: '',
|
||||
isActive: true,
|
||||
title: 'Tab 1',
|
||||
position: 0,
|
||||
pageLayoutId: 'page-layout-1',
|
||||
@@ -106,6 +110,7 @@ describe('convertPageLayoutToTabLayouts', () => {
|
||||
{
|
||||
__typename: 'PageLayoutWidget',
|
||||
id: 'rich-text-widget',
|
||||
isActive: true,
|
||||
pageLayoutTabId: 'tab-1',
|
||||
title: 'Rich Text',
|
||||
type: WidgetType.STANDALONE_RICH_TEXT,
|
||||
|
||||
+1
@@ -23,6 +23,7 @@ const createMockWidget = (
|
||||
},
|
||||
): PageLayoutWidget => ({
|
||||
id: 'widget-1',
|
||||
isActive: true,
|
||||
type: WidgetType.GRAPH,
|
||||
title: 'Test',
|
||||
objectMetadataId: null,
|
||||
|
||||
+1
@@ -12,6 +12,7 @@ describe('filterVisibleWidgets', () => {
|
||||
): PageLayoutTab['widgets'][0] => ({
|
||||
__typename: 'PageLayoutWidget',
|
||||
id,
|
||||
isActive: true,
|
||||
pageLayoutTabId: 'tab-1',
|
||||
title: `Widget ${id}`,
|
||||
type: WidgetType.FIELDS,
|
||||
|
||||
+1
@@ -5,6 +5,7 @@ describe('getPageLayoutTabListInitialActiveTabId', () => {
|
||||
const createMockTab = (id: string): PageLayoutTab => ({
|
||||
id,
|
||||
applicationId: '',
|
||||
isActive: true,
|
||||
pageLayoutId: 'page-layout-1',
|
||||
title: `Tab ${id}`,
|
||||
position: 0,
|
||||
|
||||
+1
@@ -10,6 +10,7 @@ describe('getTabsByDisplayMode', () => {
|
||||
const createMockTab = (id: string): PageLayoutTab => ({
|
||||
id,
|
||||
applicationId: '',
|
||||
isActive: true,
|
||||
pageLayoutId: 'page-layout-1',
|
||||
title: `Tab ${id}`,
|
||||
position: 0,
|
||||
|
||||
+2
@@ -12,6 +12,7 @@ describe('getTabsWithVisibleWidgets', () => {
|
||||
): PageLayoutTab['widgets'][0] => ({
|
||||
__typename: 'PageLayoutWidget',
|
||||
id,
|
||||
isActive: true,
|
||||
pageLayoutTabId: 'tab-1',
|
||||
title: `Widget ${id}`,
|
||||
type: WidgetType.FIELDS,
|
||||
@@ -41,6 +42,7 @@ describe('getTabsWithVisibleWidgets', () => {
|
||||
__typename: 'PageLayoutTab',
|
||||
applicationId: '',
|
||||
id,
|
||||
isActive: true,
|
||||
pageLayoutId: 'page-layout-1',
|
||||
title: `Tab ${id}`,
|
||||
position: 0,
|
||||
|
||||
+2
@@ -10,6 +10,7 @@ import {
|
||||
describe('prepareGridLayoutItemsWithPlaceholders', () => {
|
||||
const createMockWidget = (id: string): PageLayoutWidget => ({
|
||||
id,
|
||||
isActive: true,
|
||||
pageLayoutTabId: 'tab-1',
|
||||
title: `Test Widget ${id}`,
|
||||
type: WidgetType.GRAPH,
|
||||
@@ -215,6 +216,7 @@ describe('prepareGridLayoutItemsWithPlaceholders', () => {
|
||||
expect(resultWidget.createdAt).toBe(widget.createdAt);
|
||||
expect(resultWidget.updatedAt).toBe(widget.updatedAt);
|
||||
expect(resultWidget.deletedAt).toBe(widget.deletedAt);
|
||||
expect(resultWidget.isActive).toBe(widget.isActive);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
+5
@@ -12,6 +12,7 @@ describe('removeWidgetFromTab', () => {
|
||||
{
|
||||
id: 'tab-1',
|
||||
applicationId: '',
|
||||
isActive: true,
|
||||
title: 'Tab 1',
|
||||
position: 0,
|
||||
pageLayoutId: 'layout-1',
|
||||
@@ -19,6 +20,7 @@ describe('removeWidgetFromTab', () => {
|
||||
{
|
||||
__typename: 'PageLayoutWidget' as const,
|
||||
id: 'widget-1',
|
||||
isActive: true,
|
||||
pageLayoutTabId: 'tab-1',
|
||||
title: 'Widget 1',
|
||||
type: WidgetType.GRAPH,
|
||||
@@ -37,6 +39,7 @@ describe('removeWidgetFromTab', () => {
|
||||
{
|
||||
__typename: 'PageLayoutWidget' as const,
|
||||
id: 'widget-2',
|
||||
isActive: true,
|
||||
pageLayoutTabId: 'tab-1',
|
||||
title: 'Widget 2',
|
||||
type: WidgetType.GRAPH,
|
||||
@@ -62,6 +65,7 @@ describe('removeWidgetFromTab', () => {
|
||||
{
|
||||
id: 'tab-2',
|
||||
applicationId: '',
|
||||
isActive: true,
|
||||
title: 'Tab 2',
|
||||
position: 1,
|
||||
pageLayoutId: 'layout-1',
|
||||
@@ -69,6 +73,7 @@ describe('removeWidgetFromTab', () => {
|
||||
{
|
||||
__typename: 'PageLayoutWidget' as const,
|
||||
id: 'widget-3',
|
||||
isActive: true,
|
||||
pageLayoutTabId: 'tab-2',
|
||||
title: 'Widget 3',
|
||||
type: WidgetType.IFRAME,
|
||||
|
||||
@@ -28,6 +28,7 @@ export const createDefaultFieldWidget = ({
|
||||
id,
|
||||
pageLayoutTabId,
|
||||
title,
|
||||
isActive: true,
|
||||
type: WidgetType.FIELD,
|
||||
configuration: {
|
||||
__typename: 'FieldConfiguration',
|
||||
|
||||
@@ -23,6 +23,7 @@ export const createDefaultFieldsWidget = ({
|
||||
id,
|
||||
pageLayoutTabId,
|
||||
title: 'Fields',
|
||||
isActive: true,
|
||||
type: WidgetType.FIELDS,
|
||||
configuration: {
|
||||
__typename: 'FieldsConfiguration',
|
||||
|
||||
+1
@@ -18,6 +18,7 @@ export const createDefaultFrontComponentWidget = (
|
||||
id,
|
||||
pageLayoutTabId,
|
||||
title,
|
||||
isActive: true,
|
||||
type: WidgetType.FRONT_COMPONENT,
|
||||
configuration: {
|
||||
__typename: 'FrontComponentConfiguration',
|
||||
|
||||
@@ -72,6 +72,7 @@ export const createDefaultGraphWidget = ({
|
||||
id,
|
||||
pageLayoutTabId,
|
||||
title,
|
||||
isActive: true,
|
||||
type: WidgetType.GRAPH,
|
||||
configuration,
|
||||
gridPosition,
|
||||
|
||||
@@ -19,6 +19,7 @@ export const createDefaultIframeWidget = (
|
||||
id,
|
||||
pageLayoutTabId,
|
||||
title,
|
||||
isActive: true,
|
||||
type: WidgetType.IFRAME,
|
||||
configuration: {
|
||||
configurationType: WidgetConfigurationType.IFRAME,
|
||||
|
||||
@@ -24,6 +24,7 @@ export const createDefaultRecordTableWidget = ({
|
||||
id,
|
||||
pageLayoutTabId,
|
||||
title,
|
||||
isActive: true,
|
||||
type: WidgetType.RECORD_TABLE,
|
||||
configuration: {
|
||||
configurationType: WidgetConfigurationType.RECORD_TABLE,
|
||||
|
||||
+1
@@ -19,6 +19,7 @@ export const createDefaultStandaloneRichTextWidget = (
|
||||
id,
|
||||
pageLayoutTabId,
|
||||
title: 'Untitled Rich Text',
|
||||
isActive: true,
|
||||
type: WidgetType.STANDALONE_RICH_TEXT,
|
||||
configuration: {
|
||||
configurationType: WidgetConfigurationType.STANDALONE_RICH_TEXT,
|
||||
|
||||
@@ -15,13 +15,15 @@ export const getTabsWithVisibleWidgets = ({
|
||||
isInSidePanel,
|
||||
isEditMode,
|
||||
}: GetTabsWithVisibleWidgetsParams): PageLayoutTab[] => {
|
||||
const activeTabs = tabs.filter((tab) => tab.isActive);
|
||||
|
||||
if (isEditMode) {
|
||||
return tabs;
|
||||
return activeTabs;
|
||||
}
|
||||
|
||||
const context = buildWidgetVisibilityContext({ isMobile, isInSidePanel });
|
||||
|
||||
const tabsWithFilteredWidgets = tabs.map((tab) => ({
|
||||
const tabsWithFilteredWidgets = activeTabs.map((tab) => ({
|
||||
...tab,
|
||||
widgets: filterVisibleWidgets({ widgets: tab.widgets, context }),
|
||||
}));
|
||||
@@ -30,7 +32,7 @@ export const getTabsWithVisibleWidgets = ({
|
||||
(tab) => tab.widgets.length > 0,
|
||||
);
|
||||
|
||||
if (tabsWithVisibleWidgets.length === 0 && tabs.length > 0) {
|
||||
if (tabsWithVisibleWidgets.length === 0 && activeTabs.length > 0) {
|
||||
return tabsWithFilteredWidgets.slice(0, 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ const getRelationFieldWidgetToInsert = (
|
||||
id: `${DYNAMIC_RELATION_WIDGET_ID_PREFIX}${field.id}-${field.label}`,
|
||||
pageLayoutTabId: tabId,
|
||||
title: field.label,
|
||||
isActive: true,
|
||||
type: WidgetType.FIELD,
|
||||
objectMetadataId: null,
|
||||
gridPosition: {
|
||||
|
||||
Reference in New Issue
Block a user