Skip to content

Commit 0b48d26

Browse files
authored
Merge branch 'master' into patch-1
2 parents d81aa07 + 7371ba6 commit 0b48d26

File tree

7 files changed

+217
-88
lines changed

7 files changed

+217
-88
lines changed

.github/workflows/bump-meshery-version.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ jobs:
4545
uses: peter-evans/create-pull-request@v7
4646
with:
4747
token: ${{ secrets.RELEASEDRAFTER_PAT }}
48-
commit-message: Bump sistent v${{ needs.versions-check.outputs.current }} dependencies
48+
commit-message: Update to Sistent v${{ needs.versions-check.outputs.current }} dependencies
4949
committer: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
5050
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
5151
signoff: true
5252
branch: bump-sistent-bot
5353
delete-branch: true
54-
title: '[Chore]: Bump Sistent v${{ needs.versions-check.outputs.current }}'
54+
title: '[Chore]: Update to Sistent v${{ needs.versions-check.outputs.current }}'
5555
add-paths: |
5656
ui/package.json
5757
ui/package-lock.json
@@ -84,13 +84,13 @@ jobs:
8484
uses: peter-evans/create-pull-request@v7
8585
with:
8686
token: ${{ secrets.RELEASEDRAFTER_PAT }}
87-
commit-message: Bump sistent v${{ needs.versions-check.outputs.current }} dependencies
87+
commit-message: Update to Sistent v${{ needs.versions-check.outputs.current }} dependencies
8888
committer: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
8989
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
9090
signoff: true
9191
branch: bump-sistent-bot
9292
delete-branch: true
93-
title: '[Chore]: Bump Sistent v${{needs.versions-check.outputs.current }}'
93+
title: '[Chore]: Update to Sistent v${{needs.versions-check.outputs.current }}'
9494
add-paths: |
9595
meshmap/package.json
9696
meshmap/package-lock.json
@@ -128,7 +128,7 @@ jobs:
128128
signoff: true
129129
branch: bump-sistent-bot
130130
delete-branch: true
131-
title: '[Chore]: Bump Sistent v${{ needs.versions-check.outputs.current }}'
131+
title: '[Chore]: Update to Sistent v${{ needs.versions-check.outputs.current }}'
132132
add-paths: |
133133
package.json
134134
package-lock.json
@@ -161,13 +161,13 @@ jobs:
161161
uses: peter-evans/create-pull-request@v7
162162
with:
163163
token: ${{ secrets.RELEASEDRAFTER_PAT }}
164-
commit-message: Bump sistent v${{ needs.versions-check.outputs.current }} dependencies
164+
commit-message: Update to Sistent v${{ needs.versions-check.outputs.current }} dependencies
165165
committer: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
166166
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
167167
signoff: true
168168
branch: bump-sistent-bot
169169
delete-branch: true
170-
title: '[Chore]: Bump Sistent v${{ needs.versions-check.outputs.current }}'
170+
title: '[Chore]: Update to Sistent v${{ needs.versions-check.outputs.current }}'
171171
add-paths: |
172172
ui/package.json
173173
ui/package-lock.json

src/custom/LearningCard/LearningCard.tsx

