Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into release/v3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Carsten Schafer authored and Carsten Schafer committed Mar 21, 2024
2 parents c05bd48 + 6f56df5 commit 13bc30d
Show file tree
Hide file tree
Showing 18 changed files with 641 additions and 460 deletions.
4 changes: 3 additions & 1 deletion helm/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ metadata:
{{- end }}

spec:

{{- if $ingressValue.className }}
ingressClassName: {{ $ingressValue.className }}
{{- end }}
{{- if $ingressValue.tls }}
tls:
{{- range $ingressValue.tls }}
Expand Down
425 changes: 216 additions & 209 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wlan-cloud-owprov-ui",
"version": "3.0.0(5)",
"version": "3.0.2(2)",
"description": "",
"main": "index.tsx",
"scripts": {
Expand Down
60 changes: 20 additions & 40 deletions src/components/Buttons/FileInputButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,73 +2,55 @@ import React, { useEffect, useState } from 'react';
import { FormControl, Input, InputGroup } from '@chakra-ui/react';
import { v4 as uuid } from 'uuid';

interface Props {
interface FileInputButtonProps {
value: string;
setValue: (v: string, file?: File) => void;
setFileName?: (v: string) => void;
refreshId: string;
accept: string;
isHidden?: boolean;
isStringFile?: boolean;
wantBase64?: boolean;
sizeLimit?: number;
}

const defaultProps = {
setFileName: undefined,
isHidden: false,
isStringFile: false,
};

const FileInputButton = ({
const FileInputButton: React.FC<FileInputButtonProps> = ({
value,
setValue,
setFileName,
refreshId,
accept,
isHidden,
isStringFile,
wantBase64,
}: Props) => {
sizeLimit,
}) => {
const [fileKey, setFileKey] = useState(uuid());
let fileReader: FileReader | undefined;

const handleStringFileRead = () => {
const handleStringFileRead = (file: File) => () => {
if (fileReader) {
const content = fileReader.result;
if (content) {
setValue(content as string);
}
}
};

const handleBase64FileRead = () => {
if (fileReader) {
const content = fileReader.result;
if (content && typeof content === 'string') {
const split = content.split('base64,');
if (split[1]) {
setValue(split[1] as string);
}
setValue(content as string, file);
}
}
};

const changeFile = (e: React.ChangeEvent<HTMLInputElement>) => {
const file = e.target.files ? e.target.files[0] : undefined;
if (file) {
const newVal = URL.createObjectURL(file);
if (wantBase64) {
fileReader = new FileReader();
fileReader.onloadend = handleBase64FileRead;
fileReader.readAsDataURL(file);
} else if (!isStringFile) {
setValue(newVal, file);
if (setFileName) setFileName(file.name ?? '');
if (sizeLimit && file.size > sizeLimit) {
setFileKey(uuid());
} else {
fileReader = new FileReader();
if (setFileName) setFileName(file.name);
fileReader.onloadend = handleStringFileRead;
fileReader.readAsText(file);
const newVal = URL.createObjectURL(file);
if (!isStringFile) {
setValue(newVal, file);
if (setFileName) setFileName(file.name ?? '');
} else {
fileReader = new FileReader();
if (setFileName) setFileName(file.name);
fileReader.onloadend = handleStringFileRead(file);
fileReader.readAsText(file);
}
}
}
};
Expand All @@ -94,6 +76,4 @@ const FileInputButton = ({
);
};

FileInputButton.defaultProps = defaultProps;

export default FileInputButton;
export default React.memo(FileInputButton);
42 changes: 0 additions & 42 deletions src/components/FormFields/ConfigurationFieldExplanation/index.jsx

This file was deleted.

51 changes: 51 additions & 0 deletions src/components/FormFields/ConfigurationFieldExplanation/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import React, { useMemo } from 'react';
import { InfoIcon } from '@chakra-ui/icons';
import { Tooltip } from '@chakra-ui/react';
import { useAuth } from 'contexts/AuthProvider';

const findDefinition = (
definitionKey?: string,
CONFIGURATION_DESCRIPTIONS?: {
[key: string]: { properties?: { [key: string]: { description: string } } };
},
) => {
try {
if (!definitionKey || !CONFIGURATION_DESCRIPTIONS) return null;
const split = definitionKey.split('.');
const { length } = split;
if (length < 2) return null;
const start = split.slice(0, length - 1);
const end = split[length - 1];
return (
CONFIGURATION_DESCRIPTIONS[start.slice(0, length - 1).join('.')]?.properties?.[end ?? '']?.description ?? null
);
} catch (e) {
return null;
}
};

interface ConfigurationFieldExplanationProps {
definitionKey?: string;
}
const ConfigurationFieldExplanation: React.FC<ConfigurationFieldExplanationProps> = ({ definitionKey }) => {
const { configurationDescriptions } = useAuth();
const definition = useMemo(
() =>
findDefinition(
definitionKey,
configurationDescriptions as {
[key: string]: { properties: { [key: string]: { description: string } } };
},
),
[configurationDescriptions],
);
if (!definition) return null;

return (
<Tooltip hasArrow label={definition}>
<InfoIcon ml={2} mb="2px" />
</Tooltip>
);
};

export default React.memo(ConfigurationFieldExplanation);
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useCreateResource, useUpdateResource } from 'hooks/Network/Resources';
import { Note } from 'models/Note';
import { Resource } from 'models/Resource';
import { INTERFACE_CAPTIVE_SCHEMA } from 'pages/ConfigurationPage/ConfigurationCard/ConfigurationSectionsCard/InterfaceSection/interfacesConstants';
import Captive from 'pages/ConfigurationPage/ConfigurationCard/ConfigurationSectionsCard/InterfaceSection/SingleInterface/Captive/Captive';
import Captive from 'pages/ConfigurationPage/ConfigurationCard/ConfigurationSectionsCard/InterfaceSection/SingleInterface/SsidList/Captive/Captive';

export const EDIT_SCHEMA = (t: (str: string) => string) =>
object().shape({
Expand Down Expand Up @@ -211,7 +211,7 @@ const InterfaceCaptiveResource = ({
<StringField name="_unused_name" label={t('common.name')} isRequired isDisabled={isDisabled} />
<StringField name="_unused_description" label={t('common.description')} isDisabled={isDisabled} />
</SimpleGrid>
<Captive namePrefix="editing" isDisabled={isDisabled} isActive />
<Captive namePrefix="editing" isDisabled={isDisabled} />
</TabPanel>
<TabPanel>
<NotesTable name="_unused_notes" isDisabled={isDisabled} />
Expand Down
11 changes: 10 additions & 1 deletion src/components/Tables/InventoryTable/EditTagModal/Form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ const EditTagForm = ({
return '';
};

const deviceListWithType = React.useMemo(() => {
const { deviceType } = tag;
if (deviceTypesList.includes(deviceType)) return deviceTypesList;

const newList = [...deviceTypesList, deviceType];

return newList.sort((a, b) => a.localeCompare(b));
}, [deviceTypesList]);

useEffect(() => {
setFormKey(uuid());
setIsDeleted(false);
Expand Down Expand Up @@ -288,7 +297,7 @@ const EditTagForm = ({
<SelectField
name="deviceType"
label={t('inventory.device_type')}
options={deviceTypesList.map((deviceType) => ({
options={deviceListWithType.map((deviceType) => ({
value: deviceType,
label: deviceType,
}))}
Expand Down

This file was deleted.

Loading

0 comments on commit 13bc30d

Please sign in to comment.