From 6d40d2b7ad7ad782816df111655d7b8540f76c73 Mon Sep 17 00:00:00 2001 From: Jarek Kowalski Date: Sun, 19 Sep 2021 09:57:26 -0700 Subject: [PATCH] ui: Added UI options to select shallow restore options (#1301) --- htmlui/src/BeginRestore.js | 19 ++++++++++++++++++- htmlui/src/RepoStatus.js | 2 +- htmlui/src/forms.js | 16 ++++++++++++++++ snapshot/restore/restore.go | 2 ++ 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/htmlui/src/BeginRestore.js b/htmlui/src/BeginRestore.js index 35b928f36..3be5893c7 100644 --- a/htmlui/src/BeginRestore.js +++ b/htmlui/src/BeginRestore.js @@ -5,7 +5,7 @@ import Form from 'react-bootstrap-v5/lib/Form'; import Row from 'react-bootstrap-v5/lib/Row'; import Col from 'react-bootstrap-v5/lib/Col'; import { Link } from "react-router-dom"; -import { handleChange, RequiredBoolean, RequiredField, validateRequiredFields } from './forms'; +import { handleChange, RequiredBoolean, RequiredField, RequiredNumberField, validateRequiredFields } from './forms'; import { errorAlert, GoBackButton } from './uiutil'; export class BeginRestore extends Component { @@ -23,6 +23,8 @@ export class BeginRestore extends Component { overwriteDirectories: false, overwriteSymlinks: false, ignorePermissionErrors: true, + restoreDirEntryAtDepth: 1000, + minSizeForPlaceholder: 0, restoreTask: "", }; @@ -44,6 +46,8 @@ export class BeginRestore extends Component { options: { incremental: this.state.incremental, ignoreErrors: this.state.continueOnErrors, + restoreDirEntryAtDepth: this.state.restoreDirEntryAtDepth, + minSizeForPlaceholder: this.state.minSizeForPlaceholder, }, } @@ -119,9 +123,22 @@ export class BeginRestore extends Component { {RequiredBoolean(this, "Overwrite Symbolic Links", "overwriteSymlinks")} + +
+
+ + {RequiredNumberField(this, "Shallow Restore At Depth", "restoreDirEntryAtDepth")} + {RequiredNumberField(this, "Minimal File Size For Shallow Restore", "minSizeForPlaceholder")} + + +
+
{RequiredBoolean(this, "Disable ZIP compression", "uncompressedZip", "Do not compress when restoring to a ZIP file (faster).")} + +
+
diff --git a/htmlui/src/RepoStatus.js b/htmlui/src/RepoStatus.js index 3e438a593..05d74bca2 100644 --- a/htmlui/src/RepoStatus.js +++ b/htmlui/src/RepoStatus.js @@ -160,7 +160,7 @@ export class RepoStatus extends Component { - Supports Content Compression + Internal Compression diff --git a/htmlui/src/forms.js b/htmlui/src/forms.js index 3eb9def9d..065a4fa8e 100644 --- a/htmlui/src/forms.js +++ b/htmlui/src/forms.js @@ -138,6 +138,22 @@ export function OptionalNumberField(component, label, name, props = {}) { } + +export function RequiredNumberField(component, label, name, props = {}) { + return + {label} + component.handleChange(e, valueToNumber)} + data-testid={'control-' + name} + {...props} /> + Must be a valid number or empty + +} + export function hasExactlyOneOf(component, names) { let count = 0; diff --git a/snapshot/restore/restore.go b/snapshot/restore/restore.go index 0624ecac6..a6fdec61f 100644 --- a/snapshot/restore/restore.go +++ b/snapshot/restore/restore.go @@ -65,6 +65,8 @@ func (s *Stats) clone() Stats { // Options provides optional restore parameters. type Options struct { + // NOTE: this structure is passed as-is from the UI, make sure to add + // required bindings in the UI. Parallel int `json:"parallel"` Incremental bool `json:"incremental"` IgnoreErrors bool `json:"ignoreErrors"`