Version Entry update

This commit is contained in:
Terry 2021-05-07 17:58:36 +02:00
commit 31697b9781
6 changed files with 59 additions and 94 deletions

View File

@ -338,8 +338,10 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
/** /**
* @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com> * @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com>
*
* @author Julius Härtl <jus@bitgrid.net>
* @author Enoch <enoch@nextcloud.com> * @author Enoch <enoch@nextcloud.com>
* @author John Molakvoæ <skjnldsv@protonmail.com> *
* @license GNU AGPL version 3 or any later version * @license GNU AGPL version 3 or any later version
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -349,7 +351,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
@ -369,7 +371,7 @@ var fetchFileVersions = /*#__PURE__*/function () {
VersionsUrl = '/versions/' + fileId; VersionsUrl = '/versions/' + fileId;
_context.next = 3; _context.next = 3;
return _DavClient__WEBPACK_IMPORTED_MODULE_0__["default"].getDirectoryContents(VersionsUrl, { return _DavClient__WEBPACK_IMPORTED_MODULE_0__["default"].getDirectoryContents(VersionsUrl, {
data: "<?xml version=\"1.0\"?>\n\t\t\t<d:propfind xmlns:d=\"DAV:\" xmlns:oc=\"http://owncloud.org/ns\">\n\t\t\t <d:prop>\n\t\t\t\t<d:getcontentlength />\n\t\t\t\t<d:getcontenttype />\n\t\t\t\t<d:getlastmodified />\n\t\t\t </d:prop>\n\t\t\t</d:propfind>", data: "<?xml version=\"1.0\"?>\n\t\t\t<d:propfind xmlns:d=\"DAV:\" xmlns:oc=\"http://owncloud.org/ns\">\n\t\t\t<d:prop>\n\t\t\t\t<d:getcontentlength />\n\t\t\t\t<d:getcontenttype />\n\t\t\t\t<d:getlastmodified />\n\t\t\t</d:prop>\n\t\t\t</d:propfind>",
details: true details: true
}); });
@ -41733,7 +41735,6 @@ __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_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__ = __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 _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");
// //
// //
// //
@ -41774,9 +41775,6 @@ __webpack_require__.r(__webpack_exports__);
// //
// //
// //
//
//
@ -41804,10 +41802,6 @@ __webpack_require__.r(__webpack_exports__);
version: { version: {
type: Object, type: Object,
required: true required: true
},
tooltip: {
type: String,
default: ''
} }
}, },
computed: { computed: {
@ -41841,12 +41835,7 @@ __webpack_require__.r(__webpack_exports__);
} }
}, },
methods: { methods: {
// Restores the original file to this revision restoreVersion: function restoreVersion() {// TODO: implement restore request and loading
restoreVersion: function restoreVersion() {
// TODO: implement restore request and loading
return _services_DavClient__WEBPACK_IMPORTED_MODULE_8__["default"].move('/remote.php/dav/versions/{user}' + this.version.basename, {
user: Object(_nextcloud_auth__WEBPACK_IMPORTED_MODULE_7__["getCurrentUser"])().uid
}, '/restore/target', true);
} }
} }
}); });
@ -41862,9 +41851,9 @@ __webpack_require__.r(__webpack_exports__);
"use strict"; "use strict";
__webpack_require__.r(__webpack_exports__); __webpack_require__.r(__webpack_exports__);
/* harmony import */ var _nextcloud_vue_dist_Components_EmptyContent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @nextcloud/vue/dist/Components/EmptyContent */ "./node_modules/@nextcloud/vue/dist/Components/EmptyContent.js"); /* harmony import */ var _nextcloud_dialogs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @nextcloud/dialogs */ "./node_modules/@nextcloud/dialogs/dist/index.es.js");
/* harmony import */ var _nextcloud_vue_dist_Components_EmptyContent__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_nextcloud_vue_dist_Components_EmptyContent__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _nextcloud_vue_dist_Components_EmptyContent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @nextcloud/vue/dist/Components/EmptyContent */ "./node_modules/@nextcloud/vue/dist/Components/EmptyContent.js");
/* harmony import */ var _nextcloud_dialogs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @nextcloud/dialogs */ "./node_modules/@nextcloud/dialogs/dist/index.es.js"); /* harmony import */ var _nextcloud_vue_dist_Components_EmptyContent__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_nextcloud_vue_dist_Components_EmptyContent__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _components_VersionEntry__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../components/VersionEntry */ "./apps/files_versions/src/components/VersionEntry.vue"); /* harmony import */ var _components_VersionEntry__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../components/VersionEntry */ "./apps/files_versions/src/components/VersionEntry.vue");
/* harmony import */ var _services_FileVersion__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../services/FileVersion */ "./apps/files_versions/src/services/FileVersion.js"); /* harmony import */ var _services_FileVersion__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../services/FileVersion */ "./apps/files_versions/src/services/FileVersion.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 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); } }
@ -41912,6 +41901,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
// //
// //
// //
//
@ -41919,8 +41909,8 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
/* harmony default export */ __webpack_exports__["default"] = ({ /* harmony default export */ __webpack_exports__["default"] = ({
name: 'VersionTab', name: 'VersionTab',
components: { components: {
VersionEntry: _components_VersionEntry__WEBPACK_IMPORTED_MODULE_2__["default"], EmptyContent: _nextcloud_vue_dist_Components_EmptyContent__WEBPACK_IMPORTED_MODULE_1___default.a,
EmptyContent: _nextcloud_vue_dist_Components_EmptyContent__WEBPACK_IMPORTED_MODULE_0___default.a VersionEntry: _components_VersionEntry__WEBPACK_IMPORTED_MODULE_2__["default"]
}, },
data: function data() { data: function data() {
return { return {
@ -41936,9 +41926,9 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
}, },
methods: { methods: {
/** /**
* Update current fileInfo and fetch new data * Update current fileInfo and fetch new data
* @param {Object} fileInfo the current file FileInfo * @param {Object} fileInfo the current file FileInfo
*/ */
update: function update(fileInfo) { update: function update(fileInfo) {
var _this = this; var _this = this;
@ -41984,7 +41974,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
_this2.error = t('files_versions', 'There was an error fetching the list of versions for the file {file}', { _this2.error = t('files_versions', 'There was an error fetching the list of versions for the file {file}', {
file: _this2.fileInfo.basename file: _this2.fileInfo.basename
}); });
Object(_nextcloud_dialogs__WEBPACK_IMPORTED_MODULE_1__["showError"])(_this2.error); Object(_nextcloud_dialogs__WEBPACK_IMPORTED_MODULE_0__["showError"])(_this2.error);
console.error(_context2.t0); console.error(_context2.t0);
case 14: case 14:
@ -63711,7 +63701,7 @@ __webpack_require__.r(__webpack_exports__);
var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0___default()(function(i){return i[1]}); var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0___default()(function(i){return i[1]});
// Module // Module
___CSS_LOADER_EXPORT___.push([module.i, ".version-entry[data-v-29c8cb3b] {\n display: flex;\n align-items: center;\n height: 44px;\n}\n.version-entry__desc[data-v-29c8cb3b] {\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n padding: 8px;\n line-height: 1.6em;\n}\n.version-entry__desc p[data-v-29c8cb3b] {\n color: var(--color-text-maxcontrast);\n}\n.version-entry__desc-unique[data-v-29c8cb3b] {\n color: var(--color-text-maxcontrast);\n}\n.version-entry__actions[data-v-29c8cb3b] {\n margin-left: auto;\n}\n.version-entry[data-v-29c8cb3b] .avatardiv img {\n border-radius: 0;\n}\n", ""]); ___CSS_LOADER_EXPORT___.push([module.i, ".version-entry[data-v-29c8cb3b] .avatardiv img {\n border-radius: 0;\n}\n", ""]);
// Exports // Exports
/* harmony default export */ __webpack_exports__["default"] = (___CSS_LOADER_EXPORT___); /* harmony default export */ __webpack_exports__["default"] = (___CSS_LOADER_EXPORT___);
@ -117135,23 +117125,21 @@ var render = function() {
{ {
key: "desc", key: "desc",
fn: function() { fn: function() {
return [ return [_vm._v("\n\t\t\t" + _vm._s(_vm.error) + "\n\t\t")]
_vm._v("\n\t\t\t\t" + _vm._s(_vm.error) + "\n\t\t\t")
]
}, },
proxy: true proxy: true
} }
], ],
null, null,
false, false,
3440606865 3182802769
) )
}, },
[ [
_vm._v( _vm._v(
"\n " + "\n\t\t" +
_vm._s(_vm.t("files_versions", "Cannot load versions list")) + _vm._s(_vm.t("files_versions", "Cannot load versions list")) +
"\n\t\t\t" "\n\t\t"
) )
] ]
) )

File diff suppressed because one or more lines are too long

View File

@ -20,7 +20,6 @@
<template> <template>
<li> <li>
<ListItemIcon <ListItemIcon
v-if="!isLatestChange" v-if="!isLatestChange"
:title="relativeDate" :title="relativeDate"
@ -36,12 +35,12 @@
</ActionLink> </ActionLink>
</Actions> </Actions>
</ListItemIcon> </ListItemIcon>
</div>
</li> </li>
</template> </template>
<script> <script>
import moment from '@nextcloud/moment' import moment from '@nextcloud/moment'
import Actions from '@nextcloud/vue/dist/Components/Actions' import Actions from '@nextcloud/vue/dist/Components/Actions'
import ActionButton from '@nextcloud/vue/dist/Components/ActionButton' import ActionButton from '@nextcloud/vue/dist/Components/ActionButton'
import ActionLink from '@nextcloud/vue/dist/Components/ActionLink' import ActionLink from '@nextcloud/vue/dist/Components/ActionLink'
@ -50,8 +49,6 @@ import ListItemIcon from '@nextcloud/vue/dist/Components/ListItemIcon'
import { generateUrl } from '@nextcloud/router' import { generateUrl } from '@nextcloud/router'
import { getCurrentUser } from '@nextcloud/auth' import { getCurrentUser } from '@nextcloud/auth'
import client from "../services/DavClient";
export default { export default {
name: 'VersionEntry', name: 'VersionEntry',
@ -61,7 +58,6 @@ export default {
ActionButton, ActionButton,
ActionLink, ActionLink,
ListItemIcon, ListItemIcon,
}, },
directives: { directives: {
@ -77,18 +73,15 @@ export default {
type: Object, type: Object,
required: true, required: true,
}, },
tooltip: {
type: String,
default: '',
},
}, },
computed: { computed: {
// Does the current user have permissions to revert this file // Does the current user have permissions to revert this file
canRevert () { canRevert() {
// TODO: implement permission check // TODO: implement permission check
return true return true
}, },
/** /**
* If the basename is just the file id, * If the basename is just the file id,
* this is the latest file version entry * this is the latest file version entry
@ -97,6 +90,7 @@ export default {
isLatestChange() { isLatestChange() {
return this.fileInfo.id === this.version.basename return this.fileInfo.id === this.version.basename
}, },
versionUrl() { versionUrl() {
return generateUrl('/remote.php/dav/versions/{user}' + this.version.filename, { return generateUrl('/remote.php/dav/versions/{user}' + this.version.filename, {
user: getCurrentUser().uid, user: getCurrentUser().uid,
@ -105,51 +99,30 @@ export default {
iconUrl() { iconUrl() {
return OC.MimeType.getIconUrl(this.fileInfo.mimetype) return OC.MimeType.getIconUrl(this.fileInfo.mimetype)
}, },
formattedSize() { formattedSize() {
return OC.Util.humanFileSize(this.version.size, true) return OC.Util.humanFileSize(this.version.size, true)
}, },
relativeDate() { relativeDate() {
return moment(this.version.lastmod).fromNow() return moment(this.version.lastmod).fromNow()
}, },
}, },
methods: { methods: {
// Restores the original file to this revision restoreVersion() {
restoreVersion () {
// TODO: implement restore request and loading // TODO: implement restore request and loading
return client.move('/remote.php/dav/versions/{user}' + this.version.basename, {
user: getCurrentUser().uid,
},'/restore/target', true)
}, },
}, },
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.version-entry { .version-entry {
display: flex; // Remove avatar border-radius around file type icon
align-items: center; ::v-deep .avatardiv img {
height: 44px; border-radius: 0;
&__desc {
display: flex;
flex-direction: column;
justify-content: space-between;
padding: 8px;
line-height: 1.6em;
p {
color: var(--color-text-maxcontrast);
}
&-unique {
color: var(--color-text-maxcontrast);
}
}
&__actions {
margin-left: auto;
}
// Remove avatar border-radius around file type icon
::v-deep .avatardiv img {
border-radius: 0;
}
} }
</style> }
</style>

View File

@ -53,6 +53,7 @@ window.addEventListener('DOMContentLoaded', function() {
await TabInstance.update(fileInfo) await TabInstance.update(fileInfo)
TabInstance.$mount(el) TabInstance.$mount(el)
}, },
update(fileInfo) { update(fileInfo) {
TabInstance.update(fileInfo) TabInstance.update(fileInfo)
}, },

View File

@ -1,7 +1,9 @@
/** /**
* @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com> * @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com>
*
* @author Julius Härtl <jus@bitgrid.net>
* @author Enoch <enoch@nextcloud.com> * @author Enoch <enoch@nextcloud.com>
* @author John Molakvoæ <skjnldsv@protonmail.com> *
* @license GNU AGPL version 3 or any later version * @license GNU AGPL version 3 or any later version
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -11,7 +13,7 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
@ -29,11 +31,11 @@ export const fetchFileVersions = async function(fileId) {
const response = await client.getDirectoryContents(VersionsUrl, { const response = await client.getDirectoryContents(VersionsUrl, {
data: `<?xml version="1.0"?> data: `<?xml version="1.0"?>
<d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns"> <d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
<d:prop> <d:prop>
<d:getcontentlength /> <d:getcontentlength />
<d:getcontenttype /> <d:getcontenttype />
<d:getlastmodified /> <d:getlastmodified />
</d:prop> </d:prop>
</d:propfind>`, </d:propfind>`,
details: true, details: true,
}) })
@ -41,4 +43,3 @@ export const fetchFileVersions = async function(fileId) {
/** return response.data.map(FileVersion); */ /** return response.data.map(FileVersion); */
return response.data.map(genFileInfo) return response.data.map(genFileInfo)
} }

View File

@ -24,35 +24,35 @@
<div :class="{ 'icon-loading': loading }"> <div :class="{ 'icon-loading': loading }">
<!-- error message --> <!-- error message -->
<EmptyContent v-if="error" icon="icon-error"> <EmptyContent v-if="error" icon="icon-error">
{{ t('files_versions', 'Cannot load versions list')}} {{ t('files_versions', 'Cannot load versions list') }}
<template #desc> <template #desc>
{{error}} {{ error }}
</template> </template>
</EmptyContent> </EmptyContent>
<!-- Versions list -->
<ul> <ul>
<!-- Version information -->
<VersionEntry v-for="version in versionsList" <VersionEntry v-for="version in versionsList"
:key="version.basename" :key="version.basename"
:file-info="fileInfo" :file-info="fileInfo"
:version="version" /> :version="version" />
</ul> </ul>
</div> </div>
</template> </template>
<script> <script>
import EmptyContent from '@nextcloud/vue/dist/Components/EmptyContent'
import { showError } from '@nextcloud/dialogs' import { showError } from '@nextcloud/dialogs'
import EmptyContent from '@nextcloud/vue/dist/Components/EmptyContent'
import VersionEntry from '../components/VersionEntry' import VersionEntry from '../components/VersionEntry'
import { fetchFileVersions } from '../services/FileVersion' import { fetchFileVersions } from '../services/FileVersion'
export default { export default {
name: 'VersionTab', name: 'VersionTab',
components: { components: {
VersionEntry,
EmptyContent, EmptyContent,
VersionEntry,
}, },
data() { data() {
@ -65,21 +65,23 @@ export default {
versionsList: [], versionsList: [],
} }
}, },
beforeMount(){
beforeMount() {
this.getVersions() this.getVersions()
}, },
methods: { methods: {
/** /**
* Update current fileInfo and fetch new data * Update current fileInfo and fetch new data
* @param {Object} fileInfo the current file FileInfo * @param {Object} fileInfo the current file FileInfo
*/ */
async update(fileInfo) { async update(fileInfo) {
this.fileInfo = fileInfo this.fileInfo = fileInfo
}, },
async getVersions() { async getVersions() {
this.loading = true this.loading = true
try { try {
const fetchVersions = await fetchFileVersions(this.fileInfo.id) const fetchVersions = await fetchFileVersions(this.fileInfo.id)
this.versionsList = fetchVersions this.versionsList = fetchVersions