Skip to content

Commit

Permalink
client: imp validation ui
Browse files Browse the repository at this point in the history
  • Loading branch information
ainar-g committed Nov 21, 2022
1 parent 93882d6 commit fd65a99
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions client/src/__locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@
"encryption_issuer": "Issuer",
"encryption_hostnames": "Hostnames",
"encryption_reset": "Are you sure you want to reset encryption settings?",
"encryption_warning": "Warning",
"topline_expiring_certificate": "Your SSL certificate is about to expire. Update <0>Encryption settings</0>.",
"topline_expired_certificate": "Your SSL certificate is expired. Update <0>Encryption settings</0>.",
"form_error_port_range": "Enter port number in the range of 80-65535",
Expand Down
28 changes: 23 additions & 5 deletions client/src/components/Settings/Encryption/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,26 @@ const clearFields = (change, setTlsConfig, t) => {
}
};

const validationMessage = (warningValidation, isWarning) => {
if (!warningValidation) {
return null;
}

if (isWarning) {
return (
<div className="col-12">
<p><Trans>encryption_warning</Trans>: {warningValidation}</p>
</div>
);
}

return (
<div className="col-12">
<p className="text-danger">{warningValidation}</p>
</div>
);
};

let Form = (props) => {
const {
t,
Expand Down Expand Up @@ -95,6 +115,8 @@ let Form = (props) => {
|| !valid_cert
|| !valid_pair;

const isWarning = valid_key && valid_cert && valid_pair;

return (
<form onSubmit={handleSubmit}>
<div className="row">
Expand Down Expand Up @@ -382,11 +404,7 @@ let Form = (props) => {
)}
</div>
</div>
{warning_validation && (
<div className="col-12">
<p className="text-danger">{warning_validation}</p>
</div>
)}
{validationMessage(warning_validation, isWarning)}
</div>

<div className="btn-list mt-2">
Expand Down

0 comments on commit fd65a99

Please sign in to comment.