Lines changed: 83 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import React from 'react';
1+
import React, { useState } from 'react';
2+
import { Typography } from '../../base';
23
import { ExternalLinkIcon } from '../../icons';
4+
import { Modal, ModalBody, ModalButtonPrimary, ModalButtonSecondary, ModalFooter } from '../Modal';
35
import {
46
Card2,
57
CardActive,
@@ -30,7 +32,8 @@ interface Props {
3032
path?: string;
3133
courseCount: number;
3234
courseType: string;
33-
cardKey?: string;
35+
orgId?: string;
36+
modalContent?: string;
3437
}
3538

3639
const OptionalLink: React.FC<React.PropsWithChildren<{ path?: string; isExternal?: boolean }>> = ({
@@ -53,9 +56,19 @@ const OptionalLink: React.FC<React.PropsWithChildren<{ path?: string; isExternal
5356
);
5457
};
5558

56-
const LearningCard: React.FC<Props> = ({ tutorial, path, courseCount, courseType, cardKey }) => {
57-
const isCreateLearningPath = cardKey === 'create-learning-path';
59+
const LearningCard: React.FC<Props> = ({
60+
tutorial,
61+
path,
62+
courseCount,
63+
courseType,
64+
orgId,
65+
modalContent
66+
}) => {
67+
const isCreateLearningPath = courseType === 'learning-card';
68+
const [modalOpen, setModalOpen] = useState(false);
5869

70+
const handleModalOpen = () => setModalOpen(true);
71+
const handleModalClose = () => setModalOpen(false);
5972
return (
6073
<CardWrapper>
6174
{tutorial.frontmatter.disabled === 'yes' ? (
@@ -82,9 +95,9 @@ const LearningCard: React.FC<Props> = ({ tutorial, path, courseCount, courseType
8295
</CardParent>
8396
</Card2>
8497
) : (
85-
<OptionalLink path={path} isExternal={isCreateLearningPath}>
98+
<>
8699
{isCreateLearningPath ? (
87-
<OwnLearningCard>
100+
<OwnLearningCard onClick={handleModalOpen} style={{ cursor: 'pointer' }}>
88101
<CardParent style={{ borderTop: `5px solid ${tutorial.frontmatter.themeColor}` }}>
89102
<div>
90103
<CardHead>
@@ -112,41 +125,72 @@ const LearningCard: React.FC<Props> = ({ tutorial, path, courseCount, courseType
112125
</CardParent>
113126
</OwnLearningCard>
114127
) : (
115-
<CardActive>
116-
<CardParent style={{ borderTop: `5px solid ${tutorial.frontmatter.themeColor}` }}>
117-
<div>
118-
<CardHead>
119-
<h3>
120-
{tutorial.frontmatter.title
121-
? tutorial.frontmatter.title
122-
: tutorial.frontmatter.courseTitle}
123-
</h3>
124-
{tutorial.frontmatter.status ? (
125-
<p>
126-
<span>New</span>
127-
</p>
128-
) : null}
129-
</CardHead>
130-
<CardDesc>
131-
<p className="summary">{tutorial.frontmatter.description}</p>
132-
</CardDesc>
133-
{!isCreateLearningPath && (
134-
<CardSubdata className="card-subdata">
135-
<p>
136-
{courseCount} {courseType}
137-
{courseCount > 1 ? 's' : ''}
138-
</p>
139-
</CardSubdata>
140-
)}
141-
<CardImage>
142-
<img src={tutorial.frontmatter.cardImage} />
143-
</CardImage>
144-
</div>
145-
</CardParent>
146-
</CardActive>
128+
<OptionalLink path={path} isExternal={isCreateLearningPath}>
129+
<CardActive>
130+
<CardParent style={{ borderTop: `5px solid ${tutorial.frontmatter.themeColor}` }}>
131+
<div>
132+
<CardHead>
133+
<h3>
134+
{tutorial.frontmatter.title
135+
? tutorial.frontmatter.title
136+
: tutorial.frontmatter.courseTitle}
137+
</h3>
138+
{tutorial.frontmatter.status ? (
139+
<p>
140+
<span>New</span>
141+
</p>
142+
) : null}
143+
</CardHead>
144+
<CardDesc>
145+
<p className="summary">{tutorial.frontmatter.description}</p>
146+
</CardDesc>
147+
{!isCreateLearningPath && (
148+
<CardSubdata className="card-subdata">
149+
<p>
150+
{courseCount} {courseType}
151+
{courseCount > 1 ? 's' : ''}
152+
</p>
153+
</CardSubdata>
154+
)}
155+
<CardImage>
156+
<img src={tutorial.frontmatter.cardImage} />
157+
</CardImage>
158+
</div>
159+
</CardParent>
160+
</CardActive>
161+
</OptionalLink>
147162
)}
148-
</OptionalLink>
163+
</>
149164
)}
165+
166+
<Modal
167+
open={modalOpen}
168+
closeModal={handleModalClose}
169+
title={tutorial.frontmatter.title || tutorial.frontmatter.courseTitle}
170+
maxWidth="sm"
171+
>
172+
<ModalBody>
173+
<Typography variant="body1">{modalContent}</Typography>
174+
{orgId && (
175+
<Typography variant="body1" color="textSecondary">
176+
Your Organization ID: {orgId}
177+
</Typography>
178+
)}
179+
</ModalBody>
180+
<ModalFooter variant="filled">
181+
<ModalButtonSecondary onClick={handleModalClose}>Close</ModalButtonSecondary>
182+
{path && (
183+
<ModalButtonPrimary
184+
onClick={() => {
185+
window.open(path, '_blank');
186+
handleModalClose();
187+
}}
188+
>
189+
Visit Docs
190+
</ModalButtonPrimary>
191+
)}
192+
</ModalFooter>
193+
</Modal>
150194
</CardWrapper>
151195
);
152196
};

src/custom/LearningCard/style.tsx

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,31 @@ const CardActive = styled('div')(({ theme }) => ({
2020
const OwnLearningCard = styled('div')(({ theme }) => ({
2121
cursor: 'pointer',
2222
transition: 'all 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) 0.1s',
23+
position: 'relative',
24+
overflow: 'hidden',
2325
'&:hover': {
2426
boxShadow: `${theme.palette.background.brand?.default} 0px 0px 19px 6px`
2527
},
26-
background: `
27-
repeating-linear-gradient(
28-
45deg,
29-
transparent,
30-
transparent 10px,
31-
#ccc 10px,
32-
#ccc 20px
33-
),
34-
linear-gradient(
35-
to bottom,
36-
#eee,
37-
#999
38-
)
39-
`
28+
background: `linear-gradient(135deg,
29+
rgba(255, 255, 255, 0.85) 0%,
30+
rgba(248, 250, 252, 0.9) 50%,
31+
rgba(241, 245, 249, 0.85) 100%)`,
32+
'&::before': {
33+
content: '""',
34+
position: 'absolute',
35+
top: 0,
36+
left: 0,
37+
right: 0,
38+
bottom: 0,
39+
background: `repeating-linear-gradient(
40+
45deg,
41+
transparent,
42+
transparent 15px,
43+
rgba(148, 163, 184, 0.1) 15px,
44+
rgba(148, 163, 184, 0.1) 30px
45+
)`,
46+
pointerEvents: 'none'
47+
}
4048
}));
4149

4250
const CardLink = styled('a')({

src/custom/ResourceDetailFormatters/Formatter.tsx

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ import {
5757
TableDataFormatterProps,
5858
TextWithLinkFormatterProps
5959
} from './types';
60-
import { splitCamelCaseString } from './utils';
60+
import { parseCpu, splitCamelCaseString } from './utils';
6161

6262
interface ResourceProgressProps {
6363
title: string;
@@ -368,10 +368,12 @@ export const MemoryUsage: React.FC<MemoryUsageProps> = ({
368368
return parseInt(kiValue.replace('Ki', '')) * 1024;
369369
}, []);
370370

371-
const cpuUsage = useMemo(() => {
371+
const reservedCpu = useMemo(() => {
372372
if (!allocatable || !capacity) return 0;
373-
const usedCPU = parseInt(capacity.cpu) - parseInt(allocatable.cpu);
374-
return (usedCPU / parseInt(capacity.cpu)) * 100;
373+
const usedCPU = parseCpu(capacity.cpu) - parseCpu(allocatable.cpu);
374+
const capacityCPU = parseCpu(capacity.cpu);
375+
376+
return (usedCPU / capacityCPU) * 100;
375377
}, [allocatable, capacity]);
376378

377379
const memoryUsage = useMemo(() => {
@@ -382,12 +384,14 @@ export const MemoryUsage: React.FC<MemoryUsageProps> = ({
382384
return (usedMemory / totalMemory) * 100;
383385
}, [allocatable, capacity]);
384386

385-
const diskUsage = useMemo(() => {
387+
const diskUsagePercent = useMemo(() => {
386388
if (!allocatable || !capacity) return 0;
387-
const totalStorageInBytes = convertKiToBytes(capacity['ephemeral-storage']);
388-
const availableStorageInBytes = parseInt(allocatable['ephemeral-storage']);
389-
const usedStorageInBytes = totalStorageInBytes - availableStorageInBytes;
390-
return (usedStorageInBytes / totalStorageInBytes) * 100;
389+
390+
const total = convertKiToBytes(capacity['ephemeral-storage']);
391+
const available = convertKiToBytes(allocatable['ephemeral-storage']);
392+
393+
const used = total - available;
394+
return (used / total) * 100;
391395
}, [allocatable, capacity, convertKiToBytes]);
392396

393397
const chartOptions = useCallback(
@@ -439,9 +443,9 @@ export const MemoryUsage: React.FC<MemoryUsageProps> = ({
439443

440444
return (
441445
<FlexResourceContainer>
442-
<ResourceProgress title="CPU Usage" percentage={cpuUsage} type={'CPU'} />
446+
<ResourceProgress title="System Reserved Cpu" percentage={reservedCpu} type={'CPU'} />
443447
<ResourceProgress title="Memory Usage" percentage={memoryUsage} type={'Memory'} />
444-
<ResourceProgress title="Disk Usage" percentage={diskUsage} type={'Disk'} />
448+
<ResourceProgress title="Disk Usage" percentage={diskUsagePercent} type={'Disk'} />
445449
</FlexResourceContainer>
446450
);
447451
};

src/custom/ResourceDetailFormatters/utils.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,24 @@ export const convertToReadableUnit = (value: number): string => {
103103

104104
return `${value.toFixed(2)} ${units[index]}`;
105105
};
106+
107+
/**
108+
* Parses a Kubernetes CPU string (e.g., "100m", "1", "1000000n")
109+
* and returns the CPU value in cores as a float.
110+
*/
111+
export function parseCpu(cpu: string): number {
112+
if (!cpu) return 0;
113+
114+
if (cpu.endsWith('n')) {
115+
// Nanocores → cores
116+
return parseInt(cpu.slice(0, -1), 10) / 1_000_000_000;
117+
}
118+
119+
if (cpu.endsWith('m')) {
120+
// Millicores → cores
121+
return parseInt(cpu.slice(0, -1), 10) / 1000;
122+
}
123+
124+
// No suffix = cores
125+
return parseFloat(cpu);
126+
}

src/custom/TeamTable/TeamTable.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ interface TeamTableProps {
1616
columns: MUIDataTableColumn[];
1717
updateCols: (cols: any) => void;
1818
isRemoveFromTeamAllowed: boolean;
19+
isEditUserAllowed?: any;
20+
handleEditUser?: any;
1921
org_id: string;
2022
useGetUsersForOrgQuery: any;
2123
useNotificationHandlers: any;
@@ -39,6 +41,8 @@ const TeamTable: React.FC<TeamTableProps> = ({
3941
columns,
4042
updateCols,
4143
isRemoveFromTeamAllowed,
44+
isEditUserAllowed,
45+
handleEditUser,
4246
org_id,
4347
useGetUsersForOrgQuery,
4448
useNotificationHandlers,
@@ -66,6 +70,8 @@ const TeamTable: React.FC<TeamTableProps> = ({
6670
<UsersTable
6771
teamID={teamID}
6872
isRemoveFromTeamAllowed={isRemoveFromTeamAllowed}
73+
isEditUserAllowed={isEditUserAllowed}
74+
handleEditUser={handleEditUser}
6975
org_id={org_id}
7076
useGetUsersForOrgQuery={useGetUsersForOrgQuery}
7177
useNotificationHandlers={useNotificationHandlers}

0 commit comments

Comments
 (0)