mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
[enh] Add markdown in alert and help
This commit is contained in:
parent
f36d1aca7a
commit
b9b0dd906f
3 changed files with 43 additions and 10 deletions
|
@ -35,8 +35,7 @@
|
||||||
</b-link>
|
</b-link>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<vue-showdown :markdown="description" flavor="github" v-if="description"
|
||||||
v-if="description" v-html="description"
|
|
||||||
:class="{ ['alert p-1 px-2 alert-' + descriptionVariant]: descriptionVariant }"
|
:class="{ ['alert p-1 px-2 alert-' + descriptionVariant]: descriptionVariant }"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
<template>
|
<template>
|
||||||
<b-alert :variant="type" show>
|
<b-alert :variant="type" show>
|
||||||
<icon :iname="icon_" />
|
<icon :iname="icon_" />
|
||||||
{{ label }}
|
<vue-showdown :markdown="label" flavor="github"
|
||||||
|
tag="span" class="markdown" />
|
||||||
</b-alert>
|
</b-alert>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -29,3 +30,12 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.icon + span.markdown > *:first-child {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
.alert p:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
|
@ -50,7 +50,7 @@ import evaluate from 'simple-evaluate'
|
||||||
|
|
||||||
// FIXME needs test and rework
|
// FIXME needs test and rework
|
||||||
import api, { objectToParams } from '@/api'
|
import api, { objectToParams } from '@/api'
|
||||||
import { formatI18nField, formatYunoHostArguments, formatFormData } from '@/helpers/yunohostArguments'
|
import { formatI18nField, formatYunoHostArguments, formatFormData, pFileReader } from '@/helpers/yunohostArguments'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'AppConfigPanel',
|
name: 'AppConfigPanel',
|
||||||
|
@ -84,16 +84,40 @@ export default {
|
||||||
isVisible (expression) {
|
isVisible (expression) {
|
||||||
if (!expression) return true
|
if (!expression) return true
|
||||||
const context = {}
|
const context = {}
|
||||||
|
|
||||||
|
const promises = []
|
||||||
for (const args of Object.values(this.forms)) {
|
for (const args of Object.values(this.forms)) {
|
||||||
for (const shortname in args) {
|
for (const shortname in args) {
|
||||||
|
if (args[shortname] instanceof File) {
|
||||||
|
if (expression.includes(shortname)) {
|
||||||
|
promises.push(pFileReader(args[shortname], context, shortname, false))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
context[shortname] = args[shortname]
|
context[shortname] = args[shortname]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
return evaluate(context, expression)
|
|
||||||
} catch (error) {
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
// Allow to use match(var,regexp) function
|
||||||
|
const matchRe = new RegExp('match\\(\\s*(\\w+)\\s*,\\s*"([^"]+)"\\s*\\)', 'g')
|
||||||
|
let i = 0
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
i = 2
|
||||||
|
resolve(false)
|
||||||
|
Promise.all(promises).then((value) => {
|
||||||
|
for (const matched of expression.matchAll(matchRe)) {
|
||||||
|
i++
|
||||||
|
const varName = matched[1] + '__re' + i.toString()
|
||||||
|
context[varName] = new RegExp(matched[2]).test(context[matched[1]])
|
||||||
|
expression = expression.replace(matched[0], varName)
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
resolve(evaluate(context, expression))
|
||||||
|
} catch (error) {
|
||||||
|
resolve(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
},
|
},
|
||||||
onQueriesResponse (data) {
|
onQueriesResponse (data) {
|
||||||
if (!data.panels || data.panels.length === 0) {
|
if (!data.panels || data.panels.length === 0) {
|
||||||
|
|
Loading…
Reference in a new issue