Package manager UI-related tweaks (#4382)

* Add Plugins Path setting
* Fix/improve cache invalidation
* Hide load error when collapsing package source
* Package manager style tweaks
* Show error if installed packages query failed
* Prevent "No packages found" flicker
* Show <unknown> if empty version
* Always show latest version, highlight if new version available
* Fix issues with non-unique cross-source package ids
* Don't wrap id, version and date
* Decrease collapse button padding
* Display description for scraper packages
* Fix default packages population
* Change default package path to community
---------
Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
DingDongSoLong4
2023-12-22 05:05:53 +02:00
committed by GitHub
parent 23b4d4f1e0
commit a1bd7cf817
16 changed files with 611 additions and 500 deletions

View File

@@ -104,6 +104,7 @@ func (r *mutationResolver) ConfigureGeneral(ctx context.Context, input ConfigGen
}
refreshScraperCache := false
refreshScraperSource := false
existingScrapersPath := c.GetScrapersPath()
if input.ScrapersPath != nil && existingScrapersPath != *input.ScrapersPath {
if err := validateDir(config.ScrapersPath, *input.ScrapersPath, false); err != nil {
@@ -111,9 +112,23 @@ func (r *mutationResolver) ConfigureGeneral(ctx context.Context, input ConfigGen
}
refreshScraperCache = true
refreshScraperSource = true
c.Set(config.ScrapersPath, input.ScrapersPath)
}
refreshPluginCache := false
refreshPluginSource := false
existingPluginsPath := c.GetPluginsPath()
if input.PluginsPath != nil && existingPluginsPath != *input.PluginsPath {
if err := validateDir(config.PluginsPath, *input.PluginsPath, false); err != nil {
return makeConfigGeneralResult(), err
}
refreshPluginCache = true
refreshPluginSource = true
c.Set(config.PluginsPath, input.PluginsPath)
}
existingMetadataPath := c.GetMetadataPath()
if input.MetadataPath != nil && existingMetadataPath != *input.MetadataPath {
if err := validateDir(config.Metadata, *input.MetadataPath, true); err != nil {
@@ -347,13 +362,11 @@ func (r *mutationResolver) ConfigureGeneral(ctx context.Context, input ConfigGen
c.Set(config.DrawFunscriptHeatmapRange, input.DrawFunscriptHeatmapRange)
}
refreshScraperSource := false
if input.ScraperPackageSources != nil {
c.Set(config.ScraperPackageSources, input.ScraperPackageSources)
refreshScraperSource = true
}
refreshPluginSource := false
if input.PluginPackageSources != nil {
c.Set(config.PluginPackageSources, input.PluginPackageSources)
refreshPluginSource = true
@@ -367,6 +380,9 @@ func (r *mutationResolver) ConfigureGeneral(ctx context.Context, input ConfigGen
if refreshScraperCache {
manager.GetInstance().RefreshScraperCache()
}
if refreshPluginCache {
manager.GetInstance().RefreshPluginCache()
}
if refreshStreamManager {
manager.GetInstance().RefreshStreamManager()
}

View File

@@ -87,6 +87,7 @@ func makeConfigGeneralResult() *ConfigGeneralResult {
MetadataPath: config.GetMetadataPath(),
ConfigFilePath: config.GetConfigFile(),
ScrapersPath: config.GetScrapersPath(),
PluginsPath: config.GetPluginsPath(),
CachePath: config.GetCachePath(),
BlobsPath: config.GetBlobsPath(),
BlobsStorage: config.GetBlobsStorage(),

View File

@@ -98,11 +98,24 @@ func sortedPackageSpecKeys[V any](m map[models.PackageSpecInput]V) []models.Pack
}
sort.Slice(keys, func(i, j int) bool {
if strings.EqualFold(keys[i].ID, keys[j].ID) {
return keys[i].ID < keys[j].ID
a := keys[i]
b := keys[j]
aID := a.ID
bID := b.ID
if aID == bID {
return a.SourceURL < b.SourceURL
}
return strings.ToLower(keys[i].ID) < strings.ToLower(keys[j].ID)
aIDL := strings.ToLower(aID)
bIDL := strings.ToLower(bID)
if aIDL == bIDL {
return aID < bID
}
return aIDL < bIDL
})
return keys
@@ -129,9 +142,9 @@ func (r *queryResolver) getInstalledPackagesWithUpgrades(ctx context.Context, pm
for _, k := range sortedPackageSpecKeys(packageStatusIndex) {
v := packageStatusIndex[k]
p := manifestToPackage(*v.Local)
if v.Upgradable() {
if v.Remote != nil {
pp := remotePackageToPackage(*v.Remote, allRemoteList)
p.Upgrade = pp
p.SourcePackage = pp
}
ret[i] = p
i++
@@ -146,19 +159,19 @@ func (r *queryResolver) InstalledPackages(ctx context.Context, typeArg PackageTy
return nil, err
}
installed, err := pm.ListInstalled(ctx)
if err != nil {
return nil, err
}
var ret []*Package
if sliceutil.Contains(graphql.CollectAllFields(ctx), "upgrade") {
if sliceutil.Contains(graphql.CollectAllFields(ctx), "source_package") {
ret, err = r.getInstalledPackagesWithUpgrades(ctx, pm)
if err != nil {
return nil, err
}
} else {
installed, err := pm.ListInstalled(ctx)
if err != nil {
return nil, err
}
ret = make([]*Package, len(installed))
i := 0
for _, k := range sortedPackageSpecKeys(installed) {