This is an automated email from the ASF dual-hosted git repository.
zhangliang2022 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/main by this push:
new 5c0c74d91 feat: allow Data Scope search when creating a Blueprint in
the user flow (#5667)
5c0c74d91 is described below
commit 5c0c74d912d03b15f3020f350f376205ec3ef80c
Author: abeizn <[email protected]>
AuthorDate: Mon Jul 17 10:32:56 2023 +0800
feat: allow Data Scope search when creating a Blueprint in the user flow
(#5667)
* feat: allow Data Scope search when creating a Blueprint in the user flow
* fix: sql usage
---
backend/helpers/pluginhelper/api/scope_db_helper.go | 8 +++++++-
backend/plugins/bamboo/api/scope.go | 1 +
backend/plugins/bitbucket/api/scope.go | 1 +
backend/plugins/github/api/scope.go | 1 +
backend/plugins/gitlab/api/scope.go | 1 +
backend/plugins/jenkins/api/scope.go | 1 +
backend/plugins/jira/api/scope.go | 1 +
backend/plugins/pagerduty/api/scope.go | 1 +
backend/plugins/sonarqube/api/scope.go | 1 +
backend/plugins/tapd/api/scope.go | 1 +
backend/plugins/trello/api/scope.go | 1 +
backend/plugins/zentao/api/project_scope.go | 1 +
12 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/backend/helpers/pluginhelper/api/scope_db_helper.go
b/backend/helpers/pluginhelper/api/scope_db_helper.go
index c5ba22e50..d56133673 100644
--- a/backend/helpers/pluginhelper/api/scope_db_helper.go
+++ b/backend/helpers/pluginhelper/api/scope_db_helper.go
@@ -113,9 +113,15 @@ func (s *ScopeDatabaseHelperImpl[Conn, Scope, Tr])
GetScopeAndConfig(connectionI
}
func (s *ScopeDatabaseHelperImpl[Conn, Scope, Tr]) ListScopes(input
*plugin.ApiResourceInput, connectionId uint64) ([]*Scope, errors.Error) {
+ searchTerm := input.Query.Get("searchTerm")
+ query := dal.Where("connection_id = ?", connectionId)
+ if searchTerm != "" {
+ query = dal.Where(fmt.Sprintf("connection_id = ? AND %s LIKE
?", s.params.RawScopeParamName), connectionId, "%"+searchTerm+"%")
+
+ }
limit, offset := GetLimitOffset(input.Query, "pageSize", "page")
var scopes []*Scope
- err := s.db.All(&scopes, dal.Where("connection_id = ?", connectionId),
dal.Limit(limit), dal.Offset(offset))
+ err := s.db.All(&scopes, query, dal.Limit(limit), dal.Offset(offset))
return scopes, err
}
diff --git a/backend/plugins/bamboo/api/scope.go
b/backend/plugins/bamboo/api/scope.go
index 62172865c..beffd29fa 100644
--- a/backend/plugins/bamboo/api/scope.go
+++ b/backend/plugins/bamboo/api/scope.go
@@ -67,6 +67,7 @@ func UpdateScope(input *plugin.ApiResourceInput)
(*plugin.ApiResourceOutput, err
// @Description get Bamboo projects
// @Tags plugins/bamboo
// @Param connectionId path int false "connection ID"
+// @Param searchTerm query string false "search term for scope name"
// @Param blueprints query bool false "also return blueprints using these
scopes as part of the payload"
// @Success 200 {object} []ScopeRes
// @Failure 400 {object} shared.ApiBody "Bad Request"
diff --git a/backend/plugins/bitbucket/api/scope.go
b/backend/plugins/bitbucket/api/scope.go
index 1639fa96a..1ba10804e 100644
--- a/backend/plugins/bitbucket/api/scope.go
+++ b/backend/plugins/bitbucket/api/scope.go
@@ -70,6 +70,7 @@ func UpdateScope(input *plugin.ApiResourceInput)
(*plugin.ApiResourceOutput, err
// @Description get repos
// @Tags plugins/bitbucket
// @Param connectionId path int true "connection ID"
+// @Param searchTerm query string false "search term for scope name"
// @Param pageSize query int false "page size, default 50"
// @Param page query int false "page size, default 1"
// @Param blueprints query bool false "also return blueprints using these
scopes as part of the payload"
diff --git a/backend/plugins/github/api/scope.go
b/backend/plugins/github/api/scope.go
index 8ca575a11..8df469f7d 100644
--- a/backend/plugins/github/api/scope.go
+++ b/backend/plugins/github/api/scope.go
@@ -67,6 +67,7 @@ func UpdateScope(input *plugin.ApiResourceInput)
(*plugin.ApiResourceOutput, err
// @Description get Github repos
// @Tags plugins/github
// @Param connectionId path int true "connection ID"
+// @Param searchTerm query string false "search term for scope name"
// @Param pageSize query int false "page size, default 50"
// @Param page query int false "page size, default 1"
// @Param blueprints query bool false "also return blueprints using these
scopes as part of the payload"
diff --git a/backend/plugins/gitlab/api/scope.go
b/backend/plugins/gitlab/api/scope.go
index 705ca6c2e..42ceb7610 100644
--- a/backend/plugins/gitlab/api/scope.go
+++ b/backend/plugins/gitlab/api/scope.go
@@ -67,6 +67,7 @@ func UpdateScope(input *plugin.ApiResourceInput)
(*plugin.ApiResourceOutput, err
// @Description get Gitlab projects
// @Tags plugins/gitlab
// @Param connectionId path int false "connection ID"
+// @Param searchTerm query string false "search term for scope name"
// @Param blueprints query bool false "also return blueprints using these
scopes as part of the payload"
// @Success 200 {object} []ScopeRes
// @Failure 400 {object} shared.ApiBody "Bad Request"
diff --git a/backend/plugins/jenkins/api/scope.go
b/backend/plugins/jenkins/api/scope.go
index f1165bb1e..21e07c8f3 100644
--- a/backend/plugins/jenkins/api/scope.go
+++ b/backend/plugins/jenkins/api/scope.go
@@ -70,6 +70,7 @@ func UpdateScope(input *plugin.ApiResourceInput)
(*plugin.ApiResourceOutput, err
// @Description get Jenkins jobs
// @Tags plugins/jenkins
// @Param connectionId path int false "connection ID"
+// @Param searchTerm query string false "search term for scope name"
// @Param pageSize query int false "page size, default 50"
// @Param page query int false "page size, default 1"
// @Param blueprints query bool false "also return blueprints using these
scopes as part of the payload"
diff --git a/backend/plugins/jira/api/scope.go
b/backend/plugins/jira/api/scope.go
index b76893bfa..d1ad1e687 100644
--- a/backend/plugins/jira/api/scope.go
+++ b/backend/plugins/jira/api/scope.go
@@ -45,6 +45,7 @@ type ScopeReq api.ScopeReq[models.JiraBoard]
// @Tags plugins/jira
// @Accept application/json
// @Param connectionId path int false "connection ID"
+// @Param searchTerm query string false "search term for scope name"
// @Param scope body ScopeReq true "json"
// @Success 200 {object} []models.JiraBoard
// @Failure 400 {object} shared.ApiBody "Bad Request"
diff --git a/backend/plugins/pagerduty/api/scope.go
b/backend/plugins/pagerduty/api/scope.go
index 871de3d65..b9c8dfce9 100644
--- a/backend/plugins/pagerduty/api/scope.go
+++ b/backend/plugins/pagerduty/api/scope.go
@@ -67,6 +67,7 @@ func UpdateScope(input *plugin.ApiResourceInput)
(*plugin.ApiResourceOutput, err
// @Description get PagerDuty repos
// @Tags plugins/pagerduty
// @Param connectionId path int true "connection ID"
+// @Param searchTerm query string false "search term for scope name"
// @Param pageSize query int false "page size, default 50"
// @Param page query int false "page size, default 1"
// @Param blueprints query bool false "also return blueprints using these
scopes as part of the payload"
diff --git a/backend/plugins/sonarqube/api/scope.go
b/backend/plugins/sonarqube/api/scope.go
index e31f36ddd..4b0e11f74 100644
--- a/backend/plugins/sonarqube/api/scope.go
+++ b/backend/plugins/sonarqube/api/scope.go
@@ -66,6 +66,7 @@ func UpdateScope(input *plugin.ApiResourceInput)
(*plugin.ApiResourceOutput, err
// @Description get Sonarqube projects
// @Tags plugins/sonarqube
// @Param connectionId path int false "connection ID"
+// @Param searchTerm query string false "search term for scope name"
// @Param pageSize query int false "page size, default 50"
// @Param page query int false "page size, default 1"
// @Param blueprints query bool false "also return blueprints using these
scopes as part of the payload"
diff --git a/backend/plugins/tapd/api/scope.go
b/backend/plugins/tapd/api/scope.go
index 54da0d3f8..673194113 100644
--- a/backend/plugins/tapd/api/scope.go
+++ b/backend/plugins/tapd/api/scope.go
@@ -69,6 +69,7 @@ func UpdateScope(input *plugin.ApiResourceInput)
(*plugin.ApiResourceOutput, err
// @Description get tapd jobs
// @Tags plugins/tapd
// @Param connectionId path int false "connection ID"
+// @Param searchTerm query string false "search term for scope name"
// @Param pageSize query int false "page size, default 50"
// @Param page query int false "page size, default 1"
// @Param blueprints query bool false "also return blueprints using these
scopes as part of the payload"
diff --git a/backend/plugins/trello/api/scope.go
b/backend/plugins/trello/api/scope.go
index 94aa605de..83876f51d 100644
--- a/backend/plugins/trello/api/scope.go
+++ b/backend/plugins/trello/api/scope.go
@@ -66,6 +66,7 @@ func UpdateScope(input *plugin.ApiResourceInput)
(*plugin.ApiResourceOutput, err
// @Description get Trello boards
// @Tags plugins/trello
// @Param connectionId path int false "connection ID"
+// @Param searchTerm query string false "search term for scope name"
// @Param pageSize query int false "page size, default 50"
// @Param page query int false "page size, default 1"
// @Success 200 {object} []models.TrelloBoard
diff --git a/backend/plugins/zentao/api/project_scope.go
b/backend/plugins/zentao/api/project_scope.go
index 24e9703f6..a82e95652 100644
--- a/backend/plugins/zentao/api/project_scope.go
+++ b/backend/plugins/zentao/api/project_scope.go
@@ -67,6 +67,7 @@ func UpdateProjectScope(input *plugin.ApiResourceInput)
(*plugin.ApiResourceOutp
// @Description get Gitlab projects
// @Tags plugins/gitlab
// @Param connectionId path int false "connection ID"
+// @Param searchTerm query string false "search term for scope name"
// @Param blueprints query bool false "also return blueprints using these
scopes as part of the payload"
// @Success 200 {object} []ProjectScopeRes
// @Failure 400 {object} shared.ApiBody "Bad Request"