Skip to content

Commit

Permalink
fix: BackupInfoCollector handling of filtered events
Browse files Browse the repository at this point in the history
  • Loading branch information
garethgeorge committed Feb 29, 2024
1 parent 56f5e40 commit f1e4619
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 11 additions & 2 deletions webui/src/state/oplog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ export class BackupInfoCollector {

public addOperation(event: OperationEventType, op: Operation): BackupInfo | null {
if (!this.filter(op)) {
this.removeOperation(op);
return null;
}
const backupInfo = this.addHelper(op);
Expand All @@ -245,7 +246,15 @@ export class BackupInfoCollector {
// removeOperaiton is not quite correct from a formal standpoint; but will look correct in the UI.
public removeOperation(op: Operation) {
if (op.snapshotId) {
this.backupBySnapshotId.delete(op.snapshotId);
let existing = this.backupBySnapshotId.get(op.snapshotId);
if (existing) {
const operations = existing.operations.filter((o) => o.id !== op.id);
if (operations.length === 0) {
this.backupBySnapshotId.delete(op.snapshotId);
} else {
this.backupBySnapshotId.set(op.snapshotId, this.createBackup(operations));
}
}
} else {
this.backupByOpId.delete(op.id);
}
Expand Down Expand Up @@ -293,7 +302,7 @@ export class BackupInfoCollector {
...this.backupByOpId.values(),
...this.backupBySnapshotId.values(),
];
return arr.filter((b) => !b.forgotten);
return arr.filter((b) => !b.forgotten && !shouldHideStatus(b.status));
}

public subscribe(
Expand Down
4 changes: 0 additions & 4 deletions webui/src/views/AddPlanModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -477,21 +477,17 @@ export const AddPlanModal = ({
const RetentionPolicyView = () => {
const form = Form.useFormInstance();
const retention = Form.useWatch('retention', { form, preserve: true }) as RetentionPolicy | undefined;
console.log("RETENTION: " + JSON.stringify(retention));

let [mode, setMode] = useState(0);
useEffect(() => {
if (!retention || (!retention.keepDaily && !retention.keepHourly && !retention.keepLastN && !retention.keepMonthly && !retention.keepWeekly && !retention.keepYearly)) {
console.log("RETENTION NOT SET");
setMode(0);
} else if (!!retention.keepLastN) {
console.log("KEEP LAST N: ", retention.keepLastN);
setMode(1);
} else {
setMode(2);
}
}, [retention])
console.log("MODE: ", mode);

let elem: React.ReactNode = null;
if (mode === 0) {
Expand Down

0 comments on commit f1e4619

Please sign in to comment.