Skip to content

Commit 4be1c08

Browse files
updates
Signed-off-by: Rajesh-Nagarajan-11 <rajeshnagarajan36@gmail.com>
1 parent eb718e8 commit 4be1c08

File tree

10 files changed

+51
-30
lines changed

10 files changed

+51
-30
lines changed

src/__testing__/routing.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('routing utilities', () => {
4343
expect(getShareableResourceRoute(RESOURCE_TYPE.DESIGN, 'd2', 'design')).toBe(
4444
'http://localhost/workspace?mode=design&design=d2'
4545
);
46-
expect(() => getShareableResourceRoute('filter' as any, 'f1', 'filter')).toThrow(
46+
expect(() => getShareableResourceRoute('filter' as unknown as typeof RESOURCE_TYPE[keyof typeof RESOURCE_TYPE], 'f1', 'filter')).toThrow(
4747
'Unknown resource type filter'
4848
);
4949
});

src/actors/worker/workerfy.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,12 @@ export const workerfyActor = (actor: AnyActorLogic) => {
7171
}
7272

7373
if (event.data.type === WORKER_COMMANDS.STOP_ACTOR) {
74-
snapshotSubscription?.unsubscribe && snapshotSubscription.unsubscribe();
75-
actorRef?.stop && actorRef.stop();
74+
if (snapshotSubscription?.unsubscribe) {
75+
snapshotSubscription.unsubscribe();
76+
}
77+
if (actorRef?.stop) {
78+
actorRef.stop();
79+
}
7680
}
7781

7882
if (event.data.type === WORKER_COMMANDS.SEND_EVENT) {

src/base/Hidden/Hidden.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import { Hidden as MuiHidden, HiddenProps as MuiHiddenProps } from '@mui/materia
22
import React from 'react';
33

44
export const Hidden = React.forwardRef<HTMLDivElement, MuiHiddenProps>((props, ref) => {
5-
return React.cloneElement(<MuiHidden {...props} />, { ref });
5+
return (
6+
<div ref={ref}>
7+
<MuiHidden {...props} />
8+
</div>
9+
);
610
});
711

812
export default Hidden;

src/custom/CatalogDesignTable/CatalogDesignTable.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ export const CatalogDesignsTable: React.FC<CatalogDesignsTableProps> = ({
7272
setPageSize(tableState.rowsPerPage);
7373
break;
7474
case 'search':
75-
setSearch && setSearch(tableState.searchText !== null ? tableState.searchText : '');
75+
if (setSearch) {
76+
setSearch(tableState.searchText !== null ? tableState.searchText : '');
77+
}
7678
break;
7779
case 'sort':
7880
if (

src/custom/CatalogDetail/ChallengesSection.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEffect, useState } from 'react';
1+
import { useEffect, useRef, useState } from 'react';
22
import { Link, ListItemIcon } from '../../base';
33
import { MESHERY_CLOUD_PROD } from '../../constants/constants';
44
import { ChallengesIcon } from '../../icons';
@@ -17,9 +17,14 @@ const ChallengesSection: React.FC<ChallengesSectionProps> = ({ filteredAcademyDa
1717
const [openChallenges, setOpenChallenges] = useState(false);
1818
const [autoUpdate, setAutoUpdate] = useState(true);
1919

20+
const prevDataRef = useRef(filteredAcademyData);
21+
2022
useEffect(() => {
21-
if (autoUpdate) {
22-
setOpenChallenges((filteredAcademyData?.['challenges'] ?? []).length > 0);
23+
if (autoUpdate && prevDataRef.current !== filteredAcademyData) {
24+
prevDataRef.current = filteredAcademyData;
25+
queueMicrotask(() => {
26+
setOpenChallenges((filteredAcademyData?.['challenges'] ?? []).length > 0);
27+
});
2328
}
2429
}, [filteredAcademyData, autoUpdate]);
2530

src/custom/CatalogDetail/LearningSection.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useState } from 'react';
1+
import React, { useEffect, useRef, useState } from 'react';
22
import { Link, ListItemIcon } from '../../base';
33
import { MESHERY_CLOUD_PROD } from '../../constants/constants';
44
import { LearningIcon } from '../../icons';
@@ -17,9 +17,14 @@ const LearningSection: React.FC<LearningSectionProps> = ({ filteredAcademyData }
1717
const [openLearning, setOpenLearning] = useState<boolean>(false);
1818
const [autoUpdate, setAutoUpdate] = useState<boolean>(true);
1919

20+
const prevDataRef = useRef(filteredAcademyData);
21+
2022
useEffect(() => {
21-
if (autoUpdate) {
22-
setOpenLearning(Boolean((filteredAcademyData?.['learning-path'] ?? []).length > 0));
23+
if (autoUpdate && prevDataRef.current !== filteredAcademyData) {
24+
prevDataRef.current = filteredAcademyData;
25+
queueMicrotask(() => {
26+
setOpenLearning(Boolean((filteredAcademyData?.['learning-path'] ?? []).length > 0));
27+
});
2328
}
2429
}, [filteredAcademyData, autoUpdate]);
2530

src/custom/CustomCatalog/CatalogCardDesignLogo.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ interface CatalogCardDesignLogoProps {
1010
height: string;
1111
style?: React.CSSProperties;
1212
}
13+
const SvgComponent: React.FC<{
14+
type: { type: string };
15+
width: string;
16+
height: string;
17+
style?: React.CSSProperties;
18+
}> = ({ type, width, height, style }) => {
19+
return type.type === 'filter' ? (
20+
<MesheryFilterIcon width={width} height={height} style={style} />
21+
) : (
22+
<DesignIcon width={width} height={height} style={style} />
23+
);
24+
};
1325

1426
const CatalogCardDesignLogo: React.FC<CatalogCardDesignLogoProps> = ({
1527
zoomEffect = false,
@@ -32,14 +44,6 @@ const CatalogCardDesignLogo: React.FC<CatalogCardDesignLogoProps> = ({
3244
setIsZoomed(false);
3345
};
3446

35-
const SvgComponent: React.FC<{ type: { type: string } }> = ({ type }) => {
36-
return type.type === 'filter' ? (
37-
<MesheryFilterIcon width={width} height={height} style={style} />
38-
) : (
39-
<DesignIcon width={width} height={height} style={style} />
40-
);
41-
};
42-
4347
return (
4448
<>
4549
{imgURL && imgURL.length > 0 ? (
@@ -82,11 +86,11 @@ const CatalogCardDesignLogo: React.FC<CatalogCardDesignLogoProps> = ({
8286
</Dialog>
8387
</>
8488
) : (
85-
<SvgComponent type={type} />
89+
<SvgComponent type={type} width={width} height={height} style={style} />
8690
)}
8791
</div>
8892
) : (
89-
<SvgComponent type={type} />
93+
<SvgComponent type={type} width={width} height={height} style={style} />
9094
)}
9195
</>
9296
);

src/custom/FlipCard/FlipCard.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,12 @@ export function FlipCard({
108108
onClick={() => {
109109
if (disableFlip) return;
110110
setFlipped((flipped) => !flipped);
111-
onClick && onClick();
112-
onShow && onShow();
111+
if (onClick) {
112+
onClick();
113+
}
114+
if (onShow) {
115+
onShow();
116+
}
113117
}}
114118
>
115119
<InnerCard

src/custom/Helpers/readme.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ This directory contains a collection of utility and helper components that you c
1111
## Available Helper Components
1212

1313
1. **Window Dimensions Hook**: A custom React hook for tracking changes in window dimensions.
14-
1514
- **File**: `Dimension`
1615
- **Usage**: Provides the `useWindowDimensions` hook, which allows you to get the current window dimensions and react to changes in window size.
1716
- **Returns**: An object containing the current window dimensions and a boolean value indicating whether the window is currently in landscape mode.
1817

1918
2. **Notification Hook**: A custom React hook for displaying notifications using notistack.
20-
2119
- **File**: `Notification`
2220
- **Usage**: Provides the `useNotificationHandler` hook, which allows you to display notifications.
2321
- **Returns**: An object containing the notification state and a function for updating the notification state.

system/patterns/empty-states.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,19 @@ Empty states are essential components used to occupy spaces when no content has
99
The BlankSlate component comprises various elements that work together to inform the user about a feature and guide them on how to proceed. Here are the key elements of the BlankSlate component and how to customize them:
1010

1111
1. **Graphic**
12-
1312
- Graphics should be purposefully placed to convey the intention of the content, whether it's to bring delight, preview an interface element, or represent the feature's goal.
1413
- Different graphics may hold different meanings and appeal to users, which is why the BlankSlate component offers multiple variations.
1514

1615
2. **Primary Text**
17-
1816
- Use primary text to explain the purpose of the empty state, making users comfortable to engage with the content or start a feature flow. It should be welcoming, human, and clearly convey the feature's intention.
1917

2018
3. **Secondary Text**
21-
2219
- This optional text provides more detailed information about the feature. It should be concise and non-redundant, allowing users to understand the general purpose and benefits of the feature.
2320

2421
4. **Primary Action**
25-
2622
- Encourage the use of one primary action button that leads to a feature or component creation flow. The button copy should be brief yet descriptive. Consider adding an Octicon for further specification if needed.
2723

2824
5. **Secondary Action**
29-
3025
- A secondary action is optional and usually represented by a text link below the primary action button. It guides users to additional content related to the feature, such as "Learn more about X" or "Check out the guide on X."
3126

3227
6. **Border**

0 commit comments

Comments
 (0)