Skip to content

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

chore: remove creator entity from composed issue (#16218)

boojack3d9a36dad0ca
diff --git a/frontend/src/components/IssueV1/DataExportIssueDetailPage.vue b/frontend/src/components/IssueV1/DataExportIssueDetailPage.vue
index 630934ec38..08e56c4f36 100644
--- a/frontend/src/components/IssueV1/DataExportIssueDetailPage.vue
+++ b/frontend/src/components/IssueV1/DataExportIssueDetailPage.vue
@@ -67,7 +67,7 @@ import { FeatureAttention } from "@/components/FeatureGuard";
import type { Plan, Plan_Spec } from "@/types/proto/v1/plan_service";
import type { Task } from "@/types/proto/v1/rollout_service";
import { SQLCheckSection } from "../Plan/components";
-import { providePlanSQLCheckContext } from "../Plan/components/SQLCheckSection/context";
+import { providePlanSQLCheckContext } from "../Plan/components/SQLCheckSection";
import { provideSidebarContext } from "../Plan/logic";
import { Drawer } from "../v2";
import {
diff --git a/frontend/src/components/IssueV1/IssueDetailPage.vue b/frontend/src/components/IssueV1/IssueDetailPage.vue
index 95335b74ab..26701d5d53 100644
--- a/frontend/src/components/IssueV1/IssueDetailPage.vue
+++ b/frontend/src/components/IssueV1/IssueDetailPage.vue
@@ -42,12 +42,7 @@
<!-- mobile sidebar -->
<Drawer :show="mobileSidebarOpen" @close="mobileSidebarOpen = false">
<div
- style="
- min-width: 240px;
- width: 80vw;
- max-width: 320px;
- padding: 0.5rem 0;
- "
+ style="min-width: 240px; width: 80vw; max-width: 320px; padding: 0.5rem"
>
<Sidebar v-if="sidebarMode === 'MOBILE'" />
</div>
@@ -75,7 +70,7 @@ import { FeatureAttention } from "@/components/FeatureGuard";
import type { Plan, Plan_Spec } from "@/types/proto/v1/plan_service";
import { type Task } from "@/types/proto/v1/rollout_service";
import { SQLCheckSection } from "../Plan/components";
-import { providePlanSQLCheckContext } from "../Plan/components/SQLCheckSection/context";
+import { providePlanSQLCheckContext } from "../Plan/components/SQLCheckSection";
import { provideSidebarContext } from "../Plan/logic";
import { Drawer } from "../v2";
import {
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Actions/Actions.vue b/frontend/src/components/IssueV1/components/HeaderSection/Actions/Actions.vue
index 59817f969c..afcbb8a2d0 100644
--- a/frontend/src/components/IssueV1/components/HeaderSection/Actions/Actions.vue
+++ b/frontend/src/components/IssueV1/components/HeaderSection/Actions/Actions.vue
@@ -13,7 +13,7 @@
<script setup lang="ts">
import { asyncComputed } from "@vueuse/core";
import { computed } from "vue";
-import { useCurrentUserV1 } from "@/store";
+import { extractUserId, useCurrentUserV1 } from "@/store";
import { IssueStatus } from "@/types/proto/v1/issue_service";
import { isGrantRequestIssue, checkRoleContainsAnyPermission } from "@/utils";
import { useIssueContext } from "../../../logic";
@@ -32,8 +32,7 @@ const isFinishedGrantRequestIssueByCurrentUser = computed(() => {
if (isCreating.value) return false;
if (issue.value.status !== IssueStatus.DONE) return false;
if (!isGrantRequestIssue(issue.value)) return false;
-
- return issue.value.creatorEntity.name === currentUser.value.name;
+ return extractUserId(issue.value.creator) === currentUser.value.email;
});
const actionType = asyncComputed(async (): Promise<ActionType | undefined> => {
diff --git a/frontend/src/components/IssueV1/components/IssueCommentSection/Subscribers/SubscriberList.vue b/frontend/src/components/IssueV1/components/IssueCommentSection/Subscribers/SubscriberList.vue
index 71b14500c2..e82b7a1cac 100644
--- a/frontend/src/components/IssueV1/components/IssueCommentSection/Subscribers/SubscriberList.vue
+++ b/frontend/src/components/IssueV1/components/IssueCommentSection/Subscribers/SubscriberList.vue
@@ -21,7 +21,7 @@
size="SMALL"
class="ml-[-18px] first:ml-0"
/>
- <heroicons:ellipsis-horizontal v-if="!readonly" class="w-5 h-5" />
+ <EllipsisIcon v-if="!readonly" class="w-4 h-4" />
</div>
</NButton>
@@ -37,6 +37,7 @@
<script setup lang="ts">
import { useDebounceFn } from "@vueuse/core";
+import { EllipsisIcon } from "lucide-vue-next";
import type { SelectOption, SelectGroupOption } from "naive-ui";
import { NButton, NPopselect, NInput } from "naive-ui";
import { computed, h, nextTick, ref, reactive, watch } from "vue";
@@ -187,4 +188,16 @@ const handleSearch = useDebounceFn(async (search: string) => {
}, DEBOUNCE_SEARCH_DELAY);
watch(() => keyword.value, handleSearch, { immediate: true });
+
+// Preload subscribers' user data.
+watch(
+ () => issue.value.subscribers,
+ (newSubscribers) => {
+ userStore.batchGetUsers(newSubscribers);
+ },
+ {
+ immediate: true,
+ deep: true,
+ }
+);
</script>
diff --git a/frontend/src/components/IssueV1/components/IssueCommentSection/Subscribers/Subscribers.vue b/frontend/src/components/IssueV1/components/IssueCommentSection/Subscribers/Subscribers.vue
index 47269ce27d..1a23c325de 100644
--- a/frontend/src/components/IssueV1/components/IssueCommentSection/Subscribers/Subscribers.vue
+++ b/frontend/src/components/IssueV1/components/IssueCommentSection/Subscribers/Subscribers.vue
@@ -21,11 +21,9 @@ const allowSubscribe = computed(() => {
// Allowed if current user is the creator.
return true;
}
-
if (hasProjectPermissionV2(issue.value.projectEntity, "bb.issues.update")) {
return true;
}
-
return false;
});
</script>
diff --git a/frontend/src/components/IssueV1/components/IssueTableV1.vue b/frontend/src/components/IssueV1/components/IssueTableV1.vue
index d9a86b1b22..2158d310d6 100644
--- a/frontend/src/components/IssueV1/components/IssueTableV1.vue
+++ b/frontend/src/components/IssueV1/components/IssueTableV1.vue
@@ -51,7 +51,12 @@ import CurrentApproverV1 from "@/components/IssueV1/components/CurrentApproverV1
import { useElementVisibilityInScrollParent } from "@/composables/useElementVisibilityInScrollParent";
import { emitWindowEvent } from "@/plugins";
import { PROJECT_V1_ROUTE_ISSUE_DETAIL } from "@/router/dashboard/projectV1";
-import { getTimeForPbTimestamp, type ComposedIssue } from "@/types";
+import { useUserStore } from "@/store";
+import {
+ getTimeForPbTimestamp,
+ unknownUser,
+ type ComposedIssue,
+} from "@/types";
import {
getHighlightHTMLByRegExp,
extractProjectResourceName,
@@ -64,7 +69,66 @@ import IssueLabelSelector, {
} from "./IssueLabelSelector.vue";
import IssueStatusIconWithTaskSummary from "./IssueStatusIconWithTaskSummary.vue";
+interface LocalState {
+ selectedIssueNameList: Set<string>;
+}
+
+const props = withDefaults(
+ defineProps<{
+ issueList: ComposedIssue[];
+ bordered?: boolean;
+ title?: string;
+ highlightText?: string;
+ loading?: boolean;
+ showProject?: boolean;
+ showSelection?: boolean;
+ }>(),
+ {
+ title: "",
+ highlightText: "",
+ loading: true,
+ bordered: false,
+ showSelection: true,
+ }
+);
+
const { t } = useI18n();
+const router = useRouter();
+const userStore = useUserStore();
+const state = reactive<LocalState>({
+ selectedIssueNameList: new Set(),
+});
+
+const tableRef = ref<HTMLDivElement>();
+const isTableInViewport = useElementVisibilityInScrollParent(tableRef);
+const { width: tableWidth } = useElementSize(tableRef);
+const showExtendedColumns = computed(() => {
+ return tableWidth.value > 800;
+});
+
+const sortedIssueList = computed(() => {
+ if (!props.highlightText) {
+ return props.issueList;
+ }
+
+ return orderBy(
+ props.issueList,
+ [
+ (issue) =>
+ `${issue.title} ${issue.description}`.includes(props.highlightText)
+ ? 1
+ : 0,
+ (issue) => parseInt(extractIssueUID(issue.name)),
+ ],
+ ["desc", "desc"]
+ );
+});
+
+const selectedIssueList = computed(() => {
+ return props.issueList.filter((issue) =>
+ state.selectedIssueNameList.has(issue.name)
+ );
+});
const columnList = computed((): DataTableColumn<ComposedIssue>[] => {
const columns: (DataTableColumn<ComposedIssue> & { hide?: boolean })[] = [
@@ -167,77 +231,21 @@ const columnList = computed((): DataTableColumn<ComposedIssue>[] => {
width: 150,
title: t("issue.table.creator"),
hide: !showExtendedColumns.value,
- render: (issue) => (
- <div class="flex flex-row items-center overflow-hidden gap-x-2">
- <BBAvatar size="SMALL" username={issue.creatorEntity.title} />
- <span class="truncate">{issue.creatorEntity.title}</span>
- </div>
- ),
+ render: (issue) => {
+ const creator =
+ userStore.getUserByIdentifier(issue.creator) || unknownUser();
+ return (
+ <div class="flex flex-row items-center overflow-hidden gap-x-2">
+ <BBAvatar size="SMALL" username={creator.title} />
+ <span class="truncate">{creator.title}</span>
+ </div>
+ );
+ },
},
];
return columns.filter((column) => !column.hide);
});
-interface LocalState {
- selectedIssueNameList: Set<string>;
-}
-
-const props = withDefaults(
- defineProps<{
- issueList: ComposedIssue[];
- bordered?: boolean;
- title?: string;
- highlightText?: string;
- loading?: boolean;
- showProject?: boolean;
- showSelection?: boolean;
- }>(),
- {
- title: "",
- highlightText: "",
- loading: true,
- bordered: false,
- showSelection: true,
- }
-);
-
-const router = useRouter();
-
-const state = reactive<LocalState>({
- selectedIssueNameList: new Set(),
-});
-
-const tableRef = ref<HTMLDivElement>();
-const isTableInViewport = useElementVisibilityInScrollParent(tableRef);
-const { width: tableWidth } = useElementSize(tableRef);
-const showExtendedColumns = computed(() => {
- return tableWidth.value > 800;
-});
-
-const sortedIssueList = computed(() => {
- if (!props.highlightText) {
- return props.issueList;
- }
-
- return orderBy(
- props.issueList,
- [
- (issue) =>
- `${issue.title} ${issue.description}`.includes(props.highlightText)
- ? 1
- : 0,
- (issue) => parseInt(extractIssueUID(issue.name)),
- ],
- ["desc", "desc"]
- );
-});
-
-const selectedIssueList = computed(() => {
- return props.issueList.filter((issue) =>
- state.selectedIssueNameList.has(issue.name)
- );
-});
-
const issueUrl = (issue: ComposedIssue) => {
const route = router.resolve({
name: PROJECT_V1_ROUTE_ISSUE_DETAIL,
diff --git a/frontend/src/components/IssueV1/logic/initialize/create.ts b/frontend/src/components/IssueV1/logic/initialize/create.ts
index 031ec134cf..15c8acab1e 100644
--- a/frontend/src/components/IssueV1/logic/initialize/create.ts
+++ b/frontend/src/components/IssueV1/logic/initialize/create.ts
@@ -98,7 +98,6 @@ const buildIssue = async (params: CreateIssueParams) => {
const issue = emptyIssue();
const me = useCurrentUserV1();
issue.creator = `users/${me.value.email}`;
- issue.creatorEntity = me.value;
issue.project = project.name;
issue.projectEntity = project;
issue.name = `${project.name}/issues/${nextUID()}`;
diff --git a/frontend/src/components/Plan/PlanDetailPage.vue b/frontend/src/components/Plan/PlanDetailPage.vue
index 40530a9277..17f4ce0d41 100644
--- a/frontend/src/components/Plan/PlanDetailPage.vue
+++ b/frontend/src/components/Plan/PlanDetailPage.vue
@@ -53,7 +53,7 @@ import {
SQLCheckSection,
SpecListSection,
} from "./components";
-import { providePlanSQLCheckContext } from "./components/SQLCheckSection/context";
+import { providePlanSQLCheckContext } from "./components/SQLCheckSection";
import Sidebar from "./components/Sidebar";
import { usePlanContext, usePollPlan } from "./logic";
import { provideSidebarContext } from "./logic";
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateIssueButton.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateIssueButton.vue
index 7eb2102b57..4d6cc22099 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateIssueButton.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateIssueButton.vue
@@ -184,7 +184,6 @@ const buildIssue = () => {
const issue = emptyIssue();
const me = useCurrentUserV1();
issue.creator = `users/${me.value.email}`;
- issue.creatorEntity = me.value;
issue.project = plan.value.projectEntity.name;
issue.projectEntity = plan.value.projectEntity;
issue.title = plan.value.title;
diff --git a/frontend/src/components/Plan/components/SQLCheckSection/index.ts b/frontend/src/components/Plan/components/SQLCheckSection/index.ts
index 2028b2b13c..cbb34091bb 100644
--- a/frontend/src/components/Plan/components/SQLCheckSection/index.ts
+++ b/frontend/src/components/Plan/components/SQLCheckSection/index.ts
@@ -1,3 +1,6 @@
import SQLCheckSection from "./SQLCheckSection.vue";
+import { providePlanSQLCheckContext } from "./context";
export default SQLCheckSection;
+
+export { providePlanSQLCheckContext };
diff --git a/frontend/src/store/modules/v1/experimental-issue.ts b/frontend/src/store/modules/v1/experimental-issue.ts
index 0b44114b14..39ffed8dee 100644
--- a/frontend/src/store/modules/v1/experimental-issue.ts
+++ b/frontend/src/store/modules/v1/experimental-issue.ts
@@ -5,12 +5,11 @@ import {
planServiceClient,
rolloutServiceClient,
} from "@/grpcweb";
-import { useProjectV1Store, useUserStore } from "@/store";
+import { useProjectV1Store } from "@/store";
import type { ComposedIssue, ComposedProject, ComposedTaskRun } from "@/types";
import {
emptyIssue,
emptyRollout,
- unknownUser,
EMPTY_ID,
unknownIssue,
UNKNOWN_ID,
@@ -30,15 +29,9 @@ export const composeIssue = async (
rawIssue: Issue,
config: ComposeIssueConfig = { withPlan: true, withRollout: true }
): Promise<ComposedIssue> => {
- const userStore = useUserStore();
-
const project = `projects/${extractProjectResourceName(rawIssue.name)}`;
- const [projectEntity, creatorEntity, _] = await Promise.all([
+ const [projectEntity] = await Promise.all([
useProjectV1Store().getOrFetchProjectByName(project),
- userStore
- .getOrFetchUserByIdentifier(rawIssue.creator)
- .then((user) => user ?? unknownUser()),
- userStore.batchGetUsers(rawIssue.subscribers),
]);
const issue: ComposedIssue = {
@@ -49,7 +42,6 @@ export const composeIssue = async (
rolloutTaskRunList: [],
project,
projectEntity,
- creatorEntity,
};
if (config.withPlan && issue.plan) {
diff --git a/frontend/src/store/modules/v1/issue.ts b/frontend/src/store/modules/v1/issue.ts
index 9657d10877..08b412f46f 100644
--- a/frontend/src/store/modules/v1/issue.ts
+++ b/frontend/src/store/modules/v1/issue.ts
@@ -15,6 +15,7 @@ import {
ApprovalNode_Type,
} from "@/types/proto/v1/issue_service";
import { memberMapToRolesInProjectIAM } from "@/utils";
+import { useUserStore } from "../user";
import { userNamePrefix } from "./common";
import {
shallowComposeIssue,
@@ -96,6 +97,9 @@ export const useIssueV1Store = defineStore("issue_v1", () => {
const composedIssues = await Promise.all(
resp.issues.map((issue) => shallowComposeIssue(issue, composeIssueConfig))
);
+ // Preprare creator for the issues.
+ const users = uniq(composedIssues.map((issue) => issue.creator));
+ await useUserStore().batchGetUsers(users);
return {
nextPageToken: resp.nextPageToken,
issues: composedIssues,
diff --git a/frontend/src/types/v1/issue/issue.ts b/frontend/src/types/v1/issue/issue.ts
index a1d3ba382d..ff70b50a67 100644
--- a/frontend/src/types/v1/issue/issue.ts
+++ b/frontend/src/types/v1/issue/issue.ts
@@ -4,15 +4,12 @@ import {
UNKNOWN_PROJECT_NAME,
emptyProject,
unknownProject,
- emptyUser,
- unknownUser,
EMPTY_ROLLOUT_NAME,
UNKNOWN_ROLLOUT_NAME,
} from "@/types";
import type { Rollout } from "@/types//proto/v1/rollout_service";
import { Issue, IssueStatus, Issue_Type } from "@/types/proto/v1/issue_service";
import type { Plan, PlanCheckRun } from "@/types/proto/v1/plan_service";
-import { type User } from "@/types/proto/v1/user_service";
import { EMPTY_ID, UNKNOWN_ID } from "../../const";
// For grant request issue, it has no plan and rollout.
@@ -24,7 +21,6 @@ export interface ComposedIssue extends Issue {
rolloutTaskRunList: ComposedTaskRun[];
project: string;
projectEntity: ComposedProject;
- creatorEntity: User;
}
export const ESTABLISH_BASELINE_SQL =
@@ -47,7 +43,6 @@ export const emptyIssue = (): ComposedIssue => {
rolloutTaskRunList: [],
project: EMPTY_PROJECT_NAME,
projectEntity: emptyProject(),
- creatorEntity: emptyUser(),
};
};
@@ -65,7 +60,6 @@ export const unknownIssue = (): ComposedIssue => {
rolloutTaskRunList: [],
project: UNKNOWN_PROJECT_NAME,
projectEntity: unknownProject(),
- creatorEntity: unknownUser(),
};
};