Skip to content

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

chore: advanced search for rollouts (#16922)

boojack6c5dc856840d
diff --git a/backend/api/v1/rollout_service.go b/backend/api/v1/rollout_service.go
index 0e2bf9b247..58f159858a 100644
--- a/backend/api/v1/rollout_service.go
+++ b/backend/api/v1/rollout_service.go
@@ -201,7 +201,7 @@ func (s *RolloutService) ListRollouts(ctx context.Context, req *connect.Request[
}
// buildRolloutFindWithFilter builds the filter for rollout find.
-func (*RolloutService) buildRolloutFindWithFilter(_ context.Context, pipelineFind *store.PipelineFind, filter string) error {
+func (s *RolloutService) buildRolloutFindWithFilter(ctx context.Context, pipelineFind *store.PipelineFind, filter string) error {
if filter == "" {
return nil
}
@@ -228,6 +228,13 @@ func (*RolloutService) buildRolloutFindWithFilter(_ context.Context, pipelineFin
case celoperators.Equals:
variable, value := getVariableAndValueFromExpr(expr)
switch variable {
+ case "creator":
+ user, err := s.getUserByIdentifier(ctx, value.(string))
+ if err != nil {
+ return "", connect.NewError(connect.CodeInternal, errors.Errorf("failed to get user %v with error %v", value, err.Error()))
+ }
+ positionalArgs = append(positionalArgs, user.ID)
+ return fmt.Sprintf("pipeline.creator_id = $%d", len(positionalArgs)), nil
case "task_type":
taskType, ok := value.(string)
if !ok {
@@ -278,6 +285,24 @@ func (*RolloutService) buildRolloutFindWithFilter(_ context.Context, pipelineFin
default:
return "", connect.NewError(connect.CodeInvalidArgument, errors.Errorf("unsupported variable %q", variable))
}
+ case celoperators.GreaterEquals, celoperators.LessEquals:
+ variable, rawValue := getVariableAndValueFromExpr(expr)
+ value, ok := rawValue.(string)
+ if !ok {
+ return "", errors.Errorf("expect string, got %T, hint: filter literals should be string", rawValue)
+ }
+ if variable != "update_time" {
+ return "", errors.Errorf(`">=" and "<=" are only supported for "update_time"`)
+ }
+ t, err := time.Parse(time.RFC3339, value)
+ if err != nil {
+ return "", errors.Errorf("failed to parse time %v, error: %v", value, err)
+ }
+ positionalArgs = append(positionalArgs, t)
+ if functionName == celoperators.GreaterEquals {
+ return fmt.Sprintf("updated_at >= $%d", len(positionalArgs)), nil
+ }
+ return fmt.Sprintf("updated_at <= $%d", len(positionalArgs)), nil
default:
return "", connect.NewError(connect.CodeInvalidArgument, errors.Errorf("unsupported function %v", functionName))
}
@@ -1223,3 +1248,18 @@ func getLastApproverUID(approval *storepb.IssuePayloadApproval) *int {
}
return nil
}
+
+func (s *RolloutService) getUserByIdentifier(ctx context.Context, identifier string) (*store.UserMessage, error) {
+ email := strings.TrimPrefix(identifier, "users/")
+ if email == "" {
+ return nil, connect.NewError(connect.CodeInvalidArgument, errors.New("invalid empty creator identifier"))
+ }
+ user, err := s.store.GetUserByEmail(ctx, email)
+ if err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Errorf(`failed to find user "%s" with error: %v`, email, err))
+ }
+ if user == nil {
+ return nil, errors.Errorf("cannot found user %s", email)
+ }
+ return user, nil
+}
diff --git a/backend/generated-go/v1/plan_service.pb.go b/backend/generated-go/v1/plan_service.pb.go
index f573755fd6..42dd97d277 100644
--- a/backend/generated-go/v1/plan_service.pb.go
+++ b/backend/generated-go/v1/plan_service.pb.go
@@ -444,7 +444,7 @@ type SearchPlansRequest struct {
//
// Supported filters:
// - creator: the plan creator full name in "users/{email or id}" format, support "==" operator.
- // - create_time: issue create time in "2006-01-02T15:04:05Z07:00" format, support ">=" or "<=" operator.
+ // - create_time: the plan create time in "2006-01-02T15:04:05Z07:00" format, support ">=" or "<=" operator.
// - has_pipeline: the plan has pipeline or not, support "==" operator, the value should be "true" or "false".
// - has_issue: the plan has issue or not, support "==" operator, the value should be "true" or "false".
// - title: the plan title, support "==" operator for exact match and ".matches()" operator for case-insensitive substring match.
diff --git a/backend/generated-go/v1/rollout_service.pb.go b/backend/generated-go/v1/rollout_service.pb.go
index 1ca6de18eb..772ec6d735 100644
--- a/backend/generated-go/v1/rollout_service.pb.go
+++ b/backend/generated-go/v1/rollout_service.pb.go
@@ -808,9 +808,12 @@ type ListRolloutsRequest struct {
// The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
//
// Supported filters:
+ // - creator: the rollout creator full name in "users/{email or id}" format, support "==" operator.
+ // - update_time: rollout update time in "2006-01-02T15:04:05Z07:00" format, support ">=" or "<=" operator.
// - task_type: the task type, support "==" and "in" operators, check the Task.Type enum for the values.
//
// For example:
+ // creator == "users/[email protected]" && update_time >= "2025-01-02T15:04:05Z07:00"
// task_type == "DATABASE_SCHEMA_UPDATE"
// task_type in ["DATABASE_SCHEMA_UPDATE", "DATABASE_DATA_UPDATE"]
Filter string `protobuf:"bytes,4,opt,name=filter,proto3" json:"filter,omitempty"`
diff --git a/frontend/src/components/AdvancedSearch/ScopeTags.vue b/frontend/src/components/AdvancedSearch/ScopeTags.vue
index a340149dec..a0a7a8d81a 100644
--- a/frontend/src/components/AdvancedSearch/ScopeTags.vue
+++ b/frontend/src/components/AdvancedSearch/ScopeTags.vue
@@ -52,7 +52,7 @@ const tagProps = (scope: SearchScope): TagProps => {
};
const renderValue = (scope: SearchScope, _index: number) => {
- if (scope.id === "created") {
+ if (scope.id === "created" || scope.id === "updated") {
const [begin, end] = scope.value.split(",").map((ts) => parseInt(ts, 10));
return [dayjs(begin).format("L"), dayjs(end).format("L")].join("-");
} else if (scope.id === "database") {
diff --git a/frontend/src/components/AdvancedSearch/UpdatedTimeRange.vue b/frontend/src/components/AdvancedSearch/UpdatedTimeRange.vue
new file mode 100644
index 0000000000..f78a6eeca2
--- /dev/null
+++ b/frontend/src/components/AdvancedSearch/UpdatedTimeRange.vue
@@ -0,0 +1,60 @@
+<template>
+ <NDatePicker
+ :key="timeRange ? 'filled' : 'empty'"
+ :value="timeRange"
+ :is-date-disabled="isDateDisabled"
+ type="datetimerange"
+ clearable
+ class="time-range-picker"
+ @update:value="handleUpdate"
+ >
+ </NDatePicker>
+</template>
+
+<script setup lang="ts">
+import dayjs from "dayjs";
+import { NDatePicker } from "naive-ui";
+import { computed } from "vue";
+import type { SearchParams } from "@/utils";
+import { getTsRangeFromSearchParams, upsertScope } from "@/utils";
+
+const props = defineProps<{
+ params: SearchParams;
+}>();
+
+const emit = defineEmits<{
+ (event: "update:params", params: SearchParams): void;
+}>();
+
+const timeRange = computed(() => {
+ return getTsRangeFromSearchParams(props.params, "updated");
+});
+
+const isDateDisabled = (ts: number) => {
+ const today = dayjs().add(1, "day").endOf("day").valueOf();
+ if (ts > today) {
+ return true;
+ }
+ return false;
+};
+
+const handleUpdate = (values: [number, number] | null) => {
+ const from = values ? dayjs(values[0]).startOf("day") : null;
+ const to = values ? dayjs(values[1]).endOf("day") : null;
+ const updated = upsertScope({
+ params: props.params,
+ scopes: {
+ id: "updated",
+ value: from && to ? `${from.valueOf()},${to.valueOf()}` : "",
+ },
+ });
+ emit("update:params", updated);
+};
+</script>
+
+<style lang="postcss" scoped>
+.time-range-picker :deep(.n-input) {
+ --n-padding-left: 6px !important;
+ --n-padding-right: 6px !important;
+}
+</style>
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue
index 6409a5cf3d..77ce38a668 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue
@@ -86,6 +86,7 @@ const availableActions = computed(() => {
if (isCreating.value) return actions;
+ const currentUserEmail = currentUser.value.email;
// If no issue exists, show create issue action or close plan action.
if (!issue?.value) {
// If rollout exists, no actions are available.
@@ -98,7 +99,7 @@ const availableActions = computed(() => {
plan.value.state === State.ACTIVE &&
plan.value.issue === "" &&
plan.value.rollout === "" &&
- (currentUser.value.email === extractUserId(plan.value.creator || "") ||
+ (currentUserEmail === extractUserId(plan.value.creator || "") ||
hasProjectPermissionV2(project.value, "bb.plans.update"));
if (canClosePlan) {
@@ -110,19 +111,19 @@ const availableActions = computed(() => {
plan.value.state === State.DELETED &&
plan.value.issue === "" &&
plan.value.rollout === "" &&
- (currentUser.value.email === extractUserId(plan.value.creator || "") ||
- hasProjectPermissionV2(project.value, "bb.plans.update"));
+ currentUserEmail === extractUserId(plan.value.creator || "") &&
+ hasProjectPermissionV2(project.value, "bb.plans.update");
if (canReopenPlan) {
actions.push("PLAN_REOPEN");
return actions; // For deleted plans, only show reopen action
}
- const canCreateIssue = hasProjectPermissionV2(
- project.value,
- "bb.plans.create"
- );
- if (canCreateIssue && plan.value.state === State.ACTIVE) {
+ const canCreateIssue =
+ plan.value.state === State.ACTIVE &&
+ currentUserEmail === extractUserId(plan.value.creator || "") &&
+ hasProjectPermissionV2(project.value, "bb.issues.create");
+ if (canCreateIssue) {
actions.push("ISSUE_CREATE");
}
return actions;
@@ -134,10 +135,9 @@ const availableActions = computed(() => {
// If issue is canceled, check for re-open action
if (isCanceled) {
- const currentUserEmail = currentUser.value.email;
const issueCreator = extractUserId(issueValue.creator);
const canReopen =
- currentUserEmail === issueCreator ||
+ currentUserEmail === issueCreator &&
hasProjectPermissionV2(project.value, "bb.issues.update");
if (canReopen) {
@@ -151,7 +151,6 @@ const availableActions = computed(() => {
// Check for review actions
if (issueValue.approvalFindingDone && !reviewContext.done.value) {
- const currentUserEmail = currentUser.value.email;
const issueCreator = extractUserId(issueValue.creator);
const { approvers, approvalTemplates } = issueValue;
@@ -192,10 +191,9 @@ const availableActions = computed(() => {
}
// Check for close action
- const currentUserEmail = currentUser.value.email;
const issueCreator = extractUserId(issueValue.creator);
const canClose =
- currentUserEmail === issueCreator ||
+ currentUserEmail === issueCreator &&
hasProjectPermissionV2(project.value, "bb.issues.update");
if (canClose) {
diff --git a/frontend/src/components/Plan/components/PlanDataTable/PlanDataTable.vue b/frontend/src/components/Plan/components/PlanDataTable/PlanDataTable.vue
index 2cb9801382..c298def91b 100644
--- a/frontend/src/components/Plan/components/PlanDataTable/PlanDataTable.vue
+++ b/frontend/src/components/Plan/components/PlanDataTable/PlanDataTable.vue
@@ -56,7 +56,6 @@ const columnList = computed((): DataTableColumn<Plan>[] => {
{
key: "title",
title: t("issue.table.name"),
- resizable: true,
render: (plan) => {
const showDraftTag =
enabledNewLayout.value && plan.issue === "" && plan.rollout === "";
diff --git a/frontend/src/components/Project/ProjectRolloutsPanel.vue b/frontend/src/components/Project/ProjectRolloutsPanel.vue
deleted file mode 100644
index ec1cf50074..0000000000
--- a/frontend/src/components/Project/ProjectRolloutsPanel.vue
+++ /dev/null
@@ -1,57 +0,0 @@
-<template>
- <div class="w-full flex flex-col gap-y-2">
- <PagedTable
- :key="project.name"
- :session-key="`project-${project.name}-releases`"
- :fetch-list="fetchRolloutList"
- >
- <template #table="{ list, loading }">
- <RolloutDataTable
- :bordered="true"
- :loading="loading"
- :rollout-list="list"
- />
- </template>
- </PagedTable>
- </div>
-</template>
-
-<script lang="ts" setup>
-import PagedTable from "@/components/v2/Model/PagedTable.vue";
-import { useRolloutStore } from "@/store";
-import type { ComposedProject } from "@/types";
-import { Task_Type } from "@/types/proto-es/v1/rollout_service_pb";
-import RolloutDataTable from "../Rollout/RolloutDataTable.vue";
-
-const props = defineProps<{
- project: ComposedProject;
-}>();
-
-const rolloutStore = useRolloutStore();
-
-const fetchRolloutList = async ({
- pageToken,
- pageSize,
-}: {
- pageToken: string;
- pageSize: number;
-}) => {
- const { nextPageToken, rollouts } = await rolloutStore.listRollouts({
- find: {
- project: props.project.name,
- taskType: [
- Task_Type.DATABASE_DATA_UPDATE,
- Task_Type.DATABASE_SCHEMA_UPDATE,
- Task_Type.DATABASE_SCHEMA_UPDATE_GHOST,
- Task_Type.DATABASE_SCHEMA_UPDATE_SDL,
- ],
- },
- pageSize,
- pageToken,
- });
- return {
- nextPageToken,
- list: rollouts,
- };
-};
-</script>
diff --git a/frontend/src/components/Release/ReleaseDataTable.vue b/frontend/src/components/Release/ReleaseDataTable.vue
index 6057c34161..a8fb76b3d8 100644
--- a/frontend/src/components/Release/ReleaseDataTable.vue
+++ b/frontend/src/components/Release/ReleaseDataTable.vue
@@ -102,6 +102,15 @@ const columnList = computed(
);
},
},
+ {
+ key: "createTime",
+ title: t("common.created-at"),
+ width: 128,
+ render: (release) =>
+ humanizeTs(
+ getTimeForPbTimestampProtoEs(release.createTime, 0) / 1000
+ ),
+ },
{
key: "creator",
title: t("common.creator"),
@@ -113,15 +122,6 @@ const columnList = computed(
</div>
),
},
- {
- key: "createTime",
- title: t("common.created-at"),
- width: 128,
- render: (release) =>
- humanizeTs(
- getTimeForPbTimestampProtoEs(release.createTime, 0) / 1000
- ),
- },
];
return columns.filter((column) => !column.hide);
}
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 898c6e1133..043ecec461 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -873,7 +873,7 @@
},
"creator": {
"title": "Creator",
- "description": "Search by the issue creator"
+ "description": "Search by the creator"
},
"subscriber": {},
"approver": {
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 3ee2fc5961..e0dfcfbe37 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -873,7 +873,7 @@
},
"creator": {
"title": "Creador",
- "description": "Búsqueda por tema creador"
+ "description": "Búsqueda por creador"
},
"subscriber": {},
"approver": {
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 3451740605..b8a85c742a 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -873,7 +873,7 @@
},
"creator": {
"title": "作成者",
- "description": "イシュー作成者で検索"
+ "description": "作成者で検索"
},
"subscriber": {},
"approver": {
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 731f5fc9a2..14576dbc83 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -873,7 +873,7 @@
},
"creator": {
"title": "Người tạo",
- "description": "Tìm kiếm theo người tạo vấn đề"
+ "description": "Tìm kiếm theo người sáng tạo"
},
"subscriber": {},
"approver": {
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index eca4ed19ec..afd25f9857 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -873,7 +873,7 @@
},
"creator": {
"title": "创建人",
- "description": "根据工单创建人搜索"
+ "description": "根据创建人搜索"
},
"subscriber": {},
"approver": {
diff --git a/frontend/src/store/modules/rollout.ts b/frontend/src/store/modules/rollout.ts
index a468315a59..a111519648 100644
--- a/frontend/src/store/modules/rollout.ts
+++ b/frontend/src/store/modules/rollout.ts
@@ -1,5 +1,6 @@
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";
@@ -15,6 +16,11 @@ import {
GetRolloutRequestSchema,
ListRolloutsRequestSchema,
} from "@/types/proto-es/v1/rollout_service_pb";
+import {
+ getTsRangeFromSearchParams,
+ getValueFromSearchParams,
+ type SearchParams,
+} from "@/utils";
import { DEFAULT_PAGE_SIZE } from "./common";
import { useUserStore } from "./user";
import { useProjectV1Store, batchGetOrFetchProjects } from "./v1";
@@ -23,6 +29,10 @@ import { getProjectNameRolloutId, projectNamePrefix } from "./v1/common";
export interface RolloutFind {
project: string;
taskType?: Task_Type | Task_Type[];
+ query?: string;
+ creator?: string;
+ updatedTsAfter?: number;
+ updatedTsBefore?: number;
}
export const buildRolloutFilter = (find: RolloutFind): string => {
@@ -35,9 +45,42 @@ export const buildRolloutFilter = (find: RolloutFind): string => {
filter.push(`task_type == "${Task_Type[find.taskType]}"`);
}
}
+ if (find.creator) {
+ filter.push(`creator == "${find.creator}"`);
+ }
+ if (find.updatedTsAfter) {
+ filter.push(
+ `update_time >= "${dayjs(find.updatedTsAfter).utc().format()}"`
+ );
+ }
+ if (find.updatedTsBefore) {
+ filter.push(
+ `update_time <= "${dayjs(find.updatedTsBefore).utc().format()}"`
+ );
+ }
return filter.join(" && ");
};
+export const buildRolloutFindBySearchParams = (
+ params: SearchParams,
+ defaultFind?: Partial<RolloutFind>
+) => {
+ const { scopes } = params;
+ const projectScope = scopes.find((s) => s.id === "project");
+
+ const updatedTsRange = getTsRangeFromSearchParams(params, "updated");
+
+ const filter: RolloutFind = {
+ ...defaultFind,
+ project: `projects/${projectScope?.value ?? "-"}`,
+ query: params.query,
+ updatedTsAfter: updatedTsRange?.[0],
+ updatedTsBefore: updatedTsRange?.[1],
+ creator: getValueFromSearchParams(params, "creator", "users/"),
+ };
+ return filter;
+};
+
export type ListRolloutParams = {
find: RolloutFind;
pageSize?: number;
diff --git a/frontend/src/types/proto-es/v1/plan_service_pb.d.ts b/frontend/src/types/proto-es/v1/plan_service_pb.d.ts
index 16f233e31f..2859238de1 100644
--- a/frontend/src/types/proto-es/v1/plan_service_pb.d.ts
+++ b/frontend/src/types/proto-es/v1/plan_service_pb.d.ts
@@ -139,7 +139,7 @@ export declare type SearchPlansRequest = Message<"bytebase.v1.SearchPlansRequest
*
* Supported filters:
* - creator: the plan creator full name in "users/{email or id}" format, support "==" operator.
- * - create_time: issue create time in "2006-01-02T15:04:05Z07:00" format, support ">=" or "<=" operator.
+ * - create_time: the plan create time in "2006-01-02T15:04:05Z07:00" format, support ">=" or "<=" operator.
* - has_pipeline: the plan has pipeline or not, support "==" operator, the value should be "true" or "false".
* - has_issue: the plan has issue or not, support "==" operator, the value should be "true" or "false".
* - title: the plan title, support "==" operator for exact match and ".matches()" operator for case-insensitive substring match.
diff --git a/frontend/src/types/proto-es/v1/rollout_service_pb.d.ts b/frontend/src/types/proto-es/v1/rollout_service_pb.d.ts
index a3836793f3..9d47f7eea3 100644
--- a/frontend/src/types/proto-es/v1/rollout_service_pb.d.ts
+++ b/frontend/src/types/proto-es/v1/rollout_service_pb.d.ts
@@ -211,9 +211,12 @@ export declare type ListRolloutsRequest = Message<"bytebase.v1.ListRolloutsReque
* The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
*
* Supported filters:
+ * - creator: the rollout creator full name in "users/{email or id}" format, support "==" operator.
+ * - update_time: rollout update time in "2006-01-02T15:04:05Z07:00" format, support ">=" or "<=" operator.
* - task_type: the task type, support "==" and "in" operators, check the Task.Type enum for the values.
*
* For example:
+ * creator == "users/[email protected]" && update_time >= "2025-01-02T15:04:05Z07:00"
* task_type == "DATABASE_SCHEMA_UPDATE"
* task_type in ["DATABASE_SCHEMA_UPDATE", "DATABASE_DATA_UPDATE"]
*
diff --git a/frontend/src/utils/v1/advanced-search/common.ts b/frontend/src/utils/v1/advanced-search/common.ts
index 949583f721..55625d9b5d 100644
--- a/frontend/src/utils/v1/advanced-search/common.ts
+++ b/frontend/src/utils/v1/advanced-search/common.ts
@@ -23,6 +23,7 @@ export const AllSearchScopeIdList = [
"database",
"creator",
"created",
+ "updated",
"status",
"state",
// database related search scopes.
diff --git a/frontend/src/views/project/ProjectPlanDashboard.vue b/frontend/src/views/project/ProjectPlanDashboard.vue
index c42172ed4c..933a888ece 100644
--- a/frontend/src/views/project/ProjectPlanDashboard.vue
+++ b/frontend/src/views/project/ProjectPlanDashboard.vue
@@ -47,31 +47,46 @@ import { head } from "lodash-es";
import { PlusIcon } from "lucide-vue-next";
import { NButton } from "naive-ui";
import { v4 as uuidv4 } from "uuid";
-import { computed, reactive, watch, ref } from "vue";
+import { computed, reactive, watch, ref, h } from "vue";
import type { ComponentExposed } from "vue-component-type-helpers";
+import { useI18n } from "vue-i18n";
import { useRouter, type LocationQuery } from "vue-router";
+import BBAvatar from "@/bbkit/BBAvatar.vue";
import AdvancedSearch from "@/components/AdvancedSearch";
+import type {
+ ScopeOption,
+ ValueOption,
+} from "@/components/AdvancedSearch/types";
import { useCommonSearchScopeOptions } from "@/components/AdvancedSearch/useCommonSearchScopeOptions";
import { targetsForSpec, getLocalSheetByName } from "@/components/Plan";
import AddSpecDrawer from "@/components/Plan/components/AddSpecDrawer.vue";
import PlanDataTable from "@/components/Plan/components/PlanDataTable";
+import SystemBotTag from "@/components/misc/SystemBotTag.vue";
+import YouTag from "@/components/misc/YouTag.vue";
import PagedTable from "@/components/v2/Model/PagedTable.vue";
import { useIssueLayoutVersion } from "@/composables/useIssueLayoutVersion";
import { PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL } from "@/router/dashboard/projectV1";
-import { useCurrentProjectV1, useStorageStore } from "@/store";
+import {
+ useCurrentProjectV1,
+ useCurrentUserV1,
+ useStorageStore,
+ useUserStore,
+} from "@/store";
import { usePlanStore } from "@/store/modules/v1/plan";
import { buildPlanFindBySearchParams } from "@/store/modules/v1/plan";
-import { isValidDatabaseGroupName } from "@/types";
+import { isValidDatabaseGroupName, SYSTEM_BOT_USER_NAME } from "@/types";
import {
Plan_ChangeDatabaseConfig_Type,
type Plan,
type Plan_Spec,
} from "@/types/proto-es/v1/plan_service_pb";
+import { UserType } from "@/types/proto-es/v1/user_service_pb";
import {
extractDatabaseGroupName,
extractDatabaseResourceName,
extractProjectResourceName,
generateIssueTitle,
+ getDefaultPagination,
hasPermissionToCreatePlanInProject,
type SearchParams,
type SearchScope,
@@ -82,8 +97,11 @@ interface LocalState {
params: SearchParams;
}
+const { t } = useI18n();
+const me = useCurrentUserV1();
const { enabledNewLayout } = useIssueLayoutVersion();
const { project, ready } = useCurrentProjectV1();
+const userStore = useUserStore();
const showAddSpecDrawer = ref(false);
const readonlyScopes = computed((): SearchScope[] => {
@@ -99,6 +117,10 @@ const defaultSearchParams = () => {
id: "state",
value: "ACTIVE",
},
+ {
+ id: "creator",
+ value: me.value.email,
+ },
],
};
return params;
@@ -119,11 +141,97 @@ const planPagedTable = ref<ComponentExposed<typeof PagedTable<Plan>>>();
const supportedScopes = computed(() => {
// TODO(steven): support more scopes in backend and frontend: instance, database, planCheckRunStatus
- const supportedScopes: SearchScopeId[] = ["state"];
+ const supportedScopes: SearchScopeId[] = ["state", "creator"];
return supportedScopes;
});
-const scopeOptions = useCommonSearchScopeOptions(supportedScopes.value);
+// Custom scope options for plans that includes creator functionality
+const scopeOptions = computed((): ScopeOption[] => {
+ // Get common options but exclude both creator and state (we'll add them manually)
+ const commonOptions = useCommonSearchScopeOptions(
+ supportedScopes.value.filter((id) => id !== "creator" && id !== "state")
+ );
+
+ const renderSpan = (text: string) => h("span", text);
+
+ const searchPrincipalSearchValueOptions = (userTypes: UserType[]) => {
+ return ({
+ keyword,
+ nextPageToken,
+ }: {
+ keyword: string;
+ nextPageToken?: string;
+ }) =>
+ userStore
+ .fetchUserList({
+ pageToken: nextPageToken,
+ pageSize: getDefaultPagination(),
+ filter: {
+ types: userTypes,
+ query: keyword,
+ },
+ })
+ .then((resp) => ({
+ nextPageToken: resp.nextPageToken,
+ options: resp.users.map<ValueOption>((user) => {
+ return {
+ value: user.email,
+ keywords: [user.email, user.title],
+ bot: user.name === SYSTEM_BOT_USER_NAME,
+ render: () => {
+ const children = [
+ h(BBAvatar, { size: "TINY", username: user.title }),
+ renderSpan(user.title),
+ ];
+ if (user.name === me.value.name) {
+ children.push(h(YouTag));
+ }
+ if (user.name === SYSTEM_BOT_USER_NAME) {
+ children.push(h(SystemBotTag));
+ }
+ return h(
+ "div",
+ { class: "flex items-center gap-x-1" },
+ children
+ );
+ },
+ };
+ }),
+ }));
+ };
+
+ const creatorOption: ScopeOption = {
+ id: "creator",
+ title: t("issue.advanced-search.scope.creator.title"),
+ description: t("issue.advanced-search.scope.creator.description"),
+ search: searchPrincipalSearchValueOptions([
+ UserType.USER,
+ UserType.SERVICE_ACCOUNT,
+ UserType.SYSTEM_BOT,
+ ]),
+ };
+
+ const stateOption: ScopeOption = {
+ id: "state",
+ title: t("common.state"),
+ description: t("plan.state.description"),
+ options: [
+ {
+ value: "ACTIVE",
+ keywords: ["active", "ACTIVE"],
+ render: () => renderSpan(t("common.active")),
+ },
+ {
+ value: "DELETED",
+ keywords: ["deleted", "DELETED", "closed", "CLOSED"],
+ render: () => renderSpan(t("common.closed")),
+ },
+ ],
+ allowMultiple: false,
+ };
+
+ return [...commonOptions.value, creatorOption, stateOption];
+});
const planSearchParams = computed(() => {
const defaultScopes = [
diff --git a/frontend/src/views/project/ProjectRolloutDashboard.vue b/frontend/src/views/project/ProjectRolloutDashboard.vue
index f06cc6a6bc..84f25ea537 100644
--- a/frontend/src/views/project/ProjectRolloutDashboard.vue
+++ b/frontend/src/views/project/ProjectRolloutDashboard.vue
@@ -1,18 +1,237 @@
<template>
- <ProjectRolloutsPanel :project="project" />
+ <div class="w-full">
+ <div
+ class="w-full flex flex-col lg:flex-row items-start lg:items-center justify-between gap-2"
+ >
+ <div class="w-full flex flex-1 items-center justify-between gap-x-2">
+ <AdvancedSearch
+ v-model:params="state.params"
+ class="flex-1"
+ :scope-options="scopeOptions"
+ />
+ <UpdatedTimeRange
+ :params="state.params"
+ @update:params="state.params = $event"
+ />
+ </div>
+ </div>
+
+ <div class="relative w-full mt-4 min-h-[20rem]">
+ <PagedTable
+ ref="rolloutPagedTable"
+ :key="project.name"
+ :session-key="`project-${project.name}-rollouts`"
+ :fetch-list="fetchRolloutList"
+ >
+ <template #table="{ list, loading }">
+ <RolloutDataTable
+ :bordered="true"
+ :loading="loading"
+ :rollout-list="list"
+ />
+ </template>
+ </PagedTable>
+ </div>
+ </div>
</template>
<script lang="ts" setup>
-import { computed } from "vue";
-import ProjectRolloutsPanel from "@/components/Project/ProjectRolloutsPanel.vue";
-import { useProjectByName } from "@/store";
+import { computed, reactive, ref, watch, h } from "vue";
+import type { ComponentExposed } from "vue-component-type-helpers";
+import { useI18n } from "vue-i18n";
+import BBAvatar from "@/bbkit/BBAvatar.vue";
+import AdvancedSearch from "@/components/AdvancedSearch";
+import UpdatedTimeRange from "@/components/AdvancedSearch/UpdatedTimeRange.vue";
+import type {
+ ScopeOption,
+ ValueOption,
+} from "@/components/AdvancedSearch/types";
+import { useCommonSearchScopeOptions } from "@/components/AdvancedSearch/useCommonSearchScopeOptions";
+import RolloutDataTable from "@/components/Rollout/RolloutDataTable.vue";
+import SystemBotTag from "@/components/misc/SystemBotTag.vue";
+import YouTag from "@/components/misc/YouTag.vue";
+import PagedTable from "@/components/v2/Model/PagedTable.vue";
+import {
+ useCurrentUserV1,
+ useProjectByName,
+ useRolloutStore,
+ useUserStore,
+} from "@/store";
+import {
+ buildRolloutFindBySearchParams,
+ type RolloutFind,
+} from "@/store/modules/rollout";
import { projectNamePrefix } from "@/store/modules/v1/common";
+import { SYSTEM_BOT_USER_NAME } from "@/types";
+import {
+ Task_Type,
+ type Rollout,
+} from "@/types/proto-es/v1/rollout_service_pb";
+import { UserType } from "@/types/proto-es/v1/user_service_pb";
+import {
+ extractProjectResourceName,
+ getDefaultPagination,
+ type SearchParams,
+ type SearchScope,
+ type SearchScopeId,
+} from "@/utils";
+
+interface LocalState {
+ params: SearchParams;
+}
const props = defineProps<{
projectId: string;
}>();
+const { t } = useI18n();
+const me = useCurrentUserV1();
const { project } = useProjectByName(
computed(() => `${projectNamePrefix}${props.projectId}`)
);
+
+const rolloutStore = useRolloutStore();
+const userStore = useUserStore();
+const rolloutPagedTable = ref<ComponentExposed<typeof PagedTable<Rollout>>>();
+
+const readonlyScopes = computed((): SearchScope[] => {
+ return [];
+});
+
+const defaultSearchParams = () => {
+ const params: SearchParams = {
+ query: "",
+ scopes: [...readonlyScopes.value],
+ };
+ return params;
+};
+
+const state = reactive<LocalState>({
+ params: defaultSearchParams(),
+});
+
+watch(
+ () => project.value.name,
+ () => (state.params = defaultSearchParams())
+);
+
+const supportedScopes = computed(() => {
+ const supportedScopes: SearchScopeId[] = ["creator", "updated"];
+ return supportedScopes;
+});
+
+// Custom scope options for rollouts that includes creator functionality
+const scopeOptions = computed((): ScopeOption[] => {
+ const commonOptions = useCommonSearchScopeOptions(
+ supportedScopes.value.filter((id) => id !== "creator")
+ );
+
+ const renderSpan = (text: string) => h("span", text);
+
+ const searchPrincipalSearchValueOptions = (userTypes: UserType[]) => {
+ return ({
+ keyword,
+ nextPageToken,
+ }: {
+ keyword: string;
+ nextPageToken?: string;
+ }) =>
+ userStore
+ .fetchUserList({
+ pageToken: nextPageToken,
+ pageSize: getDefaultPagination(),
+ filter: {
+ types: userTypes,
+ query: keyword,
+ },
+ })
+ .then((resp) => ({
+ nextPageToken: resp.nextPageToken,
+ options: resp.users.map<ValueOption>((user) => {
+ return {
+ value: user.email,
+ keywords: [user.email, user.title],
+ bot: user.name === SYSTEM_BOT_USER_NAME,
+ render: () => {
+ const children = [
+ h(BBAvatar, { size: "TINY", username: user.title }),
+ renderSpan(user.title),
+ ];
+ if (user.name === me.value.name) {
+ children.push(h(YouTag));
+ }
+ if (user.name === SYSTEM_BOT_USER_NAME) {
+ children.push(h(SystemBotTag));
+ }
+ return h(
+ "div",
+ { class: "flex items-center gap-x-1" },
+ children
+ );
+ },
+ };
+ }),
+ }));
+ };
+
+ const creatorOption: ScopeOption = {
+ id: "creator",
+ title: t("issue.advanced-search.scope.creator.title"),
+ description: t("issue.advanced-search.scope.creator.description"),
+ search: searchPrincipalSearchValueOptions([
+ UserType.USER,
+ UserType.SERVICE_ACCOUNT,
+ UserType.SYSTEM_BOT,
+ ]),
+ };
+
+ return [...commonOptions.value, creatorOption];
+});
+
+const rolloutSearchParams = computed(() => {
+ const defaultScopes = [
+ {
+ id: "project",
+ value: extractProjectResourceName(project.value.name),
+ },
+ ];
+ return {
+ query: state.params.query.trim().toLowerCase(),
+ scopes: [...state.params.scopes, ...defaultScopes],
+ } as SearchParams;
+});
+
+const mergedRolloutFind = computed((): RolloutFind => {
+ return buildRolloutFindBySearchParams(rolloutSearchParams.value, {
+ taskType: [
+ Task_Type.DATABASE_DATA_UPDATE,
+ Task_Type.DATABASE_SCHEMA_UPDATE,
+ Task_Type.DATABASE_SCHEMA_UPDATE_GHOST,
+ Task_Type.DATABASE_SCHEMA_UPDATE_SDL,
+ ],
+ });
+});
+
+const fetchRolloutList = async ({
+ pageToken,
+ pageSize,
+}: {
+ pageToken: string;
+ pageSize: number;
+}) => {
+ const { nextPageToken, rollouts } = await rolloutStore.listRollouts({
+ find: mergedRolloutFind.value,
+ pageSize,
+ pageToken,
+ });
+ return {
+ nextPageToken,
+ list: rollouts,
+ };
+};
+
+watch(
+ () => JSON.stringify(mergedRolloutFind.value),
+ () => rolloutPagedTable.value?.refresh()
+);
</script>
diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yaml
index 2e5af84703..cd0a36c984 100644
--- a/proto/gen/grpc-doc/openapi.yaml
+++ b/proto/gen/grpc-doc/openapi.yaml
@@ -5370,9 +5370,12 @@ paths:
The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
Supported filters:
+ - creator: the rollout creator full name in "users/{email or id}" format, support "==" operator.
+ - update_time: rollout update time in "2006-01-02T15:04:05Z07:00" format, support ">=" or "<=" operator.
- task_type: the task type, support "==" and "in" operators, check the Task.Type enum for the values.
For example:
+ creator == "users/[email protected]" && update_time >= "2025-01-02T15:04:05Z07:00"
task_type == "DATABASE_SCHEMA_UPDATE"
task_type in ["DATABASE_SCHEMA_UPDATE", "DATABASE_DATA_UPDATE"]
schema:
@@ -13047,7 +13050,7 @@ components:
Supported filters:
- creator: the plan creator full name in "users/{email or id}" format, support "==" operator.
- - create_time: issue create time in "2006-01-02T15:04:05Z07:00" format, support ">=" or "<=" operator.
+ - create_time: the plan create time in "2006-01-02T15:04:05Z07:00" format, support ">=" or "<=" operator.
- has_pipeline: the plan has pipeline or not, support "==" operator, the value should be "true" or "false".
- has_issue: the plan has issue or not, support "==" operator, the value should be "true" or "false".
- title: the plan title, support "==" operator for exact match and ".matches()" operator for case-insensitive substring match.
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index 41d0e4c58b..b99bc1871e 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -7537,7 +7537,7 @@ When paginating, all other parameters provided to `ListPlans` must match the cal
When paginating, all other parameters provided to `SearchPlans` must match the call that provided the page token. |
| filter | [string](#string) | | Filter is used to filter plans returned in the list. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
-Supported filters: - creator: the plan creator full name in &#34;users/{email or id}&#34; format, support &#34;==&#34; operator. - create_time: issue create time in &#34;2006-01-02T15:04:05Z07:00&#34; format, support &#34;&gt;=&#34; or &#34;&lt;=&#34; operator. - has_pipeline: the plan has pipeline or not, support &#34;==&#34; operator, the value should be &#34;true&#34; or &#34;false&#34;. - has_issue: the plan has issue or not, support &#34;==&#34; operator, the value should be &#34;true&#34; or &#34;false&#34;. - title: the plan title, support &#34;==&#34; operator for exact match and &#34;.matches()&#34; operator for case-insensitive substring match. - spec_type: the plan spec config type, support &#34;==&#34; operator, the value should be &#34;create_database_config&#34;, &#34;change_database_config&#34;, or &#34;export_data_config&#34;. - state: the plan state, support &#34;==&#34; operator, the value should be &#34;ACTIVE&#34; or &#34;DELETED&#34;.
+Supported filters: - creator: the plan creator full name in &#34;users/{email or id}&#34; format, support &#34;==&#34; operator. - create_time: the plan create time in &#34;2006-01-02T15:04:05Z07:00&#34; format, support &#34;&gt;=&#34; or &#34;&lt;=&#34; operator. - has_pipeline: the plan has pipeline or not, support &#34;==&#34; operator, the value should be &#34;true&#34; or &#34;false&#34;. - has_issue: the plan has issue or not, support &#34;==&#34; operator, the value should be &#34;true&#34; or &#34;false&#34;. - title: the plan title, support &#34;==&#34; operator for exact match and &#34;.matches()&#34; operator for case-insensitive substring match. - spec_type: the plan spec config type, support &#34;==&#34; operator, the value should be &#34;create_database_config&#34;, &#34;change_database_config&#34;, or &#34;export_data_config&#34;. - state: the plan state, support &#34;==&#34; operator, the value should be &#34;ACTIVE&#34; or &#34;DELETED&#34;.
For example: creator == &#34;users/[email protected]&#34; &amp;&amp; create_time &gt;= &#34;2025-01-02T15:04:05Z07:00&#34; has_pipeline == false &amp;&amp; has_issue == true title == &#34;My Plan&#34; title.matches(&#34;database migration&#34;) spec_type == &#34;change_database_config&#34; state == &#34;ACTIVE&#34; |
@@ -9975,9 +9975,9 @@ When paginating, all other parameters provided to `ListRoles` must match the cal
When paginating, all other parameters provided to `ListRollouts` must match the call that provided the page token. |
| filter | [string](#string) | | Filter is used to filter rollouts returned in the list. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
-Supported filters: - task_type: the task type, support &#34;==&#34; and &#34;in&#34; operators, check the Task.Type enum for the values.
+Supported filters: - creator: the rollout creator full name in &#34;users/{email or id}&#34; format, support &#34;==&#34; operator. - update_time: rollout update time in &#34;2006-01-02T15:04:05Z07:00&#34; format, support &#34;&gt;=&#34; or &#34;&lt;=&#34; operator. - task_type: the task type, support &#34;==&#34; and &#34;in&#34; operators, check the Task.Type enum for the values.
-For example: task_type == &#34;DATABASE_SCHEMA_UPDATE&#34; task_type in [&#34;DATABASE_SCHEMA_UPDATE&#34;, &#34;DATABASE_DATA_UPDATE&#34;] |
+For example: creator == &#34;users/[email protected]&#34; &amp;&amp; update_time &gt;= &#34;2025-01-02T15:04:05Z07:00&#34; task_type == &#34;DATABASE_SCHEMA_UPDATE&#34; task_type in [&#34;DATABASE_SCHEMA_UPDATE&#34;, &#34;DATABASE_DATA_UPDATE&#34;] |
diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.html
index 83a2bdc21b..2d75a26bef 100644
--- a/proto/gen/grpc-doc/v1/index.html
+++ b/proto/gen/grpc-doc/v1/index.html
@@ -21064,7 +21064,7 @@ The syntax and semantics of CEL are documented at https://github.com/google/cel-
Supported filters:
- creator: the plan creator full name in &#34;users/{email or id}&#34; format, support &#34;==&#34; operator.
-- create_time: issue create time in &#34;2006-01-02T15:04:05Z07:00&#34; format, support &#34;&gt;=&#34; or &#34;&lt;=&#34; operator.
+- create_time: the plan create time in &#34;2006-01-02T15:04:05Z07:00&#34; format, support &#34;&gt;=&#34; or &#34;&lt;=&#34; operator.
- has_pipeline: the plan has pipeline or not, support &#34;==&#34; operator, the value should be &#34;true&#34; or &#34;false&#34;.
- has_issue: the plan has issue or not, support &#34;==&#34; operator, the value should be &#34;true&#34; or &#34;false&#34;.
- title: the plan title, support &#34;==&#34; operator for exact match and &#34;.matches()&#34; operator for case-insensitive substring match.
@@ -27578,9 +27578,12 @@ the call that provided the page token. </p></td>
The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
Supported filters:
+- creator: the rollout creator full name in &#34;users/{email or id}&#34; format, support &#34;==&#34; operator.
+- update_time: rollout update time in &#34;2006-01-02T15:04:05Z07:00&#34; format, support &#34;&gt;=&#34; or &#34;&lt;=&#34; operator.
- task_type: the task type, support &#34;==&#34; and &#34;in&#34; operators, check the Task.Type enum for the values.
For example:
+creator == &#34;users/[email protected]&#34; &amp;&amp; update_time &gt;= &#34;2025-01-02T15:04:05Z07:00&#34;
task_type == &#34;DATABASE_SCHEMA_UPDATE&#34;
task_type in [&#34;DATABASE_SCHEMA_UPDATE&#34;, &#34;DATABASE_DATA_UPDATE&#34;] </p></td>
</tr>
diff --git a/proto/v1/v1/plan_service.proto b/proto/v1/v1/plan_service.proto
index 1bc7b525f3..f9b9d43a75 100644
--- a/proto/v1/v1/plan_service.proto
+++ b/proto/v1/v1/plan_service.proto
@@ -165,7 +165,7 @@ message SearchPlansRequest {
//
// Supported filters:
// - creator: the plan creator full name in "users/{email or id}" format, support "==" operator.
- // - create_time: issue create time in "2006-01-02T15:04:05Z07:00" format, support ">=" or "<=" operator.
+ // - create_time: the plan create time in "2006-01-02T15:04:05Z07:00" format, support ">=" or "<=" operator.
// - has_pipeline: the plan has pipeline or not, support "==" operator, the value should be "true" or "false".
// - has_issue: the plan has issue or not, support "==" operator, the value should be "true" or "false".
// - title: the plan title, support "==" operator for exact match and ".matches()" operator for case-insensitive substring match.
diff --git a/proto/v1/v1/rollout_service.proto b/proto/v1/v1/rollout_service.proto
index d348c7001f..717beea8bf 100644
--- a/proto/v1/v1/rollout_service.proto
+++ b/proto/v1/v1/rollout_service.proto
@@ -205,9 +205,12 @@ message ListRolloutsRequest {
// The syntax and semantics of CEL are documented at https://github.com/google/cel-spec
//
// Supported filters:
+ // - creator: the rollout creator full name in "users/{email or id}" format, support "==" operator.
+ // - update_time: rollout update time in "2006-01-02T15:04:05Z07:00" format, support ">=" or "<=" operator.
// - task_type: the task type, support "==" and "in" operators, check the Task.Type enum for the values.
//
// For example:
+ // creator == "users/[email protected]" && update_time >= "2025-01-02T15:04:05Z07:00"
// task_type == "DATABASE_SCHEMA_UPDATE"
// task_type in ["DATABASE_SCHEMA_UPDATE", "DATABASE_DATA_UPDATE"]
string filter = 4;