diff options
author | Julius Härtl <jus@bitgrid.net> | 2023-08-31 16:11:13 +0200 |
---|---|---|
committer | backportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com> | 2023-09-06 13:59:34 +0000 |
commit | a518225a80fb1516dc8d6931b06db862c8d25cbe (patch) | |
tree | 2a27e9934130438158b6605d595e318bedb619ea | |
parent | 325e42f2b3760dceb44e40eb5f7724b93d9e3105 (diff) | |
download | nextcloud-server-a518225a80fb1516dc8d6931b06db862c8d25cbe.tar.gz nextcloud-server-a518225a80fb1516dc8d6931b06db862c8d25cbe.zip |
feat: Add events for version restore
Signed-off-by: Julius Härtl <jus@bitgrid.net>
-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) } }, |