diff options
author | Julius Härtl <jus@bitgrid.net> | 2023-08-31 16:11:13 +0200 |
---|---|---|
committer | max-nextcloud <max@nextcloud.com> | 2023-09-06 13:29:22 +0200 |
commit | bb419321e00d85bc9cc433d918e24365815202a8 (patch) | |
tree | f33d33f890431bee1cda5dfc8a0cf4d62daf6882 /apps/files_versions/src | |
parent | f254173a88e5234ffd0efc963782c4a1eb10c0bf (diff) | |
download | nextcloud-server-bb419321e00d85bc9cc433d918e24365815202a8.tar.gz nextcloud-server-bb419321e00d85bc9cc433d918e24365815202a8.zip |
feat: Add events for version restore
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps/files_versions/src')
-rw-r--r-- | apps/files_versions/src/views/VersionTab.vue | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/apps/files_versions/src/views/VersionTab.vue b/apps/files_versions/src/views/VersionTab.vue index 4857b8e0ded..178cc3e931a 100644 --- a/apps/files_versions/src/views/VersionTab.vue +++ b/apps/files_versions/src/views/VersionTab.vue @@ -39,6 +39,7 @@ import { showError, showSuccess } from '@nextcloud/dialogs' import isMobile from '@nextcloud/vue/dist/Mixins/isMobile.js' import { fetchVersions, deleteVersion, restoreVersion, setVersionLabel } from '../utils/versions.js' import Version from '../components/Version.vue' +import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus' export default { name: 'VersionTab', @@ -57,6 +58,12 @@ export default { loading: false, } }, + mounted() { + subscribe('files_versions:restore:restored', this.fetchVersions) + }, + beforeUnmount() { + unsubscribe('files_versions:restore:restored', this.fetchVersions) + }, computed: { /** * Order versions by mtime. @@ -163,6 +170,16 @@ export default { mtime: version.mtime, } + const restoreStartedEventState = { + preventDefault: false, + fileInfo: this.fileInfo, + version, + } + emit('files_versions:restore:requested', restoreStartedEventState) + if (restoreStartedEventState.preventDefault) { + return + } + try { await restoreVersion(version) if (version.label !== '') { @@ -172,10 +189,11 @@ export default { } else { showSuccess(t('files_versions', 'Version restored')) } - await this.fetchVersions() + emit('files_versions:restore:restored', version) } catch (exception) { this.fileInfo = oldFileInfo showError(t('files_versions', 'Could not restore version')) + emit('files_versions:restore:failed', version) } }, |