Skip to content

Commit ebcb059

Browse files
authored
Merge pull request #879 from amitamrutiya/update-da
add deplinking and collapse expand support for meshery ui
2 parents ffa3213 + b6735ba commit ebcb059

4 files changed

Lines changed: 42 additions & 8 deletions

File tree

src/custom/ResourceDetailFormatters/Component.tsx

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import React from 'react';
1+
import UnfoldLessIcon from '@mui/icons-material/UnfoldLess';
2+
import UnfoldMoreIcon from '@mui/icons-material/UnfoldMore';
3+
import React, { useState } from 'react';
24
import { Grid, IconButton, Typography } from '../../base';
3-
import { iconSmall } from '../../constants/iconsSizes';
5+
import { iconSmall, iconXSmall } from '../../constants/iconsSizes';
46
import { CopyIcon } from '../../icons';
57
import { useTheme } from '../../theme';
68
import { CustomTooltip } from './../CustomTooltip';
@@ -29,7 +31,7 @@ import {
2931
PrimaryDetailsProps,
3032
SectionHeadingProps
3133
} from './types';
32-
import { splitCamelCaseString } from './utils.js';
34+
import { splitCamelCaseString } from './utils';
3335

3436
export const PrimaryDetails: React.FC<PrimaryDetailsProps> = ({ title, value, hide = false }) => {
3537
const titleFormatted = splitCamelCaseString(title);
@@ -151,16 +153,39 @@ export const ActionIconButton: React.FC<ActionIconButtonProps> = ({ title, Icon,
151153
);
152154
};
153155

154-
export const KeyValueInRow: React.FC<KeyValueProps> = ({ Key, Value }) => {
156+
export const KeyValueInRow: React.FC<KeyValueProps> = ({ Key, Value, showFold = false }) => {
157+
const [isFolded, setIsFolded] = useState(true);
158+
155159
if (!Value || !Key) return null;
160+
161+
const handleToggleFold = () => {
162+
setIsFolded(!isFolded);
163+
};
164+
156165
return (
157166
<KeyValueGrid container>
158167
<React.Fragment key={Key}>
159-
<KeyValueGridCell item xs={3}>
168+
<KeyValueGridCell container xs={3} spacing={1}>
160169
<KeyValueGridTitle>{Key}</KeyValueGridTitle>
170+
{showFold && (
171+
<IconButton onClick={handleToggleFold}>
172+
{isFolded ? (
173+
<UnfoldMoreIcon style={iconXSmall} />
174+
) : (
175+
<UnfoldLessIcon style={iconXSmall} />
176+
)}
177+
</IconButton>
178+
)}
161179
</KeyValueGridCell>
162180
<Grid item xs={9}>
163-
<div>{React.isValidElement(Value) ? Value : String(Value)}</div>
181+
<div
182+
style={{
183+
maxHeight: showFold && isFolded ? '200px' : 'none',
184+
overflow: showFold ? 'auto' : 'none'
185+
}}
186+
>
187+
{React.isValidElement(Value) ? Value : String(Value)}
188+
</div>
164189
</Grid>
165190
</React.Fragment>
166191
</KeyValueGrid>

src/custom/ResourceDetailFormatters/styles.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,5 +306,6 @@ export const KeyValueGridTitle = styled(Typography)({
306306
});
307307

308308
export const KeyValueGridCell = styled(Grid)({
309-
placeSelf: 'center'
309+
placeSelf: 'center',
310+
alignItems: 'center'
310311
});

src/custom/ResourceDetailFormatters/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export interface ActionIconButtonProps {
6464
export interface KeyValueProps {
6565
Key: string;
6666
Value: string | number | ReactNode;
67+
showFold?: boolean;
6768
}
6869

6970
export interface EnvironmentFormatterProps {
@@ -264,5 +265,6 @@ export interface GetResourceCleanDataProps {
264265
dispatchMsgToEditor?: (msg: any) => void;
265266
activeLabels?: string[];
266267
showStatus?: boolean;
268+
router?: any;
267269
container?: any;
268270
}

src/custom/ResourceDetailFormatters/useResourceCleanData.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export const useResourceCleanData = () => {
6767
resource,
6868
activeLabels,
6969
dispatchMsgToEditor,
70+
router,
7071
showStatus = true,
7172
container
7273
}: GetResourceCleanDataProps) => {
@@ -110,8 +111,13 @@ export const useResourceCleanData = () => {
110111
links: [
111112
{ nodeName: parsedSpec?.nodeName, label: 'Node' },
112113
{ namespace: resource?.metadata?.namespace, label: 'Namespace' },
113-
{ serviceAccount: parsedSpec?.serviceAccountName, label: 'ServiceAccount' }
114+
{
115+
serviceAccount: parsedSpec?.serviceAccountName,
116+
label: 'ServiceAccount',
117+
resourceCategory: 'Security'
118+
}
114119
],
120+
router: router,
115121
dispatchMsgToEditor: dispatchMsgToEditor
116122
},
117123
selector: parsedSpec?.selector?.matchLabels

0 commit comments

Comments
 (0)