feat: Entities in icon field, and other cleanup stuff (#619)
This commit is contained in:
parent
a8ac719af7
commit
fcd1879d09
|
|
@ -108,22 +108,24 @@ func logAclNoneMatched(cfg *config.Config, aclFunction string, user *Authenticat
|
|||
}
|
||||
|
||||
func permissionsConfigToBits(permissions config.PermissionsList) PermissionBits {
|
||||
type permPair struct {
|
||||
enabled bool
|
||||
bit PermissionBits
|
||||
}
|
||||
|
||||
permMap := []permPair{
|
||||
{permissions.View, View},
|
||||
{permissions.Exec, Exec},
|
||||
{permissions.Logs, Logs},
|
||||
{permissions.Kill, Kill},
|
||||
}
|
||||
|
||||
var ret PermissionBits
|
||||
|
||||
if permissions.View {
|
||||
ret |= View
|
||||
}
|
||||
|
||||
if permissions.Exec {
|
||||
ret |= Exec
|
||||
}
|
||||
|
||||
if permissions.Logs {
|
||||
ret |= Logs
|
||||
}
|
||||
|
||||
if permissions.Kill {
|
||||
ret |= Kill
|
||||
for _, perm := range permMap {
|
||||
if perm.enabled {
|
||||
ret |= perm.bit
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ import (
|
|||
sv "github.com/OliveTin/OliveTin/internal/stringvariables"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"gopkg.in/yaml.v3"
|
||||
"math"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"math"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package entityfiles
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"github.com/stretchr/testify/assert"
|
||||
sv "github.com/OliveTin/OliveTin/internal/stringvariables"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLoadObjectPerLineJsonFile(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ func (api *oliveTinAPI) KillAction(ctx ctx.Context, req *apiv1.KillActionRequest
|
|||
|
||||
log.Warnf("Killing execution request by tracking ID: %v", req.ExecutionTrackingId)
|
||||
|
||||
user := acl.UserFromContext(ctx, cfg)
|
||||
action := cfg.FindAction(execReqLogEntry.ActionTitle)
|
||||
|
||||
if action == nil {
|
||||
|
|
@ -58,10 +57,17 @@ func (api *oliveTinAPI) KillAction(ctx ctx.Context, req *apiv1.KillActionRequest
|
|||
return ret, nil
|
||||
}
|
||||
|
||||
user := acl.UserFromContext(ctx, cfg)
|
||||
|
||||
api.killActionByTrackingId(user, action, execReqLogEntry, ret)
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (api *oliveTinAPI) killActionByTrackingId(user *acl.AuthenticatedUser, action *config.Action, execReqLogEntry *executor.InternalLogEntry, ret *apiv1.KillActionResponse) {
|
||||
if !acl.IsAllowedKill(cfg, user, action) {
|
||||
log.Warnf("Killing execution request not possible - user not allowed to kill this action: %v", req.ExecutionTrackingId)
|
||||
log.Warnf("Killing execution request not possible - user not allowed to kill this action: %v", execReqLogEntry.ExecutionTrackingID)
|
||||
ret.Killed = false
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
err := api.executor.Kill(execReqLogEntry)
|
||||
|
|
@ -73,8 +79,6 @@ func (api *oliveTinAPI) KillAction(ctx ctx.Context, req *apiv1.KillActionRequest
|
|||
} else {
|
||||
ret.Killed = true
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (api *oliveTinAPI) StartAction(ctx ctx.Context, req *apiv1.StartActionRequest) (*apiv1.StartActionResponse, error) {
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ func buildAction(actionId string, actionBinding *executor.ActionBinding, user *a
|
|||
btn := apiv1.Action{
|
||||
Id: actionId,
|
||||
Title: sv.ReplaceEntityVars(actionBinding.EntityPrefix, action.Title),
|
||||
Icon: action.Icon,
|
||||
Icon: sv.ReplaceEntityVars(actionBinding.EntityPrefix, action.Icon),
|
||||
CanExec: acl.IsAllowedExec(cfg, user, action),
|
||||
PopupOnStart: action.PopupOnStart,
|
||||
Order: int32(actionBinding.ConfigOrder),
|
||||
|
|
|
|||
Loading…
Reference in New Issue