mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
fix version sorting and icon display for marketplace
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@start9labs/marketplace",
|
"name": "@start9labs/marketplace",
|
||||||
"version": "0.3.27",
|
"version": "0.3.28",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@angular/common": ">=13.2.0",
|
"@angular/common": ">=13.2.0",
|
||||||
"@angular/core": ">=13.2.0",
|
"@angular/core": ">=13.2.0",
|
||||||
|
|||||||
@@ -39,7 +39,21 @@ export class ReleaseNotesComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
asIsOrder(a: KeyValue<string, string>, b: KeyValue<string, string>) {
|
asIsOrder(a: KeyValue<string, string>, b: KeyValue<string, string>) {
|
||||||
return a.key > b.key ? -1 : b.key > a.key ? 1 : 0
|
const a1 = a.key.split('.')
|
||||||
|
const b1 = b.key.split('.')
|
||||||
|
// contingency in case there's a 4th or 5th version
|
||||||
|
const len = Math.min(a1.length, b1.length)
|
||||||
|
// look through each version number and compare.
|
||||||
|
for (let i = 0; i < len; i++) {
|
||||||
|
const a2 = +a1[i] || 0
|
||||||
|
const b2 = +b1[i] || 0
|
||||||
|
|
||||||
|
if (a2 !== b2) {
|
||||||
|
// sort descending
|
||||||
|
return a2 > b2 ? -1 : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return a1.length - b1.length
|
||||||
}
|
}
|
||||||
|
|
||||||
async showReleaseNotes(content: PolymorpheusContent<TuiDialogContext>) {
|
async showReleaseNotes(content: PolymorpheusContent<TuiDialogContext>) {
|
||||||
|
|||||||
@@ -125,13 +125,15 @@ export class MarketplaceDepItemComponent {
|
|||||||
|
|
||||||
getImage(key: string, marketplace: StoreIdentity | null) {
|
getImage(key: string, marketplace: StoreIdentity | null) {
|
||||||
const icon = this.pkg.dependencyMetadata[key]?.icon
|
const icon = this.pkg.dependencyMetadata[key]?.icon
|
||||||
|
const camelToSnakeCase = (str: string) =>
|
||||||
|
str.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`)
|
||||||
|
|
||||||
if (icon) {
|
if (icon) {
|
||||||
try {
|
try {
|
||||||
const iconUrl = new URL(icon)
|
const iconUrl = new URL(icon)
|
||||||
return iconUrl.href
|
return iconUrl.href
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return `${marketplace?.url}package/v0/icon/${key}`
|
return `${marketplace?.url}package/v0/icon/${camelToSnakeCase(key)}`
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return key.substring(0, 2)
|
return key.substring(0, 2)
|
||||||
|
|||||||
Reference in New Issue
Block a user