fix: GetScopes panic on Advanced BP (#5722)
diff --git a/backend/helpers/pluginhelper/services/blueprint_helper.go b/backend/helpers/pluginhelper/services/blueprint_helper.go
index 6282c21..a765f6b 100644
--- a/backend/helpers/pluginhelper/services/blueprint_helper.go
+++ b/backend/helpers/pluginhelper/services/blueprint_helper.go
@@ -19,6 +19,7 @@
import (
"fmt"
+
"github.com/apache/incubator-devlake/core/dal"
"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/core/models"
@@ -36,6 +37,7 @@
Label string
SkipRecords int
PageSize int
+ Mode string
}
type BlueprintProjectPairs struct {
@@ -105,6 +107,9 @@
dal.Where("bl.name = ?", query.Label),
)
}
+ if query.Mode != "" {
+ clauses = append(clauses, dal.Where("mode = ?", query.Mode))
+ }
// count total records
count, err := b.db.Count(clauses...)
@@ -155,7 +160,7 @@
// GetBlueprintsByScopes returns all blueprints that have these scopeIds and this connection Id
func (b *BlueprintManager) GetBlueprintsByScopes(connectionId uint64, pluginName string, scopeIds ...string) (map[string][]*models.Blueprint, errors.Error) {
- bps, _, err := b.GetDbBlueprints(&GetBlueprintQuery{})
+ bps, _, err := b.GetDbBlueprints(&GetBlueprintQuery{Mode: "NORMAL"})
if err != nil {
return nil, err
}
diff --git a/config-ui/src/pages/blueprint/home/index.tsx b/config-ui/src/pages/blueprint/home/index.tsx
index 78f208a..f37e3d5 100644
--- a/config-ui/src/pages/blueprint/home/index.tsx
+++ b/config-ui/src/pages/blueprint/home/index.tsx
@@ -62,7 +62,7 @@
const connections =
it.settings?.connections
.filter((cs) => cs.plugin !== 'webhook')
- .map((cs) => onGet(`${cs.plugin}-${cs.connectionId}`)) ?? [];
+ .map((cs) => onGet(`${cs.plugin}-${cs.connectionId}`) || `${cs.plugin}-${cs.connectionId}`) ?? [];
return {
...it,
connections: connections.map((cs) => cs.name),