Skip to content

Commit

Permalink
systemd: drop unrequired validated
Browse files Browse the repository at this point in the history
validated shadows helperTextInvalid in a sense, so we can simply pass
helperTextInvalid instead.

Found by Github code scanning.
  • Loading branch information
jelly authored and martinpitt committed Jun 20, 2023
1 parent 483027a commit 934a4e3
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions pkg/systemd/timer-dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,20 +266,17 @@ const CreateTimerDialogBody = ({ owner }) => {
label = _("Run on");

let helperTextInvalid;
let validated = "default";
const min = repeatPatterns[idx].minute;
const validationFailedMinute = !(/^[0-9]+$/.test(min) && min <= 59 && min >= 0);

if (submitted && repeat == 'hourly' && validationFailedMinute) {
validated = "error";
helperTextInvalid = _("Minute needs to be a number between 0-59");
}

const sec = repeatPatterns[idx].second;
const validationFailedSecond = !(/^[0-9]+$/.test(sec) && sec <= 59 && sec >= 0);

if (submitted && repeat == 'minutely' && validationFailedSecond) {
validated = "error";
helperTextInvalid = _("Second needs to be a number between 0-59");
}

Expand Down Expand Up @@ -388,7 +385,7 @@ const CreateTimerDialogBody = ({ owner }) => {
</InputGroup>
</FlexItem>}
</Flex>
<FormHelper helperTextInvalid={validated && helperTextInvalid} />
<FormHelper helperTextInvalid={helperTextInvalid} />
</FormGroup>
);
})}
Expand Down

0 comments on commit 934a4e3

Please sign in to comment.