sc-manager/client/util.js

43 lines
1,016 B
JavaScript
Raw Permalink Normal View History

const m = require('mithril')
const regexRepoName = /([^\/]+\/[^\/]+)\/releases/
module.exports.getRepoMessage = function(app) {
let prefix = app.config.provider[0].toUpperCase() + app.config.provider.slice(1)
if (!app.config.url) {
return [prefix, null]
}
let url = app.config.url.replace('/api/v1/repos', '').replace('/releases', '')
let name = app.config.url
let temp = regexRepoName.exec(app.config.url)
if (temp) {
name = temp[1]
}
return [
prefix + ': ',
m('a', {
target: '_blank',
href: url,
}, name),
]
}
module.exports.getVersionSummary = function(version, status) {
if (!version) {
if (status && status.running) {
return '< unknown version >'
}
return '< no version >'
}
if (typeof(version) === 'string') {
return version
}
return `${version.version} (${
version.stable > 0
? 'Stable'
: version.stable === 0
? 'Not tested'
: 'Unstable'}) ${version.installed ? '' : '(Not installed)'}`
}