Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions app/client/src/IDE/utils/groupAndSortEntitySegmentList.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { groupBy, sortBy } from "lodash";
import type { EntityItem } from "ee/IDE/Interfaces/EntityItem";

export type EditorSegmentList = Array<{
group: string | "NA";
items: EntityItem[];
}>;

export const groupAndSortEntitySegmentList = (
items: EntityItem[],
): EditorSegmentList => {
const groups = groupBy(items, (item) => {
if (item.group) return item.group;

return "NA";
});

// Entity Segment Lists are sorted alphabetically at both group and item level
return sortBy(
Object.keys(groups).map((group) => {
return {
group: group,
items: sortBy(groups[group], "title"),
};
}),
"group",
);
};
2 changes: 1 addition & 1 deletion app/client/src/ce/selectors/appIDESelectors.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { EntityItem } from "ee/IDE/Interfaces/EntityItem";
import { groupAndSortEntitySegmentList } from "./appIDESelectors";
import { groupAndSortEntitySegmentList } from "IDE/utils/groupAndSortEntitySegmentList";
import { PluginType } from "entities/Plugin";

describe("groupAndSortEntitySegmentList", () => {
Expand Down
30 changes: 2 additions & 28 deletions app/client/src/ce/selectors/appIDESelectors.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { groupBy, keyBy, sortBy } from "lodash";
import { keyBy } from "lodash";
import { createSelector } from "reselect";
import type { EntityItem } from "ee/IDE/Interfaces/EntityItem";
import {
getJSSegmentItems,
getQuerySegmentItems,
Expand All @@ -10,32 +9,7 @@ import type { AppState } from "ee/reducers";
import { identifyEntityFromPath } from "navigation/FocusEntity";
import { getCurrentBasePageId } from "selectors/editorSelectors";
import { getQueryEntityItemUrl } from "ee/pages/AppIDE/layouts/routers/utils/getQueryEntityItemUrl";

export type EditorSegmentList = Array<{
group: string | "NA";
items: EntityItem[];
}>;

export const groupAndSortEntitySegmentList = (
items: EntityItem[],
): EditorSegmentList => {
const groups = groupBy(items, (item) => {
if (item.group) return item.group;

return "NA";
});

// Entity Segment Lists are sorted alphabetically at both group and item level
return sortBy(
Object.keys(groups).map((group) => {
return {
group: group,
items: sortBy(groups[group], "title"),
};
}),
"group",
);
};
import { groupAndSortEntitySegmentList } from "IDE/utils/groupAndSortEntitySegmentList";

export const selectQuerySegmentEditorList = createSelector(
getQuerySegmentItems,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const ListJSObjects = () => {
<Flex
data-testid="t--ide-list"
flexDirection="column"
gap="spaces-4"
gap="spaces-3"
overflowY="auto"
>
{isNewADSTemplatesEnabled ? (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { ListQuery } from "./List";
import { ListQuery } from "./QuerySegmentList";
import styled from "styled-components";
import { Flex } from "@appsmith/ads";
import { useSelector } from "react-redux";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const ListQuery = () => {
<Flex
data-testid="t--ide-list"
flexDirection={"column"}
gap="spaces-4"
gap="spaces-3"
overflowY="auto"
>
{isNewADSTemplatesEnabled ? (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { QueryExplorer } from "./Explorer";
export { ListQuery } from "./List";
export { ListQuery } from "./QuerySegmentList";
Loading