Skip to content

Commit f655047

Browse files
authored
Merge branch 'master' into patch-1
2 parents e288bf2 + 873ef35 commit f655047

File tree

14 files changed

+434
-136
lines changed

14 files changed

+434
-136
lines changed

src/constants/constants.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,21 @@ export const MESHERY_CLOUD_PROD = 'https://cloud.layer5.io';
6767
export const MESHERY_CLOUD_STAGING = 'staging-cloud.layer5.io';
6868
export const MESHERY_CLOUD_WS_PROD = 'cloud-ws.layer5.io';
6969
export const MESHERY_CLOUD_WS_STAGING = 'staging-cloud-ws.layer5.io:6543';
70+
71+
export const EVENT_TYPES = {
72+
SUCCESS: {
73+
type: 'success'
74+
},
75+
DEFAULT: {
76+
type: 'default'
77+
},
78+
INFO: {
79+
type: 'info'
80+
},
81+
WARNING: {
82+
type: 'warning'
83+
},
84+
ERROR: {
85+
type: 'error'
86+
}
87+
};

src/custom/Carousel/style.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,31 @@ export const CarouselButton = styled('button')(({ theme }) => ({
1717
color: '#fff'
1818
},
1919
'&:first-of-type': {
20-
left: '-1.2rem'
20+
left: '-0.5rem'
2121
},
2222
'&:last-of-type': {
23-
right: '-1.2rem'
23+
right: '-0.5rem'
2424
}
2525
}));
2626

2727
export const CarouselWrapper = styled('div')({
2828
display: 'flex',
2929
alignItems: 'center',
3030
width: '100%',
31-
position: 'relative'
31+
position: 'relative',
32+
padding: '0 3rem'
3233
});
3334

