Skip to content

Commit

Permalink
Dash body cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
flops committed Dec 19, 2024
1 parent c06a3bb commit 31ea7f7
Showing 1 changed file with 0 additions and 42 deletions.
42 changes: 0 additions & 42 deletions src/ui/units/dash/containers/Body/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ import {
getPastedWidgetData,
getPreparedCopyItemOptions,
memoizedGetLocalTabs,
sortByOrderIdOrLayoutComparator,
} from '../../modules/helpers';
import type {TabsHashStates} from '../../store/actions/dashTyped';
import {
Expand Down Expand Up @@ -182,12 +181,6 @@ type GetPreparedCopyItemOptions<T extends object = {}> = (
itemToCopy: PreparedCopyItemOptions<T>,
) => PreparedCopyItemOptions<T>;

const GROUPS_WEIGHT = {
[FIXED_GROUP_HEADER_ID]: 2,
[FIXED_GROUP_CONTAINER_ID]: 1,
[DEFAULT_GROUP]: 0,
} as const;

// Body is used as a core in different environments
class Body extends React.PureComponent<BodyProps> {
static getDerivedStateFromProps(props: BodyProps, state: DashBodyState) {
Expand Down Expand Up @@ -882,41 +875,6 @@ class Body extends React.PureComponent<BodyProps> {
return this._memoizedMenu;
};

getMobileLayout(): DashKitProps['config'] | null {
const {tabData} = this.props;
const tabDataConfig = tabData as DashKitProps['config'] | null;

if (!tabDataConfig) {
return tabDataConfig;
}

const {byId, columns} = this.getMemoLayoutMap();
const getWeight = (item: DashTabItem): number => {
const parentId = getLayoutParentId(byId[item.id]);

return (GROUPS_WEIGHT as any)[parentId] || 0;
};

return {
...tabDataConfig,
items: (tabDataConfig.items as DashTab['items'])
.sort((prev, next) => {
const prevWeight = getWeight(prev);
const nextWeight = getWeight(next);

if (prevWeight === nextWeight) {
return sortByOrderIdOrLayoutComparator(prev, next, byId, columns);
}

return nextWeight - prevWeight;
})
.map((item, index) => ({
...item,
orderId: item.orderId || index,
})) as ConfigItem[],
};
}

dataProviderContextGetter = () => {
const {tabId, entryId} = this.props;

Expand Down

0 comments on commit 31ea7f7

Please sign in to comment.