Skip to content
Open
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
1 change: 0 additions & 1 deletion src/__testing__/ResponsiveDataTable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ jest.mock('@sistent/mui-datatables', () => {
};
});

// eslint-disable-next-line import/first
import ResponsiveDataTable from '../custom/ResponsiveDataTable';

const mockColumns = [
Expand Down
2 changes: 1 addition & 1 deletion src/__testing__/routing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('routing utilities', () => {
expect(getShareableResourceRoute(RESOURCE_TYPE.DESIGN, 'd2', 'design')).toBe(
'http://localhost/workspace?mode=design&design=d2'
);
expect(() => getShareableResourceRoute('filter' as any, 'f1', 'filter')).toThrow(
expect(() => getShareableResourceRoute('filter' as unknown as RESOURCE_TYPE, 'f1', 'filter')).toThrow(
'Unknown resource type filter'
);
});
Expand Down
4 changes: 2 additions & 2 deletions src/actors/worker/workerfy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ export const workerfyActor = (actor: AnyActorLogic) => {
}

if (event.data.type === WORKER_COMMANDS.STOP_ACTOR) {
snapshotSubscription?.unsubscribe && snapshotSubscription.unsubscribe();
actorRef?.stop && actorRef.stop();
if (snapshotSubscription?.unsubscribe) snapshotSubscription.unsubscribe();
if (actorRef?.stop) actorRef.stop();
}

if (event.data.type === WORKER_COMMANDS.SEND_EVENT) {
Expand Down
6 changes: 3 additions & 3 deletions src/base/Hidden/Hidden.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Hidden as MuiHidden, HiddenProps as MuiHiddenProps } from '@mui/material';
import React from 'react';

export const Hidden = React.forwardRef<HTMLDivElement, MuiHiddenProps>((props, ref) => {
return React.cloneElement(<MuiHidden {...props} />, { ref });
});
export const Hidden: React.FC<MuiHiddenProps> = (props) => {
return <MuiHidden {...props} />;
};

export default Hidden;
4 changes: 3 additions & 1 deletion src/custom/CatalogDesignTable/CatalogDesignTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ export const CatalogDesignsTable: React.FC<CatalogDesignsTableProps> = ({
setPageSize(tableState.rowsPerPage);
break;
case 'search':
setSearch && setSearch(tableState.searchText !== null ? tableState.searchText : '');
if (setSearch) {
setSearch(tableState.searchText !== null ? tableState.searchText : '');
}
break;
case 'sort':
if (
Expand Down
19 changes: 9 additions & 10 deletions src/custom/CatalogDetail/ChallengesSection.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState } from 'react';
import { useMemo, useState } from 'react';
import { Link, ListItemIcon } from '../../base';
import { MESHERY_CLOUD_PROD } from '../../constants/constants';
import { ChallengesIcon } from '../../icons';
Expand All @@ -14,18 +14,17 @@ interface ChallengesSectionProps {

const ChallengesSection: React.FC<ChallengesSectionProps> = ({ filteredAcademyData }) => {
const theme = useTheme();
const [openChallenges, setOpenChallenges] = useState(false);
const [autoUpdate, setAutoUpdate] = useState(true);
const [manualOverride, setManualOverride] = useState<boolean | null>(null);

useEffect(() => {
if (autoUpdate) {
setOpenChallenges((filteredAcademyData?.['challenges'] ?? []).length > 0);
}
}, [filteredAcademyData, autoUpdate]);
const hasChallenges = useMemo(
() => (filteredAcademyData?.['challenge'] ?? []).length > 0,
[filteredAcademyData]
);

const openChallenges = manualOverride !== null ? manualOverride : hasChallenges;

const toggleOpenChallenges = () => {
setOpenChallenges((prev) => !prev);
setAutoUpdate(false);
setManualOverride((prev) => (prev !== null ? !prev : !hasChallenges));
};

const renderChallengeItem = (item: string, index: number) => (
Expand Down
43 changes: 22 additions & 21 deletions src/custom/CatalogDetail/ContentClassInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useMemo } from 'react';
import { Box } from '../../base';
import { CommunityClassIcon, OfficialClassIcon, VerificationClassIcon } from '../../icons';
import { KEPPEL, useTheme } from '../../theme';
Expand All @@ -20,26 +20,27 @@ const ContentClassInfo: React.FC<ContentClassInfoProps> = ({ contentClass, class

const theme = useTheme();

const CONTENT_CLASS: ContentClassType = {
community: {
icon: CommunityClassIcon,
color: theme.palette.icon.secondary
},
official: {
icon: OfficialClassIcon,
color: '#EBC017'
},
verified: {
icon: VerificationClassIcon,
color: theme.palette.primary.brand?.default || KEPPEL
}
} as const;
const CONTENT_CLASS: ContentClassType = useMemo(
() => ({
community: {
icon: CommunityClassIcon,
color: theme.palette.icon.secondary
},
official: {
icon: OfficialClassIcon,
color: '#EBC017'
},
verified: {
icon: VerificationClassIcon,
color: theme.palette.primary.brand?.default || KEPPEL
}
}),
[theme.palette.icon.secondary, theme.palette.primary.brand?.default]
);
Comment on lines +23 to +39
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constant CONTENT_CLASS is being memoized, but it contains static component references (icon classes) that never change. Only the color values depend on theme. Consider extracting just the color computation into useMemo, or using a simpler approach since the object structure is constant and only colors are dynamic.

Copilot uses AI. Check for mistakes.

const ClassIcon: React.FC<{ className: string }> = ({ className }) => {
const Icon = CONTENT_CLASS[className]?.icon;
const fill = CONTENT_CLASS[className]?.color;
return Icon ? <Icon width="25px" height="25px" fill={fill} /> : null;
};
const classConfig = CONTENT_CLASS[contentClass];
const Icon = classConfig?.icon;
const fill = classConfig?.color;

return (
<div>
Expand All @@ -61,7 +62,7 @@ const ContentClassInfo: React.FC<ContentClassInfoProps> = ({ contentClass, class
fontFamily: 'inherit'
}}
>
<ClassIcon className={contentClass} />
{Icon && <Icon width="25px" height="25px" fill={fill} />}
{formatToTitleCase(contentClass)}
</ContentDetailsText>
</div>
Expand Down
19 changes: 9 additions & 10 deletions src/custom/CatalogDetail/LearningSection.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react';
import React, { useMemo, useState } from 'react';
import { Link, ListItemIcon } from '../../base';
import { MESHERY_CLOUD_PROD } from '../../constants/constants';
import { LearningIcon } from '../../icons';
Expand All @@ -14,18 +14,17 @@ interface LearningSectionProps {

const LearningSection: React.FC<LearningSectionProps> = ({ filteredAcademyData }) => {
const theme = useTheme();
const [openLearning, setOpenLearning] = useState<boolean>(false);
const [autoUpdate, setAutoUpdate] = useState<boolean>(true);
const [manualOverride, setManualOverride] = useState<boolean | null>(null);

useEffect(() => {
if (autoUpdate) {
setOpenLearning(Boolean((filteredAcademyData?.['learning-path'] ?? []).length > 0));
}
}, [filteredAcademyData, autoUpdate]);
const hasLearningPaths = useMemo(
() => (filteredAcademyData?.['learning-path'] ?? []).length > 0,
[filteredAcademyData]
);

const openLearning = manualOverride !== null ? manualOverride : hasLearningPaths;

const toggleOpenLearning = (): void => {
setOpenLearning((prev) => !prev);
setAutoUpdate(false);
setManualOverride((prev) => (prev !== null ? !prev : !hasLearningPaths));
};

const renderLearningItem = (item: string, index: number) => (
Expand Down
6 changes: 3 additions & 3 deletions src/custom/CustomCatalog/CatalogCardDesignLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const CatalogCardDesignLogo: React.FC<CatalogCardDesignLogoProps> = ({
setIsZoomed(false);
};

const SvgComponent: React.FC<{ type: { type: string } }> = ({ type }) => {
const renderSvgComponent = () => {
return type.type === 'filter' ? (
<MesheryFilterIcon width={width} height={height} style={style} />
) : (
Expand Down Expand Up @@ -82,11 +82,11 @@ const CatalogCardDesignLogo: React.FC<CatalogCardDesignLogoProps> = ({
</Dialog>
</>
) : (
<SvgComponent type={type} />
renderSvgComponent()
)}
</div>
) : (
<SvgComponent type={type} />
renderSvgComponent()
)}
</>
);
Expand Down
4 changes: 2 additions & 2 deletions src/custom/FlipCard/FlipCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ export function FlipCard({
onClick={() => {
if (disableFlip) return;
setFlipped((flipped) => !flipped);
onClick && onClick();
onShow && onShow();
if (onClick) onClick();
if (onShow) onShow();
}}
>
<InnerCard
Expand Down