3435
export const CarouselContainer = styled('div')({
3536
display: 'flex',
3637
overflowX: 'auto',
3738
scrollBehavior: 'smooth',
3839
scrollSnapType: 'x mandatory',
39-
gap: '1rem',
40-
padding: '1rem 0',
40+
gap: '0.5rem',
41+
paddingBottom: '1rem',
4142
width: '100%',
43+
msOverflowStyle: 'none',
44+
scrollbarWidth: 'none',
4245
'&::-webkit-scrollbar': {
4346
display: 'none'
4447
},

src/custom/CatalogDesignTable/DesignTableColumnConfig.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { Lock, Public } from '@mui/icons-material';
2-
import RemoveCircleIcon from '@mui/icons-material/RemoveCircle';
32
import { Theme } from '@mui/material';
43
import { MUIDataTableColumn, MUIDataTableMeta } from 'mui-datatables';
54
import { Typography } from '../../base';
65
import { PLAYGROUND_MODES } from '../../constants/constants';
7-
import { ChainIcon, CopyIcon, KanvasIcon, PublishIcon } from '../../icons';
6+
import { ChainIcon, CopyIcon, KanvasIcon, MoveFileIcon, PublishIcon } from '../../icons';
87
import Download from '../../icons/Download/Download';
98
import { downloadPattern, slugify } from '../CatalogDetail/helper';
109
import { RESOURCE_TYPES } from '../CatalogDetail/types';
@@ -267,14 +266,10 @@ export const createDesignsColumnsConfig = ({
267266
},
268267

269268
{
270-
title: isFromWorkspaceTable ? 'Move Design' : 'Delete',
271-
disabled: isFromWorkspaceTable ? !isRemoveAllowed : !isDeleteAllowed,
269+
title: 'Delete',
270+
disabled: !isDeleteAllowed,
272271
onClick: () => handleDeleteModal(rowData)(),
273-
icon: isFromWorkspaceTable ? (
274-
<RemoveCircleIcon style={{ color: theme?.palette.icon.default }} />
275-
) : (
276-
<L5DeleteIcon />
277-
)
272+
icon: <L5DeleteIcon />
278273
}
279274
].filter((a) => a?.hidden != true);
280275

@@ -299,6 +294,17 @@ export const createDesignsColumnsConfig = ({
299294
icon: <CopyIcon width={24} height={24} fill={theme?.palette.icon.secondary} />
300295
};
301296

297+
const moveAction = {
298+
title: 'Move Design',
299+
disabled: !isRemoveAllowed,
300+
onClick: () => handleDeleteModal(rowData)(),
301+
icon: <MoveFileIcon />
302+
};
303+
304+
if (isFromWorkspaceTable) {
305+
actionsList.splice(0, 0, moveAction);
306+
}
307+
302308
if (rowData.visibility === 'published') {
303309
actionsList.splice(0, 0, cloneAction);
304310
actionsList.splice(2, 0, unpublishAction);

src/custom/PerformersSection/PerformersSection.tsx

Lines changed: 37 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22
import { memo, useMemo } from 'react';
3-
import {
4-
CloneIcon,
5-
DeploymentsIcon,
6-
DownloadIcon,
7-
OpenIcon,
8-
ShareIcon,
9-
TropyIcon
10-
} from '../../icons';
3+
import { Box, Button } from '../../base';
4+
import { iconXSmall } from '../../constants/iconsSizes';
5+
import { LeaderBoardIcon, TropyIcon } from '../../icons';
116
import { useTheme } from '../../theme';
127
import { Carousel } from '../Carousel';
138
import { Pattern } from '../CustomCatalog/CustomCard';
@@ -21,18 +16,16 @@ import {
2116
HeaderTitle,
2217
IconContainer,
2318
MainContainer,
24-
RepoSection,
2519
RepoTitle,
2620
StatsValue,
27-
StatusLabel,
2821
StyledCard,
2922
Title,
23+
TitleBox,
3024
UserNameText
3125
} from './styles';
3226

3327
interface MetricConfig {
3428
label: string;
35-
icon: React.ComponentType<any>;
3629
id: string;
3730
countKey: keyof Pattern;
3831
}
@@ -54,22 +47,18 @@ interface StatCardProps {
5447
patternName: string;
5548
pattern: Pattern;
5649
userName: string;
57-
userid: string;
58-
icon: React.ComponentType<any>;
5950
status: string;
6051
id: string;
6152
onCardClick: (pattern: Pattern) => void;
6253
onIconClick: (sortOrder: string) => void;
63-
onAuthorClick: (userId: string) => void;
64-
onStatusClick: (status: string) => void;
54+
onOpenLeaderboard?: () => void;
6555
}
6656

6757
interface PerformersSectionProps {
6858
useGetCatalogFilters: (params: any) => any;
6959
onCardClick: (pattern: Pattern) => void;
7060
onIconClick: (sortOrder: string) => void;
71-
onAuthorClick: (userId: string) => void;
72-
onStatusClick: (status: string) => void;
61+
onOpenLeaderboard?: () => void;
7362
}
7463

7564
type MetricType = 'view' | 'clone' | 'download' | 'deployment' | 'share';
@@ -86,32 +75,27 @@ const BASE_QUERY_PARAMS: BaseQueryParams = {
8675
const METRICS: Record<MetricType, MetricConfig> = {
8776
view: {
8877
label: 'Most Opens',
89-
icon: OpenIcon,
90-
id: 'open-icon',
78+
id: 'open',
9179
countKey: 'view_count'
9280
},
9381
clone: {
9482
label: 'Most Clones',
95-
icon: CloneIcon,
96-
id: 'clone-icon',
83+
id: 'clone',
9784
countKey: 'clone_count'
9885
},
9986
download: {
10087
label: 'Most Downloads',
101-
icon: DownloadIcon,
102-
id: 'download-icon',
88+
id: 'download',
10389
countKey: 'download_count'
10490
},
10591
deployment: {
10692
label: 'Most Deploys',
107-
icon: DeploymentsIcon,
108-
id: 'deployments-icon',
93+
id: 'deployments',
10994
countKey: 'deployment_count'
11095
},
11196
share: {
11297
label: 'Most Shares',
113-
icon: ShareIcon,
114-
id: 'share-icon',
98+
id: 'share',
11599
countKey: 'share_count'
116100
}
117101
};
@@ -128,14 +112,10 @@ const StatCardComponent: React.FC<StatCardProps> = ({
128112
patternName,
129113
pattern,
130114
userName,
131-
userid,
132-
icon: Icon,
133115
status,
134116
id,
135117
onCardClick,
136-
onIconClick,
137-
onAuthorClick,
138-
onStatusClick
118+
onIconClick
139119
}) => {
140120
const handleCardClick = () => {
141121
onCardClick(pattern);
@@ -146,36 +126,25 @@ const StatCardComponent: React.FC<StatCardProps> = ({
146126
onIconClick(sortOrder);
147127
};
148128

149-
const handleAuthorClick = (e: React.MouseEvent) => {
150-
e.stopPropagation();
151-
onAuthorClick(userid);
152-
};
153-
154-
const handleStatusClick = (e: React.MouseEvent) => {
155-
e.stopPropagation();
156-
onStatusClick(status);
157-
};
129+
const theme = useTheme();
158130

159131
return (
160132
<StyledCard elevation={0} status={status} onClick={handleCardClick}>
161133
<ContentWrapper cardId={id}>
162134
<HeaderSection>
163135
<HeaderTitle>{label}</HeaderTitle>
164136
<IconContainer onClick={(e) => handleIconClick(e, `${countKey}+desc`)}>
165-
<Icon className={id} />
137+
<LeaderBoardIcon {...iconXSmall} fill={theme.palette.common.black} />
166138
</IconContainer>
167139
</HeaderSection>
168140

169141
<StatsValue>{count}</StatsValue>
170142

171-
<RepoSection>
143+
<Box>
172144
<RepoTitle>{patternName}</RepoTitle>
173-
<UserNameText onClick={handleAuthorClick}>by {userName}</UserNameText>
174-
</RepoSection>
145+
<UserNameText>by {userName}</UserNameText>
146+
</Box>
175147
</ContentWrapper>
176-
<StatusLabel labelType={status} onClick={handleStatusClick}>
177-
{status}
178-
</StatusLabel>
179148
</StyledCard>
180149
);
181150
};
@@ -246,8 +215,6 @@ const processQueryData = (
246215
patternName: pattern.name || 'Unknown',
247216
pattern: pattern,
248217
userName: pattern.user?.first_name || 'Unknown',
249-
userid: pattern.user?.id,
250-
icon: config.icon,
251218
id: config.id,
252219
status: pattern?.catalog_data?.content_class
253220
};
@@ -257,8 +224,7 @@ const PerformersSection: React.FC<PerformersSectionProps> = ({
257224
useGetCatalogFilters,
258225
onCardClick,
259226
onIconClick,
260-
onAuthorClick,
261-
onStatusClick
227+
onOpenLeaderboard
262228
}) => {
263229
const theme = useTheme();
264230
const { queries, isLoading, hasError } = useMetricQueries(useGetCatalogFilters);
@@ -267,13 +233,8 @@ const PerformersSection: React.FC<PerformersSectionProps> = ({
267233
() =>
268234
(Object.keys(METRICS) as MetricType[])
269235
.map((metric) => processQueryData(queries, metric))
270-
.filter(
271-
(
272-
stat
273-
): stat is Omit<
274-
StatCardProps,
275-
'onCardClick' | 'onIconClick' | 'onAuthorClick' | 'onStatusClick'
276-
> => Boolean(stat)
236+
.filter((stat): stat is Omit<StatCardProps, 'onCardClick' | 'onIconClick'> =>
237+
Boolean(stat)
277238
),
278239
[queries]
279240
);
@@ -291,24 +252,29 @@ const PerformersSection: React.FC<PerformersSectionProps> = ({
291252
{...stat}
292253
onCardClick={onCardClick}
293254
onIconClick={onIconClick}
294-
onAuthorClick={onAuthorClick}
295-
onStatusClick={onStatusClick}
296255
/>
297256
));
298257

299258
return (
300259
<ErrorBoundary>
301260
<MainContainer>
302-
<Title>
303-
Top Performers
304-
<TropyIcon
305-
style={{
306-
height: '2rem',
307-
width: '2rem',
308-
color: theme.palette.icon.secondary
309-
}}
310-
/>
311-
</Title>
261+
<TitleBox>
262+
<Box display={'flex'} alignItems="center" gap={1}>
263+
<Title>Top Performers</Title>
264+
<TropyIcon
265+
style={{
266+
height: '2rem',
267+
width: '2rem',
268+
color: theme.palette.icon.secondary
269+
}}
270+
/>
271+
</Box>
272+
{onOpenLeaderboard && (
273+
<Button variant="contained" onClick={() => onOpenLeaderboard()}>
274+
Open Leaderboard
275+
</Button>
276+
)}
277+
</TitleBox>
312278
<CardsContainer>
313279
{isLoading && <StateCardSekeleton />}
314280
<Carousel items={statComponents} />

0 commit comments

Comments
 (0)