Skip to content

Commit

Permalink
Merge branch 'master' into feat/panel
Browse files Browse the repository at this point in the history
  • Loading branch information
amitamrutiya authored Jan 27, 2025
2 parents b13ff72 + fdb745a commit df32123
Show file tree
Hide file tree
Showing 33 changed files with 692 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bump-meshery-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ jobs:
cache: "npm"
cache-dependency-path: '**/package-lock.json'
- name: Make changes to pull request
run: npm install @layer5/sistent@${{needs.versions-check.outputs.current}}
run: npm install @layer5/sistent@${{needs.versions-check.outputs.current}} --legacy-peer-deps
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v7
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ Find out more on the <a href="https://layer5.io/community">Layer5 community</a>.
<br /><br /><br /><br />

</p>

<div>&nbsp;</div>

<a href="https://slack.meshery.io">
Expand Down
7 changes: 6 additions & 1 deletion src/base/Pagination/Pagination.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { Pagination as MuiPagination, PaginationProps as MuiPaginationProps } from '@mui/material';
import {
Pagination as MuiPagination,
PaginationItem as MuiPaginationItem,
PaginationProps as MuiPaginationProps
} from '@mui/material';
import React from 'react';

const Pagination = React.forwardRef<HTMLDivElement, MuiPaginationProps>((props, ref) => {
return <MuiPagination {...props} ref={ref} />;
});

export { MuiPaginationItem as PaginationItem };
export default Pagination;
4 changes: 2 additions & 2 deletions src/base/Pagination/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PaginationProps } from '@mui/material';
import Pagination from './Pagination';
import Pagination, { PaginationItem } from './Pagination';

export { Pagination };
export { Pagination, PaginationItem };
export type { PaginationProps };
39 changes: 19 additions & 20 deletions src/custom/CatalogDetail/ActionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,31 +76,13 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
width: '100%'
}}
>
<ActionButton
sx={{
borderRadius: '0.2rem',
backgroundColor: 'transparent',
border: `1px solid ${theme.palette.border.normal}`,
gap: '10px',
color: theme.palette.text.default
}}
onClick={() =>
cleanedType === VIEWS
? downloadYaml(details.pattern_file, details.name)
: downloadPattern(details.id, details.name, getDownloadUrl)
}
>
<Download width={24} height={24} fill={theme.palette.icon.default} />
Download
</ActionButton>

{cleanedType !== FILTERS && (
<ActionButton
sx={{
backgroundColor: showOpenPlaygroundAction ? 'transparent' : undefined,
color: theme.palette.text.default,
borderRadius: '0.2rem',
gap: '10px',
color: theme.palette.text.default,
backgroundColor: 'transparent',
border: `1px solid ${theme.palette.border.normal}`
}}
onClick={() => handleClone(details?.name, details?.id)}
Expand All @@ -116,6 +98,23 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
)}
</ActionButton>
)}
<ActionButton
sx={{
borderRadius: '0.2rem',
backgroundColor: 'transparent',
border: `1px solid ${theme.palette.border.normal}`,
gap: '10px',
color: theme.palette.text.default
}}
onClick={() =>
cleanedType === VIEWS
? downloadYaml(details.pattern_file, details.name)
: downloadPattern(details.id, details.name, getDownloadUrl)
}
>
<Download width={24} height={24} fill={theme.palette.icon.default} />
Download
</ActionButton>
</div>
)}

