Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

refactor: use issue title/description when issue exists (#18744)

boojacka36e193d6acc
diff --git a/backend/api/v1/issue_service.go b/backend/api/v1/issue_service.go
index 163cf9308c..fbb44f36e2 100644
--- a/backend/api/v1/issue_service.go
+++ b/backend/api/v1/issue_service.go
@@ -903,10 +903,6 @@ func (s *IssueService) UpdateIssue(ctx context.Context, req *connect.Request[v1p
updateMasks[path] = true
switch path {
case "title":
- // Prevent updating title if plan exists.
- if issue.PlanUID != nil {
- return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("cannot update issue title when plan exists"))
- }
if req.Msg.Issue.Title == "" {
return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("title cannot be empty"))
}
@@ -926,11 +922,6 @@ func (s *IssueService) UpdateIssue(ctx context.Context, req *connect.Request[v1p
})
case "description":
- // Prevent updating description if plan exists
- if issue.PlanUID != nil {
- return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("cannot update issue description when plan exists"))
- }
-
patch.Description = &req.Msg.Issue.Description
issueCommentCreates = append(issueCommentCreates, &store.IssueCommentMessage{
diff --git a/frontend/src/components/Plan/components/HeaderSection/TitleInput.vue b/frontend/src/components/Plan/components/HeaderSection/TitleInput.vue
index f736e2385e..f243d7cfb1 100644
--- a/frontend/src/components/Plan/components/HeaderSection/TitleInput.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/TitleInput.vue
@@ -31,7 +31,6 @@ import {
useCurrentUserV1,
} from "@/store";
import {
- Issue_Type,
IssueSchema,
UpdateIssueRequestSchema,
} from "@/types/proto-es/v1/issue_service_pb";
@@ -49,10 +48,6 @@ const currentUser = useCurrentUserV1();
const { project } = useCurrentProjectV1();
const { isCreating, plan, issue, readonly } = usePlanContext();
-const isGrantRequest = computed(
- () => issue.value?.type === Issue_Type.GRANT_REQUEST
-);
-
const state = reactive({
isEditing: false,
isUpdating: false,
@@ -61,11 +56,9 @@ const state = reactive({
// Watch for changes in issue/plan to update the title
watch(
- () => [plan.value, issue.value, isGrantRequest.value],
+ () => [plan.value, issue.value],
() => {
- state.title = isGrantRequest.value
- ? issue.value?.title || ""
- : plan.value.title;
+ state.title = issue.value ? issue.value.title : plan.value.title;
},
{ immediate: true }
);
@@ -104,8 +97,8 @@ const allowEdit = computed(() => {
return false;
}
- // For grant requests, check issue permissions
- if (isGrantRequest.value && issue.value) {
+ // If issue exists, check issue permissions
+ if (issue.value) {
// Allowed if current user is the creator.
if (extractUserId(issue.value.creator) === currentUser.value.email) {
return true;
@@ -117,7 +110,7 @@ const allowEdit = computed(() => {
return false;
}
- // For regular plans, check plan permissions
+ // For plans without issue, check plan permissions
// Allowed if current user is the creator.
if (extractUserId(plan.value.creator) === currentUser.value.email) {
return true;
@@ -140,8 +133,8 @@ const onBlur = async () => {
return;
}
- // For grant requests, update issue title
- if (isGrantRequest.value && issue.value) {
+ // If issue exists, update issue title
+ if (issue.value) {
if (state.title === issue.value.title) {
cleanup();
return;
@@ -225,8 +218,8 @@ const onUpdateValue = (value: string) => {
if (!isCreating.value) {
return;
}
- // When creating, update issue title for grant requests, plan title otherwise
- if (isGrantRequest.value && issue.value) {
+ // When creating, update issue title if issue exists, plan title otherwise
+ if (issue.value) {
issue.value.title = value;
} else {
plan.value.title = value;
diff --git a/frontend/src/components/Plan/components/IssueReviewView/ActivitySection/IssueCommentView/IssueDescriptionComment.vue b/frontend/src/components/Plan/components/IssueReviewView/ActivitySection/IssueCommentView/IssueDescriptionComment.vue
index 5344aadf94..b09baa4920 100644
--- a/frontend/src/components/Plan/components/IssueReviewView/ActivitySection/IssueCommentView/IssueDescriptionComment.vue
+++ b/frontend/src/components/Plan/components/IssueReviewView/ActivitySection/IssueCommentView/IssueDescriptionComment.vue
@@ -26,7 +26,7 @@
>
<ActionCreator :creator="creatorName" />
<span class="text-gray-600 wrap-break-word min-w-0">{{
- createdSentence
+ $t("activity.sentence.created-issue")
}}</span>
<HumanizeTs
:ts="getTimeForPbTimestampProtoEs(createTime, 0) / 1000"
@@ -72,11 +72,10 @@ import type { Timestamp } from "@bufbuild/protobuf/wkt";
import { PencilIcon, PlusIcon } from "lucide-vue-next";
import { NButton } from "naive-ui";
import { computed, reactive } from "vue";
-import { useI18n } from "vue-i18n";
import HumanizeTs from "@/components/misc/HumanizeTs.vue";
import { usePlanContext } from "@/components/Plan/logic";
import UserAvatar from "@/components/User/UserAvatar.vue";
-import { issueServiceClientConnect, planServiceClientConnect } from "@/grpcweb";
+import { issueServiceClientConnect } from "@/grpcweb";
import { useCurrentProjectV1, useCurrentUserV1, useUserStore } from "@/store";
import { getTimeForPbTimestampProtoEs } from "@/types";
import type { IssueComment } from "@/types/proto-es/v1/issue_service_pb";
@@ -84,11 +83,7 @@ import {
IssueSchema,
UpdateIssueRequestSchema,
} from "@/types/proto-es/v1/issue_service_pb";
-import {
- PlanSchema,
- UpdatePlanRequestSchema,
-} from "@/types/proto-es/v1/plan_service_pb";
-import { hasProjectPermissionV2, isValidPlanName } from "@/utils";
+import { hasProjectPermissionV2 } from "@/utils";
import ActionCreator from "./ActionCreator.vue";
import EditableMarkdownContent from "./EditableMarkdownContent.vue";
@@ -96,8 +91,7 @@ defineProps<{
issueComments: IssueComment[];
}>();
-const { t } = useI18n();
-const { plan, issue } = usePlanContext();
+const { issue } = usePlanContext();
const currentUser = useCurrentUserV1();
const userStore = useUserStore();
const { project } = useCurrentProjectV1();
@@ -108,20 +102,12 @@ const state = reactive({
isSaving: false,
});
-const hasPlan = computed(() => isValidPlanName(plan.value.name));
-
-const createdSentence = computed(() => {
- // In IssueReviewView context, we always show "created issue"
- // because this view is for managing issues (even though data may come from plan)
- return t("activity.sentence.created-issue");
-});
-
const creatorName = computed(() => {
- return issue.value?.creator || plan.value?.creator || "";
+ return issue.value?.creator || "";
});
const createTime = computed((): Timestamp | undefined => {
- return issue.value?.createTime || plan.value?.createTime;
+ return issue.value?.createTime;
});
const creator = computed(() => {
@@ -129,18 +115,13 @@ const creator = computed(() => {
});
const description = computed(() => {
- return hasPlan.value
- ? plan.value.description || ""
- : issue.value?.description || "";
+ return issue.value?.description || "";
});
const allowEdit = computed(() => {
if (currentUser.value.name === creator.value?.name) {
return true;
}
- if (hasPlan.value) {
- return hasProjectPermissionV2(project.value, "bb.plans.update");
- }
return hasProjectPermissionV2(project.value, "bb.issues.update");
});
@@ -159,34 +140,21 @@ const cancelEdit = () => {
};
const saveEdit = async () => {
- if (!allowSave.value) return;
+ if (!allowSave.value || !issue.value) return;
try {
state.isSaving = true;
- if (hasPlan.value) {
- const planPatch = create(PlanSchema, {
- name: plan.value.name,
- description: state.editContent,
- });
- const request = create(UpdatePlanRequestSchema, {
- plan: planPatch,
- updateMask: { paths: ["description"] },
- });
- const response = await planServiceClientConnect.updatePlan(request);
- Object.assign(plan.value, response);
- } else if (issue.value) {
- const issuePatch = create(IssueSchema, {
- name: issue.value.name,
- description: state.editContent,
- });
- const request = create(UpdateIssueRequestSchema, {
- issue: issuePatch,
- updateMask: { paths: ["description"] },
- });
- const response = await issueServiceClientConnect.updateIssue(request);
- Object.assign(issue.value, response);
- }
+ const issuePatch = create(IssueSchema, {
+ name: issue.value.name,
+ description: state.editContent,
+ });
+ const request = create(UpdateIssueRequestSchema, {
+ issue: issuePatch,
+ updateMask: { paths: ["description"] },
+ });
+ const response = await issueServiceClientConnect.updateIssue(request);
+ Object.assign(issue.value, response);
cancelEdit();
} catch (error) {
diff --git a/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue b/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue
index 0096b02524..fbfd3c8148 100644
--- a/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue
+++ b/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue
@@ -190,7 +190,7 @@
<script setup lang="ts">
import { create } from "@bufbuild/protobuf";
-import { cloneDeep, includes, isEmpty } from "lodash-es";
+import { cloneDeep, isEmpty } from "lodash-es";
import { ExpandIcon, TableIcon } from "lucide-vue-next";
import { NButton, NTooltip, useDialog } from "naive-ui";
import { v1 as uuidv1 } from "uuid";
@@ -220,7 +220,6 @@ import {
import type { SQLDialect } from "@/types";
import { dialectOfEngineV1, isValidDatabaseGroupName } from "@/types";
import { UpdatePlanRequestSchema } from "@/types/proto-es/v1/plan_service_pb";
-import { Task_Status } from "@/types/proto-es/v1/rollout_service_pb";
import { SheetSchema } from "@/types/proto-es/v1/sheet_service_pb";
import {
getSheetStatement,
@@ -244,8 +243,7 @@ type LocalState = {
const { t } = useI18n();
const dialog = useDialog();
const { project } = useCurrentProjectV1();
-const { isCreating, plan, planCheckRuns, rollout, events, readonly } =
- usePlanContext();
+const { isCreating, plan, planCheckRuns, events, readonly } = usePlanContext();
const { selectedSpec, getDatabaseTargets, targets } = useSelectedSpec();
const editorState = useEditorState();
@@ -337,25 +335,9 @@ const shouldShowEditButton = computed(() => {
if (editorState.isEditing.value) {
return false;
}
- if (plan.value.hasRollout && rollout?.value) {
- const tasks = rollout.value.stages
- .flatMap((stage) => stage.tasks)
- .filter((task) => task.specId === selectedSpec.value.id);
- if (
- tasks.some((task) =>
- includes(
- [
- Task_Status.RUNNING,
- Task_Status.PENDING,
- Task_Status.DONE,
- Task_Status.SKIPPED,
- ],
- task.status
- )
- )
- ) {
- return false;
- }
+ // Hide edit button for plans that have a rollout.
+ if (plan.value.hasRollout) {
+ return false;
}
return true;
});