mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-09-20 06:35:56 +08:00
Add restricted extensions for scinote edit [SCI-11010]
This commit is contained in:
parent
28810ed1f5
commit
e5196774fd
|
@ -19,5 +19,6 @@ const GLOBAL_CONSTANTS = {
|
|||
ASSET_POLLING_INTERVAL: <%= Constants::ASSET_POLLING_INTERVAL %>,
|
||||
ASSET_SYNC_URL: '<%= Constants::ASSET_SYNC_URL %>',
|
||||
GLOBAL_SEARCH_PREVIEW_LIMIT: <%= Constants::GLOBAL_SEARCH_PREVIEW_LIMIT %>,
|
||||
SEARCH_LIMIT: <%= Constants::SEARCH_LIMIT %>
|
||||
SEARCH_LIMIT: <%= Constants::SEARCH_LIMIT %>,
|
||||
SCINOTE_EDIT_RESTRICTED_EXTENSIONS: <%= Constants::SCINOTE_EDIT_RESTRICTED_EXTENSIONS %>
|
||||
};
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
/* global GLOBAL_CONSTANTS */
|
||||
|
||||
import axios from '../../../../../packs/custom_axios.js';
|
||||
import { satisfies } from 'compare-versions';
|
||||
import editLaunchingApplicationModal from '../../modal/edit_launching_application_modal.vue';
|
||||
import NoPredefinedAppModal from '../../modal/no_predefined_app_modal.vue';
|
||||
import RestrictedExtensionModal from '../../modal/restricted_extension_modal.vue';
|
||||
import UpdateVersionModal from '../../modal/update_version_modal.vue';
|
||||
|
||||
export default {
|
||||
|
@ -10,15 +13,17 @@ export default {
|
|||
localAppName: null,
|
||||
scinoteEditRunning: null,
|
||||
showNoPredefinedAppModal: false,
|
||||
showRestrictedExtensionModal: false,
|
||||
showUpdateVersionModal: false,
|
||||
editAppModal: false,
|
||||
pollingInterval: null,
|
||||
pollingInterval: null
|
||||
};
|
||||
},
|
||||
components: {
|
||||
editLaunchingApplicationModal,
|
||||
NoPredefinedAppModal,
|
||||
UpdateVersionModal
|
||||
UpdateVersionModal,
|
||||
RestrictedExtensionModal
|
||||
},
|
||||
computed: {
|
||||
attributes() {
|
||||
|
@ -93,9 +98,16 @@ export default {
|
|||
}
|
||||
},
|
||||
async openLocally() {
|
||||
const restrictedExtension = GLOBAL_CONSTANTS.SCINOTE_EDIT_RESTRICTED_EXTENSIONS.includes(
|
||||
this.attributes.file_extension.toUpperCase()
|
||||
);
|
||||
|
||||
if (this.isWrongVersion(window.scinoteEditVersion)) {
|
||||
this.showUpdateVersionModal = true;
|
||||
return;
|
||||
} else if (restrictedExtension) {
|
||||
this.showRestrictedExtensionModal = true;
|
||||
return;
|
||||
} else if (this.localAppName === null) {
|
||||
this.showNoPredefinedAppModal = true;
|
||||
return;
|
||||
|
|
|
@ -33,6 +33,10 @@
|
|||
:fileName="attachment.attributes.file_name"
|
||||
@close="showNoPredefinedAppModal = false"
|
||||
/>
|
||||
<RestrictedExtensionModal
|
||||
v-if="showRestrictedExtensionModal"
|
||||
@close="showRestrictedExtensionModal = false"
|
||||
/>
|
||||
<editLaunchingApplicationModal
|
||||
v-if="editAppModal"
|
||||
:fileName="attachment.attributes.file_name"
|
||||
|
|
|
@ -93,6 +93,10 @@
|
|||
:fileName="attachment.attributes.file_name"
|
||||
@close="showNoPredefinedAppModal = false"
|
||||
/>
|
||||
<RestrictedExtensionModal
|
||||
v-if="showRestrictedExtensionModal"
|
||||
@close="showRestrictedExtensionModal = false"
|
||||
/>
|
||||
<UpdateVersionModal
|
||||
v-if="showUpdateVersionModal"
|
||||
@close="showUpdateVersionModal = false"
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
<template>
|
||||
<div ref="modal" @keydown.esc="cancel" class="modal" id="RestrictedExtensionModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog modal-md" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="sn-icon sn-icon-close"></i></button>
|
||||
<h4 class="modal-title" id="modal-delete-result-element">
|
||||
{{ i18n.t('assets.restricted_extension_modal.title') }}
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p v-html="i18n.t('assets.restricted_extension_modal.body')"></p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary" @click="close">{{ this.i18n.t('assets.restricted_extension_modal.action') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import modalMixin from '../../modal_mixin';
|
||||
|
||||
export default {
|
||||
name: 'RestrictedExtensionModal',
|
||||
mixins: [modalMixin]
|
||||
};
|
||||
</script>
|
|
@ -447,6 +447,12 @@ class Constants
|
|||
MIN_SCINOTE_EDIT_VERSION = ENV['MIN_SCINOTE_EDIT_VERSION'].freeze
|
||||
MAX_SCINOTE_EDIT_VERSION = ENV['MAX_SCINOTE_EDIT_VERSION'].freeze
|
||||
|
||||
# SciNote Edit unsupported extensions
|
||||
SCINOTE_EDIT_RESTRICTED_EXTENSIONS = %w(
|
||||
ACTION APP BIN COMMAND CSH OSX WORKFLOW DMG BAT BIN CAB CMD COM CPL EX_ EXE GADGET INF1 INS INX ISU JOB
|
||||
JSE LNK MSC MSI MSP MST PAF PIF PS1 REG RGS SCR SCT SHB SHS U3P VB VBE VBS VBSCRIPT WS WSF WSH
|
||||
).freeze
|
||||
|
||||
# quick search
|
||||
QUICK_SEARCH_LIMIT = 5
|
||||
QUICK_SEARCH_SEARCHABLE_OBJECTS = %w(project experiment my_module protocol repository_row
|
||||
|
|
|
@ -3907,6 +3907,10 @@ en:
|
|||
body_text_html: "The specified application for accessing the <b>%{file_name}</b> is not preconfigured. To successfully open this file, please set up the appropriate application in your local environment beforehand.</p>"
|
||||
understand_button: "I understand"
|
||||
set_up_app: "Set up an application to open this file"
|
||||
restricted_extension_modal:
|
||||
title: "Open file - Security warning"
|
||||
body: "This file type appears to be executable and can potentially harm your computer. It cannot be opened with SciNote Edit. To open the file please download it manually."
|
||||
action: "I understand"
|
||||
update_version_modal:
|
||||
title: "Update required"
|
||||
body_text_html: "The current version of the SciNote Edit application is no longer supported. To ensure a seamless and secure user experience, we recommend updating to the latest version."
|
||||
|
|
Loading…
Reference in a new issue