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>
*
* @author Julius Härtl <jus@bitgrid.net>
* @author Enoch <enoch@nextcloud.com>
* @author John Molakvoæ <skjnldsv@protonmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
@ -369,7 +371,7 @@ var fetchFileVersions = /*#__PURE__*/function () {
VersionsUrl = '/versions/' + fileId;
_context.next = 3;
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
});
@ -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_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");
//
//
//
@ -41774,9 +41775,6 @@ __webpack_require__.r(__webpack_exports__);
//
//
//
//
//
@ -41804,10 +41802,6 @@ __webpack_require__.r(__webpack_exports__);
version: {
type: Object,
required: true
},
tooltip: {
type: String,
default: ''
}
},
computed: {
@ -41841,12 +41835,7 @@ __webpack_require__.r(__webpack_exports__);
}
},
methods: {
// Restores the original file to this revision
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);
restoreVersion: function restoreVersion() {// TODO: implement restore request and loading
}
}
});
@ -41862,9 +41851,9 @@ __webpack_require__.r(__webpack_exports__);
"use strict";
__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_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_dialogs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @nextcloud/dialogs */ "./node_modules/@nextcloud/dialogs/dist/index.es.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_1__ = __webpack_require__(/*! @nextcloud/vue/dist/Components/EmptyContent */ "./node_modules/@nextcloud/vue/dist/Components/EmptyContent.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 _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); } }
@ -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"] = ({
name: 'VersionTab',
components: {
VersionEntry: _components_VersionEntry__WEBPACK_IMPORTED_MODULE_2__["default"],
EmptyContent: _nextcloud_vue_dist_Components_EmptyContent__WEBPACK_IMPORTED_MODULE_0___default.a
EmptyContent: _nextcloud_vue_dist_Components_EmptyContent__WEBPACK_IMPORTED_MODULE_1___default.a,
VersionEntry: _components_VersionEntry__WEBPACK_IMPORTED_MODULE_2__["default"]
},
data: function data() {
return {
@ -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}', {
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);
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]});
// 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
/* harmony default export */ __webpack_exports__["default"] = (___CSS_LOADER_EXPORT___);
@ -117135,23 +117125,21 @@ var render = function() {
{
key: "desc",
fn: function() {
return [
_vm._v("\n\t\t\t\t" + _vm._s(_vm.error) + "\n\t\t\t")
]
return [_vm._v("\n\t\t\t" + _vm._s(_vm.error) + "\n\t\t")]
},
proxy: true
}
],
null,
false,
3440606865
3182802769
)
},
[
_vm._v(
"\n " +
"\n\t\t" +
_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>
<li>
<ListItemIcon
v-if="!isLatestChange"
:title="relativeDate"
@ -36,12 +35,12 @@
</ActionLink>
</Actions>
</ListItemIcon>
</div>
</li>
</template>
<script>
import moment from '@nextcloud/moment'
import Actions from '@nextcloud/vue/dist/Components/Actions'
import ActionButton from '@nextcloud/vue/dist/Components/ActionButton'
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 { getCurrentUser } from '@nextcloud/auth'
import client from "../services/DavClient";
export default {
name: 'VersionEntry',
@ -61,7 +58,6 @@ export default {
ActionButton,
ActionLink,
ListItemIcon,
},
directives: {
@ -77,18 +73,15 @@ export default {
type: Object,
required: true,
},
tooltip: {
type: String,
default: '',
},
},
computed: {
// Does the current user have permissions to revert this file
canRevert () {
canRevert() {
// TODO: implement permission check
return true
},
/**
* If the basename is just the file id,
* this is the latest file version entry
@ -97,6 +90,7 @@ export default {
isLatestChange() {
return this.fileInfo.id === this.version.basename
},
versionUrl() {
return generateUrl('/remote.php/dav/versions/{user}' + this.version.filename, {
user: getCurrentUser().uid,
@ -105,51 +99,30 @@ export default {
iconUrl() {
return OC.MimeType.getIconUrl(this.fileInfo.mimetype)
},
formattedSize() {
return OC.Util.humanFileSize(this.version.size, true)
},
relativeDate() {
return moment(this.version.lastmod).fromNow()
},
},
methods: {
// Restores the original file to this revision
restoreVersion () {
restoreVersion() {
// TODO: implement restore request and loading
return client.move('/remote.php/dav/versions/{user}' + this.version.basename, {
user: getCurrentUser().uid,
},'/restore/target', true)
},
},
}
</script>
<style lang="scss" scoped>
.version-entry {
display: flex;
align-items: center;
height: 44px;
&__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;
}
<style lang="scss" scoped>
.version-entry {
// 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)
TabInstance.$mount(el)
},
update(fileInfo) {
TabInstance.update(fileInfo)
},

View File

@ -1,7 +1,9 @@
/**
* @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com>
*
* @author Julius Härtl <jus@bitgrid.net>
* @author Enoch <enoch@nextcloud.com>
* @author John Molakvoæ <skjnldsv@protonmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
@ -41,4 +43,3 @@ export const fetchFileVersions = async function(fileId) {
/** return response.data.map(FileVersion); */
return response.data.map(genFileInfo)
}

View File

@ -24,13 +24,14 @@
<div :class="{ 'icon-loading': loading }">
<!-- error message -->
<EmptyContent v-if="error" icon="icon-error">
{{ t('files_versions', 'Cannot load versions list')}}
{{ t('files_versions', 'Cannot load versions list') }}
<template #desc>
{{error}}
{{ error }}
</template>
</EmptyContent>
<!-- Versions list -->
<ul>
<!-- Version information -->
<VersionEntry v-for="version in versionsList"
:key="version.basename"
:file-info="fileInfo"
@ -40,19 +41,18 @@
</template>
<script>
import EmptyContent from '@nextcloud/vue/dist/Components/EmptyContent'
import { showError } from '@nextcloud/dialogs'
import EmptyContent from '@nextcloud/vue/dist/Components/EmptyContent'
import VersionEntry from '../components/VersionEntry'
import { fetchFileVersions } from '../services/FileVersion'
export default {
name: 'VersionTab',
components: {
VersionEntry,
EmptyContent,
VersionEntry,
},
data() {
@ -65,7 +65,8 @@ export default {
versionsList: [],
}
},
beforeMount(){
beforeMount() {
this.getVersions()
},
@ -80,6 +81,7 @@ export default {
async getVersions() {
this.loading = true
try {
const fetchVersions = await fetchFileVersions(this.fileInfo.id)
this.versionsList = fetchVersions