Skip to content

Commit

Permalink
fix: hide delete operation button if operation is in progress or pending
Browse files Browse the repository at this point in the history
  • Loading branch information
garethgeorge committed Feb 15, 2024
1 parent f5521e7 commit 08c8762
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions webui/src/components/OperationTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,28 @@ const BackupView = ({ backup }: { backup?: BackupInfo }) => {
}
}

const deleteButton = backup.snapshotId ?
<Tooltip title="This will remove the snapshot from the repository. This is irreversible.">
<ConfirmButton
type="text"
style={{ color: "white" }}
confirmTitle="Confirm forget?"
confirmTimeout={2000}
onClickAsync={doDeleteSnapshot}
>Forget (Destructive)</ConfirmButton>
</Tooltip> : <ConfirmButton
type="text"
style={{ color: "white" }}
confirmTitle="Confirm clear?"
onClickAsync={async () => {
backrestService.clearHistory(new ClearHistoryRequest({
ops: backup.operations.map((op) => op.id),
}))
}}
>
Delete Event
</ConfirmButton>;

return <div style={{ width: "100%" }}>
<div style={{
alignItems: "center",
Expand All @@ -291,27 +313,7 @@ const BackupView = ({ backup }: { backup?: BackupInfo }) => {
}}>
<h3>Backup on {formatTime(backup.displayTime)}</h3>
<div style={{ position: "absolute", right: "20px" }}>
{backup.snapshotId ?
<Tooltip title="This will remove the snapshot from the repository. This is irreversible.">
<ConfirmButton
type="text"
style={{ color: "white" }}
confirmTitle="Confirm forget?"
confirmTimeout={2000}
onClickAsync={doDeleteSnapshot}
>Forget Snapshot (Destructive)</ConfirmButton>
</Tooltip> : <ConfirmButton
type="text"
style={{ color: "white" }}
confirmTitle="Confirm clear?"
onClickAsync={async () => {
backrestService.clearHistory(new ClearHistoryRequest({
ops: backup.operations.map((op) => op.id),
}))
}}
>
Delete Event
</ConfirmButton>}
{backup.status !== OperationStatus.STATUS_PENDING && backup.status != OperationStatus.STATUS_INPROGRESS ? deleteButton : null}
</div>
</div>
<OperationList key={backup.id} useBackups={[backup]} filter={(op) => op && !shouldHideOperation(op)} />
Expand Down

0 comments on commit 08c8762

Please sign in to comment.