Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fixes for orphan clean up modal #138

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/components/orphan-cleanup-task-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
NumberInput,
} from '@patternfly/react-core';
import React from 'react';
import { FormFieldHelper } from 'src/components/form-field-helper';

interface IProps {
cancelAction: () => void;
Expand Down Expand Up @@ -48,14 +49,29 @@ export const OrphanCleanupTaskModal = (props: IProps) => {
orphan_protection_time: taskValue.orphan_protection_time - 1,
});
}}
onChange={(event) => {
// @ts-expect-error:Property 'value' does not exist on type 'EventTarget'.
const value = Number(event.target.value);
if (value < 0 || Number.isNaN(value)) {
updateTask({
orphan_protection_time: 0,
});
} else {
updateTask({
orphan_protection_time: value,
});
}
}}
min={0}
max={100}
onPlus={() => {
updateTask({
orphan_protection_time: taskValue.orphan_protection_time + 1,
});
}}
/>
<FormFieldHelper>
{t`The value is in minutes. Usually the default is a day (1440). If set to zero it will clean all orphans.`}
</FormFieldHelper>
<br />
</FormGroup>
</Form>
Expand Down
4 changes: 3 additions & 1 deletion src/containers/task-management/task-list-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ interface IState {
repairTask: { verify_checksums: boolean };
}

const ORPHAN_PROTECTION_TIME = 1440;

export class TaskListView extends Component<RouteProps, IState> {
constructor(props) {
super(props);
Expand Down Expand Up @@ -102,7 +104,7 @@ export class TaskListView extends Component<RouteProps, IState> {
finished_before: `${today.getFullYear()}-${today.getMonth() + 1}-${today.getDate()}`,
states: ['completed'],
},
orphanCleanupTask: { orphan_protection_time: 0 },
orphanCleanupTask: { orphan_protection_time: ORPHAN_PROTECTION_TIME },
repairTask: { verify_checksums: true },
};
}
Expand Down