- add OnBlur to Field and Select
- update regex to remove dot for jwtttl
This commit is contained in:
1 parent
f707965155
commit
6425113766
4 files changed
+27
-6
No files matched your search
@@ -41,6 +41,7 @@ const Field = forwardRef(
|
|||||||
placeholder,
|
placeholder,
|
||||||
value,
|
value,
|
||||||
onChange,
|
onChange,
|
||||||
|
onBlur,
|
||||||
onInput,
|
onInput,
|
||||||
error,
|
error,
|
||||||
disabled,
|
disabled,
|
||||||
@@ -115,6 +116,7 @@ const Field = forwardRef(
|
|||||||
value={value}
|
value={value}
|
||||||
onInput={onInput}
|
onInput={onInput}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
|
onBlur={onBlur}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
inputRef={ref}
|
inputRef={ref}
|
||||||
inputProps={{
|
inputProps={{
|
||||||
@@ -216,6 +218,7 @@ Field.propTypes = {
|
|||||||
placeholder: PropTypes.string,
|
placeholder: PropTypes.string,
|
||||||
value: PropTypes.string.isRequired,
|
value: PropTypes.string.isRequired,
|
||||||
onChange: PropTypes.func,
|
onChange: PropTypes.func,
|
||||||
|
onBlur: PropTypes.func,
|
||||||
onInput: PropTypes.func,
|
onInput: PropTypes.func,
|
||||||
error: PropTypes.string,
|
error: PropTypes.string,
|
||||||
disabled: PropTypes.bool,
|
disabled: PropTypes.bool,
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ const Select = ({
|
|||||||
value,
|
value,
|
||||||
items,
|
items,
|
||||||
onChange,
|
onChange,
|
||||||
|
onBlur,
|
||||||
sx,
|
sx,
|
||||||
name = "",
|
name = "",
|
||||||
}) => {
|
}) => {
|
||||||
@@ -76,6 +77,7 @@ const Select = ({
|
|||||||
className="select-component"
|
className="select-component"
|
||||||
value={value}
|
value={value}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
|
onBlur={onBlur}
|
||||||
displayEmpty
|
displayEmpty
|
||||||
name={name}
|
name={name}
|
||||||
inputProps={{ id: id }}
|
inputProps={{ id: id }}
|
||||||
@@ -140,6 +142,7 @@ Select.propTypes = {
|
|||||||
})
|
})
|
||||||
).isRequired,
|
).isRequired,
|
||||||
onChange: PropTypes.func.isRequired,
|
onChange: PropTypes.func.isRequired,
|
||||||
|
onBlur: PropTypes.func,
|
||||||
sx: PropTypes.object,
|
sx: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -74,18 +74,23 @@ const AdvancedSettings = ({ isAdmin }) => {
|
|||||||
setLocalSettings({ ...localSettings, logLevel: newLogLevel });
|
setLocalSettings({ ...localSettings, logLevel: newLogLevel });
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleChange = (event) => {
|
const handleBlur = (event) => {
|
||||||
const { value, id } = event.target;
|
const { value, id } = event.target;
|
||||||
setLocalSettings({ ...localSettings, [id]: value });
|
|
||||||
const { error } = advancedSettingsValidation.validate(
|
const { error } = advancedSettingsValidation.validate(
|
||||||
{ [id]: value },
|
{ [id]: value },
|
||||||
{
|
{
|
||||||
abortEarly: false,
|
abortEarly: false,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
setErrors((prev) => {
|
if (error) {
|
||||||
return buildErrors(prev, id, error);
|
setErrors((prev) => {
|
||||||
});
|
return buildErrors(prev, id, error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const handleChange = (event) => {
|
||||||
|
const { value, id } = event.target;
|
||||||
|
setLocalSettings({ ...localSettings, [id]: value });
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
@@ -131,6 +136,7 @@ const AdvancedSettings = ({ isAdmin }) => {
|
|||||||
label="API URL Host"
|
label="API URL Host"
|
||||||
value={localSettings.apiBaseUrl}
|
value={localSettings.apiBaseUrl}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
onBlur={handleBlur}
|
||||||
error={errors.apiBaseUrl}
|
error={errors.apiBaseUrl}
|
||||||
/>
|
/>
|
||||||
<Select
|
<Select
|
||||||
@@ -140,6 +146,7 @@ const AdvancedSettings = ({ isAdmin }) => {
|
|||||||
items={logItems}
|
items={logItems}
|
||||||
value={logItemLookup[localSettings.logLevel]}
|
value={logItemLookup[localSettings.logLevel]}
|
||||||
onChange={handleLogLevel}
|
onChange={handleLogLevel}
|
||||||
|
onBlur={handleBlur}
|
||||||
error={errors.logLevel}
|
error={errors.logLevel}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
@@ -160,6 +167,7 @@ const AdvancedSettings = ({ isAdmin }) => {
|
|||||||
name="systemEmailHost"
|
name="systemEmailHost"
|
||||||
value={localSettings.systemEmailHost}
|
value={localSettings.systemEmailHost}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
onBlur={handleBlur}
|
||||||
error={errors.systemEmailHost}
|
error={errors.systemEmailHost}
|
||||||
/>
|
/>
|
||||||
<Field
|
<Field
|
||||||
@@ -169,6 +177,7 @@ const AdvancedSettings = ({ isAdmin }) => {
|
|||||||
name="systemEmailPort"
|
name="systemEmailPort"
|
||||||
value={localSettings.systemEmailPort.toString()}
|
value={localSettings.systemEmailPort.toString()}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
onBlur={handleBlur}
|
||||||
error={errors.systemEmailPort}
|
error={errors.systemEmailPort}
|
||||||
/>
|
/>
|
||||||
<Field
|
<Field
|
||||||
@@ -187,6 +196,7 @@ const AdvancedSettings = ({ isAdmin }) => {
|
|||||||
name="systemEmailPassword"
|
name="systemEmailPassword"
|
||||||
value={localSettings.systemEmailPassword}
|
value={localSettings.systemEmailPassword}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
onBlur={handleBlur}
|
||||||
error={errors.systemEmailPassword}
|
error={errors.systemEmailPassword}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
@@ -206,6 +216,7 @@ const AdvancedSettings = ({ isAdmin }) => {
|
|||||||
name="jwtTTL"
|
name="jwtTTL"
|
||||||
value={localSettings.jwtTTL}
|
value={localSettings.jwtTTL}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
onBlur={handleBlur}
|
||||||
error={errors.jwtTTL}
|
error={errors.jwtTTL}
|
||||||
/>
|
/>
|
||||||
<Field
|
<Field
|
||||||
@@ -215,6 +226,7 @@ const AdvancedSettings = ({ isAdmin }) => {
|
|||||||
name="dbType"
|
name="dbType"
|
||||||
value={localSettings.dbType}
|
value={localSettings.dbType}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
onBlur={handleBlur}
|
||||||
error={errors.dbType}
|
error={errors.dbType}
|
||||||
/>
|
/>
|
||||||
<Field
|
<Field
|
||||||
@@ -224,6 +236,7 @@ const AdvancedSettings = ({ isAdmin }) => {
|
|||||||
name="redisHost"
|
name="redisHost"
|
||||||
value={localSettings.redisHost}
|
value={localSettings.redisHost}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
onBlur={handleBlur}
|
||||||
error={errors.redisHost}
|
error={errors.redisHost}
|
||||||
/>
|
/>
|
||||||
<Field
|
<Field
|
||||||
@@ -233,6 +246,7 @@ const AdvancedSettings = ({ isAdmin }) => {
|
|||||||
name="redisPort"
|
name="redisPort"
|
||||||
value={localSettings.redisPort.toString()}
|
value={localSettings.redisPort.toString()}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
onBlur={handleBlur}
|
||||||
error={errors.redisPort}
|
error={errors.redisPort}
|
||||||
/>
|
/>
|
||||||
<Field
|
<Field
|
||||||
@@ -242,6 +256,7 @@ const AdvancedSettings = ({ isAdmin }) => {
|
|||||||
name="pagespeedApiKey"
|
name="pagespeedApiKey"
|
||||||
value={localSettings.pagespeedApiKey}
|
value={localSettings.pagespeedApiKey}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
onBlur={handleBlur}
|
||||||
error={errors.pagespeedApiKey}
|
error={errors.pagespeedApiKey}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ const advancedSettingsValidation = joi.object({
|
|||||||
.custom((value, helpers) => {
|
.custom((value, helpers) => {
|
||||||
// test against regx start with a number followed by number or .,
|
// test against regx start with a number followed by number or .,
|
||||||
//ends with d or h
|
//ends with d or h
|
||||||
const regex = /^[1-9]+\d*(.)*(d|h)$/;
|
const regex = /^[1-9]+\d*(d|h)$/;
|
||||||
const found = value.match(regex);
|
const found = value.match(regex);
|
||||||
if (!found) {
|
if (!found) {
|
||||||
return helpers.message(
|
return helpers.message(
|
||||||
|
|||||||
Reference in new issue
Block a user