Add support for disabling plugins (#4141)

* Move timestamp to own file
* Backend changes
* UI changes
This commit is contained in:
WithoutPants
2023-10-16 16:15:12 +11:00
committed by GitHub
parent e5af37efbc
commit b6808dc714
18 changed files with 260 additions and 62 deletions

View File

@@ -4,8 +4,10 @@ import (
"context"
"github.com/stashapp/stash/internal/manager"
"github.com/stashapp/stash/internal/manager/config"
"github.com/stashapp/stash/pkg/logger"
"github.com/stashapp/stash/pkg/plugin"
"github.com/stashapp/stash/pkg/sliceutil/stringslice"
)
func (r *mutationResolver) RunPluginTask(ctx context.Context, pluginID string, taskName string, args []*plugin.PluginArgInput) (string, error) {
@@ -22,3 +24,32 @@ func (r *mutationResolver) ReloadPlugins(ctx context.Context) (bool, error) {
return true, nil
}
func (r *mutationResolver) SetPluginsEnabled(ctx context.Context, enabledMap map[string]bool) (bool, error) {
c := config.GetInstance()
existingDisabled := c.GetDisabledPlugins()
var newDisabled []string
// remove plugins that are no longer disabled
for _, disabledID := range existingDisabled {
if enabled, found := enabledMap[disabledID]; !enabled || !found {
newDisabled = append(newDisabled, disabledID)
}
}
// add plugins that are newly disabled
for pluginID, enabled := range enabledMap {
if !enabled {
newDisabled = stringslice.StrAppendUnique(newDisabled, pluginID)
}
}
c.Set(config.DisabledPlugins, newDisabled)
if err := c.Write(); err != nil {
return false, err
}
return true, nil
}