Skip to content

Commit

Permalink
Support for multiple versions of libraries and plugins.
Browse files Browse the repository at this point in the history
  • Loading branch information
gokr committed Oct 13, 2016
1 parent 4c2996d commit 7835b0f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 11 deletions.
43 changes: 32 additions & 11 deletions app/hyper/ui/main-window-func.js
Original file line number Diff line number Diff line change
Expand Up @@ -1628,7 +1628,6 @@ function createNewsEntry(item) {
var html = ''
var count = 0
for (plugin of hyper.UI.mPluginList) {
count++
var checked = ''
var usedVersion = plugin.version
if (plugins) {
Expand All @@ -1638,20 +1637,22 @@ function createNewsEntry(item) {
// If more versions are available, we list each separately
if (plugin.versions) {
for (ver of plugin.versions) {
if (usedPlugin) {
if (usedPlugin.version == ver) {
checked = `checked="checked"`
}
if (usedPlugin && usedPlugin.version == ver) {
checked = `checked="checked"`
} else {
checked = ''
}
count++
html += `<div class="checkbox">
<input type="checkbox" ${checked} id="input-config-app-plugin-${count}" data-plugin="${plugin.name}" data-version="${usedVersion}">
<input type="checkbox" ${checked} id="input-config-app-plugin-${count}" data-plugin="${plugin.name}" data-version="${ver}">
<label for="input-config-app-plugin-${count}">${plugin.name} (${ver}) - ${plugin.description}</label></div>`
}
} else {
// Otherwise we just make one listing without version
if (usedPlugin) {
checked = `checked="checked"`
}
count++
html += `<div class="checkbox">
<input type="checkbox" ${checked} id="input-config-app-plugin-${count}" data-plugin="${plugin.name}">
<label for="input-config-app-plugin-${count}">${plugin.name} - ${plugin.description}</label></div>`
Expand All @@ -1667,17 +1668,17 @@ function createNewsEntry(item) {
var html = ''
var count = 0
for (lib of hyper.UI.mLibraryList) {
count++
var checked = ''
// Ok, the app has a list of libraries we can check against
var usedLib = libs.find(each => each.name == lib.name)
// If more versions are available, we list each separately
for (ver of lib.versions) {
if (usedLib) {
if (usedLib.version == ver) {
checked = `checked="checked"`
}
if (usedLib && usedLib.version == ver) {
checked = `checked="checked"`
} else {
checked = ''
}
count++
html += `<div class="checkbox">
<input type="checkbox" ${checked} id="input-config-app-library-${count}" data-lib="${lib.name}" data-version="${ver}">
<label for="input-config-app-library-${count}">
Expand Down Expand Up @@ -1752,6 +1753,16 @@ function createNewsEntry(item) {
}
})

// We can today select multiple versions - prevent that
var names = new Set()
for (let p of plugins) {
if (names.has(p.name)) {
window.alert(`You can only have one version of ${p.name}.`)
return
}
names.add(p.name)
}

// Collect checked libs
var checkboxes = hyper.UI.$('#input-config-app-libraries').find('input')
var libs = []
Expand All @@ -1763,6 +1774,16 @@ function createNewsEntry(item) {
}
})

// We can today select multiple versions - prevent that
var names = new Set()
for (let l of libs) {
if (names.has(l.name)) {
window.alert(`You can only have one version of ${l.name}.`)
return
}
names.add(l.name)
}

// Hide dialog.
hyper.UI.$('#dialog-config-app').modal('hide')

Expand Down
16 changes: 16 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=759670
// for the documentation about the jsconfig.json format
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"allowSyntheticDefaultImports": true
},
"exclude": [
"node_modules",
"bower_components",
"jspm_packages",
"tmp",
"temp"
]
}

0 comments on commit 7835b0f

Please sign in to comment.