Validate uploader services (#1183)

This commit is contained in:
Felix Häusler 2019-07-26 05:18:58 +02:00 committed by Ran Luo
parent 4a1d5651c6
commit aa0e491f1d
2 changed files with 13 additions and 4 deletions

View File

@ -2,8 +2,8 @@
<div class="pref-image-uploader"> <div class="pref-image-uploader">
<h4>Image Uploader</h4> <h4>Image Uploader</h4>
<section class="current-uploader"> <section class="current-uploader">
<div v-if="currentUploader !== 'none'">The current image uploader is {{ getServiceNameById(currentUploader) }}.</div> <div v-if="isValidUploaderService(currentUploader)">The current image uploader is {{ getServiceNameById(currentUploader) }}.</div>
<span v-else>Currently is no uploader selected. Please select an uploader and click on "Set as default".</span> <span v-else>Currently no uploader is selected. Please select an uploader and click on "Set as default".</span>
</section> </section>
<section class="configration"> <section class="configration">
<el-tabs v-model="activeTab"> <el-tabs v-model="activeTab">
@ -56,7 +56,7 @@
<script> <script>
import { shell } from 'electron' import { shell } from 'electron'
import services from './services.js' import services, { isValidService } from './services.js'
import legalNoticesCheckbox from './legalNoticesCheckbox' import legalNoticesCheckbox from './legalNoticesCheckbox'
export default { export default {
@ -116,6 +116,9 @@ export default {
}) })
}, },
methods: { methods: {
isValidUploaderService (name) {
return isValidService(name)
},
getServiceNameById (id) { getServiceNameById (id) {
const service = services[id] const service = services[id]
return service ? service.name : id return service ? service.name : id

View File

@ -1,6 +1,10 @@
// TODO: Remove information from other vue source files into this file. // TODO: Remove information from other vue source files into this file.
export default { export const isValidService = name => {
return name !== 'none' && services.hasOwnProperty(name)
}
const services = {
// Dummy service used to opt-in real services. // Dummy service used to opt-in real services.
none: { none: {
name: '', name: '',
@ -32,3 +36,5 @@ export default {
agreedToLegalNotices: false agreedToLegalNotices: false
} }
} }
export default services