mirror of
https://github.com/kopia/kopia.git
synced 2026-03-16 21:28:15 -04:00
* htmlui: upgraded bootstrap to v5.0.2 and react-bootstrap to v5 * htmlui: fixed test warnings * app: removed unused dependencies on bootstrap and react-bootstrap * more style fixes
134 lines
4.9 KiB
JavaScript
134 lines
4.9 KiB
JavaScript
import axios from 'axios';
|
|
import React, { Component } from 'react';
|
|
import Button from 'react-bootstrap-v5/lib/Button';
|
|
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 { errorAlert, GoBackButton } from './uiutil';
|
|
|
|
export class BeginRestore extends Component {
|
|
constructor(props) {
|
|
super();
|
|
|
|
this.state = {
|
|
incremental: true,
|
|
continueOnErrors: false,
|
|
restoreOwnership: true,
|
|
restorePermissions: true,
|
|
restoreModTimes: true,
|
|
uncompressedZip: true,
|
|
overwriteFiles: false,
|
|
overwriteDirectories: false,
|
|
overwriteSymlinks: false,
|
|
ignorePermissionErrors: true,
|
|
restoreTask: "",
|
|
};
|
|
|
|
this.handleChange = handleChange.bind(this);
|
|
this.start = this.start.bind(this);
|
|
}
|
|
|
|
start(e) {
|
|
e.preventDefault();
|
|
|
|
if (!validateRequiredFields(this, ["destination"])) {
|
|
return;
|
|
}
|
|
|
|
const dst = (this.state.destination + "");
|
|
|
|
let req = {
|
|
root: this.props.match.params.oid,
|
|
options: {
|
|
incremental: this.state.incremental,
|
|
ignoreErrors: this.state.continueOnErrors,
|
|
},
|
|
}
|
|
|
|
if (dst.endsWith(".zip")) {
|
|
req.zipFile = dst;
|
|
req.uncompressedZip = this.state.uncompressedZip;
|
|
} else if (dst.endsWith(".tar")) {
|
|
req.tarFile = dst;
|
|
} else {
|
|
req.fsOutput = {
|
|
targetPath: dst,
|
|
skipOwners: !this.state.restoreOwnership,
|
|
skipPermissions: !this.state.restorePermissions,
|
|
skipTimes: !this.state.restoreModTimes,
|
|
|
|
ignorePermissionErrors: this.state.ignorePermissionErrors,
|
|
overwriteFiles: this.state.overwriteFiles,
|
|
overwriteDirectories: this.state.overwriteDirectories,
|
|
overwriteSymlinks: this.state.overwriteSymlinks,
|
|
}
|
|
}
|
|
|
|
axios.post('/api/v1/restore', req).then(result => {
|
|
this.setState({
|
|
restoreTask: result.data.id,
|
|
})
|
|
this.props.history.replace("/tasks/" + result.data.id);
|
|
}).catch(error => {
|
|
errorAlert(error);
|
|
});
|
|
}
|
|
|
|
render() {
|
|
if (this.state.restoreTask) {
|
|
return <p>
|
|
<GoBackButton onClick={this.props.history.goBack} />
|
|
<Link replace="true" to={"/tasks/" + this.state.restoreTask}>Go To Restore Task</Link>.
|
|
</p>;
|
|
}
|
|
|
|
return <div className="padded-top">
|
|
<GoBackButton onClick={this.props.history.goBack} /> <span className="page-title">Restore</span>
|
|
<hr/>
|
|
<Form onSubmit={this.start}>
|
|
<Row>
|
|
{RequiredField(this, "Destination", "destination", {
|
|
autoFocus: true,
|
|
placeholder: "enter destination path",
|
|
},
|
|
"You can also restore to a .zip or .tar file by providing the appropriate extension.")}
|
|
</Row>
|
|
<Row>
|
|
{RequiredBoolean(this, "Skip previously restored files and symlinks", "incremental")}
|
|
</Row>
|
|
<Row>
|
|
{RequiredBoolean(this, "Continue on Errors", "continueOnErrors", "When a restore error occurs, attempt to continue instead of failing fast.")}
|
|
</Row>
|
|
<Row>
|
|
{RequiredBoolean(this, "Restore File Ownership", "restoreOwnership")}
|
|
</Row>
|
|
<Row>
|
|
{RequiredBoolean(this, "Restore File Permissions", "restorePermissions")}
|
|
</Row>
|
|
<Row>
|
|
{RequiredBoolean(this, "Restore File Modification Time", "restoreModTimes")}
|
|
</Row>
|
|
<Row>
|
|
{RequiredBoolean(this, "Overwrite Files", "overwriteFiles")}
|
|
</Row>
|
|
<Row>
|
|
{RequiredBoolean(this, "Overwrite Directories", "overwriteDirectories")}
|
|
</Row>
|
|
<Row>
|
|
{RequiredBoolean(this, "Overwrite Symbolic Links", "overwriteSymlinks")}
|
|
</Row>
|
|
<Row>
|
|
{RequiredBoolean(this, "Disable ZIP compression", "uncompressedZip", "Do not compress when restoring to a ZIP file (faster).")}
|
|
</Row>
|
|
<Row>
|
|
<Col>
|
|
<Button variant="primary" type="submit" data-testid="submit-button">Begin Restore</Button>
|
|
</Col>
|
|
</Row>
|
|
</Form>
|
|
</div>;
|
|
}
|
|
}
|