Expand Down
3 changes: 1 addition & 2 deletions src/custom/CatalogDetail/style.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,7 @@ export const RedirectLink = styled(Link)(({ theme }) => ({
export const ShareButtonGroup = styled(ButtonGroup)({
boxShadow: 'none',
border: 'none',
outline: 'none',
height: '76%'
outline: 'none'
});

export const ShareButton = styled(Button)(({ theme }) => ({
Expand Down
4 changes: 3 additions & 1 deletion src/custom/Markdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
BasicAnchorMarkdown,
StyledMarkdown,
StyledMarkdownBlockquote,
StyledMarkdownCode,
StyledMarkdownH1,
StyledMarkdownH2,
StyledMarkdownH3,
Expand Down Expand Up @@ -54,7 +55,8 @@ export const RenderMarkdown: React.FC<RenderMarkdownProps> = ({ content }) => {
li: ({ ...props }) => <StyledMarkdownLi>{props.children}</StyledMarkdownLi>,
th: ({ ...props }) => <StyledMarkdownTh>{props.children}</StyledMarkdownTh>,
td: ({ ...props }) => <StyledMarkdownTd>{props.children}</StyledMarkdownTd>,
pre: ({ ...props }) => <StyledMarkdownPre>{props.children}</StyledMarkdownPre>
pre: ({ ...props }) => <StyledMarkdownPre>{props.children}</StyledMarkdownPre>,
code: ({ ...props }) => <StyledMarkdownCode>{props.children}</StyledMarkdownCode>
}}
>
{content}
Expand Down
9 changes: 9 additions & 0 deletions src/custom/Markdown/style.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,12 @@ export const StyledMarkdownPre = styled('pre')(({ theme }) => ({
whiteSpace: 'pre-line',
fontFamily: 'inherit'
}));

export const StyledMarkdownCode = styled('code')(({ theme }) => ({
background: theme.palette.background.code,
whiteSpace: 'pre-line',
padding: '1.5px',
paddingInline: '5px',
fontFamily: 'inherit',
borderRadius: 3
}));
4 changes: 2 additions & 2 deletions src/custom/Prompt/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import PromptComponent from './promt-component';

import PromptComponent, { PROMPT_VARIANTS } from './promt-component';
export { PROMPT_VARIANTS, PromptComponent };
export default PromptComponent;
46 changes: 40 additions & 6 deletions src/custom/Prompt/promt-component.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { forwardRef, useImperativeHandle, useRef, useState } from 'react';
import { Typography } from '../../base';
import { Checkbox, FormControlLabel, Typography } from '../../base';
import { useTheme } from '../../theme';
import { Modal, ModalBody, ModalButtonPrimary, ModalButtonSecondary, ModalFooter } from '../Modal';
import { ActionComponent, Subtitle } from './style';
Expand All @@ -26,6 +26,8 @@ interface State {
showInfoIcon?: string;
variant?: PromptVariant;
headerIcon?: React.ReactNode;
showCheckbox?: boolean;
isChecked?: boolean;
}

interface ShowParams {
Expand All @@ -34,11 +36,13 @@ interface ShowParams {
primaryOption: string;
variant: PromptVariant;
showInfoIcon?: string;
showCheckbox?: boolean;
headerIcon?: React.ReactNode;
}

export interface PromptRef {
show: (params: ShowParams) => Promise<string>;
getCheckboxState: () => boolean;
}

const PromptComponent = forwardRef<PromptRef, PromptProps>(({ variant }, ref) => {
Expand All @@ -49,7 +53,9 @@ const PromptComponent = forwardRef<PromptRef, PromptProps>(({ variant }, ref) =>
primaryOption: '',
showInfoIcon: '',
variant,
headerIcon: undefined
headerIcon: undefined,
isChecked: false,
showCheckbox: false
});

/* This ref is used to store the resolve and reject functions of the promise returned by the show method */
Expand All @@ -67,7 +73,8 @@ const PromptComponent = forwardRef<PromptRef, PromptProps>(({ variant }, ref) =>
setState({
...params,
isOpen: true,
showInfoIcon: params.showInfoIcon || ''
showInfoIcon: params.showInfoIcon || '',
showCheckbox: !!params.showCheckbox
});
});
};
Expand All @@ -77,11 +84,20 @@ const PromptComponent = forwardRef<PromptRef, PromptProps>(({ variant }, ref) =>
setState((prevState) => ({ ...prevState, isOpen: false }));
};

const handleCheckboxChange = () => {
setState((prevState) => ({ ...prevState, isChecked: !prevState.isChecked }));
};

const getCheckboxState = () => {
return !!state.isChecked;
};

useImperativeHandle(ref, () => ({
show
show,
getCheckboxState
}));

const { isOpen, primaryOption, title, subtitle, showInfoIcon, headerIcon } = state;
const { isOpen, primaryOption, title, subtitle, showInfoIcon, headerIcon, showCheckbox } = state;
const { resolve } = promiseInfoRef.current;

return (
Expand All @@ -96,10 +112,28 @@ const PromptComponent = forwardRef<PromptRef, PromptProps>(({ variant }, ref) =>
{subtitle && (
<ModalBody>
<Subtitle id="alert-dialog-description" variant="body1" component="div">
<Typography variant="body1" component="div">
<Typography
variant="body1"
component="div"
style={{
color: theme.palette.text.primary
}}
>
{subtitle}
</Typography>
</Subtitle>
{showCheckbox && (
<FormControlLabel
control={
<Checkbox
checked={getCheckboxState()}
onChange={handleCheckboxChange}
color="primary"
/>
}
label={<span style={{ fontSize: '1rem' }}>Do not show again</span>}
/>
)}
</ModalBody>
)}
<ModalFooter variant="filled" helpText={showInfoIcon}>
Expand Down
3 changes: 2 additions & 1 deletion src/custom/ResourceDetailFormatters/Formatter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
StyledEnvironmentVariablesCode,
StyledEnvironmentVariablesPre,
StyledTitle,
TextValue,
Wrap
} from './styles';
import {
Expand Down Expand Up @@ -201,7 +202,7 @@ export const OperatorDynamicFormatter: React.FC<OperatorDynamicFormatterProps> =
return (
<>
<ElementData>
{data}
<TextValue>{data}</TextValue>
{regex.test(data) && <CopyToClipboard data={data} />}
</ElementData>
</>
Expand Down
13 changes: 10 additions & 3 deletions src/custom/ResourceDetailFormatters/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const Title = styled('span')({
fontFamily: 'Qanelas Soft, sans-serif'
});

export const ElementData = styled('span')({
export const ElementData = styled('div')({
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
Expand Down Expand Up @@ -184,14 +184,21 @@ export const EnvironmentVariableValue = styled('span')({
export const CodeFormatterPre = styled('pre')(({ theme }) => ({
backgroundColor: theme.palette.mode === 'light' ? '#e9eff1' : '#212121',
color: theme.palette.text.primary,
width: '100%',
wordWrap: 'break-word',
overflowWrap: 'break-word',
wordBreak: 'break-all',
margin: 0,
padding: '0.5rem'
padding: '0.5rem',
maxWidth: '-moz-available'
}));

export const TextValue = styled(Box)({
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
width: 'inherit',
overflow: 'hidden'
});

export const CodeFormatterCode = styled('code')(({ theme }) => ({
backgroundColor: theme.palette.mode === 'light' ? '#e9eff1' : '#212121',
color: theme.palette.text.primary,
Expand Down
1 change: 1 addition & 0 deletions src/custom/ResourceDetailFormatters/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,5 @@ export interface GetResourceCleanDataProps {
dispatchMsgToEditor?: (msg: any) => void;
activeLabels?: string[];
showStatus?: boolean;
container?: any;
}
4 changes: 3 additions & 1 deletion src/custom/ResourceDetailFormatters/useResourceCleanData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@ export const useResourceCleanData = () => {
resource,
activeLabels,
dispatchMsgToEditor,
showStatus = true
showStatus = true,
container
}: GetResourceCleanDataProps) => {
const parsedStatus = resource?.status?.attribute && JSON.parse(resource?.status?.attribute);
const parsedSpec = resource?.spec?.attribute && JSON.parse(resource?.spec.attribute);
const numberStates = structureNumberStates(parsedStatus, parsedSpec);
const kind = resource?.kind ?? resource?.component?.kind;
const cleanData = {
container: container,
age: getAge(resource?.metadata?.creationTimestamp),
kind: kind,
status: showStatus && getStatus(parsedStatus),
Expand Down
2 changes: 1 addition & 1 deletion src/custom/TransferModal/TransferList/TransferList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function getFallbackImageBasedOnKind(kind: string | undefined): JSX.Eleme
}

export interface TransferListProps {
name: string;
name?: string;
assignableData: ListItemType[];
assignedData: (data: ListItemType[]) => void;
originalAssignedData: ListItemType[];
Expand Down
30 changes: 16 additions & 14 deletions src/custom/UserSearchField/UserSearchField.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Autocomplete from '@mui/material/Autocomplete';
import CircularProgress from '@mui/material/CircularProgress';
import { debounce } from 'lodash';
import React, { useState } from 'react';
import { Avatar, Box, Chip, Grid, TextField, Tooltip, Typography } from '../../base';
import { iconSmall } from '../../constants/iconsSizes';
Expand Down Expand Up @@ -88,21 +89,22 @@ const UserShareSearch: React.FC<UserSearchFieldProps> = ({
}
};

const handleInputChange = (_event: React.SyntheticEvent<Element, Event>, value: string) => {
if (value === '') {
setOptions([]);
setOpen(false);
} else {
setSearchUserLoading(true);
fetchSuggestions(value).then((filteredData) => {
setOptions(filteredData);
const handleInputChange = debounce(
async (_event: React.SyntheticEvent<Element, Event>, value: string) => {
if (value === '') {
setOptions([]);
setOpen(false);
} else {
setSearchUserLoading(true);
const suggestions = await fetchSuggestions(value);
setOptions(suggestions);
setSearchUserLoading(false);
});
setError(false);
setOpen(true);
}
};

setError(false);
setOpen(true);
}
},
300
);
/**
* Clone customUsersList component to pass necessary props
*/
Expand Down
Loading

0 comments on commit df32123

Please sign in to comment.