Move OVE trial period handling [SCI-9301]

This commit is contained in:
Andrej 2023-09-15 16:07:10 +02:00
parent 94db5c1155
commit 9f672ecfe2
3 changed files with 6 additions and 22 deletions

View file

@ -10,9 +10,9 @@
:placeholder="i18n.t('open_vector_editor.sequence_name_placeholder')"/>
</div>
</span>
<div v-if="oveEnabledDaysLeft <= 30" class="flex items-center">
<div v-if="oveWarning" class="flex items-center">
<i class="mr-1 text-brand-warning sn-icon sn-icon-alert-warning"></i>
<p v-html="i18n.t('open_vector_editor.trial_expiration_warning_html', { count: oveEnabledDaysLeft })" class="mb-0"></p>
<p v-html="oveWarning" class="mb-0"></p>
</div>
<div class="ove-buttons text-sn-blue">
<button :style="{ pointerEvents: 'all' }" @click="saveAndClose" class="btn btn-light font-sans" :disabled="this.readOnly">
@ -40,19 +40,17 @@
fileName: { type: String },
updateUrl: { type: String },
canEditFile: { type: String },
oveEnabledDaysLeftString: { type: String }
oveWarning: { type: String }
},
data() {
return {
editor: null,
sequenceName: null,
closeAfterSave: false,
readOnly: this.canEditFile !== 'true',
oveEnabledDaysLeft: 0
readOnly: this.canEditFile !== 'true'
}
},
mounted() {
this.oveEnabledDaysLeft = parseInt(this.oveEnabledDaysLeftString);
let editorConfig = {
onSave: this.saveFile,
generatePng: true,

View file

@ -3,21 +3,7 @@
class OpenVectorEditorService
class << self
def enabled?
ove_enabled_until = ENV.fetch('SCINOTE_OVE_ENABLED_UNTIL', nil)
return false if ove_enabled_until.blank?
DateTime.now.utc.to_date < DateTime.strptime(ove_enabled_until, '%d-%m-%Y').utc.to_date
end
def evaluation_period_left
return 0 unless enabled?
ove_enabled_until = ENV.fetch('SCINOTE_OVE_ENABLED_UNTIL', nil)
return 0 if ove_enabled_until.blank?
(DateTime.strptime(ove_enabled_until, '%d-%m-%Y').utc.to_date - DateTime.now.utc.to_date).to_i
false
end
end
end

View file

@ -20,7 +20,7 @@
file-name="<%= @file_name %>"
update-url="<%= @asset ? gene_sequence_asset_url(@asset) : gene_sequence_assets_url(parent_type: params[:parent_type], parent_id: params[:parent_id]) %>"
can-edit-file="<%= asset_managable? %>"
ove-enabled-days-left-string="<%= OpenVectorEditorService.evaluation_period_left %>"
ove-warning="<%= defined?(@warnings) ? @warnings : '' %>"
/>
</div>
<%= javascript_include_tag 'open_vector_editor' %>