Merge pull request #868 from Hexastack/fix/custom-plugins-displayed-sorted

fix: custom plugins displayed unsorted
This commit is contained in:
Med Marrouchi 2025-04-07 09:09:03 +01:00 committed by GitHub
commit b90776a4a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Hexastack. All rights reserved. * Copyright © 2025 Hexastack. All rights reserved.
* *
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. * 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
@ -7,6 +7,7 @@
*/ */
import { Grid } from "@mui/material"; import { Grid } from "@mui/material";
import { useMemo } from "react";
import PluginIcon from "@/app-components/svg/toolbar/PluginIcon"; import PluginIcon from "@/app-components/svg/toolbar/PluginIcon";
import { useFind } from "@/hooks/crud/useFind"; import { useFind } from "@/hooks/crud/useFind";
@ -17,18 +18,22 @@ import { Block, StyledTitle } from "./Aside";
export const CustomBlocks = () => { export const CustomBlocks = () => {
const { t } = useTranslate(); const { t } = useTranslate();
const { data: customBlocks } = useFind( const { data: customBlocks = [] } = useFind(
{ entity: EntityType.CUSTOM_BLOCK }, { entity: EntityType.CUSTOM_BLOCK },
{ hasCount: false }, { hasCount: false },
); );
const memoizedCustomBlocks = useMemo(
() => customBlocks.sort((a, b) => a.id.localeCompare(b.id)),
[customBlocks],
);
return customBlocks?.length ? ( return memoizedCustomBlocks.length ? (
<> <>
<Grid mb="2"> <Grid mb="2">
<StyledTitle>{t("title.custom_blocks")}</StyledTitle> <StyledTitle>{t("title.custom_blocks")}</StyledTitle>
</Grid> </Grid>
<Grid container> <Grid container>
{customBlocks?.map((customBlock) => ( {memoizedCustomBlocks.map((customBlock) => (
<Block <Block
key={customBlock.id} key={customBlock.id}
title={t(`title.${customBlock.namespace}`, { title={t(`title.${customBlock.namespace}`, {