Skip to content

Commit b341c9e

Browse files
committed
fix: add sorting for parent plugin list and env list
1 parent c117dbc commit b341c9e

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

src/Shared/Components/Plugin/service.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,5 +119,11 @@ export const getAvailablePluginTags = async (appId: number): Promise<string[]> =
119119

120120
export const getParentPluginList = async (
121121
params?: Partial<GetParentPluginListPayloadType>,
122-
): Promise<ResponseType<MinParentPluginDTO[]>> =>
123-
get<MinParentPluginDTO[]>(getUrlWithSearchParams(ROUTES.PLUGIN_LIST_MIN, params))
122+
): Promise<ResponseType<MinParentPluginDTO[]>> => {
123+
const response = await get<MinParentPluginDTO[]>(getUrlWithSearchParams(ROUTES.PLUGIN_LIST_MIN, params))
124+
125+
return {
126+
...response,
127+
result: (response?.result ?? []).sort((a, b) => stringComparatorBySortOrder(a.name, b.name)),
128+
}
129+
}

src/Shared/Hooks/useGetResourceKindsOptions/service.ts

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -77,23 +77,25 @@ export const getEnvironmentOptionsGroupedByClusters = async (): Promise<Environm
7777
return []
7878
}
7979

80-
const sortedEnvList = result.map(
81-
({
82-
id,
83-
environment_name: name,
84-
isVirtualEnvironment,
85-
cluster_name: cluster,
86-
default: isDefault,
87-
namespace,
88-
}) => ({
89-
id,
90-
name,
91-
isVirtual: isVirtualEnvironment ?? false,
92-
cluster,
93-
environmentType: isDefault ? EnvironmentTypeEnum.production : EnvironmentTypeEnum.nonProduction,
94-
namespace,
95-
}),
96-
)
80+
const sortedEnvList = result
81+
.map(
82+
({
83+
id,
84+
environment_name: name,
85+
isVirtualEnvironment,
86+
cluster_name: cluster,
87+
default: isDefault,
88+
namespace,
89+
}) => ({
90+
id,
91+
name,
92+
isVirtual: isVirtualEnvironment ?? false,
93+
cluster,
94+
environmentType: isDefault ? EnvironmentTypeEnum.production : EnvironmentTypeEnum.nonProduction,
95+
namespace,
96+
}),
97+
)
98+
.sort((a, b) => stringComparatorBySortOrder(a.name, b.name))
9799

98100
const envGroupedByCluster = Object.values(
99101
sortedEnvList.reduce<

0 commit comments

Comments
 (0)