From 1a99350611dd067536b851bc8a73dda15cb86ba5 Mon Sep 17 00:00:00 2001 From: Martin Artnik Date: Fri, 8 Nov 2024 14:30:09 +0100 Subject: [PATCH] Make file versioning disclaimer overridable [SCI-11040] --- app/controllers/assets_controller.rb | 3 ++- app/javascript/vue/shared/file_versions_modal.vue | 11 ++++++----- app/models/concerns/versioned_attachments.rb | 7 +++++++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb index 8c5c7ca2f..5f4914759 100644 --- a/app/controllers/assets_controller.rb +++ b/app/controllers/assets_controller.rb @@ -407,7 +407,8 @@ class AssetsController < ApplicationController user: current_user ).as_json.merge( enabled: VersionedAttachments.enabled?, - enable_url: ENV.fetch('SCINOTE_FILE_VERSIONING_ENABLE_URL', nil) + enable_url: ENV.fetch('SCINOTE_FILE_VERSIONING_ENABLE_URL', nil), + disabled_disclaimer: VersionedAttachments.disabled_disclaimer ) ) end diff --git a/app/javascript/vue/shared/file_versions_modal.vue b/app/javascript/vue/shared/file_versions_modal.vue index 767592321..1cf084138 100644 --- a/app/javascript/vue/shared/file_versions_modal.vue +++ b/app/javascript/vue/shared/file_versions_modal.vue @@ -67,7 +67,7 @@

{{ i18n.t('assets.file_versions_modal.title') }}

- {{ i18n.t('assets.file_versions_modal.disabled_disclaimer') }} + {{ disabledDisclaimer.text }}
@@ -76,7 +76,7 @@ {{ i18n.t('general.cancel') }} - {{ i18n.t('assets.file_versions_modal.enable_button') }} + {{ disabledDisclaimer.button }} @@ -96,8 +96,7 @@ export default { required: true }, restoreVersionUrl: { - type: String, - required: true + type: String } }, mixins: [modalMixin], @@ -105,7 +104,8 @@ export default { return { fileVersions: null, enabled: null, - enableUrl: null + enableUrl: null, + disabledDisclaimer: null }; }, created() { @@ -122,6 +122,7 @@ export default { this.fileVersions = response.data.data; this.enabled = response.data.enabled; this.enableUrl = response.data.enable_url; + this.disabledDisclaimer = response.data.disabled_disclaimer; this.$nextTick(() => { document.querySelectorAll('[data-render-tooltip]').forEach((e) => { window.initTooltip(e); diff --git a/app/models/concerns/versioned_attachments.rb b/app/models/concerns/versioned_attachments.rb index a286c9022..b999fc501 100644 --- a/app/models/concerns/versioned_attachments.rb +++ b/app/models/concerns/versioned_attachments.rb @@ -51,4 +51,11 @@ module VersionedAttachments def enabled? ApplicationSettings.instance.values['versioned_attachments_enabled'] end + + def disabled_disclaimer + { + text: I18n.t('assets.file_versions_modal.disabled_disclaimer'), + button: I18n.t('assets.file_versions_modal.enable_button') + } + end end