Version Revert

This commit is contained in:
Terry 2021-05-10 11:00:14 +02:00
parent 31697b9781
commit ab9efa09d4
4 changed files with 75 additions and 5 deletions

View File

@ -338,7 +338,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
/**
* @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com>
*
* @author John Molakvoæ <skjnldsv@protonmail.com>
* @author Julius Härtl <jus@bitgrid.net>
* @author Enoch <enoch@nextcloud.com>
*
@ -41735,6 +41735,12 @@ __webpack_require__.r(__webpack_exports__);
/* harmony import */ var _nextcloud_router__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_nextcloud_router__WEBPACK_IMPORTED_MODULE_6__);
/* harmony import */ var _nextcloud_auth__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @nextcloud/auth */ "./node_modules/@nextcloud/auth/dist/index.js");
/* harmony import */ var _nextcloud_auth__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_nextcloud_auth__WEBPACK_IMPORTED_MODULE_7__);
/* harmony import */ var _services_DavClient__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../services/DavClient */ "./apps/files_versions/src/services/DavClient.js");
/* harmony import */ var _nextcloud_dialogs__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @nextcloud/dialogs */ "./node_modules/@nextcloud/dialogs/dist/index.es.js");
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
//
//
//
@ -41783,6 +41789,8 @@ __webpack_require__.r(__webpack_exports__);
/* harmony default export */ __webpack_exports__["default"] = ({
name: 'VersionEntry',
components: {
@ -41804,6 +41812,13 @@ __webpack_require__.r(__webpack_exports__);
required: true
}
},
data: function data() {
return {
error: '',
revert: '',
file: ''
};
},
computed: {
// Does the current user have permissions to revert this file
canRevert: function canRevert() {
@ -41835,7 +41850,42 @@ __webpack_require__.r(__webpack_exports__);
}
},
methods: {
restoreVersion: function restoreVersion() {// TODO: implement restore request and loading
restoreVersion: function restoreVersion() {
var _this = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
var revert;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.prev = 0;
_context.next = 3;
return Object(_services_DavClient__WEBPACK_IMPORTED_MODULE_8__["move"])('/remote.php/dav/versions/{user}' + _this.version.basename, {
user: Object(_nextcloud_auth__WEBPACK_IMPORTED_MODULE_7__["getCurrentUser"])().uid
}, '/restore/target', true);
case 3:
revert = _context.sent;
_this.revert = revert;
_context.next = 11;
break;
case 7:
_context.prev = 7;
_context.t0 = _context["catch"](0);
_this.error = t('files_versions', 'There was an error reverting the version {file}', {
file: _this.fileInfo.basename
});
Object(_nextcloud_dialogs__WEBPACK_IMPORTED_MODULE_9__["showError"])(_this.error);
case 11:
case "end":
return _context.stop();
}
}
}, _callee, null, [[0, 7]]);
}))();
}
}
});

File diff suppressed because one or more lines are too long

View File

@ -49,6 +49,8 @@ import ListItemIcon from '@nextcloud/vue/dist/Components/ListItemIcon'
import { generateUrl } from '@nextcloud/router'
import { getCurrentUser } from '@nextcloud/auth'
import { move } from '../services/DavClient'
import { showError } from '@nextcloud/dialogs'
export default {
name: 'VersionEntry',
@ -74,6 +76,13 @@ export default {
required: true,
},
},
data() {
return {
error: '',
revert: '',
file: '',
}
},
computed: {
// Does the current user have permissions to revert this file
@ -110,8 +119,19 @@ export default {
},
methods: {
restoreVersion() {
async restoreVersion() {
// TODO: implement restore request and loading
try {
const revert = await move('/remote.php/dav/versions/{user}' + this.version.basename, {
user: getCurrentUser().uid,
}, '/restore/target', true)
this.revert = revert
} catch (error) {
this.error = t('files_versions', 'There was an error reverting the version {file}', {
file: this.fileInfo.basename,
})
showError(this.error)
}
},
},
}

View File

@ -1,6 +1,6 @@
/**
* @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com>
*
* @author John Molakvoæ <skjnldsv@protonmail.com>
* @author Julius Härtl <jus@bitgrid.net>
* @author Enoch <enoch@nextcloud.com>
*