fix: Tab Widget Sagas fixed.
This commit is contained in:
parent
87c4645a87
commit
0253019d34
|
|
@ -2,9 +2,8 @@ import React from "react";
|
|||
import BaseControl, { ControlProps } from "./BaseControl";
|
||||
import { StyledPropertyPaneButton } from "./StyledControls";
|
||||
import styled from "constants/DefaultTheme";
|
||||
import { generateReactKey } from "utils/generators";
|
||||
import { DroppableComponent } from "components/ads/DraggableListComponent";
|
||||
import { getNextEntityName, noop } from "utils/AppsmithUtils";
|
||||
import { noop } from "utils/AppsmithUtils";
|
||||
import orderBy from "lodash/orderBy";
|
||||
import isString from "lodash/isString";
|
||||
import isUndefined from "lodash/isUndefined";
|
||||
|
|
@ -222,28 +221,6 @@ class TabControl extends BaseControl<ControlProps, State> {
|
|||
);
|
||||
};
|
||||
|
||||
addOption = () => {
|
||||
let tabs = this.props.propertyValue;
|
||||
const tabsArray = this.getTabItems();
|
||||
const newTabId = generateReactKey({ prefix: "tab" });
|
||||
const newTabLabel = getNextEntityName(
|
||||
"Tab ",
|
||||
tabsArray.map((tab: any) => tab.label),
|
||||
);
|
||||
tabs = {
|
||||
...tabs,
|
||||
[newTabId]: {
|
||||
id: newTabId,
|
||||
index: tabsArray.length,
|
||||
label: newTabLabel,
|
||||
widgetId: generateReactKey(),
|
||||
isVisible: true,
|
||||
},
|
||||
};
|
||||
|
||||
this.updateProperty(this.props.propertyName, tabs);
|
||||
};
|
||||
|
||||
updateFocus = (index: number, isFocused: boolean) => {
|
||||
this.setState({ focusedIndex: isFocused ? index : null });
|
||||
};
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import { getDataTree } from "selectors/dataTreeSelectors";
|
|||
import { generateReactKey } from "utils/generators";
|
||||
import { WidgetProps } from "widgets/BaseWidget";
|
||||
import WidgetFactory from "utils/WidgetFactory";
|
||||
import { omit } from "lodash";
|
||||
import omit from "lodash/omit";
|
||||
import produce from "immer";
|
||||
import { GRID_DENSITY_MIGRATION_V1 } from "widgets/constants";
|
||||
const WidgetTypes = WidgetFactory.widgetTypes;
|
||||
|
|
@ -405,16 +405,15 @@ function* addNewTabChildSaga(
|
|||
"Tab ",
|
||||
tabsArray.map((tab: any) => tab.label),
|
||||
);
|
||||
const newTabIndex = Object.keys(tabs)?.length - 1;
|
||||
|
||||
tabs = {
|
||||
...tabs,
|
||||
[newTabId]: {
|
||||
id: newTabId,
|
||||
index: tabsArray.length,
|
||||
label: newTabLabel,
|
||||
widgetId: newTabWidgetId,
|
||||
isVisible: true,
|
||||
index: newTabIndex,
|
||||
},
|
||||
};
|
||||
const newTabProps: any = getChildTabData(tabProps, {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import {
|
|||
import { GridDefaults } from "constants/WidgetConstants";
|
||||
import { ENTITY_TYPE } from "entities/AppsmithConsole";
|
||||
import LOG_TYPE from "entities/AppsmithConsole/logtype";
|
||||
import { flattenDeep, omit } from "lodash";
|
||||
import { flattenDeep, omit, orderBy } from "lodash";
|
||||
import {
|
||||
CanvasWidgetsReduxState,
|
||||
FlattenedWidgetProps,
|
||||
|
|
@ -54,7 +54,11 @@ function* deleteTabChildSaga(
|
|||
const tabWidget = allWidgets[widgetId];
|
||||
if (tabWidget && tabWidget.parentId) {
|
||||
const tabParentWidget = allWidgets[tabWidget.parentId];
|
||||
const tabsArray: any = Object.values(tabParentWidget.tabsObj);
|
||||
const tabsArray: any = orderBy(
|
||||
Object.values(tabParentWidget.tabsObj),
|
||||
"index",
|
||||
"asc",
|
||||
);
|
||||
if (tabsArray && tabsArray.length === 1) return;
|
||||
const updatedArray = tabsArray.filter((eachItem: any, i: number) => {
|
||||
return i !== index;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user