Skip to content

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

refactor: remove `ComposedRollout` and `ComposedIssueComment` types (#17232)

boojack2970ca57f470
diff --git a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentList.vue b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentList.vue
index 8ca8569d38..36d22a3d88 100644
--- a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentList.vue
+++ b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentList.vue
@@ -124,11 +124,11 @@ import {
useIssueCommentStore,
useIssueV1Store,
useCurrentProjectV1,
- type ComposedIssueComment,
extractUserId,
} from "@/store";
import { isValidProjectName } from "@/types";
import type { ComposedIssue } from "@/types";
+import type { IssueComment } from "@/types/proto-es/v1/issue_service_pb";
import { ListIssueCommentsRequestSchema } from "@/types/proto-es/v1/issue_service_pb";
import { hasProjectPermissionV2 } from "@/utils";
import { useIssueContext } from "../../logic";
@@ -142,7 +142,7 @@ import IssueCreatedComment from "./IssueCommentView/IssueCreatedComment.vue";
interface LocalState {
editCommentMode: boolean;
- activeComment?: ComposedIssueComment;
+ activeComment?: IssueComment;
editComment: string;
newComment: string;
}
@@ -228,7 +228,7 @@ const doCreateComment = async (comment: string) => {
await prepareIssueComments();
};
-const allowEditIssueComment = (comment: ComposedIssueComment) => {
+const allowEditIssueComment = (comment: IssueComment) => {
if (!isUserEditableComment(comment)) {
return false;
}
@@ -238,7 +238,7 @@ const allowEditIssueComment = (comment: ComposedIssueComment) => {
return hasProjectPermissionV2(project.value, "bb.issueComments.update");
};
-const onUpdateComment = (issueComment: ComposedIssueComment) => {
+const onUpdateComment = (issueComment: IssueComment) => {
state.activeComment = issueComment;
state.editCommentMode = true;
state.editComment = issueComment.comment;
diff --git a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/ActionIcon.vue b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/ActionIcon.vue
index bebe0dced6..f60461f9d7 100644
--- a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/ActionIcon.vue
+++ b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/ActionIcon.vue
@@ -117,12 +117,9 @@ import {
import { computed } from "vue";
import { SkipIcon } from "@/components/Icon";
import PrincipalAvatar from "@/components/PrincipalAvatar.vue";
-import {
- IssueCommentType,
- useUserStore,
- type ComposedIssueComment,
-} from "@/store";
+import { IssueCommentType, useUserStore, getIssueCommentType } from "@/store";
import { extractUserId } from "@/store";
+import type { IssueComment } from "@/types/proto-es/v1/issue_service_pb";
import {
IssueComment_Approval_Status,
IssueComment_TaskUpdate_Status,
@@ -145,7 +142,7 @@ type ActionIconType =
| "commit";
const props = defineProps<{
- issueComment: ComposedIssueComment;
+ issueComment: IssueComment;
}>();
const userStore = useUserStore();
@@ -156,8 +153,9 @@ const user = computedAsync(() => {
const icon = computed((): ActionIconType => {
const { issueComment } = props;
+ const commentType = getIssueCommentType(issueComment);
if (
- issueComment.type === IssueCommentType.APPROVAL &&
+ commentType === IssueCommentType.APPROVAL &&
issueComment.event?.case === "approval"
) {
const { status } = issueComment.event.value;
@@ -169,10 +167,10 @@ const icon = computed((): ActionIconType => {
case IssueComment_Approval_Status.PENDING:
return "re-request-review";
}
- } else if (issueComment.type === IssueCommentType.STAGE_END) {
+ } else if (commentType === IssueCommentType.STAGE_END) {
return "complete";
} else if (
- issueComment.type === IssueCommentType.TASK_UPDATE &&
+ commentType === IssueCommentType.TASK_UPDATE &&
issueComment.event?.case === "taskUpdate"
) {
const { toStatus } = issueComment.event.value;
@@ -207,7 +205,7 @@ const icon = computed((): ActionIconType => {
}
return action;
} else if (
- issueComment.type === IssueCommentType.ISSUE_UPDATE &&
+ commentType === IssueCommentType.ISSUE_UPDATE &&
issueComment.event?.case === "issueUpdate"
) {
const { toTitle, toDescription, toLabels, fromLabels } =
@@ -222,7 +220,7 @@ const icon = computed((): ActionIconType => {
}
// Otherwise, show avatar icon based on the creator.
} else if (
- issueComment.type === IssueCommentType.TASK_PRIOR_BACKUP &&
+ commentType === IssueCommentType.TASK_PRIOR_BACKUP &&
issueComment.event?.case === "taskPriorBackup"
) {
const taskPriorBackup = issueComment.event.value;
diff --git a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/ActionSentence.vue b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/ActionSentence.vue
index 0be2827ade..b660cad6db 100644
--- a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/ActionSentence.vue
+++ b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/ActionSentence.vue
@@ -6,13 +6,10 @@
import type { h } from "vue";
import { defineComponent } from "vue";
import { Translation, useI18n } from "vue-i18n";
-import {
- useUserStore,
- IssueCommentType,
- type ComposedIssueComment,
-} from "@/store";
+import { useUserStore, IssueCommentType, getIssueCommentType } from "@/store";
import { extractUserId } from "@/store";
import { type ComposedIssue } from "@/types";
+import type { IssueComment } from "@/types/proto-es/v1/issue_service_pb";
import {
IssueComment_Approval_Status,
IssueComment_TaskUpdate_Status,
@@ -27,7 +24,7 @@ type RenderedContent = string | ReturnType<typeof h>;
const props = defineProps<{
issue: ComposedIssue;
- issueComment: ComposedIssueComment;
+ issueComment: IssueComment;
}>();
const { t } = useI18n();
@@ -35,8 +32,9 @@ const userStore = useUserStore();
const renderActionSentence = () => {
const { issueComment, issue } = props;
+ const commentType = getIssueCommentType(issueComment);
if (
- issueComment.type === IssueCommentType.APPROVAL &&
+ commentType === IssueCommentType.APPROVAL &&
issueComment.event?.case === "approval"
) {
const { status } = issueComment.event.value;
@@ -52,7 +50,7 @@ const renderActionSentence = () => {
return maybeAutomaticallyVerb(issueComment, verb);
}
} else if (
- issueComment.type === IssueCommentType.ISSUE_UPDATE &&
+ commentType === IssueCommentType.ISSUE_UPDATE &&
issueComment.event?.case === "issueUpdate"
) {
const {
@@ -86,7 +84,7 @@ const renderActionSentence = () => {
return t("activity.sentence.changed-labels");
}
} else if (
- issueComment.type === IssueCommentType.STAGE_END &&
+ commentType === IssueCommentType.STAGE_END &&
issueComment.event?.case === "stageEnd"
) {
const { stage } = issueComment.event.value;
@@ -99,7 +97,7 @@ const renderActionSentence = () => {
};
return renderVerbTypeTarget(params);
} else if (
- issueComment.type === IssueCommentType.TASK_UPDATE &&
+ commentType === IssueCommentType.TASK_UPDATE &&
issueComment.event?.case === "taskUpdate"
) {
const { tasks, fromSheet, toSheet, toStatus } = issueComment.event.value;
@@ -162,7 +160,7 @@ const renderActionSentence = () => {
);
}
} else if (
- issueComment.type === IssueCommentType.TASK_PRIOR_BACKUP &&
+ commentType === IssueCommentType.TASK_PRIOR_BACKUP &&
issueComment.event?.case === "taskPriorBackup"
) {
const { task, tables, originalLine, database, error } =
@@ -206,7 +204,7 @@ const renderActionSentence = () => {
};
const maybeAutomaticallyVerb = (
- issueComment: ComposedIssueComment,
+ issueComment: IssueComment,
verb: string
): string => {
if (extractUserId(issueComment.creator) !== userStore.systemBotUser?.email) {
@@ -218,7 +216,7 @@ const maybeAutomaticallyVerb = (
};
type VerbTypeTarget = {
- issueComment: ComposedIssueComment;
+ issueComment: IssueComment;
verb: RenderedContent;
type: RenderedContent;
target?: RenderedContent;
diff --git a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCommentAction.vue b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCommentAction.vue
index 265336604b..15c8986492 100644
--- a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCommentAction.vue
+++ b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCommentAction.vue
@@ -10,7 +10,7 @@
v-if="
extractUserId(issueComment.creator) !==
userStore.systemBotUser?.email ||
- issueComment.type === IssueCommentType.USER_COMMENT
+ getIssueCommentType(issueComment) === IssueCommentType.USER_COMMENT
"
:creator="issueComment.creator"
/>
@@ -26,7 +26,7 @@
v-if="
getTimeForPbTimestampProtoEs(issueComment.createTime) !==
getTimeForPbTimestampProtoEs(issueComment.updateTime) &&
- issueComment.type === IssueCommentType.USER_COMMENT
+ getIssueCommentType(issueComment) === IssueCommentType.USER_COMMENT
"
>
<span class="opacity-80">({{ $t("common.edited") }}</span>
@@ -64,10 +64,11 @@ import {
getProjectIdIssueIdIssueCommentId,
issueCommentNamePrefix,
IssueCommentType,
- type ComposedIssueComment,
+ getIssueCommentType,
} from "@/store";
import { useUserStore, extractUserId } from "@/store";
import { getTimeForPbTimestampProtoEs, type ComposedIssue } from "@/types";
+import type { IssueComment } from "@/types/proto-es/v1/issue_service_pb";
import type { Rollout } from "@/types/proto-es/v1/rollout_service_pb";
import ActionCreator from "./ActionCreator.vue";
import ActionSentence from "./ActionSentence.vue";
@@ -75,8 +76,8 @@ import ActionSentence from "./ActionSentence.vue";
defineProps<{
issue: ComposedIssue;
index: number;
- issueComment: ComposedIssueComment;
- similar: ComposedIssueComment[];
+ issueComment: IssueComment;
+ similar: IssueComment[];
rollout?: Rollout;
}>();
diff --git a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCommentView.vue b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCommentView.vue
index 534a4d0476..a24ff7ed93 100644
--- a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCommentView.vue
+++ b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCommentView.vue
@@ -29,8 +29,8 @@
</template>
<script lang="ts" setup>
-import type { ComposedIssueComment } from "@/store";
import type { ComposedIssue } from "@/types";
+import type { IssueComment } from "@/types/proto-es/v1/issue_service_pb";
import type { Rollout } from "@/types/proto-es/v1/rollout_service_pb";
import ActionIcon from "./ActionIcon.vue";
import IssueCommentAction from "./IssueCommentAction.vue";
@@ -39,8 +39,8 @@ defineProps<{
issue: ComposedIssue;
isLast: boolean;
index: number;
- issueComment: ComposedIssueComment;
- similar: ComposedIssueComment[];
+ issueComment: IssueComment;
+ similar: IssueComment[];
rollout?: Rollout;
}>();
</script>
diff --git a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/common.ts b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/common.ts
index 6deebea115..379b4ed93b 100644
--- a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/common.ts
+++ b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/common.ts
@@ -1,21 +1,24 @@
import { isEqual } from "lodash-es";
-import { IssueCommentType, type ComposedIssueComment } from "@/store";
+import { IssueCommentType, getIssueCommentType } from "@/store";
+import type { IssueComment } from "@/types/proto-es/v1/issue_service_pb";
import { isNullOrUndefined } from "@/utils";
export type DistinctIssueComment = {
- comment: ComposedIssueComment;
- similar: ComposedIssueComment[];
+ comment: IssueComment;
+ similar: IssueComment[];
};
export const isSimilarIssueComment = (
- a: ComposedIssueComment,
- b: ComposedIssueComment
+ a: IssueComment,
+ b: IssueComment
): boolean => {
- if (a.type !== b.type || a.creator !== b.creator) {
+ const aType = getIssueCommentType(a);
+ const bType = getIssueCommentType(b);
+ if (aType !== bType || a.creator !== b.creator) {
return false;
}
- if (a.type === IssueCommentType.TASK_UPDATE) {
+ if (aType === IssueCommentType.TASK_UPDATE) {
const fromTaskUpdate =
a.event?.case === "taskUpdate" ? a.event.value : null;
const toTaskUpdate = b.event?.case === "taskUpdate" ? b.event.value : null;
@@ -38,7 +41,7 @@ export const isSimilarIssueComment = (
return true;
}
}
- if (a.type === IssueCommentType.ISSUE_UPDATE) {
+ if (aType === IssueCommentType.ISSUE_UPDATE) {
const aIssueUpdate = a.event?.case === "issueUpdate" ? a.event.value : null;
const bIssueUpdate = b.event?.case === "issueUpdate" ? b.event.value : null;
if (
@@ -64,13 +67,14 @@ export const isSimilarIssueComment = (
return false;
};
-export const isUserEditableComment = (comment: ComposedIssueComment) => {
+export const isUserEditableComment = (comment: IssueComment) => {
+ const commentType = getIssueCommentType(comment);
// Always allow editing user comments.
- if (comment.type === IssueCommentType.USER_COMMENT) {
+ if (commentType === IssueCommentType.USER_COMMENT) {
return true;
}
// For approval comments, we allow editing if the comment is not empty.
- if (comment.type === IssueCommentType.APPROVAL && comment.comment !== "") {
+ if (commentType === IssueCommentType.APPROVAL && comment.comment !== "") {
return true;
}
return false;
diff --git a/frontend/src/components/Rollout/RolloutDataTable.vue b/frontend/src/components/Rollout/RolloutDataTable.vue
index e6339a3a21..ce3c1cdef4 100644
--- a/frontend/src/components/Rollout/RolloutDataTable.vue
+++ b/frontend/src/components/Rollout/RolloutDataTable.vue
@@ -6,7 +6,7 @@
:striped="true"
:bordered="bordered"
:loading="loading"
- :row-key="(rollout: ComposedRollout) => rollout.name"
+ :row-key="(rollout) => rollout.name"
:row-props="rowProps"
/>
</template>
@@ -22,7 +22,7 @@ import TaskStatus from "@/components/Rollout/kits/TaskStatus.vue";
import Timestamp from "@/components/misc/Timestamp.vue";
import { EnvironmentV1Name } from "@/components/v2";
import { useEnvironmentV1Store } from "@/store";
-import { type ComposedRollout } from "@/types";
+import type { Rollout } from "@/types/proto-es/v1/rollout_service_pb";
import type { Task_Status } from "@/types/proto-es/v1/rollout_service_pb";
import {
stringifyTaskStatus,
@@ -32,7 +32,7 @@ import {
withDefaults(
defineProps<{
- rolloutList: ComposedRollout[];
+ rolloutList: Rollout[];
bordered?: boolean;
loading?: boolean;
showSelection?: boolean;
@@ -53,8 +53,8 @@ const getStageTaskCount = (stage: any, status: Task_Status) => {
};
const columnList = computed(
- (): (DataTableColumn<ComposedRollout> & { hide?: boolean })[] => {
- const columns: (DataTableColumn<ComposedRollout> & { hide?: boolean })[] = [
+ (): (DataTableColumn<Rollout> & { hide?: boolean })[] => {
+ const columns: (DataTableColumn<Rollout> & { hide?: boolean })[] = [
{
key: "title",
title: t("issue.table.name"),
@@ -179,7 +179,7 @@ const columnList = computed(
}
);
-const rowProps = (rollout: ComposedRollout) => {
+const rowProps = (rollout: Rollout) => {
return {
style: "cursor: pointer;",
onClick: (e: MouseEvent) => {
diff --git a/frontend/src/store/modules/rollout.ts b/frontend/src/store/modules/rollout.ts
index a111519648..88429e689e 100644
--- a/frontend/src/store/modules/rollout.ts
+++ b/frontend/src/store/modules/rollout.ts
@@ -1,13 +1,12 @@
import { create } from "@bufbuild/protobuf";
import { createContextValues } from "@connectrpc/connect";
import dayjs from "dayjs";
-import { head } from "lodash-es";
import { defineStore } from "pinia";
import { computed, reactive, ref, unref, watch } from "vue";
import { rolloutServiceClientConnect } from "@/grpcweb";
import { silentContextKey } from "@/grpcweb/context-key";
-import type { MaybeRef, ComposedRollout } from "@/types";
-import { isValidRolloutName, unknownRollout, unknownUser } from "@/types";
+import type { MaybeRef } from "@/types";
+import { isValidRolloutName, unknownRollout } from "@/types";
import {
Task_Type,
type Rollout,
@@ -22,9 +21,6 @@ import {
type SearchParams,
} from "@/utils";
import { DEFAULT_PAGE_SIZE } from "./common";
-import { useUserStore } from "./user";
-import { useProjectV1Store, batchGetOrFetchProjects } from "./v1";
-import { getProjectNameRolloutId, projectNamePrefix } from "./v1/common";
export interface RolloutFind {
project: string;
@@ -88,7 +84,7 @@ export type ListRolloutParams = {
};
export const useRolloutStore = defineStore("rollout", () => {
- const rolloutMapByName = reactive(new Map<string, ComposedRollout>());
+ const rolloutMapByName = reactive(new Map<string, Rollout>());
const rolloutList = computed(() => {
return Array.from(rolloutMapByName.values());
@@ -106,12 +102,12 @@ export const useRolloutStore = defineStore("rollout", () => {
filter: buildRolloutFilter(find),
});
const resp = await rolloutServiceClientConnect.listRollouts(request);
- const composedRolloutList = await batchComposeRollout(resp.rollouts);
- composedRolloutList.forEach((rollout) => {
+ const rollouts = resp.rollouts;
+ rollouts.forEach((rollout) => {
rolloutMapByName.set(rollout.name, rollout);
});
return {
- rollouts: composedRolloutList,
+ rollouts: rollouts,
nextPageToken: resp.nextPageToken,
};
};
@@ -123,13 +119,8 @@ export const useRolloutStore = defineStore("rollout", () => {
const rollout = await rolloutServiceClientConnect.getRollout(request, {
contextValues: createContextValues().set(silentContextKey, silent),
});
- const [composedRollout] = await batchComposeRollout([rollout]);
- rolloutMapByName.set(composedRollout.name, composedRollout);
- return composedRollout;
- };
-
- const getRolloutsByProject = (project: string) => {
- return rolloutList.value.filter((rollout) => rollout.project === project);
+ rolloutMapByName.set(rollout.name, rollout);
+ return rollout;
};
const getRolloutByName = (name: string) => {
@@ -140,7 +131,6 @@ export const useRolloutStore = defineStore("rollout", () => {
rolloutList,
listRollouts,
fetchRolloutByName,
- getRolloutsByProject,
getRolloutByName,
};
});
@@ -171,25 +161,3 @@ export const useRolloutByName = (name: MaybeRef<string>) => {
ready,
};
};
-
-export const batchComposeRollout = async (rolloutList: Rollout[]) => {
- const userStore = useUserStore();
- await userStore.batchGetUsers(rolloutList.map((rollout) => rollout.creator));
-
- const composedRolloutList = rolloutList.map((rollout) => {
- const composed = rollout as ComposedRollout;
- composed.project = `${projectNamePrefix}${head(getProjectNameRolloutId(rollout.name))}`;
- composed.creatorEntity =
- userStore.getUserByIdentifier(composed.creator) ?? unknownUser();
- return composed;
- });
- await batchGetOrFetchProjects(
- composedRolloutList.map((rollout) => rollout.project)
- );
-
- const projectV1Store = useProjectV1Store();
- return composedRolloutList.map((rollout) => {
- rollout.projectEntity = projectV1Store.getProjectByName(rollout.project);
- return rollout;
- });
-};
diff --git a/frontend/src/store/modules/v1/issueComment.ts b/frontend/src/store/modules/v1/issueComment.ts
index c34bda2b50..05a8f88234 100644
--- a/frontend/src/store/modules/v1/issueComment.ts
+++ b/frontend/src/store/modules/v1/issueComment.ts
@@ -27,34 +27,26 @@ export enum IssueCommentType {
TASK_PRIOR_BACKUP = "TASK_PRIOR_BACKUP",
}
-export interface ComposedIssueComment extends IssueComment {
- type: IssueCommentType;
-}
-
-const composeIssueComment = (
+export const getIssueCommentType = (
issueComment: IssueComment
-): ComposedIssueComment => {
- let type = IssueCommentType.USER_COMMENT;
+): IssueCommentType => {
if (issueComment.event?.case === "approval") {
- type = IssueCommentType.APPROVAL;
+ return IssueCommentType.APPROVAL;
} else if (issueComment.event?.case === "issueUpdate") {
- type = IssueCommentType.ISSUE_UPDATE;
+ return IssueCommentType.ISSUE_UPDATE;
} else if (issueComment.event?.case === "stageEnd") {
- type = IssueCommentType.STAGE_END;
+ return IssueCommentType.STAGE_END;
} else if (issueComment.event?.case === "taskUpdate") {
- type = IssueCommentType.TASK_UPDATE;
+ return IssueCommentType.TASK_UPDATE;
} else if (issueComment.event?.case === "taskPriorBackup") {
- type = IssueCommentType.TASK_PRIOR_BACKUP;
+ return IssueCommentType.TASK_PRIOR_BACKUP;
}
- return {
- ...issueComment,
- type,
- };
+ return IssueCommentType.USER_COMMENT;
};
export const useIssueCommentStore = defineStore("issue_comment", () => {
- // issueCommentMap is a map of issueName to ComposedIssueComment[].
- const issueCommentMap = reactive(new Map<string, ComposedIssueComment[]>());
+ // issueCommentMap is a map of issueName to IssueComment[].
+ const issueCommentMap = reactive(new Map<string, IssueComment[]>());
const listIssueComments = async (request: ListIssueCommentsRequest) => {
const connectRequest = create(ListIssueCommentsRequestSchema, {
@@ -65,7 +57,7 @@ export const useIssueCommentStore = defineStore("issue_comment", () => {
const resp =
await issueServiceClientConnect.listIssueComments(connectRequest);
const issueComments = resp.issueComments;
- issueCommentMap.set(request.parent, issueComments.map(composeIssueComment));
+ issueCommentMap.set(request.parent, issueComments);
return {
nextPageToken: resp.nextPageToken,
@@ -91,7 +83,7 @@ export const useIssueCommentStore = defineStore("issue_comment", () => {
const issueComment = newIssueComment;
issueCommentMap.set(issueName, [
...(issueCommentMap.get(issueName) ?? []),
- composeIssueComment(issueComment),
+ issueComment,
]);
};
@@ -128,7 +120,7 @@ export const useIssueCommentStore = defineStore("issue_comment", () => {
);
};
- const getIssueComments = (issueName: string): ComposedIssueComment[] => {
+ const getIssueComments = (issueName: string): IssueComment[] => {
return issueCommentMap.get(issueName) ?? [];
};
diff --git a/frontend/src/types/rollout.ts b/frontend/src/types/rollout.ts
index 95f4ea6a5d..ec56737391 100644
--- a/frontend/src/types/rollout.ts
+++ b/frontend/src/types/rollout.ts
@@ -3,50 +3,21 @@ import { getProjectNameRolloutId } from "@/store/modules/v1/common";
import { EMPTY_ID, UNKNOWN_ID } from "./const";
import type { Rollout } from "./proto-es/v1/rollout_service_pb";
import { RolloutSchema } from "./proto-es/v1/rollout_service_pb";
-import type { User } from "./proto-es/v1/user_service_pb";
-import { emptyUser, unknownUser } from "./v1";
-import {
- EMPTY_PROJECT_NAME,
- emptyProject,
- UNKNOWN_PROJECT_NAME,
- unknownProject,
- type ComposedProject,
-} from "./v1/project";
-
-export interface ComposedRollout extends Rollout {
- // Format: projects/{project}
- project: string;
- projectEntity: ComposedProject;
- creatorEntity: User;
-}
+import { EMPTY_PROJECT_NAME, UNKNOWN_PROJECT_NAME } from "./v1/project";
export const EMPTY_ROLLOUT_NAME = `${EMPTY_PROJECT_NAME}/rollouts/${EMPTY_ID}`;
export const UNKNOWN_ROLLOUT_NAME = `${UNKNOWN_PROJECT_NAME}/rollouts/${UNKNOWN_ID}`;
-export const emptyRollout = (): ComposedRollout => {
- const projectEntity = emptyProject();
- const rollout = createProto(RolloutSchema, {
- name: `${projectEntity.name}/rollouts/${EMPTY_ID}`,
+export const emptyRollout = (): Rollout => {
+ return createProto(RolloutSchema, {
+ name: EMPTY_ROLLOUT_NAME,
});
- return {
- ...rollout,
- project: projectEntity.name,
- projectEntity,
- creatorEntity: emptyUser(),
- };
};
-export const unknownRollout = (): ComposedRollout => {
- const projectEntity = unknownProject();
- const rollout = createProto(RolloutSchema, {
- name: `${projectEntity.name}/rollouts/${UNKNOWN_ID}`,
+export const unknownRollout = (): Rollout => {
+ return createProto(RolloutSchema, {
+ name: UNKNOWN_ROLLOUT_NAME,
});
- return {
- ...rollout,
- project: projectEntity.name,
- projectEntity,
- creatorEntity: unknownUser(),
- };
};
export const isValidRolloutName = (name: any): name is string => {