Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: implement enforce issue title setting (#13567)
boojack1fbabeb25f97
diff --git a/backend/api/v1/issue_service.go b/backend/api/v1/issue_service.goindex c232a9f9eb..503d4a7eec 100644--- a/backend/api/v1/issue_service.go+++ b/backend/api/v1/issue_service.go@@ -388,9 +388,15 @@ func (s *IssueService) getUserByIdentifier(ctx context.Context, identifier strin// CreateIssue creates a issue.func (s *IssueService) CreateIssue(ctx context.Context, request *v1pb.CreateIssueRequest) (*v1pb.Issue, error) {- switch request.Issue.Type {- case v1pb.Issue_TYPE_UNSPECIFIED:+ // Validate requests.+ if request.Issue.Title == "" {+ return nil, status.Errorf(codes.InvalidArgument, "issue title is required")+ }+ if request.Issue.Type == v1pb.Issue_TYPE_UNSPECIFIED {return nil, status.Errorf(codes.InvalidArgument, "issue type is required")+ }++ switch request.Issue.Type {case v1pb.Issue_GRANT_REQUEST:return s.createIssueGrantRequest(ctx, request)case v1pb.Issue_DATABASE_CHANGE:@@ -1156,6 +1162,10 @@ func (s *IssueService) UpdateIssue(ctx context.Context, request *v1pb.UpdateIssu}case "title":+ if request.Issue.Title == "" {+ return nil, status.Errorf(codes.InvalidArgument, "title cannot be empty")+ }+patch.Title = &request.Issue.TitleissueCommentCreates = append(issueCommentCreates, &store.IssueCommentMessage{diff --git a/backend/api/v1/project_service.go b/backend/api/v1/project_service.goindex 410a6dee2a..3c7611df21 100644--- a/backend/api/v1/project_service.go+++ b/backend/api/v1/project_service.go@@ -220,6 +220,10 @@ func (s *ProjectService) UpdateProject(ctx context.Context, request *v1pb.UpdateprojectSettings := project.SettingprojectSettings.AutoResolveIssue = request.Project.AutoResolveIssuepatch.Setting = projectSettings+ case "enforce_issue_title":+ projectSettings := project.Setting+ projectSettings.EnforceIssueTitle = request.Project.EnforceIssueTitle+ patch.Setting = projectSettingsdefault:return nil, status.Errorf(codes.InvalidArgument, `unsupport update_mask "%s"`, path)}@@ -1253,6 +1257,7 @@ func convertToProject(projectMessage *store.ProjectMessage) *v1pb.Project {ForceIssueLabels: projectMessage.Setting.ForceIssueLabels,AllowModifyStatement: projectMessage.Setting.AllowModifyStatement,AutoResolveIssue: projectMessage.Setting.AutoResolveIssue,+ EnforceIssueTitle: projectMessage.Setting.EnforceIssueTitle,}}diff --git a/frontend/src/components/IssueV1/logic/initialize/create.ts b/frontend/src/components/IssueV1/logic/initialize/create.tsindex d9356b42c2..f1e5633ed6 100644--- a/frontend/src/components/IssueV1/logic/initialize/create.ts+++ b/frontend/src/components/IssueV1/logic/initialize/create.ts@@ -116,8 +116,11 @@ const buildIssue = async (params: CreateIssueParams) => {issue.project = project.name;issue.projectEntity = project;issue.name = `${project.name}/issues/${nextUID()}`;- issue.title = query.name;issue.status = IssueStatus.OPEN;+ // Only set title from query if enforceIssueTitle is false.+ if (!project.enforceIssueTitle) {+ issue.title = query.name;+ }const template = query.template as TemplateType | undefined;if (template === "bb.issue.database.data.export") {diff --git a/frontend/src/components/Project/Settings/ProjectIssueRelatedSettingPanel.vue b/frontend/src/components/Project/Settings/ProjectIssueRelatedSettingPanel.vueindex 1d739c30c4..8d477ed6f9 100644--- a/frontend/src/components/Project/Settings/ProjectIssueRelatedSettingPanel.vue+++ b/frontend/src/components/Project/Settings/ProjectIssueRelatedSettingPanel.vue@@ -33,6 +33,19 @@}}</p></div>+ <div>+ <NCheckbox+ v-model:checked="state.enforceIssueTitle"+ size="large"+ :disabled="!allowEdit"+ :label="$t('project.settings.issue-related.enforce-issue-title.self')"+ />+ <p class="text-sm text-gray-400 pl-6 ml-0.5">+ {{+ $t("project.settings.issue-related.enforce-issue-title.description")+ }}+ </p>+ </div><div><NCheckboxv-model:checked="state.allowModifyStatement"@@ -92,6 +105,7 @@ const getInitialLocalState = (): LocalState => {forceIssueLabels: project.forceIssueLabels,allowModifyStatement: project.allowModifyStatement,autoResolveIssue: project.autoResolveIssue,+ enforceIssueTitle: project.enforceIssueTitle,};};@@ -100,6 +114,7 @@ interface LocalState {forceIssueLabels: boolean;allowModifyStatement: boolean;autoResolveIssue: boolean;+ enforceIssueTitle: boolean;}const defaultColor = "#4f46e5";@@ -200,6 +215,9 @@ const getUpdateMask = () => {if (state.autoResolveIssue !== props.project.autoResolveIssue) {mask.push("auto_resolve_issue");}+ if (state.enforceIssueTitle !== props.project.enforceIssueTitle) {+ mask.push("enforce_issue_title");+ }return mask;};</script>diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex f6e6f9b85a..e428cfb2ff 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -2098,6 +2098,10 @@"auto-resolve-issue": {"self": "Auto resolve issue","description": "Automatically resolve the issue after all tasks are completed."+ },+ "enforce-issue-title": {+ "self": "Enforce issue title",+ "description": "Enforce issue title to be non-empty and created by user instead of auto generated."}}},diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 5c88a45086..b0d9b8a3d0 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -2098,6 +2098,10 @@"auto-resolve-issue": {"self": "Problema de resolución automática","description": "Resuelva automáticamente el problema después de completar todas las tareas."+ },+ "enforce-issue-title": {+ "self": "Hacer cumplir el título del problema",+ "description": "Exigir que el título del problema no esté vacío y que lo cree el usuario en lugar de generarse automáticamente."}}},@@ -3695,4 +3699,4 @@"worksheet": {"self": "Hoja de trabajo"}-}+}\ No newline at end of filediff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex e2cb4fae33..648b692397 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -2098,6 +2098,10 @@"auto-resolve-issue": {"self": "自動解決の問題","description": "すべてのタスクが完了すると、問題が自動的に解決されます。"+ },+ "enforce-issue-title": {+ "self": "問題のタイトルを強制する",+ "description": "問題のタイトルが空でないこと、および自動生成ではなくユーザーが作成することを強制します。"}}},@@ -3695,4 +3699,4 @@"worksheet": {"self": "ワークシート"}-}+}\ No newline at end of filediff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 7bc217e95e..489958d222 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -2098,6 +2098,10 @@"auto-resolve-issue": {"self": "自动完成工单","description": "所有任务执行成功后自动完成工单。"+ },+ "enforce-issue-title": {+ "self": "要求手动输入工单标题",+ "description": "工单标题必须由用户输入而不是自动生成。"}}},diff --git a/frontend/src/types/proto/v1/project_service.ts b/frontend/src/types/proto/v1/project_service.tsindex 42ce7245f3..0ac14190b2 100644--- a/frontend/src/types/proto/v1/project_service.ts+++ b/frontend/src/types/proto/v1/project_service.ts@@ -275,6 +275,8 @@ export interface Project {allowModifyStatement: boolean;/** Enable auto resolve issue. */autoResolveIssue: boolean;+ /** Enforce issue title created by user instead of generated by Bytebase. */+ enforceIssueTitle: boolean;}export interface AddWebhookRequest {@@ -1776,6 +1778,7 @@ function createBaseProject(): Project {forceIssueLabels: false,allowModifyStatement: false,autoResolveIssue: false,+ enforceIssueTitle: false,};}@@ -1814,6 +1817,9 @@ export const Project = {if (message.autoResolveIssue === true) {writer.uint32(128).bool(message.autoResolveIssue);}+ if (message.enforceIssueTitle === true) {+ writer.uint32(136).bool(message.enforceIssueTitle);+ }return writer;},@@ -1901,6 +1907,13 @@ export const Project = {message.autoResolveIssue = reader.bool();continue;+ case 17:+ if (tag !== 136) {+ break;+ }++ message.enforceIssueTitle = reader.bool();+ continue;}if ((tag & 7) === 4 || tag === 0) {break;@@ -1929,6 +1942,7 @@ export const Project = {? globalThis.Boolean(object.allowModifyStatement): false,autoResolveIssue: isSet(object.autoResolveIssue) ? globalThis.Boolean(object.autoResolveIssue) : false,+ enforceIssueTitle: isSet(object.enforceIssueTitle) ? globalThis.Boolean(object.enforceIssueTitle) : false,};},@@ -1967,6 +1981,9 @@ export const Project = {if (message.autoResolveIssue === true) {obj.autoResolveIssue = message.autoResolveIssue;}+ if (message.enforceIssueTitle === true) {+ obj.enforceIssueTitle = message.enforceIssueTitle;+ }return obj;},@@ -1986,6 +2003,7 @@ export const Project = {message.forceIssueLabels = object.forceIssueLabels ?? false;message.allowModifyStatement = object.allowModifyStatement ?? false;message.autoResolveIssue = object.autoResolveIssue ?? false;+ message.enforceIssueTitle = object.enforceIssueTitle ?? false;return message;},};diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.mdindex 389f1f4e2f..8c143dc549 100644--- a/proto/gen/grpc-doc/v1/README.md+++ b/proto/gen/grpc-doc/v1/README.md@@ -7330,6 +7330,7 @@ When paginating, all other parameters provided to `ListProjects` must match the| force_issue_labels | [bool](#bool) | | Force issue labels to be used when creating an issue. || allow_modify_statement | [bool](#bool) | | Allow modifying statement after issue is created. || auto_resolve_issue | [bool](#bool) | | Enable auto resolve issue. |+| enforce_issue_title | [bool](#bool) | | Enforce issue title created by user instead of generated by Bytebase. |diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.htmlindex f6deb2efa9..d1e9c653ba 100644--- a/proto/gen/grpc-doc/v1/index.html+++ b/proto/gen/grpc-doc/v1/index.html@@ -20445,6 +20445,13 @@ Format: projects/{project} </p></td><td><p>Enable auto resolve issue. </p></td></tr>+ <tr>+ <td>enforce_issue_title</td>+ <td><a href="#bool">bool</a></td>+ <td></td>+ <td><p>Enforce issue title created by user instead of generated by Bytebase. </p></td>+ </tr>+</tbody></table>diff --git a/proto/generated-go/v1/project_service.pb.go b/proto/generated-go/v1/project_service.pb.goindex f37c8d479a..2f8c223ee9 100644--- a/proto/generated-go/v1/project_service.pb.go+++ b/proto/generated-go/v1/project_service.pb.go@@ -1117,6 +1117,8 @@ type Project struct {AllowModifyStatement bool `protobuf:"varint,15,opt,name=allow_modify_statement,json=allowModifyStatement,proto3" json:"allow_modify_statement,omitempty"`// Enable auto resolve issue.AutoResolveIssue bool `protobuf:"varint,16,opt,name=auto_resolve_issue,json=autoResolveIssue,proto3" json:"auto_resolve_issue,omitempty"`+ // Enforce issue title created by user instead of generated by Bytebase.+ EnforceIssueTitle bool `protobuf:"varint,17,opt,name=enforce_issue_title,json=enforceIssueTitle,proto3" json:"enforce_issue_title,omitempty"`}func (x *Project) Reset() {@@ -1228,6 +1230,13 @@ func (x *Project) GetAutoResolveIssue() bool {return false}+func (x *Project) GetEnforceIssueTitle() bool {+ if x != nil {+ return x.EnforceIssueTitle+ }+ return false+}+type AddWebhookRequest struct {state protoimpl.MessageStatesizeCache protoimpl.SizeCache@@ -2130,7 +2139,7 @@ var file_v1_project_service_proto_rawDesc = []byte{0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75,0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,0x52, 0x05, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70,- 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x22, 0x95, 0x04,+ 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x22, 0xc5, 0x04,0x0a, 0x07, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d,0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a,0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x62,@@ -2161,6 +2170,9 @@ var file_v1_project_service_proto_rawDesc = []byte{0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x12, 0x61, 0x75, 0x74, 0x6f, 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x6c,0x76, 0x65, 0x5f, 0x69, 0x73, 0x73, 0x75, 0x65, 0x18, 0x10, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10,0x61, 0x75, 0x74, 0x6f, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x49, 0x73, 0x73, 0x75, 0x65,+ 0x12, 0x2e, 0x0a, 0x13, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x73, 0x73, 0x75,+ 0x65, 0x5f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x11, 0x20, 0x01, 0x28, 0x08, 0x52, 0x11, 0x65,+ 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x49, 0x73, 0x73, 0x75, 0x65, 0x54, 0x69, 0x74, 0x6c, 0x65,0x3a, 0x2d, 0xea, 0x41, 0x2a, 0x0a, 0x14, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e,0x63, 0x6f, 0x6d, 0x2f, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x12, 0x70, 0x72, 0x6f,0x6a, 0x65, 0x63, 0x74, 0x73, 0x2f, 0x7b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x7d, 0x4a,diff --git a/proto/v1/project_service.proto b/proto/v1/project_service.protoindex c8df5c36fd..4678b413a8 100644--- a/proto/v1/project_service.proto+++ b/proto/v1/project_service.proto@@ -309,6 +309,8 @@ message Project {bool allow_modify_statement = 15;// Enable auto resolve issue.bool auto_resolve_issue = 16;+ // Enforce issue title created by user instead of generated by Bytebase.+ bool enforce_issue_title = 17;}enum Workflow {