change the boolean variable isAdminPwdField to hasComplexityRequirements

This commit is contained in:
dorj222 2023-02-21 16:10:38 +01:00
parent 1d535ea9b5
commit 63e25fae3f
3 changed files with 12 additions and 12 deletions

View file

@ -32,7 +32,7 @@ export type TextFieldProps = {
useTrim?: boolean; useTrim?: boolean;
useTrimLead?: boolean; useTrimLead?: boolean;
value?: string | number; value?: string | number;
isAdminPwdField?: boolean; hasComplexityRequirements?: boolean;
onBlur?: FieldUpdaterFunc; onBlur?: FieldUpdaterFunc;
onChange?: FieldUpdaterFunc; onChange?: FieldUpdaterFunc;
}; };
@ -55,7 +55,7 @@ export const TextField: FC<TextFieldProps> = ({
type, type,
useTrim, useTrim,
value, value,
isAdminPwdField, hasComplexityRequirements,
}) => { }) => {
const [hasPwdChanged, setHasPwdChanged] = useState(false); const [hasPwdChanged, setHasPwdChanged] = useState(false);
const [showPwdButton, setShowPwdButton] = useState(false); const [showPwdButton, setShowPwdButton] = useState(false);
@ -65,7 +65,7 @@ export const TextField: FC<TextFieldProps> = ({
if (onChange) { if (onChange) {
const val = type === TEXTFIELD_TYPE_NUMBER ? e : e.target.value; const val = type === TEXTFIELD_TYPE_NUMBER ? e : e.target.value;
setShowPwdButton(true); setShowPwdButton(true);
if (isAdminPwdField && REGEX_PASSWORD.test(val)) { if (hasComplexityRequirements && REGEX_PASSWORD.test(val)) {
setHasPwdChanged(true); setHasPwdChanged(true);
} else { } else {
setHasPwdChanged(false); setHasPwdChanged(false);
@ -150,7 +150,7 @@ export const TextField: FC<TextFieldProps> = ({
</div> </div>
) : null} ) : null}
{!isAdminPwdField ? ( {!hasComplexityRequirements ? (
<div className="input-side"> <div className="input-side">
<div className="input-group"> <div className="input-group">
<Field <Field
@ -231,7 +231,7 @@ TextField.defaultProps = {
pattern: '', pattern: '',
useTrim: false, useTrim: false,
useTrimLead: false, useTrimLead: false,
isAdminPwdField: false, hasComplexityRequirements: false,
onSubmit: () => {}, onSubmit: () => {},
onBlur: () => {}, onBlur: () => {},

View file

@ -24,7 +24,7 @@ export type TextFieldWithSubmitProps = TextFieldProps & {
apiPath: string; apiPath: string;
configPath?: string; configPath?: string;
initialValue?: string; initialValue?: string;
isAdminPwdField?: boolean; hasComplexityRequirements?: boolean;
}; };
export const TextFieldWithSubmit: FC<TextFieldWithSubmitProps> = ({ export const TextFieldWithSubmit: FC<TextFieldWithSubmitProps> = ({
@ -44,7 +44,7 @@ export const TextFieldWithSubmit: FC<TextFieldWithSubmitProps> = ({
let resetTimer = null; let resetTimer = null;
const { fieldName, required, tip, status, value, isAdminPwdField, onChange, onSubmit } = const { fieldName, required, tip, status, value, hasComplexityRequirements, onChange, onSubmit } =
textFieldProps; textFieldProps;
// Clear out any validation states and messaging // Clear out any validation states and messaging
@ -138,7 +138,7 @@ export const TextFieldWithSubmit: FC<TextFieldWithSubmitProps> = ({
<div className="field-tip">{tip}</div> <div className="field-tip">{tip}</div>
<FormStatusIndicator status={status || submitStatus} /> <FormStatusIndicator status={status || submitStatus} />
<div className="update-button-container"> <div className="update-button-container">
{!isAdminPwdField && ( {!hasComplexityRequirements && (
<Button <Button
type="primary" type="primary"
size="small" size="small"

View file

@ -122,7 +122,7 @@ export const TEXTFIELD_PROPS_ADMIN_PASSWORD = {
label: 'Admin Password', label: 'Admin Password',
tip: 'Save this password somewhere safe, you will need it to login to the admin dashboard!', tip: 'Save this password somewhere safe, you will need it to login to the admin dashboard!',
required: true, required: true,
isAdminPwdField: true, hasComplexityRequirements: true,
}; };
export const TEXTFIELD_PROPS_FFMPEG = { export const TEXTFIELD_PROPS_FFMPEG = {
apiPath: API_FFMPEG, apiPath: API_FFMPEG,
@ -132,7 +132,7 @@ export const TEXTFIELD_PROPS_FFMPEG = {
label: 'FFmpeg Path', label: 'FFmpeg Path',
tip: 'Absolute file path of the FFMPEG application on your server', tip: 'Absolute file path of the FFMPEG application on your server',
required: true, required: true,
isAdminPwdField: false, hasComplexityRequirements: false,
}; };
export const TEXTFIELD_PROPS_WEB_PORT = { export const TEXTFIELD_PROPS_WEB_PORT = {
apiPath: API_WEB_PORT, apiPath: API_WEB_PORT,
@ -142,7 +142,7 @@ export const TEXTFIELD_PROPS_WEB_PORT = {
label: 'Owncast port', label: 'Owncast port',
tip: 'What port is your Owncast web server listening? Default is 8080', tip: 'What port is your Owncast web server listening? Default is 8080',
required: true, required: true,
isAdminPwdField: false, hasComplexityRequirements: false,
}; };
export const TEXTFIELD_PROPS_RTMP_PORT = { export const TEXTFIELD_PROPS_RTMP_PORT = {
apiPath: API_RTMP_PORT, apiPath: API_RTMP_PORT,
@ -152,7 +152,7 @@ export const TEXTFIELD_PROPS_RTMP_PORT = {
label: 'RTMP port', label: 'RTMP port',
tip: 'What port should accept inbound broadcasts? Default is 1935', tip: 'What port should accept inbound broadcasts? Default is 1935',
required: true, required: true,
isAdminPwdField: false, hasComplexityRequirements: false,
}; };
export const TEXTFIELD_PROPS_INSTANCE_URL = { export const TEXTFIELD_PROPS_INSTANCE_URL = {
apiPath: API_INSTANCE_URL, apiPath: API_INSTANCE_URL,