Skip to content

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

feat: user pagination (#15473)

ecmadao0f663fc4356a
diff --git a/backend/api/v1/common.go b/backend/api/v1/common.go
index 61b773c680..7474078529 100644
--- a/backend/api/v1/common.go
+++ b/backend/api/v1/common.go
@@ -455,7 +455,7 @@ func parseLimitAndOffset(size *pageSize) (*pageOffset, error) {
if token.Limit < 0 {
return nil, status.Errorf(codes.InvalidArgument, "page size cannot be negative")
}
- offset.limit = int(token.Limit)
+ offset.limit = int(size.limit)
offset.offset = int(token.Offset)
} else {
offset.limit = int(size.limit)
diff --git a/backend/api/v1/user_service.go b/backend/api/v1/user_service.go
index 697f5b68df..1fb44459ce 100644
--- a/backend/api/v1/user_service.go
+++ b/backend/api/v1/user_service.go
@@ -88,13 +88,30 @@ func (s *UserService) GetUser(ctx context.Context, request *v1pb.GetUserRequest)
return convertToUser(user), nil
}
+// StatUsers count users by type and state.
+func (s *UserService) StatUsers(ctx context.Context, _ *v1pb.StatUsersRequest) (*v1pb.StatUsersResponse, error) {
+ stats, err := s.store.StatUsers(ctx)
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, "failed to stat users, error: %v", err)
+ }
+ response := &v1pb.StatUsersResponse{}
+
+ for _, stat := range stats {
+ response.Stats = append(response.Stats, &v1pb.StatUsersResponse_StatUser{
+ State: convertDeletedToState(stat.Deleted),
+ UserType: convertToV1UserType(stat.Type),
+ Count: int32(stat.Count),
+ })
+ }
+ return response, nil
+}
+
// ListUsers lists all users.
func (s *UserService) ListUsers(ctx context.Context, request *v1pb.ListUsersRequest) (*v1pb.ListUsersResponse, error) {
offset, err := parseLimitAndOffset(&pageSize{
- token: request.PageToken,
- limit: int(request.PageSize),
- // TODO(ed): support pagination.
- maximum: 100000,
+ token: request.PageToken,
+ limit: int(request.PageSize),
+ maximum: 1000,
})
if err != nil {
return nil, err
@@ -169,7 +186,14 @@ func getListUserFilter(filter string) (*store.ListResourceFilter, error) {
}
positionalArgs = append(positionalArgs, principalType)
return fmt.Sprintf("principal.type = $%d", len(positionalArgs)), nil
- // TODO(ed): support project filter
+ case "state":
+ v1State, ok := v1pb.State_value[value.(string)]
+ if !ok {
+ return "", status.Errorf(codes.InvalidArgument, "invalid state filter %q", value)
+ }
+ positionalArgs = append(positionalArgs, v1pb.State(v1State) == v1pb.State_DELETED)
+ return fmt.Sprintf("principal.deleted = $%d", len(positionalArgs)), nil
+ // TODO(ed): support role/project filter
default:
return "", status.Errorf(codes.InvalidArgument, "unsupport variable %q", variable)
}
@@ -221,14 +245,14 @@ func getListUserFilter(filter string) (*store.ListResourceFilter, error) {
return "", status.Errorf(codes.InvalidArgument, `invalid args for %q`, variable)
}
value := args[0].AsLiteral().Value()
- if variable != "name" {
- return "", status.Errorf(codes.InvalidArgument, `only "name" support %q operator, but found %q`, celoverloads.Matches, variable)
+ if variable != "name" && variable != "email" {
+ return "", status.Errorf(codes.InvalidArgument, `only "name" and "email" support %q operator, but found %q`, celoverloads.Matches, variable)
}
strValue, ok := value.(string)
if !ok {
return "", status.Errorf(codes.InvalidArgument, "expect string, got %T, hint: filter literals should be string", value)
}
- return "LOWER(principal.name) LIKE '%" + strings.ToLower(strValue) + "%'", nil
+ return "LOWER(principal." + variable + ") LIKE '%" + strings.ToLower(strValue) + "%'", nil
case celoperators.In:
return parseToUserTypeSQL(expr, "IN")
case celoperators.LogicalNot:
@@ -699,24 +723,27 @@ func (s *UserService) UndeleteUser(ctx context.Context, request *v1pb.UndeleteUs
return convertToUser(user), nil
}
-func convertToUser(user *store.UserMessage) *v1pb.User {
- userType := v1pb.UserType_USER_TYPE_UNSPECIFIED
- switch user.Type {
+func convertToV1UserType(userType api.PrincipalType) v1pb.UserType {
+ switch userType {
case api.EndUser:
- userType = v1pb.UserType_USER
+ return v1pb.UserType_USER
case api.SystemBot:
- userType = v1pb.UserType_SYSTEM_BOT
+ return v1pb.UserType_SYSTEM_BOT
case api.ServiceAccount:
- userType = v1pb.UserType_SERVICE_ACCOUNT
+ return v1pb.UserType_SERVICE_ACCOUNT
+ default:
+ return v1pb.UserType_USER_TYPE_UNSPECIFIED
}
+}
+func convertToUser(user *store.UserMessage) *v1pb.User {
convertedUser := &v1pb.User{
Name: common.FormatUserUID(user.ID),
State: convertDeletedToState(user.MemberDeleted),
Email: user.Email,
Phone: user.Phone,
Title: user.Name,
- UserType: userType,
+ UserType: convertToV1UserType(user.Type),
Profile: &v1pb.User_Profile{
LastLoginTime: user.Profile.LastLoginTime,
LastChangePasswordTime: user.Profile.LastChangePasswordTime,
diff --git a/backend/store/principal.go b/backend/store/principal.go
index aa420b9f83..53c18d51eb 100644
--- a/backend/store/principal.go
+++ b/backend/store/principal.go
@@ -63,6 +63,12 @@ type UserMessage struct {
CreatedAt time.Time
}
+type UserStat struct {
+ Type api.PrincipalType
+ Deleted bool
+ Count int
+}
+
// GetSystemBotUser gets the system bot.
func (s *Store) GetSystemBotUser(ctx context.Context) *UserMessage {
user, err := s.GetUserByID(ctx, api.SystemBotID)
@@ -104,6 +110,39 @@ func (s *Store) GetUserByEmail(ctx context.Context, email string) (*UserMessage,
return user, nil
}
+func (s *Store) StatUsers(ctx context.Context) ([]*UserStat, error) {
+ rows, err := s.db.db.QueryContext(ctx, `
+ SELECT
+ COUNT(*),
+ type,
+ deleted
+ FROM principal
+ GROUP BY type, deleted`)
+ if err != nil {
+ return nil, err
+ }
+ defer rows.Close()
+
+ var stats []*UserStat
+
+ for rows.Next() {
+ var stat UserStat
+ if err := rows.Scan(
+ &stat.Count,
+ &stat.Type,
+ &stat.Deleted,
+ ); err != nil {
+ return nil, err
+ }
+ stats = append(stats, &stat)
+ }
+ if err := rows.Err(); err != nil {
+ return nil, errors.Wrapf(err, "failed to scan rows")
+ }
+
+ return stats, nil
+}
+
// ListUsers list users.
func (s *Store) ListUsers(ctx context.Context, find *FindUserMessage) ([]*UserMessage, error) {
tx, err := s.db.BeginTx(ctx, nil)
@@ -188,7 +227,7 @@ func listUserImpl(ctx context.Context, tx *Tx, find *FindUserMessage) ([]*UserMe
principal.profile,
principal.created_at
FROM principal
- WHERE ` + strings.Join(where, " AND ")
+ WHERE ` + strings.Join(where, " AND ") + ` ORDER BY type DESC, created_at ASC`
if v := find.Limit; v != nil {
query += fmt.Sprintf(" LIMIT %d", *v)
diff --git a/frontend/src/components/AuditLog/AuditLogDataTable.vue b/frontend/src/components/AuditLog/AuditLogDataTable.vue
index e940cbf9d1..61683ac0b5 100644
--- a/frontend/src/components/AuditLog/AuditLogDataTable.vue
+++ b/frontend/src/components/AuditLog/AuditLogDataTable.vue
@@ -15,7 +15,7 @@ import { NDataTable, type DataTableColumn } from "naive-ui";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
import BBAvatar from "@/bbkit/BBAvatar.vue";
-import { extractUserEmail, useProjectV1Store, useUserStore } from "@/store";
+import { useProjectV1Store, useUserStore } from "@/store";
import { projectNamePrefix } from "@/store/modules/v1/common";
import { getDateForPbTimestamp } from "@/types";
import { AuditData, type AuditLog } from "@/types/proto/v1/audit_log_service";
@@ -89,9 +89,7 @@ const columnList = computed((): AuditDataTableColumn[] => {
width: 128,
title: t("audit-log.table.actor"),
render: (auditLog) => {
- const user = userStore.getUserByEmail(
- extractUserEmail(auditLog.user)
- );
+ const user = userStore.getUserByIdentifier(auditLog.user);
if (!user) {
return <span>-</span>;
}
diff --git a/frontend/src/components/AuditLog/AuditLogSearch/AuditLogSearch.vue b/frontend/src/components/AuditLog/AuditLogSearch/AuditLogSearch.vue
index 42c4a169b2..0564a43059 100644
--- a/frontend/src/components/AuditLog/AuditLogSearch/AuditLogSearch.vue
+++ b/frontend/src/components/AuditLog/AuditLogSearch/AuditLogSearch.vue
@@ -17,6 +17,7 @@
</template>
<script lang="tsx" setup>
+import { computedAsync } from "@vueuse/core";
import { orderBy } from "lodash-es";
import { computed, ref } from "vue";
import { useI18n } from "vue-i18n";
@@ -33,7 +34,10 @@ import { ALL_METHODS_WITH_AUDIT } from "@/grpcweb/methods";
import { useCurrentUserV1, useProjectV1List, useUserStore } from "@/store";
import { SYSTEM_BOT_USER_NAME } from "@/types";
import { AuditLog_Severity } from "@/types/proto/v1/audit_log_service";
+import { State, stateToJSON } from "@/types/proto/v1/common";
+import { UserType, userTypeToJSON } from "@/types/proto/v1/user_service";
import {
+ getDefaultPagination,
extractProjectResourceName,
type SearchParams,
type SearchScope,
@@ -59,10 +63,19 @@ const { projectList } = useProjectV1List();
const showTimeRange = ref(false);
+const activeUserList = computedAsync(async () => {
+ const { users } = await userStore.fetchUserList({
+ pageSize: getDefaultPagination(),
+ showDeleted: false,
+ filter: `state == "${stateToJSON(State.ACTIVE)}" && user_type == "${userTypeToJSON(UserType.USER)}"`,
+ });
+ return users;
+}, []);
+
const principalSearchValueOptions = computed(() => {
// Put "you" to the top
const sortedUsers = orderBy(
- userStore.activeUserList,
+ activeUserList.value,
(user) => (user.name === me.value.name ? -1 : 1),
"asc"
);
diff --git a/frontend/src/components/Changelist/ChangelistDashboard/ChangelistDataTable.vue b/frontend/src/components/Changelist/ChangelistDashboard/ChangelistDataTable.vue
index 61fc615996..d970dccb4a 100644
--- a/frontend/src/components/Changelist/ChangelistDashboard/ChangelistDataTable.vue
+++ b/frontend/src/components/Changelist/ChangelistDashboard/ChangelistDataTable.vue
@@ -25,10 +25,7 @@ import HumanizeDate from "@/components/misc/HumanizeDate.vue";
import { useUserStore } from "@/store";
import { getDateForPbTimestamp } from "@/types";
import type { Changelist } from "@/types/proto/v1/changelist_service";
-import {
- extractUserResourceName,
- extractChangelistResourceName,
-} from "@/utils";
+import { extractChangelistResourceName } from "@/utils";
import { projectForChangelist } from "../ChangelistDetail/common";
type ChangelistDataTableColumn = DataTableColumn<Changelist> & {
@@ -52,6 +49,7 @@ const props = withDefaults(
const { t } = useI18n();
const router = useRouter();
+const userStore = useUserStore();
const columnList = computed((): ChangelistDataTableColumn[] => {
return (
@@ -87,7 +85,7 @@ const columnList = computed((): ChangelistDataTableColumn[] => {
title: t("common.creator"),
width: 256,
render: (changelist) => {
- const creator = getUser(changelist.creator);
+ const creator = userStore.getUserByIdentifier(changelist.creator);
if (!creator) return null;
return (
<div class="flex flex-row items-center overflow-hidden gap-x-1">
@@ -101,11 +99,6 @@ const columnList = computed((): ChangelistDataTableColumn[] => {
).filter((column) => !column.hide);
});
-const getUser = (name: string) => {
- const email = extractUserResourceName(name);
- return useUserStore().getUserByEmail(email);
-};
-
const rowProps = (changelist: Changelist) => {
return {
style: "cursor: pointer;",
diff --git a/frontend/src/components/Changelist/ChangelistDetail/context.ts b/frontend/src/components/Changelist/ChangelistDetail/context.ts
index bb1606edc7..e4a8af9371 100644
--- a/frontend/src/components/Changelist/ChangelistDetail/context.ts
+++ b/frontend/src/components/Changelist/ChangelistDetail/context.ts
@@ -7,6 +7,7 @@ import {
useChangelistStore,
useCurrentUserV1,
useProjectV1Store,
+ extractUserId,
} from "@/store";
import { projectNamePrefix } from "@/store/modules/v1/common";
import type { ComposedProject, Permission } from "@/types";
@@ -16,7 +17,6 @@ import type {
Changelist_Change as Change,
} from "@/types/proto/v1/changelist_service";
import {
- extractUserResourceName,
hasPermissionToCreateChangeDatabaseIssueInProject,
hasProjectPermissionV2,
} from "@/utils";
@@ -84,7 +84,7 @@ export const provideChangelistDetailContext = () => {
const checkPermission = (permission: Permission): boolean => {
return (
hasProjectPermissionV2(project.value, permission) ||
- extractUserResourceName(changelist.value.creator) === me.value.email
+ extractUserId(changelist.value.creator) === me.value.email
);
};
diff --git a/frontend/src/components/Database/DatabaseChangelogPanel.vue b/frontend/src/components/Database/DatabaseChangelogPanel.vue
index 6551853a64..b80505dc66 100644
--- a/frontend/src/components/Database/DatabaseChangelogPanel.vue
+++ b/frontend/src/components/Database/DatabaseChangelogPanel.vue
@@ -77,7 +77,6 @@
<PagedTable
ref="changedlogPagedTable"
:session-key="`bb.paged-changelog-table.${database.name}`"
- :page-size="50"
:fetch-list="fetchChangelogList"
>
<template #table="{ list, loading }">
diff --git a/frontend/src/components/Database/DatabaseRevisionPanel.vue b/frontend/src/components/Database/DatabaseRevisionPanel.vue
index e7ab4b5d37..a7d5c5db26 100644
--- a/frontend/src/components/Database/DatabaseRevisionPanel.vue
+++ b/frontend/src/components/Database/DatabaseRevisionPanel.vue
@@ -3,7 +3,6 @@
<PagedTable
:key="pagedRevisionTableSessionKey"
:session-key="pagedRevisionTableSessionKey"
- :page-size="50"
:fetch-list="fetchRevisionList"
>
<template #table="{ list, loading }">
diff --git a/frontend/src/components/GrantRequestPanel/DatabaseResourceForm/DatabaseResourceSelector.vue b/frontend/src/components/GrantRequestPanel/DatabaseResourceForm/DatabaseResourceSelector.vue
index c5fef67445..7811d7d7fe 100644
--- a/frontend/src/components/GrantRequestPanel/DatabaseResourceForm/DatabaseResourceSelector.vue
+++ b/frontend/src/components/GrantRequestPanel/DatabaseResourceForm/DatabaseResourceSelector.vue
@@ -34,6 +34,7 @@ import {
} from "@/store";
import type { ComposedDatabase, DatabaseResource } from "@/types";
import { DatabaseMetadataView } from "@/types/proto/v1/database_service";
+import { getDefaultPagination } from "@/utils";
import Label from "./Label.vue";
import type { DatabaseTreeOption } from "./common";
import {
@@ -103,7 +104,7 @@ const cascadeLoopTreeNode = (
const fetchDatabaseList = useDebounceFn(async () => {
const { databases } = await databaseStore.fetchDatabases({
- pageSize: 100,
+ pageSize: getDefaultPagination(),
parent: props.projectName,
filter: searchText.value ? `name.matches("${searchText.value}")` : "",
});
diff --git a/frontend/src/components/IssueV1/components/CurrentApproverV1.vue b/frontend/src/components/IssueV1/components/CurrentApproverV1.vue
index cabc406fbd..40acd6e25d 100644
--- a/frontend/src/components/IssueV1/components/CurrentApproverV1.vue
+++ b/frontend/src/components/IssueV1/components/CurrentApproverV1.vue
@@ -21,7 +21,7 @@
<i18n-t
keypath="custom-approval.approval-flow.issue-review.review-sent-back-by"
>
- <template #user>{{ currentStep.approver?.title }}</template>
+ <template #user>{{ approverInCurrentStep?.title }}</template>
</i18n-t>
</template>
</NTooltip>
@@ -39,6 +39,7 @@
</template>
<script lang="ts" setup>
+import { computedAsync } from "@vueuse/core";
import { NTooltip } from "naive-ui";
import { computed } from "vue";
import { toRef } from "vue";
@@ -47,8 +48,9 @@ import {
extractReviewContext,
useWrappedReviewStepsV1,
} from "@/components/IssueV1";
-import { useCurrentUserV1 } from "@/store";
-import type { ComposedIssue } from "@/types";
+import { useCurrentUserV1, useUserStore } from "@/store";
+import { userNamePrefix } from "@/store/modules/v1/common";
+import { type ComposedIssue } from "@/types";
import { IssueStatus } from "@/types/proto/v1/issue_service";
const props = defineProps<{
@@ -58,6 +60,7 @@ const props = defineProps<{
const context = extractReviewContext(toRef(props, "issue"));
const { ready, done } = context;
const me = useCurrentUserV1();
+const userStore = useUserStore();
const wrappedSteps = useWrappedReviewStepsV1(toRef(props, "issue"), context);
@@ -67,14 +70,21 @@ const currentStep = computed(() => {
);
});
-const currentApprover = computed(() => {
+const approverInCurrentStep = computedAsync(() => {
+ if (!currentStep.value?.approver) {
+ return;
+ }
+ return userStore.getOrFetchUserByIdentifier(currentStep.value.approver);
+});
+
+const currentApprover = computedAsync(() => {
if (!currentStep.value) return undefined;
- const myself = currentStep.value.candidates.find(
- (user) => user.name === me.value.name
+ const includeMyself = currentStep.value.candidates.includes(
+ `${userNamePrefix}${me.value.email}`
);
// Show currentUser if currentUser is one of the validate approver candidates.
- if (myself) return myself;
+ if (includeMyself) return me.value;
// Show the first approver candidate otherwise.
- return currentStep.value.candidates[0];
+ return userStore.getOrFetchUserByIdentifier(currentStep.value.candidates[0]);
});
</script>
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Actions/review/IssueReviewButtonGroup.vue b/frontend/src/components/IssueV1/components/HeaderSection/Actions/review/IssueReviewButtonGroup.vue
index 94a7f8dd0a..7e15951073 100644
--- a/frontend/src/components/IssueV1/components/HeaderSection/Actions/review/IssueReviewButtonGroup.vue
+++ b/frontend/src/components/IssueV1/components/HeaderSection/Actions/review/IssueReviewButtonGroup.vue
@@ -30,13 +30,12 @@ import {
taskRolloutActionDisplayName,
useIssueContext,
} from "@/components/IssueV1";
-import { useCurrentUserV1, useAppFeature, extractUserEmail } from "@/store";
+import { useCurrentUserV1, useAppFeature, extractUserId } from "@/store";
import {
IssueStatus,
Issue_Approver_Status,
} from "@/types/proto/v1/issue_service";
import {
- extractUserResourceName,
isDatabaseChangeRelatedIssue,
hasWorkspacePermissionV2,
hasProjectPermissionV2,
@@ -65,7 +64,7 @@ const shouldShowApproveOrReject = computed(() => {
// Hide review actions if self-approval is disabled.
if (
!issue.value.projectEntity.allowSelfApproval &&
- currentUser.value.email === extractUserEmail(issue.value.creator)
+ currentUser.value.email === extractUserId(issue.value.creator)
) {
return false;
}
@@ -89,7 +88,7 @@ const shouldShowReject = computed(() => {
});
const shouldShowReRequestReview = computed(() => {
return (
- extractUserResourceName(issue.value.creator) === currentUser.value.email &&
+ extractUserId(issue.value.creator) === currentUser.value.email &&
status.value === Issue_Approver_Status.REJECTED
);
});
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Actions/rollout/CombinedRolloutButtonGroup.vue b/frontend/src/components/IssueV1/components/HeaderSection/Actions/rollout/CombinedRolloutButtonGroup.vue
index 2771c998a1..21b13504ff 100644
--- a/frontend/src/components/IssueV1/components/HeaderSection/Actions/rollout/CombinedRolloutButtonGroup.vue
+++ b/frontend/src/components/IssueV1/components/HeaderSection/Actions/rollout/CombinedRolloutButtonGroup.vue
@@ -82,17 +82,11 @@ const allowUserToSkipTask = asyncComputed(async () => {
(item) => item.action === "SKIP"
);
if (!skip) return false;
- const allowed = await Promise.all(
- skip.tasks.map((task) =>
- allowUserToApplyTaskRolloutAction(
- issue.value,
- task,
- "SKIP",
- releaserCandidates.value
- )
- )
+ return allowUserToApplyTaskRolloutAction(
+ issue.value,
+ "SKIP",
+ releaserCandidates.value
);
- return allowed.every((allow) => allow);
});
const extraActionList = computed(() => {
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Actions/rollout/RolloutActionButton.vue b/frontend/src/components/IssueV1/components/HeaderSection/Actions/rollout/RolloutActionButton.vue
index b2bd8b1534..7265ecda35 100644
--- a/frontend/src/components/IssueV1/components/HeaderSection/Actions/rollout/RolloutActionButton.vue
+++ b/frontend/src/components/IssueV1/components/HeaderSection/Actions/rollout/RolloutActionButton.vue
@@ -35,7 +35,7 @@ import ErrorList from "@/components/misc/ErrorList.vue";
import { ContextMenuButton } from "@/components/v2";
import { useUserStore } from "@/store";
import { userNamePrefix, roleNamePrefix } from "@/store/modules/v1/common";
-import { displayRoleTitle, extractUserResourceName } from "@/utils";
+import { displayRoleTitle } from "@/utils";
import type { RolloutAction, RolloutButtonAction } from "./common";
const props = defineProps<{
@@ -53,12 +53,11 @@ const { issue, selectedTask, releaserCandidates } = useIssueContext();
const errors = asyncComputed(async () => {
const errors: ErrorItem[] = [];
if (
- !(await allowUserToApplyTaskRolloutAction(
+ !allowUserToApplyTaskRolloutAction(
issue.value,
- selectedTask.value,
props.action,
releaserCandidates.value
- ))
+ )
) {
errors.push(t("issue.error.you-are-not-allowed-to-perform-this-action"));
const { releasers } = issue.value;
@@ -71,8 +70,8 @@ const errors = asyncComputed(async () => {
});
}
if (roleOrUser.startsWith(userNamePrefix)) {
- const email = extractUserResourceName(roleOrUser);
- const user = useUserStore().getUserByEmail(email);
+ const user =
+ await useUserStore().getOrFetchUserByIdentifier(roleOrUser);
if (user) {
errors.push({
error: `${user.title} (${user.email})`,
diff --git a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentList.vue b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentList.vue
index 44c93b9a5e..ac2eca1662 100644
--- a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentList.vue
+++ b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentList.vue
@@ -118,11 +118,12 @@ import {
useIssueCommentStore,
useIssueV1Store,
type ComposedIssueComment,
+ extractUserId,
} from "@/store";
import { isValidProjectName } from "@/types";
import type { ComposedIssue } from "@/types";
import { ListIssueCommentsRequest } from "@/types/proto/v1/issue_service";
-import { extractUserResourceName, hasProjectPermissionV2 } from "@/utils";
+import { hasProjectPermissionV2 } from "@/utils";
import { useIssueContext } from "../../logic";
import {
IssueCommentView,
@@ -226,7 +227,7 @@ const allowEditIssueComment = (comment: ComposedIssueComment) => {
if (!isUserEditableComment(comment)) {
return false;
}
- if (currentUser.value.email === extractUserResourceName(comment.creator)) {
+ if (currentUser.value.email === extractUserId(comment.creator)) {
return true;
}
return hasProjectPermissionV2(
diff --git a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/ActionCreator.vue b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/ActionCreator.vue
index 4710ed9ced..68fe504873 100644
--- a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/ActionCreator.vue
+++ b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/ActionCreator.vue
@@ -17,10 +17,10 @@
</template>
<script lang="ts" setup>
+import { computedAsync } from "@vueuse/core";
import { computed } from "vue";
import SystemBotTag from "@/components/misc/SystemBotTag.vue";
-import { useAppFeature, useUserStore } from "@/store";
-import { extractUserResourceName } from "@/utils";
+import { useAppFeature, useUserStore, extractUserId } from "@/store";
const props = defineProps<{
// Format: users/{email}
@@ -33,11 +33,11 @@ const disallowNavigateToConsole = useAppFeature(
);
const userEmail = computed(() => {
- return extractUserResourceName(props.creator);
+ return extractUserId(props.creator);
});
-const user = computed(() => {
- return userStore.getUserByEmail(userEmail.value);
+const user = computedAsync(() => {
+ return userStore.getOrFetchUserByIdentifier(props.creator);
});
const bindings = computed(() => {
diff --git a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/ActionIcon.vue b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/ActionIcon.vue
index ecd4998250..5066d31517 100644
--- a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/ActionIcon.vue
+++ b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/ActionIcon.vue
@@ -102,6 +102,7 @@
</template>
<script lang="ts" setup>
+import { computedAsync } from "@vueuse/core";
import { computed } from "vue";
import { SkipIcon } from "@/components/Icon";
import PrincipalAvatar from "@/components/PrincipalAvatar.vue";
@@ -110,6 +111,7 @@ import {
useUserStore,
type ComposedIssueComment,
} from "@/store";
+import { extractUserId } from "@/store";
import {
IssueComment_Approval,
IssueComment_Approval_Status,
@@ -118,7 +120,6 @@ import {
IssueComment_TaskUpdate,
IssueComment_TaskUpdate_Status,
} from "@/types/proto/v1/issue_service";
-import { extractUserResourceName } from "@/utils";
type ActionIconType =
| "avatar"
@@ -142,9 +143,8 @@ const props = defineProps<{
const userStore = useUserStore();
-const user = computed(() => {
- const email = extractUserResourceName(props.issueComment.creator);
- return userStore.getUserByEmail(email);
+const user = computedAsync(() => {
+ return userStore.getOrFetchUserByIdentifier(props.issueComment.creator);
});
const icon = computed((): ActionIconType => {
@@ -220,8 +220,7 @@ const icon = computed((): ActionIconType => {
}
}
- return extractUserResourceName(issueComment.creator) ==
- userStore.systemBotUser?.email
+ return extractUserId(issueComment.creator) == userStore.systemBotUser?.email
? "system"
: "avatar";
});
diff --git a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/ActionSentence.vue b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/ActionSentence.vue
index 57e45b2fa4..e85b533683 100644
--- a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/ActionSentence.vue
+++ b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/ActionSentence.vue
@@ -12,6 +12,7 @@ import {
IssueCommentType,
type ComposedIssueComment,
} from "@/store";
+import { extractUserId } from "@/store";
import { getDateForPbTimestamp, type ComposedIssue } from "@/types";
import {
IssueComment_Approval,
@@ -24,7 +25,6 @@ import {
IssueStatus,
} from "@/types/proto/v1/issue_service";
import { findStageByName, findTaskByName } from "@/utils";
-import { extractUserResourceName } from "@/utils";
import StageName from "./StageName.vue";
import StatementUpdate from "./StatementUpdate.vue";
import TaskName from "./TaskName.vue";
@@ -222,17 +222,14 @@ const renderActionSentence = () => {
}
return renderVerbTypeTarget(params);
}
- return t("activity.sentence.empty");
+ return "";
};
const maybeAutomaticallyVerb = (
issueComment: ComposedIssueComment,
verb: string
): string => {
- if (
- extractUserResourceName(issueComment.creator) !==
- userStore.systemBotUser?.email
- ) {
+ if (extractUserId(issueComment.creator) !== userStore.systemBotUser?.email) {
return verb;
}
return t("activity.sentence.xxx-automatically", {
@@ -249,7 +246,7 @@ type VerbTypeTarget = {
const renderVerbTypeTarget = (params: VerbTypeTarget, props: object = {}) => {
const keypath =
- extractUserResourceName(params.issueComment.creator) ===
+ extractUserId(params.issueComment.creator) ===
userStore.systemBotUser?.email
? "dynamic.activity.sentence.verb-type-target-by-system-bot"
: "dynamic.activity.sentence.verb-type-target-by-people";
diff --git a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCommentAction.vue b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCommentAction.vue
index 9670afeaae..c78bce77b8 100644
--- a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCommentAction.vue
+++ b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCommentAction.vue
@@ -4,7 +4,7 @@
<div class="text-sm text-control-light space-x-1">
<ActionCreator
v-if="
- extractUserResourceName(issueComment.creator) !==
+ extractUserId(issueComment.creator) !==
userStore.systemBotUser?.email ||
issueComment.type === IssueCommentType.USER_COMMENT
"
@@ -55,9 +55,8 @@
<script lang="ts" setup>
import HumanizeTs from "@/components/misc/HumanizeTs.vue";
import { IssueCommentType, type ComposedIssueComment } from "@/store";
-import { useUserStore } from "@/store";
+import { useUserStore, extractUserId } from "@/store";
import { getTimeForPbTimestamp, type ComposedIssue } from "@/types";
-import { extractUserResourceName } from "@/utils";
import ActionCreator from "./ActionCreator.vue";
import ActionSentence from "./ActionSentence.vue";
diff --git a/frontend/src/components/IssueV1/components/IssueCommentSection/Subscribers/SubscriberList.vue b/frontend/src/components/IssueV1/components/IssueCommentSection/Subscribers/SubscriberList.vue
index 5448ddd7e3..86bf6acb96 100644
--- a/frontend/src/components/IssueV1/components/IssueCommentSection/Subscribers/SubscriberList.vue
+++ b/frontend/src/components/IssueV1/components/IssueCommentSection/Subscribers/SubscriberList.vue
@@ -1,13 +1,17 @@
<template>
<NPopselect
+ :remote="true"
+ :loading="state.loading"
:multiple="true"
:value="issue.subscribers"
:options="options"
:render-label="renderLabel"
:scrollable="true"
+ :filterable="true"
trigger="click"
placement="left"
:disabled="readonly"
+ @search="handleSearch"
@update:show="onUpdateShow"
@update:value="onUpdateSubscribers"
>
@@ -35,17 +39,18 @@
</template>
<script setup lang="ts">
+import { useDebounceFn } from "@vueuse/core";
import type { SelectOption, SelectGroupOption } from "naive-ui";
import { NButton, NPopselect, NInput } from "naive-ui";
-import { computed, h, nextTick, ref } from "vue";
+import { computed, h, nextTick, ref, onMounted, reactive } from "vue";
import { updateIssueSubscribers, useIssueContext } from "@/components/IssueV1";
import UserAvatar from "@/components/User/UserAvatar.vue";
import { useUserStore } from "@/store";
import { unknownUser } from "@/types";
+import { State, stateToJSON } from "@/types/proto/v1/common";
import { type User } from "@/types/proto/v1/user_service";
-import { UserType } from "@/types/proto/v1/user_service";
-import { State } from "@/types/proto/v1/common";
-import { extractUserResourceName } from "@/utils";
+import { UserType, userTypeToJSON } from "@/types/proto/v1/user_service";
+import { getDefaultPagination } from "@/utils";
import SubscriberListItem from "./SubscriberListItem.vue";
defineProps<{
@@ -57,6 +62,16 @@ type UserSelectOption = SelectOption & {
value: string;
};
+interface LocalState {
+ loading: boolean;
+ rawUserList: User[];
+}
+
+const state = reactive<LocalState>({
+ loading: false,
+ rawUserList: [],
+});
+
const userStore = useUserStore();
const { issue } = useIssueContext();
const keyword = ref("");
@@ -64,14 +79,13 @@ const filterInputRef = ref<InstanceType<typeof NInput>>();
const subscriberList = computed(() => {
return issue.value.subscribers.map((subscriber) => {
- const email = extractUserResourceName(subscriber);
- return userStore.getUserByEmail(email) ?? unknownUser();
+ return userStore.getUserByIdentifier(subscriber) ?? unknownUser();
});
});
const options = computed(() => {
const subscribers = new Set(issue.value.subscribers);
- const options = userStore.userList
+ const options = state.rawUserList
.filter(
(user) => user.userType === UserType.USER && user.state === State.ACTIVE
)
@@ -141,4 +155,33 @@ const onUpdateShow = (show: boolean) => {
});
}
};
+
+// TODO(ed): I found the NPopselect NOT support search.
+// We need to use the NSelector instead.
+const handleSearch = useDebounceFn(async (search: string) => {
+ const filter = [
+ `state == "${stateToJSON(State.ACTIVE)}"`,
+ `user_type == "${userTypeToJSON(UserType.USER)}"`,
+ ];
+ if (search) {
+ filter.push(`(name.matches("${search}") || email.matches("${search}"))`);
+ }
+
+ state.loading = true;
+
+ try {
+ const { users } = await userStore.fetchUserList({
+ filter: filter.join(" && "),
+ pageSize: getDefaultPagination(),
+ showDeleted: false,
+ });
+ state.rawUserList = users;
+ } finally {
+ state.loading = false;
+ }
+});
+
+onMounted(async () => {
+ await handleSearch("");
+});
</script>
diff --git a/frontend/src/components/IssueV1/components/IssueCommentSection/Subscribers/Subscribers.vue b/frontend/src/components/IssueV1/components/IssueCommentSection/Subscribers/Subscribers.vue
index 9c033e1662..47269ce27d 100644
--- a/frontend/src/components/IssueV1/components/IssueCommentSection/Subscribers/Subscribers.vue
+++ b/frontend/src/components/IssueV1/components/IssueCommentSection/Subscribers/Subscribers.vue
@@ -8,8 +8,8 @@
<script setup lang="ts">
import { computed } from "vue";
import { useIssueContext } from "@/components/IssueV1/logic";
-import { useCurrentUserV1 } from "@/store";
-import { extractUserResourceName, hasProjectPermissionV2 } from "@/utils";
+import { useCurrentUserV1, extractUserId } from "@/store";
+import { hasProjectPermissionV2 } from "@/utils";
import SubscribeButton from "./SubscribeButton.vue";
import SubscriberList from "./SubscriberList.vue";
@@ -17,9 +17,7 @@ const { issue } = useIssueContext();
const currentUser = useCurrentUserV1();
const allowSubscribe = computed(() => {
- if (
- extractUserResourceName(issue.value.creator) === currentUser.value.email
- ) {
+ if (extractUserId(issue.value.creator) === currentUser.value.email) {
// Allowed if current user is the creator.
return true;
}
diff --git a/frontend/src/components/IssueV1/components/IssueSearch/IssueSearch.vue b/frontend/src/components/IssueV1/components/IssueSearch/IssueSearch.vue
index 2cdc59b3d6..43e9c5fc35 100644
--- a/frontend/src/components/IssueV1/components/IssueSearch/IssueSearch.vue
+++ b/frontend/src/components/IssueV1/components/IssueSearch/IssueSearch.vue
@@ -40,11 +40,19 @@
</template>
<script lang="ts" setup>
+import { computedAsync } from "@vueuse/core";
import { ref, computed } from "vue";
import AdvancedSearch from "@/components/AdvancedSearch";
import TimeRange from "@/components/AdvancedSearch/TimeRange.vue";
+import { useUserStore } from "@/store";
+import { State, stateToJSON } from "@/types/proto/v1/common";
+import { UserType, userTypeToJSON } from "@/types/proto/v1/user_service";
import type { SearchParams, SearchScope, SearchScopeId } from "@/utils";
-import { UIIssueFilterScopeIdList, useSearchScopeIdList } from "@/utils";
+import {
+ getDefaultPagination,
+ UIIssueFilterScopeIdList,
+ useSearchScopeIdList,
+} from "@/utils";
import Status from "./Status.vue";
import { useIssueSearchScopeOptions } from "./useIssueSearchScopeOptions";
@@ -72,6 +80,7 @@ defineEmits<{
const SearchScopeIdList = useSearchScopeIdList();
const showTimeRange = ref(false);
+const userStore = useUserStore();
const allowedScopes = computed(() => {
if (props.overrideScopeIdList && props.overrideScopeIdList.length > 0) {
@@ -80,8 +89,18 @@ const allowedScopes = computed(() => {
return [...UIIssueFilterScopeIdList, ...SearchScopeIdList.value];
});
+const activeUserList = computedAsync(async () => {
+ const { users } = await userStore.fetchUserList({
+ pageSize: getDefaultPagination(),
+ showDeleted: false,
+ filter: `state == "${stateToJSON(State.ACTIVE)}" && user_type == "${userTypeToJSON(UserType.USER)}"`,
+ });
+ return users;
+}, []);
+
const scopeOptions = useIssueSearchScopeOptions(
computed(() => props.params),
- allowedScopes
+ allowedScopes,
+ activeUserList
);
</script>
diff --git a/frontend/src/components/IssueV1/components/IssueSearch/useIssueSearchScopeOptions.ts b/frontend/src/components/IssueV1/components/IssueSearch/useIssueSearchScopeOptions.ts
index aa9ac6d1c7..a3f01e3d04 100644
--- a/frontend/src/components/IssueV1/components/IssueSearch/useIssueSearchScopeOptions.ts
+++ b/frontend/src/components/IssueV1/components/IssueSearch/useIssueSearchScopeOptions.ts
@@ -9,11 +9,11 @@ import YouTag from "@/components/misc/YouTag.vue";
import {
useCurrentUserV1,
useDatabaseV1Store,
- useUserStore,
useProjectV1List,
} from "@/store";
import { SYSTEM_BOT_USER_NAME, UNKNOWN_ID } from "@/types";
import { Label } from "@/types/proto/v1/project_service";
+import { User } from "@/types/proto/v1/user_service";
import type { SearchParams, SearchScopeId } from "@/utils";
export type ScopeOption = {
@@ -52,11 +52,11 @@ const useProjectLabels = (params: Ref<SearchParams>) => {
export const useIssueSearchScopeOptions = (
params: Ref<SearchParams>,
- supportOptionIdList: Ref<SearchScopeId[]>
+ supportOptionIdList: Ref<SearchScopeId[]>,
+ activeUserList: Ref<User[]>
) => {
const { t } = useI18n();
const me = useCurrentUserV1();
- const userStore = useUserStore();
const databaseV1Store = useDatabaseV1Store();
const commonScopeOptions = useCommonSearchScopeOptions(
@@ -67,7 +67,7 @@ export const useIssueSearchScopeOptions = (
const principalSearchValueOptions = computed(() => {
// Put "you" to the top
const sortedUsers = orderBy(
- userStore.activeUserList,
+ activeUserList.value,
(user) => (user.name === me.value.name ? -1 : 1),
"asc"
);
diff --git a/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckSection.vue b/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckSection.vue
index 99ccf4d0fe..dcc77f7edf 100644
--- a/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckSection.vue
+++ b/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckSection.vue
@@ -18,12 +18,8 @@ import {
useIssueContext,
} from "@/components/IssueV1/logic";
import PlanCheckRunBar from "@/components/PlanCheckRun/PlanCheckRunBar.vue";
-import { useCurrentUserV1 } from "@/store";
-import {
- extractUserResourceName,
- hasProjectPermissionV2,
- isValidTaskName,
-} from "@/utils";
+import { useCurrentUserV1, extractUserId } from "@/store";
+import { hasProjectPermissionV2, isValidTaskName } from "@/utils";
const currentUser = useCurrentUserV1();
const { issue, selectedTask, getPlanCheckRunsForTask } = useIssueContext();
@@ -45,7 +41,7 @@ const allowRunChecks = computed(() => {
// - the creator of the issue
// - ones who have bb.planCheckRuns.run permission in the project
const me = currentUser.value;
- if (extractUserResourceName(issue.value.creator) === me.email) {
+ if (extractUserId(issue.value.creator) === me.email) {
return true;
}
if (
diff --git a/frontend/src/components/IssueV1/components/Sidebar/EarliestAllowedTime.vue b/frontend/src/components/IssueV1/components/Sidebar/EarliestAllowedTime.vue
index 9c83ba6739..a1fddf3b6e 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/EarliestAllowedTime.vue
+++ b/frontend/src/components/IssueV1/components/Sidebar/EarliestAllowedTime.vue
@@ -70,7 +70,12 @@ import {
import ErrorList from "@/components/misc/ErrorList.vue";
import { planServiceClient } from "@/grpcweb";
import { emitWindowEvent } from "@/plugins";
-import { hasFeature, pushNotification, useCurrentUserV1 } from "@/store";
+import {
+ hasFeature,
+ pushNotification,
+ useCurrentUserV1,
+ extractUserId,
+} from "@/store";
import { getTimeForPbTimestamp } from "@/types";
import { Timestamp } from "@/types/proto/google/protobuf/timestamp";
import { IssueStatus } from "@/types/proto/v1/issue_service";
@@ -83,7 +88,6 @@ import {
} from "@/types/proto/v1/rollout_service";
import {
defer,
- extractUserResourceName,
flattenTaskV1List,
hasProjectPermissionV2,
isDatabaseChangeRelatedIssue,
@@ -132,9 +136,7 @@ const disallowEditReasons = computed(() => {
let allow = false;
// Issue creator is allowed to change the rollout time.
- if (
- extractUserResourceName(issue.value.creator) === currentUser.value.email
- ) {
+ if (extractUserId(issue.value.creator) === currentUser.value.email) {
allow = true;
}
if (hasProjectPermissionV2(issue.value.projectEntity, "bb.plans.update")) {
diff --git a/frontend/src/components/IssueV1/components/Sidebar/GhostSection/common.ts b/frontend/src/components/IssueV1/components/Sidebar/GhostSection/common.ts
index d007ffe12b..96f23b18f6 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/GhostSection/common.ts
+++ b/frontend/src/components/IssueV1/components/Sidebar/GhostSection/common.ts
@@ -15,6 +15,7 @@ import {
useCurrentUserV1,
useStorageStore,
useSubscriptionV1Store,
+ extractUserId,
} from "@/store";
import type { ComposedDatabase, ComposedIssue } from "@/types";
import { Engine } from "@/types/proto/v1/common";
@@ -29,7 +30,6 @@ import {
task_StatusToJSON,
} from "@/types/proto/v1/rollout_service";
import {
- extractUserResourceName,
flattenTaskV1List,
getSheetStatement,
hasProjectPermissionV2,
@@ -85,7 +85,7 @@ export const provideIssueGhostContext = () => {
const errors: string[] = [];
- if (extractUserResourceName(issue.value.creator) !== me.value.email) {
+ if (extractUserId(issue.value.creator) !== me.value.email) {
if (
!hasProjectPermissionV2(issue.value.projectEntity, "bb.plans.update")
) {
diff --git a/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/common.ts b/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/common.ts
index 6a14ac1edb..e5ba382294 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/common.ts
+++ b/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/common.ts
@@ -13,6 +13,7 @@ import {
pushNotification,
useCurrentUserV1,
useIssueCommentStore,
+ extractUserId,
} from "@/store";
import { Engine } from "@/types/proto/v1/common";
import {
@@ -20,11 +21,7 @@ import {
Task_Type,
TaskRun_Status,
} from "@/types/proto/v1/rollout_service";
-import {
- extractUserResourceName,
- hasProjectPermissionV2,
- isDatabaseChangeRelatedIssue,
-} from "@/utils";
+import { hasProjectPermissionV2, isDatabaseChangeRelatedIssue } from "@/utils";
const PRE_BACKUP_AVAILABLE_ENGINES = [
Engine.MYSQL,
@@ -34,7 +31,12 @@ const PRE_BACKUP_AVAILABLE_ENGINES = [
Engine.POSTGRES,
];
-const ROLLBACK_AVAILABLE_ENGINES = [Engine.MYSQL, Engine.POSTGRES, Engine.MSSQL, Engine.ORACLE];
+const ROLLBACK_AVAILABLE_ENGINES = [
+ Engine.MYSQL,
+ Engine.POSTGRES,
+ Engine.MSSQL,
+ Engine.ORACLE,
+];
export const usePreBackupContext = () => {
const { t } = useI18n();
@@ -86,9 +88,7 @@ export const usePreBackupContext = () => {
}
// Allowed to the issue creator.
- if (
- currentUserV1.value.email === extractUserResourceName(issue.value.creator)
- ) {
+ if (currentUserV1.value.email === extractUserId(issue.value.creator)) {
return true;
}
diff --git a/frontend/src/components/IssueV1/components/Sidebar/ReviewSection/Approver.vue b/frontend/src/components/IssueV1/components/Sidebar/ReviewSection/Approver.vue
index f71f7325f1..b166b48735 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/ReviewSection/Approver.vue
+++ b/frontend/src/components/IssueV1/components/Sidebar/ReviewSection/Approver.vue
@@ -1,32 +1,42 @@
<template>
- <div :class="step.approver?.name === currentUser.name && 'font-bold'">
- <slot name="title" :approver="step.approver">
+ <div :class="approver?.name === currentUser.name && 'font-bold'">
+ <slot name="title" :approver="approver">
<span class="truncate">
<NPerformantEllipsis>
- {{ step.approver?.title }}
+ {{ approver?.title }}
</NPerformantEllipsis>
</span>
</slot>
<span
- v-if="step.approver?.name === currentUser.name"
+ v-if="approver?.name === currentUser.name"
class="ml-1 px-1 py-0.5 rounded-lg text-xs font-semibold bg-green-100 text-green-800"
>
{{ $t("custom-approval.issue-review.you") }}
</span>
- <SystemBotTag v-if="step.approver?.name === SYSTEM_BOT_USER_NAME" />
+ <SystemBotTag v-if="approver?.name === SYSTEM_BOT_USER_NAME" />
</div>
</template>
<script setup lang="ts">
+import { computedAsync } from "@vueuse/core";
import { NPerformantEllipsis } from "naive-ui";
import SystemBotTag from "@/components/misc/SystemBotTag.vue";
-import { useCurrentUserV1 } from "@/store";
+import { useCurrentUserV1, useUserStore } from "@/store";
import type { WrappedReviewStep } from "@/types";
import { SYSTEM_BOT_USER_NAME } from "@/types";
const currentUser = useCurrentUserV1();
+const userStore = useUserStore();
-defineProps<{
+const props = defineProps<{
step: WrappedReviewStep;
}>();
+
+const approver = computedAsync(async () => {
+ if (!props.step.approver) {
+ return;
+ }
+ const user = await userStore.getOrFetchUserByIdentifier(props.step.approver);
+ return user;
+});
</script>
diff --git a/frontend/src/components/IssueV1/components/Sidebar/ReviewSection/Candidate.vue b/frontend/src/components/IssueV1/components/Sidebar/ReviewSection/Candidate.vue
new file mode 100644
index 0000000000..0fe6ed004b
--- /dev/null
+++ b/frontend/src/components/IssueV1/components/Sidebar/ReviewSection/Candidate.vue
@@ -0,0 +1,43 @@
+<template>
+ <div
+ v-if="candidateUser"
+ class="flex items-center py-1 gap-x-1"
+ :class="[candidateUser.name === currentUser.name && 'font-bold']"
+ >
+ <PrincipalAvatar :user="candidateUser" size="SMALL" />
+ <span class="whitespace-nowrap">{{ candidateUser.title }}</span>
+ <span
+ v-if="currentUser.name === candidateUser.name"
+ class="inline-flex items-center px-1 py-0.5 rounded-lg text-xs font-semibold bg-green-100 text-green-800"
+ >
+ {{ $t("custom-approval.issue-review.you") }}
+ </span>
+ </div>
+</template>
+
+<script lang="tsx" setup>
+import { computedAsync } from "@vueuse/core";
+import PrincipalAvatar from "@/components/PrincipalAvatar.vue";
+import { useCurrentUserV1, useUserStore } from "@/store";
+import { State } from "@/types/proto/v1/common";
+import { UserType } from "@/types/proto/v1/user_service";
+
+const props = defineProps<{
+ // candidate in users/{email} format.
+ candidate: string;
+}>();
+
+const currentUser = useCurrentUserV1();
+const userStore = useUserStore();
+
+const candidateUser = computedAsync(async () => {
+ const user = await userStore.getOrFetchUserByIdentifier(props.candidate);
+ if (!user) {
+ return;
+ }
+ if (user.userType !== UserType.USER || user.state !== State.ACTIVE) {
+ return;
+ }
+ return user;
+});
+</script>
diff --git a/frontend/src/components/IssueV1/components/Sidebar/ReviewSection/Candidates.vue b/frontend/src/components/IssueV1/components/Sidebar/ReviewSection/Candidates.vue
deleted file mode 100644
index c7e4359739..0000000000
--- a/frontend/src/components/IssueV1/components/Sidebar/ReviewSection/Candidates.vue
+++ /dev/null
@@ -1,45 +0,0 @@
-<template>
- <div
- v-if="candidates.length === 0"
- class="w-[14rem] text-wrap text-warning italic"
- >
- {{ $t("custom-approval.issue-review.no-one-matched") }}
- </div>
-
- <div
- v-else
- class="min-w-[8rem] max-w-[12rem] max-h-[18rem] flex flex-col text-control-light overflow-y-hidden"
- >
- <div class="flex-1 overflow-auto text-sm">
- <div
- v-for="user in candidates"
- :key="user.name"
- class="flex items-center py-1 gap-x-1"
- :class="[user.name === currentUser.name && 'font-bold']"
- >
- <PrincipalAvatar :user="user" size="SMALL" />
- <span class="whitespace-nowrap">{{ user.title }}</span>
- <span
- v-if="currentUser.name === user.name"
- class="inline-flex items-center px-1 py-0.5 rounded-lg text-xs font-semibold bg-green-100 text-green-800"
- >
- {{ $t("custom-approval.issue-review.you") }}
- </span>
- </div>
- </div>
- </div>
-</template>
-
-<script lang="ts" setup>
-import { computed } from "vue";
-import PrincipalAvatar from "@/components/PrincipalAvatar.vue";
-import { useCurrentUserV1 } from "@/store";
-import type { WrappedReviewStep } from "@/types";
-
-const props = defineProps<{
- step: WrappedReviewStep;
-}>();
-
-const currentUser = useCurrentUserV1();
-const candidates = computed(() => props.step.candidates);
-</script>
diff --git a/frontend/src/components/IssueV1/components/Sidebar/ReviewSection/Timeline.vue b/frontend/src/components/IssueV1/components/Sidebar/ReviewSection/Timeline.vue
index d128db7e2e..7ee4cdffd5 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/ReviewSection/Timeline.vue
+++ b/frontend/src/components/IssueV1/components/Sidebar/ReviewSection/Timeline.vue
@@ -71,7 +71,24 @@
</li>
</ul>
<hr />
- <Candidates :step="step" />
+ <div
+ v-if="step.candidates.length === 0"
+ class="w-[14rem] text-wrap text-warning italic"
+ >
+ {{ $t("custom-approval.issue-review.no-one-matched") }}
+ </div>
+ <div
+ v-else
+ class="min-w-[8rem] max-w-[12rem] max-h-[18rem] flex flex-col text-control-light overflow-y-hidden"
+ >
+ <div class="flex-1 overflow-auto text-sm">
+ <Candidate
+ v-for="candidate in step.candidates"
+ :key="candidate"
+ :candidate="candidate"
+ />
+ </div>
+ </div>
</div>
</template>
</NPopover>
@@ -90,7 +107,7 @@ import type { WrappedReviewStep } from "@/types";
import { type User } from "@/types/proto/v1/user_service";
import { approvalNodeText } from "@/utils";
import Approver from "./Approver.vue";
-import Candidates from "./Candidates.vue";
+import Candidate from "./Candidate.vue";
import TimelineIcon from "./TimelineIcon.vue";
defineProps<{
diff --git a/frontend/src/components/IssueV1/components/TaskListSection/TaskExtraActionsButton.vue b/frontend/src/components/IssueV1/components/TaskListSection/TaskExtraActionsButton.vue
index cf54d2bec0..176acb296a 100644
--- a/frontend/src/components/IssueV1/components/TaskListSection/TaskExtraActionsButton.vue
+++ b/frontend/src/components/IssueV1/components/TaskListSection/TaskExtraActionsButton.vue
@@ -21,7 +21,6 @@
</template>
<script setup lang="ts">
-import { asyncComputed } from "@vueuse/core";
import type { DropdownOption } from "naive-ui";
import { NDropdown, NButton } from "naive-ui";
import type { VNode } from "vue";
@@ -57,10 +56,9 @@ const actionList = computed(() => {
);
});
-const allowUserToSkipTask = asyncComputed(() => {
+const allowUserToSkipTask = computed(() => {
return allowUserToApplyTaskRolloutAction(
issue.value,
- props.task,
"SKIP",
releaserCandidates.value
);
diff --git a/frontend/src/components/IssueV1/logic/action/issue.ts b/frontend/src/components/IssueV1/logic/action/issue.ts
index 6f052e4dd2..e6c8ff8e31 100644
--- a/frontend/src/components/IssueV1/logic/action/issue.ts
+++ b/frontend/src/components/IssueV1/logic/action/issue.ts
@@ -1,6 +1,6 @@
import type { ButtonProps } from "naive-ui";
import { t } from "@/plugins/i18n";
-import { useCurrentUserV1 } from "@/store";
+import { useCurrentUserV1, extractUserId } from "@/store";
import type { ComposedIssue } from "@/types";
import {
IssueStatus,
@@ -8,7 +8,6 @@ import {
} from "@/types/proto/v1/issue_service";
import { Task_Status } from "@/types/proto/v1/rollout_service";
import {
- extractUserResourceName,
flattenTaskV1List,
hasProjectPermissionV2,
isDatabaseChangeRelatedIssue,
@@ -118,7 +117,7 @@ export const allowUserToApplyIssueStatusAction = (
// User does not have permission to update the issue and is not the creator of the issue.
if (
!hasProjectPermissionV2(issue.projectEntity, "bb.issues.update") &&
- extractUserResourceName(issue.creator) !== user.value.email
+ extractUserId(issue.creator) !== user.value.email
) {
return [false, t("issue.error.you-don-have-privilege-to-edit-this-issue")];
}
diff --git a/frontend/src/components/IssueV1/logic/action/review.ts b/frontend/src/components/IssueV1/logic/action/review.ts
index 3f4e948f03..08c90763c0 100644
--- a/frontend/src/components/IssueV1/logic/action/review.ts
+++ b/frontend/src/components/IssueV1/logic/action/review.ts
@@ -1,12 +1,16 @@
import type { ButtonProps } from "naive-ui";
import { t } from "@/plugins/i18n";
-import { candidatesOfApprovalStepV1, useCurrentUserV1 } from "@/store";
+import {
+ candidatesOfApprovalStepV1,
+ useCurrentUserV1,
+ extractUserId,
+} from "@/store";
import type { ComposedIssue } from "@/types";
import {
IssueStatus,
Issue_Approver_Status,
} from "@/types/proto/v1/issue_service";
-import { extractUserResourceName } from "@/utils";
+import { isUserIncludedInList } from "@/utils";
import type { ReviewContext } from "../context";
export type IssueReviewAction = "APPROVE" | "SEND_BACK" | "RE_REQUEST";
@@ -79,9 +83,9 @@ export const allowUserToApplyReviewAction = (
const step = steps[index];
if (!step) return false;
const candidates = candidatesOfApprovalStepV1(issue, step);
- return candidates.includes(me.value.name);
+ return isUserIncludedInList(me.value.email, candidates);
}
// action === 'RE_REQUEST'
- return me.value.email === extractUserResourceName(issue.creator);
+ return me.value.email === extractUserId(issue.creator);
};
diff --git a/frontend/src/components/IssueV1/logic/action/task.ts b/frontend/src/components/IssueV1/logic/action/task.ts
index 99db2facca..8ae1e628d2 100644
--- a/frontend/src/components/IssueV1/logic/action/task.ts
+++ b/frontend/src/components/IssueV1/logic/action/task.ts
@@ -7,8 +7,11 @@ import type { ComposedIssue } from "@/types";
import { IssueStatus, Issue_Type } from "@/types/proto/v1/issue_service";
import type { Task } from "@/types/proto/v1/rollout_service";
import { Task_Status, Task_Type } from "@/types/proto/v1/rollout_service";
-import { type User } from "@/types/proto/v1/user_service";
-import { hasProjectPermissionV2, hasWorkspacePermissionV2 } from "@/utils";
+import {
+ hasProjectPermissionV2,
+ hasWorkspacePermissionV2,
+ isUserIncludedInList,
+} from "@/utils";
export type TaskRolloutAction =
| "ROLLOUT" // NOT_STARTED -> PENDING
@@ -128,9 +131,8 @@ export const taskRolloutActionButtonProps = (
export const allowUserToApplyTaskRolloutAction = (
issue: ComposedIssue,
- task: Task,
action: TaskRolloutAction,
- releaserCandidates: User[]
+ releaserCandidates: string[]
) => {
const me = useCurrentUserV1();
// For data export issues, only the creator can take actions.
@@ -146,7 +148,5 @@ export const allowUserToApplyTaskRolloutAction = (
return true;
}
- return releaserCandidates.some(
- (candidate) => candidate.name === me.value.name
- );
+ return isUserIncludedInList(me.value.email, releaserCandidates);
};
diff --git a/frontend/src/components/IssueV1/logic/context.ts b/frontend/src/components/IssueV1/logic/context.ts
index 0cb63702ef..769a67ff38 100644
--- a/frontend/src/components/IssueV1/logic/context.ts
+++ b/frontend/src/components/IssueV1/logic/context.ts
@@ -4,7 +4,6 @@ import { v4 as uuidv4 } from "uuid";
import type { InjectionKey, Ref, ComputedRef } from "vue";
import { inject, provide } from "vue";
import type { ComposedIssue, ReviewFlow } from "@/types";
-import { type User } from "@/types/proto/v1/user_service";
import type { Issue_Approver_Status } from "@/types/proto/v1/issue_service";
import type { PlanCheckRun } from "@/types/proto/v1/plan_service";
import type { Stage, Task } from "@/types/proto/v1/rollout_service";
@@ -47,7 +46,8 @@ export type IssueContext = {
issue: Ref<ComposedIssue>;
phase: Ref<IssuePhase>;
isLegacyIssue: Ref<boolean>;
- releaserCandidates: Ref<User[]>;
+ // users in users/{email} format.
+ releaserCandidates: Ref<string[]>;
allowEditIssue: ComputedRef<boolean>;
// review status
diff --git a/frontend/src/components/IssueV1/logic/initialize/index.ts b/frontend/src/components/IssueV1/logic/initialize/index.ts
index 6e835e2112..fc689435f2 100644
--- a/frontend/src/components/IssueV1/logic/initialize/index.ts
+++ b/frontend/src/components/IssueV1/logic/initialize/index.ts
@@ -2,15 +2,15 @@ import type { MaybeRef } from "vue";
import { computed, ref, unref, watch } from "vue";
import type { LocationQuery } from "vue-router";
import { useRoute, useRouter } from "vue-router";
-import { experimentalFetchIssueByUID, useCurrentUserV1 } from "@/store";
+import {
+ experimentalFetchIssueByUID,
+ useCurrentUserV1,
+ extractUserId,
+} from "@/store";
import type { ComposedIssue } from "@/types";
import { emptyIssue, EMPTY_ID, UNKNOWN_ID } from "@/types";
import { IssueStatus } from "@/types/proto/v1/issue_service";
-import {
- uidFromSlug,
- hasProjectPermissionV2,
- extractUserResourceName,
-} from "@/utils";
+import { uidFromSlug, hasProjectPermissionV2 } from "@/utils";
import { createIssueSkeleton } from "./create";
export * from "./create";
@@ -102,9 +102,7 @@ export function useInitializeIssue(
return false;
}
- if (
- extractUserResourceName(issue.value.creator) === currentUser.value.email
- ) {
+ if (extractUserId(issue.value.creator) === currentUser.value.email) {
// Allowed if current user is the creator.
return true;
}
diff --git a/frontend/src/components/IssueV1/logic/releaser.ts b/frontend/src/components/IssueV1/logic/releaser.ts
index f32f4da190..0a8a6de339 100644
--- a/frontend/src/components/IssueV1/logic/releaser.ts
+++ b/frontend/src/components/IssueV1/logic/releaser.ts
@@ -1,34 +1,28 @@
-import { uniqBy } from "lodash-es";
-import { useUserStore } from "@/store";
+import { uniq } from "lodash-es";
import { userNamePrefix, roleNamePrefix } from "@/store/modules/v1/common";
import type { ComposedIssue } from "@/types";
-import { type User } from "@/types/proto/v1/user_service";
-import { extractUserResourceName, memberListInProjectIAM } from "@/utils";
+import { memberMapToRolesInProjectIAM } from "@/utils";
+// releaserCandidatesForIssue return a users/{email} list as issue releaser candidates
+// The list could includs users/ALL_USERS_USER_EMAIL
export const releaserCandidatesForIssue = (issue: ComposedIssue) => {
- const users: User[] = [];
+ const users: string[] = [];
const project = issue.projectEntity;
- const projectMembers = memberListInProjectIAM(project.iamPolicy);
- const workspaceMembers = useUserStore().activeUserList;
+ const projectMembersMap = memberMapToRolesInProjectIAM(project.iamPolicy);
for (let i = 0; i < issue.releasers.length; i++) {
const releaserRole = issue.releasers[i];
if (releaserRole.startsWith(roleNamePrefix)) {
- users.push(
- ...projectMembers
- .filter((membership) => membership.roleList.includes(releaserRole))
- .map((membership) => membership.user)
- );
- }
- if (releaserRole.startsWith(userNamePrefix)) {
- const email = extractUserResourceName(releaserRole);
- const user = workspaceMembers.find((u) => u.email === email);
- if (user) {
- users.push(user);
+ for (const [user, roleSet] of projectMembersMap.entries()) {
+ if (roleSet.has(releaserRole)) {
+ users.push(user);
+ }
}
+ } else if (releaserRole.startsWith(userNamePrefix)) {
+ users.push(releaserRole);
}
}
- return uniqBy(users, (user) => user.name);
+ return uniq(users);
};
diff --git a/frontend/src/components/IssueV1/logic/review.ts b/frontend/src/components/IssueV1/logic/review.ts
index f4e9026114..a0b05e41a6 100644
--- a/frontend/src/components/IssueV1/logic/review.ts
+++ b/frontend/src/components/IssueV1/logic/review.ts
@@ -1,9 +1,10 @@
-import { computed, unref } from "vue";
+import { computed, unref, watchEffect } from "vue";
import {
candidatesOfApprovalStepV1,
useAuthStore,
- useUserStore,
+ batchGetOrFetchUsers,
} from "@/store";
+import { userNamePrefix } from "@/store/modules/v1/common";
import type {
ReviewFlow,
MaybeRef,
@@ -17,7 +18,8 @@ import {
ApprovalNode_Type,
Issue_Approver_Status,
} from "@/types/proto/v1/issue_service";
-import { displayRoleTitle, extractUserResourceName } from "@/utils";
+import { displayRoleTitle } from "@/utils";
+import { isUserIncludedInList } from "@/utils";
import type { ReviewContext } from "./context";
export const extractReviewContext = (issue: MaybeRef<Issue>): ReviewContext => {
@@ -94,8 +96,19 @@ export const useWrappedReviewStepsV1 = (
issue: MaybeRef<ComposedIssue>,
context: ReviewContext
) => {
- const userStore = useUserStore();
- const currentUserName = computed(() => useAuthStore().currentUser.name);
+ const currentUserName = computed(
+ () => `${userNamePrefix}${useAuthStore().currentUser.email}`
+ );
+
+ watchEffect(async () => {
+ const { flow } = context;
+ const approvers = flow.value.approvers;
+ const steps = flow.value.template.flow?.steps;
+ await batchGetOrFetchUsers(
+ steps?.map((_, i) => approvers[i]?.principal) ?? []
+ );
+ });
+
return computed(() => {
const { flow, done } = context;
const steps = flow.value.template.flow?.steps;
@@ -122,22 +135,23 @@ export const useWrappedReviewStepsV1 = (
}
return "PENDING";
};
+
const approverOfStep = (index: number) => {
- const principal = approvers[index]?.principal;
- if (!principal) return undefined;
- const email = extractUserResourceName(principal);
- return userStore.getUserByEmail(email);
+ return approvers[index]?.principal;
};
+
const candidatesOfStep = (index: number) => {
const step = steps?.[index];
if (!step) return [];
const users = candidatesOfApprovalStepV1(unref(issue), step);
- const idx = users.indexOf(currentUserName.value);
- if (idx > 0) {
- users.splice(idx, 1);
+ if (isUserIncludedInList(currentUserName.value, users)) {
+ const idx = users.indexOf(currentUserName.value);
+ if (idx >= 0) {
+ users.splice(idx, 1);
+ }
users.unshift(currentUserName.value);
}
- return users.map((user) => userStore.getUserByName(user)!);
+ return users;
};
return steps?.map<WrappedReviewStep>((step, index) => ({
diff --git a/frontend/src/components/IssueV1/logic/rollout.ts b/frontend/src/components/IssueV1/logic/rollout.ts
index b07f543061..f594f119cf 100644
--- a/frontend/src/components/IssueV1/logic/rollout.ts
+++ b/frontend/src/components/IssueV1/logic/rollout.ts
@@ -1,6 +1,6 @@
import { planCheckRunSummaryForCheckRunList } from "@/components/PlanCheckRun/common";
import { t } from "@/plugins/i18n";
-import { useCurrentUserV1 } from "@/store";
+import { useCurrentUserV1, extractUserId } from "@/store";
import type { ComposedIssue } from "@/types";
import { IssueStatus, Issue_Type } from "@/types/proto/v1/issue_service";
import type { PlanCheckRun } from "@/types/proto/v1/plan_service";
@@ -10,11 +10,7 @@ import {
task_StatusToJSON,
Task_Type,
} from "@/types/proto/v1/rollout_service";
-import {
- extractDatabaseGroupName,
- extractUserResourceName,
- hasProjectPermissionV2,
-} from "@/utils";
+import { extractDatabaseGroupName, hasProjectPermissionV2 } from "@/utils";
import { specForTask, useIssueContext } from ".";
export const isGroupingChangeTaskV1 = (issue: ComposedIssue, task: Task) => {
@@ -65,7 +61,7 @@ export const allowUserToEditStatementForTask = (
denyReasons.push(...isTaskEditable(task, getPlanCheckRunsForTask(task)));
- if (extractUserResourceName(issue.creator) !== user.value.email) {
+ if (extractUserId(issue.creator) !== user.value.email) {
if (!hasProjectPermissionV2(issue.projectEntity, "bb.plans.update")) {
denyReasons.push(
t("issue.error.you-don-have-privilege-to-edit-this-issue")
diff --git a/frontend/src/components/Member/EditMemberRoleDrawer.vue b/frontend/src/components/Member/EditMemberRoleDrawer.vue
index f4f8a57daa..7624caf956 100644
--- a/frontend/src/components/Member/EditMemberRoleDrawer.vue
+++ b/frontend/src/components/Member/EditMemberRoleDrawer.vue
@@ -77,7 +77,7 @@ import { Drawer, DrawerContent } from "@/components/v2";
import { RoleSelect } from "@/components/v2/Select";
import {
extractGroupEmail,
- extractUserEmail,
+ extractUserId,
pushNotification,
useWorkspaceV1Store,
} from "@/store";
@@ -122,7 +122,7 @@ const email = computed(() => {
return "";
}
if (props.member.type === "users") {
- return extractUserEmail(props.member.binding);
+ return extractUserId(props.member.binding);
}
return extractGroupEmail(props.member.binding);
});
diff --git a/frontend/src/components/Member/MembersBindingSelect.vue b/frontend/src/components/Member/MembersBindingSelect.vue
index 69308079d9..98a285c297 100644
--- a/frontend/src/components/Member/MembersBindingSelect.vue
+++ b/frontend/src/components/Member/MembersBindingSelect.vue
@@ -40,7 +40,6 @@
:project-name="projectName"
:include-all-users="includeAllUsers"
:include-service-account="includeServiceAccount"
- :allowed-workspace-role-list="[]"
@update:users="onMemberListUpdate"
/>
</div>
@@ -65,16 +64,21 @@
<script setup lang="ts">
import { uniq } from "lodash-es";
import { NRadio, NRadioGroup } from "naive-ui";
-import { computed, ref, onMounted } from "vue";
+import { computed, ref, onMounted, watchEffect } from "vue";
import { GroupSelect, UserSelect } from "@/components/v2";
-import { extractGroupEmail, useUserStore, useGroupStore } from "@/store";
+import {
+ extractGroupEmail,
+ useUserStore,
+ useGroupStore,
+ batchGetOrFetchUsers,
+ extractUserId,
+} from "@/store";
import { groupNamePrefix } from "@/store/modules/v1/common";
import {
getUserEmailInBinding,
getGroupEmailInBinding,
groupBindingPrefix,
} from "@/types";
-import { extractUserUID } from "@/utils";
type MemberType = "USERS" | "GROUPS";
@@ -114,6 +118,14 @@ onMounted(() => {
memberType.value = isGroupType ? "GROUPS" : "USERS";
});
+watchEffect(async () => {
+ await batchGetOrFetchUsers(
+ props.value.map((binding) =>
+ binding.startsWith(groupBindingPrefix) ? "" : binding
+ )
+ );
+});
+
const onTypeChange = (type: MemberType) => {
emit("update:value", []);
memberType.value = type;
@@ -134,7 +146,7 @@ const memberList = computed(() => {
if (!user) {
continue;
}
- list.push(extractUserUID(user.name));
+ list.push(extractUserId(user.name));
}
}
@@ -148,7 +160,7 @@ const onMemberListUpdate = (memberList: string[]) => {
const email = extractGroupEmail(member);
return getGroupEmailInBinding(email);
}
- const user = userStore.getUserById(member);
+ const user = userStore.getUserByIdentifier(member);
if (!user) {
return "";
}
diff --git a/frontend/src/components/Member/utils.ts b/frontend/src/components/Member/utils.ts
index 694155511d..0844c885f6 100644
--- a/frontend/src/components/Member/utils.ts
+++ b/frontend/src/components/Member/utils.ts
@@ -8,17 +8,16 @@ import { State } from "@/types/proto/v1/common";
import { IamPolicy } from "@/types/proto/v1/iam_policy";
import type { MemberBinding } from "./types";
-const getMemberBinding = (
+const getMemberBinding = async (
member: string,
searchText: string
-): MemberBinding | undefined => {
+): Promise<MemberBinding | undefined> => {
const groupStore = useGroupStore();
const userStore = useUserStore();
let memberBinding: MemberBinding | undefined = undefined;
-
if (member.startsWith(groupBindingPrefix)) {
- const group = groupStore.getGroupByIdentifier(member);
+ const group = await groupStore.getOrFetchGroupByIdentifier(member);
if (!group) {
return undefined;
}
@@ -33,7 +32,7 @@ const getMemberBinding = (
projectRoleBindings: [],
};
} else {
- const user = userStore.getUserByIdentifier(member);
+ const user = await userStore.getOrFetchUserByIdentifier(member);
if (!user) {
return undefined;
}
@@ -62,7 +61,9 @@ const getMemberBinding = (
return memberBinding;
};
-export const getMemberBindingsByRole = ({
+// getMemberBindingsByRole returns a map from the input policies.
+// The map will in the Map<roles/{role}, Map<user:{email} or group:{email}, MemberBinding>> format
+export const getMemberBindingsByRole = async ({
policies,
searchText,
ignoreRoles,
@@ -70,19 +71,21 @@ export const getMemberBindingsByRole = ({
policies: { level: "WORKSPACE" | "PROJECT"; policy: IamPolicy }[];
searchText: string;
ignoreRoles: Set<string>;
-}) => {
+}): Promise<Map<string, Map<string, MemberBinding>>> => {
// Map<role, Map<member, MemberBinding>>
const memberMap = new Map<string, MemberBinding>();
const roleMap = new Map<string, Map<string, MemberBinding>>();
const search = searchText.trim().toLowerCase();
- const ensureMemberBinding = (member: string) => {
+ const ensureMemberBinding = async (member: string) => {
if (!memberMap.has(member)) {
- const memberBinding = getMemberBinding(member, search);
- if (!memberBinding) {
- return undefined;
- }
- memberMap.set(member, memberBinding);
+ try {
+ const memberBinding = await getMemberBinding(member, search);
+ if (!memberBinding) {
+ return undefined;
+ }
+ memberMap.set(member, memberBinding);
+ } catch {}
}
return memberMap.get(member);
};
@@ -96,7 +99,7 @@ export const getMemberBindingsByRole = ({
roleMap.set(binding.role, new Map<string, MemberBinding>());
}
for (const member of binding.members) {
- const memberBinding = ensureMemberBinding(member);
+ const memberBinding = await ensureMemberBinding(member);
if (!memberBinding) {
continue;
}
diff --git a/frontend/src/components/Plan/components/DescriptionSection/DescriptionSection.vue b/frontend/src/components/Plan/components/DescriptionSection/DescriptionSection.vue
index c7363538aa..4252208190 100644
--- a/frontend/src/components/Plan/components/DescriptionSection/DescriptionSection.vue
+++ b/frontend/src/components/Plan/components/DescriptionSection/DescriptionSection.vue
@@ -72,9 +72,9 @@ import { computed, nextTick, reactive, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
import { useRenderMarkdown } from "@/components/MarkdownEditor";
import { planServiceClient } from "@/grpcweb";
-import { pushNotification, useCurrentUserV1 } from "@/store";
+import { pushNotification, useCurrentUserV1, extractUserId } from "@/store";
import { Plan } from "@/types/proto/v1/plan_service";
-import { extractUserResourceName, hasProjectPermissionV2 } from "@/utils";
+import { hasProjectPermissionV2 } from "@/utils";
import { usePlanContext } from "../../logic";
type LocalState = {
@@ -105,7 +105,7 @@ const allowEdit = computed(() => {
return true;
}
// Allowed if current user is the creator.
- if (extractUserResourceName(plan.value.creator) === currentUser.value.email) {
+ if (extractUserId(plan.value.creator) === currentUser.value.email) {
return true;
}
// Allowed if current has plan update permission in the project
diff --git a/frontend/src/components/Plan/components/HeaderSection/Title.vue b/frontend/src/components/Plan/components/HeaderSection/Title.vue
index 9976f44a2c..364b5b1da6 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Title.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Title.vue
@@ -22,9 +22,9 @@ import type { CSSProperties } from "vue";
import { computed, reactive, watch } from "vue";
import { useI18n } from "vue-i18n";
import { planServiceClient } from "@/grpcweb";
-import { pushNotification, useCurrentUserV1 } from "@/store";
+import { pushNotification, useCurrentUserV1, extractUserId } from "@/store";
import { Plan } from "@/types/proto/v1/plan_service";
-import { extractUserResourceName, hasProjectPermissionV2 } from "@/utils";
+import { hasProjectPermissionV2 } from "@/utils";
import { usePlanContext } from "../../logic";
type ViewMode = "EDIT" | "VIEW";
@@ -66,7 +66,7 @@ const allowEdit = computed(() => {
return true;
}
- if (extractUserResourceName(plan.value.creator) === currentUser.value.email) {
+ if (extractUserId(plan.value.creator) === currentUser.value.email) {
// Allowed if current user is the creator.
return true;
}
diff --git a/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue b/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue
index 744a6bccc8..2348b08657 100644
--- a/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue
+++ b/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue
@@ -19,9 +19,9 @@ import {
databaseForSpec,
} from "@/components/Plan/logic";
import PlanCheckRunBar from "@/components/PlanCheckRun/PlanCheckRunBar.vue";
-import { useCurrentUserV1 } from "@/store";
+import { useCurrentUserV1, extractUserId } from "@/store";
import { EMPTY_ID } from "@/types";
-import { extractUserResourceName, hasProjectPermissionV2 } from "@/utils";
+import { hasProjectPermissionV2 } from "@/utils";
const currentUser = useCurrentUserV1();
const { plan, selectedSpec } = usePlanContext();
@@ -42,7 +42,7 @@ const allowRunChecks = computed(() => {
// - the creator of the plan
// - ones who have bb.planCheckRuns.run permission in the project
const me = currentUser.value;
- if (extractUserResourceName(plan.value.creator) === me.email) {
+ if (extractUserId(plan.value.creator) === me.email) {
return true;
}
if (
diff --git a/frontend/src/components/PrincipalAvatar.vue b/frontend/src/components/PrincipalAvatar.vue
index de82351ace..58d584c21f 100644
--- a/frontend/src/components/PrincipalAvatar.vue
+++ b/frontend/src/components/PrincipalAvatar.vue
@@ -13,10 +13,10 @@ import type { PropType } from "vue";
import { computed } from "vue";
import { BBAvatar } from "@/bbkit";
import type { BBAvatarSizeType } from "@/bbkit/types";
+import { extractUserId } from "@/store";
import { UNKNOWN_ID, unknownUser } from "@/types";
import type { User } from "@/types/proto/v1/user_service";
import type { VueClass } from "@/utils";
-import { extractUserUID } from "@/utils";
const props = defineProps({
user: {
@@ -42,14 +42,14 @@ const props = defineProps({
});
const name = computed((): string => {
- const uid = extractUserUID(props.user.name);
+ const uid = extractUserId(props.user.name);
if (uid === String(UNKNOWN_ID)) {
return props.username;
}
return props.user.title;
});
const email = computed((): string => {
- const uid = extractUserUID(props.user.name);
+ const uid = extractUserId(props.user.name);
if (uid === String(UNKNOWN_ID)) {
return "";
}
diff --git a/frontend/src/components/ProfileDropdown.vue b/frontend/src/components/ProfileDropdown.vue
index 5497156842..4afee446fd 100644
--- a/frontend/src/components/ProfileDropdown.vue
+++ b/frontend/src/components/ProfileDropdown.vue
@@ -21,7 +21,7 @@ import { computed, ref, h } from "vue";
import { useI18n } from "vue-i18n";
import { useLanguage } from "@/composables/useLanguage";
import {
- useActiveUsers,
+ useUserStore,
useActuatorV1Store,
useAppFeature,
useAuthStore,
@@ -41,6 +41,7 @@ const props = defineProps<{
link?: boolean;
}>();
+const userStore = useUserStore();
const actuatorStore = useActuatorV1Store();
const authStore = useAuthStore();
const subscriptionStore = useSubscriptionV1Store();
@@ -53,7 +54,7 @@ const hideQuickstart = computed(() => {
return true;
}
// Hide quickstart if there are more than 1 active users.
- return useActiveUsers().length > 1;
+ return userStore.activeUserCountWithoutBot > 1;
});
const hideHelp = useAppFeature("bb.feature.hide-help");
diff --git a/frontend/src/components/ProjectMember/ProjectMemberPanel.vue b/frontend/src/components/ProjectMember/ProjectMemberPanel.vue
index 8d6bd5b84f..864e1a8c96 100644
--- a/frontend/src/components/ProjectMember/ProjectMemberPanel.vue
+++ b/frontend/src/components/ProjectMember/ProjectMemberPanel.vue
@@ -90,6 +90,7 @@
</template>
<script lang="ts" setup>
+import { computedAsync } from "@vueuse/core";
import { cloneDeep } from "lodash-es";
import { NButton, NTabs, NTabPane, useDialog } from "naive-ui";
import { computed, reactive } from "vue";
@@ -102,7 +103,7 @@ import {
getMemberBindings,
} from "@/components/Member/utils";
import {
- extractUserEmail,
+ extractUserId,
pushNotification,
useCurrentUserV1,
useProjectIamPolicy,
@@ -156,7 +157,7 @@ const allowEdit = computed(() => {
const workspaceRoles = computed(() => new Set(PRESET_WORKSPACE_ROLES));
-const memberBindingsByRole = computed(() => {
+const memberBindingsByRole = computedAsync(() => {
return getMemberBindingsByRole({
policies: [
{
@@ -171,7 +172,7 @@ const memberBindingsByRole = computed(() => {
searchText: state.searchText,
ignoreRoles: workspaceRoles.value,
});
-});
+}, new Map());
const memberBindings = computed(() => {
return getMemberBindings(memberBindingsByRole.value);
@@ -206,7 +207,7 @@ const revokeMember = async (binding: MemberBinding) => {
const selectedUserEmails = computed(() => {
return state.selectedMembers
.filter((member) => !member.startsWith(groupBindingPrefix))
- .map(extractUserEmail);
+ .map(extractUserId);
});
const handleRevokeSelectedMembers = () => {
diff --git a/frontend/src/components/ProjectMember/ProjectMemberRolePanel/index.vue b/frontend/src/components/ProjectMember/ProjectMemberRolePanel/index.vue
index e61d94c5b4..9fd07c45a8 100644
--- a/frontend/src/components/ProjectMember/ProjectMemberRolePanel/index.vue
+++ b/frontend/src/components/ProjectMember/ProjectMemberRolePanel/index.vue
@@ -207,7 +207,7 @@
</template>
<script lang="ts" setup>
-import { cloneDeep, isEqual, uniqBy } from "lodash-es";
+import { cloneDeep, isEqual } from "lodash-es";
import { Building2Icon } from "lucide-vue-next";
import { NButton, NTag, NTooltip, useDialog } from "naive-ui";
import { computed, reactive, ref, watch } from "vue";
@@ -220,7 +220,7 @@ import GroupNameCell from "@/components/User/Settings/UserDataTableByGroup/cells
import { Drawer, DrawerContent, InstanceV1Name } from "@/components/v2";
import {
extractGroupEmail,
- extractUserEmail,
+ extractUserId,
useDatabaseV1Store,
useProjectIamPolicy,
useProjectIamPolicyStore,
@@ -228,13 +228,15 @@ import {
pushNotification,
batchGetOrFetchDatabases,
} from "@/store";
-import { groupNamePrefix } from "@/store/modules/v1/common";
import type { ComposedProject, DatabaseResource } from "@/types";
import { PresetRoleType, PRESET_ROLES } from "@/types";
import { State } from "@/types/proto/v1/common";
import { Binding } from "@/types/proto/v1/iam_policy";
-import { type User } from "@/types/proto/v1/user_service";
-import { displayRoleTitle, hasProjectPermissionV2 } from "@/utils";
+import {
+ displayRoleTitle,
+ hasProjectPermissionV2,
+ memberMapToRolesInProjectIAM,
+} from "@/utils";
import {
convertFromExpr,
stringifyConditionExpression,
@@ -288,7 +290,7 @@ const editingBinding = ref<Binding | null>(null);
const panelTitle = computed(() => {
let email = props.binding.binding;
if (props.binding.type === "users") {
- email = extractUserEmail(email);
+ email = extractUserId(email);
} else {
email = extractGroupEmail(email);
}
@@ -368,26 +370,9 @@ const allowRemoveRole = (role: string) => {
}
if (role === PresetRoleType.PROJECT_OWNER) {
- const ownerBindings = iamPolicy.value.bindings.filter(
- (binding) => binding.role === PresetRoleType.PROJECT_OWNER
- );
- const members: User[] = [];
- // Find those never expires owner members.
- for (const binding of ownerBindings) {
- if (binding.condition?.expression !== "") {
- continue;
- }
- members.push(
- ...((binding?.members || [])
- .filter((member) => !member.startsWith(groupNamePrefix))
- .map((userIdentifier) => {
- return userStore.getUserByIdentifier(userIdentifier);
- })
- .filter((user) => user && user.state === State.ACTIVE) as User[])
- );
- }
+ const memberMap = memberMapToRolesInProjectIAM(iamPolicy.value, role);
// If there is only one owner, disallow removing.
- if (uniqBy(members, "email").length <= 1) {
+ if (memberMap.size <= 1) {
return false;
}
}
diff --git a/frontend/src/components/ProvideDashboardContext.vue b/frontend/src/components/ProvideDashboardContext.vue
index 95034b578e..40607e27ae 100644
--- a/frontend/src/components/ProvideDashboardContext.vue
+++ b/frontend/src/components/ProvideDashboardContext.vue
@@ -67,8 +67,7 @@ onMounted(async () => {
// Then prepare the other resources.
await Promise.all([
- // TODO(ed): support pagination.
- useUserStore().fetchUserList({ pageSize: 100000 }),
+ useUserStore().refreshUserStat(),
useGroupStore().fetchGroupList(),
useEnvironmentV1Store().fetchEnvironments(),
prepareProjects(),
diff --git a/frontend/src/components/ProvideSQLEditorSettingContext.vue b/frontend/src/components/ProvideSQLEditorSettingContext.vue
index 421f982bd8..64e2e6e7bd 100644
--- a/frontend/src/components/ProvideSQLEditorSettingContext.vue
+++ b/frontend/src/components/ProvideSQLEditorSettingContext.vue
@@ -8,8 +8,7 @@ import { useGroupStore, useRoleStore, useUserStore } from "@/store";
onMounted(async () => {
await Promise.all([
- // TODO(ed): support pagination.
- useUserStore().fetchUserList({ pageSize: 100000 }),
+ useUserStore().refreshUserStat(),
useRoleStore().fetchRoleList(),
useGroupStore().fetchGroupList(),
]);
diff --git a/frontend/src/components/Quickstart.vue b/frontend/src/components/Quickstart.vue
index 6b7135f488..79cc245cff 100644
--- a/frontend/src/components/Quickstart.vue
+++ b/frontend/src/components/Quickstart.vue
@@ -126,7 +126,7 @@ import {
pushNotification,
useUIStateStore,
useProjectV1Store,
- useActiveUsers,
+ useUserStore,
} from "@/store";
import { projectNamePrefix } from "@/store/modules/v1/common";
import type { Permission } from "@/types";
@@ -152,6 +152,7 @@ type IntroItem = {
const { t } = useI18n();
const projectStore = useProjectV1Store();
const uiStateStore = useUIStateStore();
+const userStore = useUserStore();
const show = computed(() => {
return !uiStateStore.getIntroStateByKey("hidden");
@@ -250,7 +251,9 @@ const introList = computed(() => {
);
});
-const isFirstUser = computed(() => useActiveUsers().length === 1);
+const isFirstUser = computed(() => {
+ return userStore.activeUserCountWithoutBot === 1;
+});
const showQuickstart = computed(() => {
// Only show quickstart for the first user.
diff --git a/frontend/src/components/RegenerateRecoveryCodesView.vue b/frontend/src/components/RegenerateRecoveryCodesView.vue
index 71241e4028..959a56bb7a 100644
--- a/frontend/src/components/RegenerateRecoveryCodesView.vue
+++ b/frontend/src/components/RegenerateRecoveryCodesView.vue
@@ -63,7 +63,6 @@ const regenerateTempMfaSecret = async () => {
regenerateTempMfaSecret: true,
})
);
- await authStore.refreshUserIfNeeded(currentUser.value.name);
};
const regenerateRecoveryCodes = async () => {
@@ -76,7 +75,6 @@ const regenerateRecoveryCodes = async () => {
regenerateRecoveryCodes: true,
})
);
- await authStore.refreshUserIfNeeded(currentUser.value.name);
pushNotification({
module: "bytebase",
style: "SUCCESS",
diff --git a/frontend/src/components/Role/Setting/components/RoleDataTable/cells/RoleOperationsCell.vue b/frontend/src/components/Role/Setting/components/RoleDataTable/cells/RoleOperationsCell.vue
index 9de850b5bc..ab692b86bf 100644
--- a/frontend/src/components/Role/Setting/components/RoleDataTable/cells/RoleOperationsCell.vue
+++ b/frontend/src/components/Role/Setting/components/RoleDataTable/cells/RoleOperationsCell.vue
@@ -14,12 +14,7 @@
import { NButton, useDialog } from "naive-ui";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
-import {
- useRoleStore,
- useUserStore,
- useWorkspaceV1Store,
- pushNotification,
-} from "@/store";
+import { useRoleStore, useWorkspaceV1Store, pushNotification } from "@/store";
import type { Role } from "@/types/proto/v1/role_service";
import { hasWorkspacePermissionV2, isCustomRole } from "@/utils";
import { useCustomRoleSettingContext } from "../../../context";
@@ -34,7 +29,6 @@ defineEmits<{
const { hasCustomRoleFeature, showFeatureModal } =
useCustomRoleSettingContext();
-const userStore = useUserStore();
const workspaceStore = useWorkspaceV1Store();
const $dialog = useDialog();
const { t } = useI18n();
@@ -43,12 +37,9 @@ const allowUpdate = computed(() => hasWorkspacePermissionV2("bb.roles.update"));
const allowDelete = computed(() => hasWorkspacePermissionV2("bb.roles.delete"));
const usersWithRole = computed(() => {
- return userStore.activeUserList.filter((user) => {
- return (
- workspaceStore.emailMapToRoles.get(user.email)?.has(props.role.name) ??
- false
- );
- });
+ return [
+ ...(workspaceStore.roleMapToUsers.get(props.role.name) ?? new Set([])),
+ ];
});
const handleDeleteRole = async () => {
@@ -78,9 +69,7 @@ const handleDeleteRole = async () => {
</p>
<ul class="list-disc ml-4 textinfolabel">
{usersWithRole.value.map((user) => (
- <li>
- {user.title} ({user.email})
- </li>
+ <li>{user}</li>
))}
</ul>
<p>{t("role.setting.delete-warning-retry")}</p>
diff --git a/frontend/src/components/SensitiveData/MaskingExceptionUserTable.vue b/frontend/src/components/SensitiveData/MaskingExceptionUserTable.vue
index f26f9980dd..a54d1ec983 100644
--- a/frontend/src/components/SensitiveData/MaskingExceptionUserTable.vue
+++ b/frontend/src/components/SensitiveData/MaskingExceptionUserTable.vue
@@ -181,10 +181,10 @@ const getDatabaseAccessResource = (access: AccessUser): VNodeChild => {
const expirationTimeRegex = /request.time < timestamp\("(.+)?"\)/;
-const getAccessUsers = (
+const getAccessUsers = async (
exception: MaskingExceptionPolicy_MaskingException,
condition: ConditionExpression
-): AccessUser | undefined => {
+): Promise<AccessUser | undefined> => {
let expirationTimestamp: number | undefined;
const expression = exception.condition?.expression ?? "";
const matches = expirationTimeRegex.exec(expression);
@@ -208,7 +208,7 @@ const getAccessUsers = (
access.group = groupStore.getGroupByIdentifier(exception.member);
} else {
access.type = "user";
- access.user = userStore.getUserByIdentifier(exception.member);
+ access.user = await userStore.getOrFetchUserByIdentifier(exception.member);
}
if (!access.group && !access.user) {
@@ -258,7 +258,7 @@ const updateAccessUserList = async () => {
const exception = maskingExceptions[i];
const condition = conditionList[i];
- const item = getAccessUsers(exception, condition);
+ const item = await getAccessUsers(exception, condition);
if (!item) {
continue;
}
@@ -562,10 +562,11 @@ const updateExceptionPolicy = async () => {
).toISOString()}")`
);
}
+ const member = getMemberBinding(accessUser);
for (const action of accessUser.supportActions) {
exceptions.push({
action,
- member: getMemberBinding(accessUser),
+ member,
condition: Expr.fromPartial({
expression: expressions.join(" && "),
}),
diff --git a/frontend/src/components/User/Settings/CreateGroupDrawer.vue b/frontend/src/components/User/Settings/CreateGroupDrawer.vue
index d26880ad80..c34045b790 100644
--- a/frontend/src/components/User/Settings/CreateGroupDrawer.vue
+++ b/frontend/src/components/User/Settings/CreateGroupDrawer.vue
@@ -58,7 +58,6 @@
:multiple="false"
:size="'medium'"
:include-all="false"
- :allowed-workspace-role-list="[]"
@update:user="(uid) => updateMemberEmail(i, uid)"
/>
<GroupMemberRoleSelect
@@ -149,18 +148,17 @@ import {
useUserStore,
useSettingV1Store,
} from "@/store";
-import { userNamePrefix, groupNamePrefix } from "@/store/modules/v1/common";
-import { getUserEmailFromIdentifier } from "@/store/modules/v1/common";
+import {
+ userNamePrefix,
+ groupNamePrefix,
+ extractUserId,
+} from "@/store/modules/v1/common";
import {
Group,
GroupMember,
GroupMember_Role,
} from "@/types/proto/v1/group_service";
-import {
- isValidEmail,
- extractUserUID,
- hasWorkspacePermissionV2,
-} from "@/utils";
+import { isValidEmail, hasWorkspacePermissionV2 } from "@/utils";
import RemoveGroupButton from "./RemoveGroupButton.vue";
import GroupMemberRoleSelect from "./UserDataTableByGroup/cells/GroupMemberRoleSelect.vue";
@@ -216,8 +214,7 @@ const disallowEditMember = computed(() => !!props.group?.source);
const isGroupOwner = computed(() => {
return (
props.group?.members.find(
- (member) =>
- getUserEmailFromIdentifier(member.member) === currentUserV1.value.email
+ (member) => extractUserId(member.member) === currentUserV1.value.email
)?.role === GroupMember_Role.OWNER
);
});
@@ -299,19 +296,18 @@ const getUserUidForMember = (member: GroupMember) => {
if (!member.member) {
return;
}
- const email = getUserEmailFromIdentifier(member.member);
- const user = userStore.getUserByEmail(email);
+ const user = userStore.getUserByIdentifier(member.member);
if (!user) {
return;
}
- return extractUserUID(user.name);
+ return extractUserId(user.name);
};
const updateMemberEmail = (index: number, uid: string | undefined) => {
if (!uid) {
return;
}
- const user = userStore.getUserById(uid);
+ const user = userStore.getUserByIdentifier(uid);
if (!user) {
return;
}
diff --git a/frontend/src/components/User/Settings/CreateUserDrawer.vue b/frontend/src/components/User/Settings/CreateUserDrawer.vue
index 376b2ea173..1b4dcb6487 100644
--- a/frontend/src/components/User/Settings/CreateUserDrawer.vue
+++ b/frontend/src/components/User/Settings/CreateUserDrawer.vue
@@ -167,12 +167,12 @@ import {
useWorkspaceV1Store,
} from "@/store";
import { PresetRoleType, emptyUser } from "@/types";
+import { State } from "@/types/proto/v1/common";
import {
UpdateUserRequest,
UserType,
User,
} from "@/types/proto/v1/user_service";
-import { State } from "@/types/proto/v1/common";
import UserPassword from "./UserPassword.vue";
interface LocalState {
@@ -190,6 +190,7 @@ const props = defineProps<{
const emit = defineEmits<{
(event: "close"): void;
+ (event: "created"): void;
}>();
const workspaceStore = useWorkspaceV1Store();
@@ -283,13 +284,8 @@ const allowDeactivate = computed(() => {
const hasMoreThanOneOwner = computed(() => {
return (
- userStore.activeUserList.filter(
- (user) =>
- user.userType === UserType.USER &&
- workspaceStore.emailMapToRoles
- .get(user.email)
- ?.has(PresetRoleType.WORKSPACE_ADMIN)
- ).length > 1
+ (workspaceStore.roleMapToUsers.get(PresetRoleType.WORKSPACE_ADMIN)?.size ??
+ 0) > 1
);
});
@@ -327,6 +323,7 @@ const tryCreateOrUpdateUser = async () => {
},
]);
}
+ emit("created");
pushNotification({
module: "bytebase",
style: "SUCCESS",
diff --git a/frontend/src/components/User/Settings/RemoveGroupButton.vue b/frontend/src/components/User/Settings/RemoveGroupButton.vue
index 0a8f0e5444..fe7f21efe1 100644
--- a/frontend/src/components/User/Settings/RemoveGroupButton.vue
+++ b/frontend/src/components/User/Settings/RemoveGroupButton.vue
@@ -31,7 +31,7 @@ import {
usePolicyV1Store,
} from "@/store";
import { getProjectName } from "@/store/modules/v1/common";
-import { getUserEmailFromIdentifier } from "@/store/modules/v1/common";
+import { extractUserId } from "@/store/modules/v1/common";
import { getGroupEmailInBinding } from "@/types";
import { type Group, GroupMember_Role } from "@/types/proto/v1/group_service";
import { PolicyType } from "@/types/proto/v1/org_policy_service";
@@ -55,8 +55,7 @@ const policyStore = usePolicyV1Store();
const selfMemberInGroup = computed(() => {
return props.group?.members.find(
- (member) =>
- getUserEmailFromIdentifier(member.member) === currentUserV1.value.email
+ (member) => extractUserId(member.member) === currentUserV1.value.email
);
});
diff --git a/frontend/src/components/User/Settings/UserDataTable/cells/GroupsCell.vue b/frontend/src/components/User/Settings/UserDataTable/cells/GroupsCell.vue
index cb1306f6a0..fde20db508 100644
--- a/frontend/src/components/User/Settings/UserDataTable/cells/GroupsCell.vue
+++ b/frontend/src/components/User/Settings/UserDataTable/cells/GroupsCell.vue
@@ -16,9 +16,9 @@
import { NTag } from "naive-ui";
import { computed } from "vue";
import { useGroupStore } from "@/store";
-import { getUserEmailFromIdentifier } from "@/store/modules/v1/common";
-import { type User } from "@/types/proto/v1/user_service";
+import { extractUserId } from "@/store/modules/v1/common";
import type { Group } from "@/types/proto/v1/group_service";
+import { type User } from "@/types/proto/v1/user_service";
const props = defineProps<{
user: User;
@@ -34,7 +34,7 @@ const groups = computed(() => {
const groups = [];
for (const group of groupStore.groupList) {
for (const member of group.members) {
- if (getUserEmailFromIdentifier(member.member) === props.user.email) {
+ if (extractUserId(member.member) === props.user.email) {
groups.push(group);
break;
}
diff --git a/frontend/src/components/User/Settings/UserDataTable/cells/UserOperationsCell.vue b/frontend/src/components/User/Settings/UserDataTable/cells/UserOperationsCell.vue
index 9c536bdd36..0de6126f59 100644
--- a/frontend/src/components/User/Settings/UserDataTable/cells/UserOperationsCell.vue
+++ b/frontend/src/components/User/Settings/UserDataTable/cells/UserOperationsCell.vue
@@ -1,7 +1,10 @@
<template>
<div class="flex justify-end">
<template v-if="allowEdit">
- <NPopconfirm v-if="allowDeleteUser" @positive-click="handleArchiveUser">
+ <NPopconfirm
+ v-if="allowDeleteUser"
+ @positive-click="() => changeRowStatus(State.DELETED)"
+ >
<template #trigger>
<NButton quaternary circle @click.stop>
<template #icon>
@@ -56,16 +59,17 @@ import { NButton, NPopconfirm } from "naive-ui";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { useUserStore, pushNotification, useCurrentUserV1 } from "@/store";
-import { type User, UserType } from "@/types/proto/v1/user_service";
import { State } from "@/types/proto/v1/common";
+import { type User, UserType } from "@/types/proto/v1/user_service";
import { hasWorkspacePermissionV2 } from "@/utils";
const props = defineProps<{
user: User;
}>();
-defineEmits<{
+const emit = defineEmits<{
(event: "click-user", user: User, e: MouseEvent): void;
+ (event: "update-user", user: User): void;
}>();
const userStore = useUserStore();
@@ -91,24 +95,21 @@ const allowDeleteUser = computed(() => {
return me.value.name !== props.user.name;
});
-const handleArchiveUser = async () => {
- await userStore.archiveUser(props.user!);
- pushNotification({
- module: "bytebase",
- style: "INFO",
- title: t("common.archived"),
- });
-};
-
const allowReactiveUser = computed(() => {
return allowEdit.value && props.user.state === State.DELETED;
});
-const changeRowStatus = (state: State) => {
+const changeRowStatus = async (state: State) => {
if (state === State.ACTIVE) {
- userStore.restoreUser(props.user);
+ await userStore.restoreUser(props.user);
} else {
- userStore.archiveUser(props.user);
+ await userStore.archiveUser(props.user);
}
+ emit("update-user", props.user);
+ pushNotification({
+ module: "bytebase",
+ style: "INFO",
+ title: t("common.updated"),
+ });
};
</script>
diff --git a/frontend/src/components/User/Settings/UserDataTable/index.vue b/frontend/src/components/User/Settings/UserDataTable/index.vue
index 0c10cc6df1..8d9c1fc6d2 100644
--- a/frontend/src/components/User/Settings/UserDataTable/index.vue
+++ b/frontend/src/components/User/Settings/UserDataTable/index.vue
@@ -3,6 +3,7 @@
key="user-table"
:columns="columns"
:data="userList"
+ :loading="loading"
:striped="true"
:bordered="true"
:max-height="'calc(100vh - 15rem)'"
@@ -28,8 +29,8 @@ import { computed, reactive, h } from "vue";
import { useI18n } from "vue-i18n";
import { BBAlert } from "@/bbkit";
import { useAppFeature, useUserStore, useWorkspaceV1Store } from "@/store";
-import { type User } from "@/types/proto/v1/user_service";
import type { Group } from "@/types/proto/v1/group_service";
+import { type User } from "@/types/proto/v1/user_service";
import { copyServiceKeyToClipboardIfNeeded } from "../common";
import GroupsCell from "./cells/GroupsCell.vue";
import UserNameCell from "./cells/UserNameCell.vue";
@@ -48,6 +49,7 @@ defineOptions({
const props = defineProps<{
showRoles: boolean;
userList: User[];
+ loading: boolean;
onClickUser?: (user: User, event: MouseEvent) => void;
}>();
@@ -113,10 +115,11 @@ const columns = computed(() => {
"onClick-user": (user: User, e: MouseEvent) => {
if (props.onClickUser) {
props.onClickUser(user, e);
- } else {
- emit("update-user", user);
}
},
+ "onUpdate-user": (user: User) => {
+ emit("update-user", user);
+ },
});
},
},
diff --git a/frontend/src/components/User/Settings/UserDataTableByGroup/cells/GroupNameCell.vue b/frontend/src/components/User/Settings/UserDataTableByGroup/cells/GroupNameCell.vue
index 2add2f7664..b7a07366d4 100644
--- a/frontend/src/components/User/Settings/UserDataTableByGroup/cells/GroupNameCell.vue
+++ b/frontend/src/components/User/Settings/UserDataTableByGroup/cells/GroupNameCell.vue
@@ -46,7 +46,7 @@ import { computed } from "vue";
import UserRolesCell from "@/components/Member/MemberDataTable/cells/UserRolesCell.vue";
import type { MemberRole } from "@/components/Member/types";
import { WORKSPACE_ROUTE_USERS } from "@/router/dashboard/workspaceRoutes";
-import { extractGroupEmail, extractUserEmail, useCurrentUserV1 } from "@/store";
+import { extractGroupEmail, extractUserId, useCurrentUserV1 } from "@/store";
import { Group } from "@/types/proto/v1/group_service";
import { hasWorkspacePermissionV2 } from "@/utils";
@@ -71,7 +71,7 @@ const currentUser = useCurrentUserV1();
const allowGetGroup = computed(() => {
if (
props.group.members.find(
- (member) => extractUserEmail(member.member) === currentUser.value.name
+ (member) => extractUserId(member.member) === currentUser.value.name
)
) {
return true;
diff --git a/frontend/src/components/User/Settings/UserDataTableByGroup/cells/GroupOperationsCell.vue b/frontend/src/components/User/Settings/UserDataTableByGroup/cells/GroupOperationsCell.vue
index 5ee45ee09c..2021266e30 100644
--- a/frontend/src/components/User/Settings/UserDataTableByGroup/cells/GroupOperationsCell.vue
+++ b/frontend/src/components/User/Settings/UserDataTableByGroup/cells/GroupOperationsCell.vue
@@ -24,7 +24,7 @@ import { PencilIcon, Trash2Icon } from "lucide-vue-next";
import { NButton } from "naive-ui";
import { computed } from "vue";
import { useCurrentUserV1 } from "@/store";
-import { getUserEmailFromIdentifier } from "@/store/modules/v1/common";
+import { extractUserId } from "@/store/modules/v1/common";
import type { Group } from "@/types/proto/v1/group_service";
import { GroupMember_Role } from "@/types/proto/v1/group_service";
import { hasWorkspacePermissionV2 } from "@/utils";
@@ -43,7 +43,7 @@ const currentUser = useCurrentUserV1();
const isGroupOwner = computed(() => {
return (
props.group.members.find(
- (m) => getUserEmailFromIdentifier(m.member) === currentUser.value.email
+ (m) => extractUserId(m.member) === currentUser.value.email
)?.role === GroupMember_Role.OWNER
);
});
diff --git a/frontend/src/components/User/Settings/UserDataTableByGroup/index.vue b/frontend/src/components/User/Settings/UserDataTableByGroup/index.vue
index eeef3c83f9..d03a85bd2d 100644
--- a/frontend/src/components/User/Settings/UserDataTableByGroup/index.vue
+++ b/frontend/src/components/User/Settings/UserDataTableByGroup/index.vue
@@ -17,9 +17,8 @@ import { NDataTable } from "naive-ui";
import { computed, h } from "vue";
import { useI18n } from "vue-i18n";
import { useUserStore } from "@/store";
-import { getUserEmailFromIdentifier } from "@/store/modules/v1/common";
-import { type User } from "@/types/proto/v1/user_service";
import { Group, GroupMember_Role } from "@/types/proto/v1/group_service";
+import { type User } from "@/types/proto/v1/user_service";
import GroupMemberNameCell from "./cells/GroupMemberNameCell.vue";
import GroupNameCell from "./cells/GroupNameCell.vue";
import GroupOperationsCell from "./cells/GroupOperationsCell.vue";
@@ -106,9 +105,7 @@ const userListByGroup = computed(() => {
for (const group of props.groups) {
const members: UserRowData[] = [];
for (const member of group.members) {
- const user = userStore.activeUserList.find(
- (user) => user.email === getUserEmailFromIdentifier(member.member)
- );
+ const user = userStore.getUserByIdentifier(member.member);
if (!user) {
continue;
}
diff --git a/frontend/src/components/misc/Watermark.vue b/frontend/src/components/misc/Watermark.vue
index 75ad91b2db..b7cd0e92a4 100644
--- a/frontend/src/components/misc/Watermark.vue
+++ b/frontend/src/components/misc/Watermark.vue
@@ -21,10 +21,9 @@
<script lang="ts" setup>
import { NWatermark } from "naive-ui";
import { computed } from "vue";
-import { featureToRef, useCurrentUserV1 } from "@/store";
+import { featureToRef, useCurrentUserV1, extractUserId } from "@/store";
import { useSettingV1Store } from "@/store/modules/v1/setting";
import { UNKNOWN_USER_NAME } from "@/types";
-import { extractUserUID } from "@/utils";
const GAP = 320;
const SIZE = 16;
@@ -38,7 +37,7 @@ const hasWatermarkFeature = featureToRef("bb.feature.watermark");
const lines = computed(() => {
const user = currentUserV1.value;
- const uid = extractUserUID(user.name);
+ const uid = extractUserId(user.name);
if (user.name === UNKNOWN_USER_NAME) return [];
if (!hasWatermarkFeature.value) return [];
if (setting.value?.value?.stringValue !== "1") return [];
diff --git a/frontend/src/components/v2/Model/DatabaseV1Table/PagedDatabaseTable.vue b/frontend/src/components/v2/Model/DatabaseV1Table/PagedDatabaseTable.vue
index 1cbc940450..c746d1e3bf 100644
--- a/frontend/src/components/v2/Model/DatabaseV1Table/PagedDatabaseTable.vue
+++ b/frontend/src/components/v2/Model/DatabaseV1Table/PagedDatabaseTable.vue
@@ -22,7 +22,6 @@
</template>
<script setup lang="tsx">
-import { useDebounceFn } from "@vueuse/core";
import { ref, watch, computed } from "vue";
import type { ComponentExposed } from "vue-component-type-helpers";
import { useRouter } from "vue-router";
@@ -150,9 +149,7 @@ const fetchDatabses = async ({
watch(
() => [filter.value, props.parent],
- useDebounceFn(async () => {
- await databasePagedTable.value?.refresh();
- }, 500)
+ () => databasePagedTable.value?.refresh()
);
const handleDatabaseClick = (event: MouseEvent, database: ComposedDatabase) => {
diff --git a/frontend/src/components/v2/Model/PagedProjectTable.vue b/frontend/src/components/v2/Model/PagedProjectTable.vue
index 39675d1c4a..4ca6eca021 100644
--- a/frontend/src/components/v2/Model/PagedProjectTable.vue
+++ b/frontend/src/components/v2/Model/PagedProjectTable.vue
@@ -11,7 +11,6 @@
</template>
<script lang="tsx" setup>
-import { useDebounceFn } from "@vueuse/core";
import { ref, watch } from "vue";
import type { ComponentExposed } from "vue-component-type-helpers";
import PagedTable from "@/components/v2/Model/PagedTable.vue";
@@ -56,8 +55,6 @@ const fetchProjects = async ({
watch(
() => props.search,
- useDebounceFn(async () => {
- await projectPagedTable.value?.refresh();
- }, 500)
+ () => projectPagedTable.value?.refresh()
);
</script>
diff --git a/frontend/src/components/v2/Model/PagedTable.vue b/frontend/src/components/v2/Model/PagedTable.vue
index 3bc7944144..62ea7a14de 100644
--- a/frontend/src/components/v2/Model/PagedTable.vue
+++ b/frontend/src/components/v2/Model/PagedTable.vue
@@ -32,10 +32,12 @@
</template>
<script lang="ts" setup generic="T extends { name: string }">
+import { useDebounceFn } from "@vueuse/core";
+import { sortBy, uniq } from "lodash-es";
import { NSelect, NButton } from "naive-ui";
import { computed, reactive, watch, ref, type Ref } from "vue";
import { useIsLoggedIn, useCurrentUserV1 } from "@/store";
-import { useDynamicLocalStorage } from "@/utils";
+import { useDynamicLocalStorage, getDefaultPagination } from "@/utils";
type LocalState = {
loading: boolean;
@@ -58,6 +60,7 @@ const props = withDefaults(
sessionKey: string;
hideLoadMore?: boolean;
footerClass?: string;
+ debounce?: number;
fetchList: (params: {
pageSize: number;
pageToken: string;
@@ -66,6 +69,7 @@ const props = withDefaults(
{
hideLoadMore: false,
footerClass: "",
+ debounce: 500,
}
);
@@ -73,8 +77,12 @@ const emit = defineEmits<{
(event: "list:update", list: T[]): void;
}>();
+const currentUser = useCurrentUserV1();
+
const options = computed(() => {
- return [50, 100, 200, 500].map((num) => ({
+ const defaultPageSize = getDefaultPagination();
+ const list = [defaultPageSize, 50, 100, 200, 500];
+ return sortBy(uniq(list)).map((num) => ({
value: num,
label: `${num}`,
}));
@@ -84,7 +92,6 @@ const state = reactive<LocalState>({
loading: false,
paginationToken: "",
});
-const currentUser = useCurrentUserV1();
// https://stackoverflow.com/questions/69813587/vue-unwraprefsimplet-generics-type-cant-assignable-to-t-at-reactive
const dataList = ref([]) as Ref<T[]>;
@@ -123,7 +130,7 @@ const fetchData = async (refresh = false) => {
const isFirstFetch = state.paginationToken === "";
const expectedRowCount = isFirstFetch
? // Load one or more page for the first fetch to restore the session
- pageSize.value * 1
+ pageSize.value * sessionState.value.page
: // Always load one page if NOT the first fetch
pageSize.value;
@@ -162,7 +169,6 @@ const resetSession = () => {
const refresh = async () => {
state.paginationToken = "";
- resetSession();
await fetchData(true);
};
@@ -197,7 +203,9 @@ const refreshCache = (data: T[]) => {
};
defineExpose({
- refresh,
+ refresh: useDebounceFn(async () => {
+ await refresh();
+ }, props.debounce),
refreshCache,
});
</script>
diff --git a/frontend/src/components/v2/Model/User/UserByEmail.vue b/frontend/src/components/v2/Model/User/UserByEmail.vue
index 654a7005cd..8d7e6422f4 100644
--- a/frontend/src/components/v2/Model/User/UserByEmail.vue
+++ b/frontend/src/components/v2/Model/User/UserByEmail.vue
@@ -9,9 +9,9 @@
</template>
<script setup lang="ts">
+import { computedAsync } from "@vueuse/core";
import { computed } from "vue";
import { useUserStore } from "@/store";
-import { getUserEmailFromIdentifier } from "@/store/modules/v1/common";
const props = withDefaults(
defineProps<{
@@ -29,8 +29,8 @@ const props = withDefaults(
const store = useUserStore();
-const user = computed(() => {
- return store.getUserByEmail(getUserEmailFromIdentifier(props.email));
+const user = computedAsync(() => {
+ return store.getOrFetchUserByIdentifier(props.email);
});
const bindings = computed(() => {
diff --git a/frontend/src/components/v2/Select/DatabaseSelect.vue b/frontend/src/components/v2/Select/DatabaseSelect.vue
index 1634b9ccdb..1819c2470b 100644
--- a/frontend/src/components/v2/Select/DatabaseSelect.vue
+++ b/frontend/src/components/v2/Select/DatabaseSelect.vue
@@ -29,8 +29,12 @@ import {
isValidProjectName,
unknownDatabase,
} from "@/types";
-import type { Engine } from "@/types/proto/v1/common";
-import { instanceV1Name, supportedEngineV1List } from "@/utils";
+import { type Engine, engineToJSON } from "@/types/proto/v1/common";
+import {
+ instanceV1Name,
+ supportedEngineV1List,
+ getDefaultPagination,
+} from "@/utils";
import { InstanceV1EngineIcon } from "../Model";
import ResourceSelect from "./ResourceSelect.vue";
@@ -96,7 +100,7 @@ const filterParams = computed(() => {
}
if (props.allowedEngineTypeList.length > 0) {
list.push(
- `engine in [${props.allowedEngineTypeList.map((e) => `"${e}"`).join(", ")}]`
+ `engine in [${props.allowedEngineTypeList.map((e) => `"${engineToJSON(e)}"`).join(", ")}]`
);
}
@@ -111,7 +115,7 @@ const searchDatabases = async (name: string) => {
const { databases } = await databaseStore.fetchDatabases({
parent: "workspaces/-",
filter: dbFilter.join(" && "),
- pageSize: 100,
+ pageSize: getDefaultPagination(),
});
return databases;
};
diff --git a/frontend/src/components/v2/Select/GroupSelect.vue b/frontend/src/components/v2/Select/GroupSelect.vue
index 6dc5451db4..14a3dbd3e2 100644
--- a/frontend/src/components/v2/Select/GroupSelect.vue
+++ b/frontend/src/components/v2/Select/GroupSelect.vue
@@ -61,7 +61,7 @@ const groupList = computedAsync(async () => {
const project = await projectV1Store.getOrFetchProjectByName(
props.projectName
);
- const memberMap = getMemberBindingsByRole({
+ const memberMap = await getMemberBindingsByRole({
policies: [
{
level: "WORKSPACE",
diff --git a/frontend/src/components/v2/Select/ProjectSelect.vue b/frontend/src/components/v2/Select/ProjectSelect.vue
index a74d077ff7..f1e6e6e671 100644
--- a/frontend/src/components/v2/Select/ProjectSelect.vue
+++ b/frontend/src/components/v2/Select/ProjectSelect.vue
@@ -37,7 +37,11 @@ import {
} from "@/types";
import { State } from "@/types/proto/v1/common";
import type { Project } from "@/types/proto/v1/project_service";
-import { extractProjectResourceName, hasWorkspacePermissionV2 } from "@/utils";
+import {
+ extractProjectResourceName,
+ hasWorkspacePermissionV2,
+ getDefaultPagination,
+} from "@/utils";
import ResourceSelect from "./ResourceSelect.vue";
const props = withDefaults(
@@ -168,7 +172,7 @@ const combinedProjectList = computed(() => {
const searchProjects = async (query: string) => {
const { projects } = await projectStore.fetchProjectList({
query,
- pageSize: 100,
+ pageSize: getDefaultPagination(),
showDeleted: props.includeArchived,
});
return projects;
diff --git a/frontend/src/components/v2/Select/UserSelect.vue b/frontend/src/components/v2/Select/UserSelect.vue
index 4bcf9d5f0f..294a864ec3 100644
--- a/frontend/src/components/v2/Select/UserSelect.vue
+++ b/frontend/src/components/v2/Select/UserSelect.vue
@@ -1,5 +1,8 @@
<template>
<ResourceSelect
+ v-bind="$attrs"
+ :remote="true"
+ :loading="state.loading"
:multiple="multiple"
:value="user"
:values="users"
@@ -10,36 +13,34 @@
:filter="filterByEmail"
:show-resource-name="false"
class="bb-user-select"
+ @search="handleSearch"
@update:value="(val) => $emit('update:user', val)"
@update:values="(val) => $emit('update:users', val)"
/>
</template>
<script lang="tsx" setup>
-import { computedAsync } from "@vueuse/core";
-import { computed, watch, watchEffect } from "vue";
+import { useDebounceFn } from "@vueuse/core";
+import { computed, watch, reactive, onMounted } from "vue";
import { useI18n } from "vue-i18n";
import UserIcon from "~icons/heroicons-outline/user";
-import {
- getMemberBindingsByRole,
- getMemberBindings,
-} from "@/components/Member/utils";
import UserAvatar from "@/components/User/UserAvatar.vue";
import ServiceAccountTag from "@/components/misc/ServiceAccountTag.vue";
-import { useProjectV1Store, useUserStore, useWorkspaceV1Store } from "@/store";
+import { useProjectV1Store, extractUserId, useUserStore } from "@/store";
+import { userNamePrefix } from "@/store/modules/v1/common";
import {
SYSTEM_BOT_USER_NAME,
- UNKNOWN_ID,
UNKNOWN_USER_NAME,
allUsersUser,
- unknownUser,
- PresetRoleType,
isValidProjectName,
- PRESET_WORKSPACE_ROLES,
+ ALL_USERS_USER_EMAIL,
} from "@/types";
-import { State } from "@/types/proto/v1/common";
-import { UserType, type User } from "@/types/proto/v1/user_service";
-import { extractUserUID } from "@/utils";
+import {
+ UserType,
+ userTypeToJSON,
+ type User,
+} from "@/types/proto/v1/user_service";
+import { memberMapToRolesInProjectIAM, getDefaultPagination } from "@/utils";
import ResourceSelect from "./ResourceSelect.vue";
const props = withDefaults(
@@ -48,7 +49,6 @@ const props = withDefaults(
user?: string;
users?: string[];
projectName?: string;
- includeAll?: boolean;
// allUsers is a special user that represents all users in the project.
includeAllUsers?: boolean;
includeSystemBot?: boolean;
@@ -64,16 +64,10 @@ const props = withDefaults(
user: undefined,
users: undefined,
projectName: undefined,
- includeAll: false,
includeAllUsers: false,
includeSystemBot: false,
includeServiceAccount: false,
includeArchived: false,
- allowedWorkspaceRoleList: () => [
- PresetRoleType.WORKSPACE_ADMIN,
- PresetRoleType.WORKSPACE_DBA,
- PresetRoleType.WORKSPACE_MEMBER,
- ],
autoReset: true,
filter: undefined,
size: "medium",
@@ -85,124 +79,92 @@ const emit = defineEmits<{
(event: "update:users", value: string[]): void;
}>();
+interface LocalState {
+ loading: boolean;
+ rawUserList: User[];
+}
+
const { t } = useI18n();
const projectV1Store = useProjectV1Store();
const userStore = useUserStore();
-const workspaceStore = useWorkspaceV1Store();
+const state = reactive<LocalState>({
+ loading: false,
+ rawUserList: [],
+});
-const prepare = () => {
- if (props.projectName && isValidProjectName(props.projectName)) {
- projectV1Store.getOrFetchProjectByName(props.projectName);
+const getFilter = (search: string) => {
+ const filter = [];
+ if (search) {
+ filter.push(`(name.matches("${search}") || email.matches("${search}"))`);
+ }
+ const allowedType = [UserType.USER];
+ if (props.includeServiceAccount) {
+ allowedType.push(UserType.SERVICE_ACCOUNT);
+ }
+ if (props.includeSystemBot) {
+ allowedType.push(UserType.SYSTEM_BOT);
+ }
+ if (allowedType.length === 1) {
+ filter.push(`user_type == "${userTypeToJSON(allowedType[0])}"`);
} else {
- // Need not to fetch the entire member list since it's done in
- // root component
+ filter.push(
+ `user_type in [${allowedType.map((t) => `"${userTypeToJSON(t)}"`).join(", ")}]`
+ );
}
+
+ return filter.join(" && ");
};
-watchEffect(prepare);
-const getUserListFromProject = async (projectName: string) => {
- const project = await projectV1Store.getOrFetchProjectByName(projectName);
- const memberMap = getMemberBindingsByRole({
- policies: [
- {
- level: "WORKSPACE",
- policy: workspaceStore.workspaceIamPolicy,
- },
- {
- level: "PROJECT",
- policy: project.iamPolicy,
- },
- ],
- searchText: "",
- ignoreRoles: new Set(PRESET_WORKSPACE_ROLES),
+const searchUsers = async (search: string) => {
+ const { users } = await userStore.fetchUserList({
+ filter: getFilter(search),
+ pageSize: getDefaultPagination(),
+ showDeleted: props.includeArchived,
});
-
- return getMemberBindings(memberMap)
- .map((binding) => binding.user)
- .filter((u) => u) as User[];
+ return users;
};
-const getUserListFromWorkspace = () => {
- return userStore.userList
- .filter((user) => {
- if (props.includeArchived) return true;
- return user.state === State.ACTIVE;
- })
- .filter((user) => {
- if (props.allowedWorkspaceRoleList.length === 0) {
- // Need not to filter by workspace role
- return true;
- }
- return [...workspaceStore.getWorkspaceRolesByEmail(user.email)].some(
- (role) => props.allowedWorkspaceRoleList.includes(role)
+const handleSearch = useDebounceFn(async (search: string) => {
+ state.loading = true;
+ try {
+ const users = await searchUsers(search);
+ state.rawUserList = users;
+ if (props.projectName && isValidProjectName(props.projectName)) {
+ // TODO(ed): filter by project in the backend.
+ state.rawUserList = await filterUsersByProject(
+ state.rawUserList,
+ props.projectName
);
- });
-};
-
-const rawUserList = computedAsync(async () => {
- let list = [];
- if (props.projectName && isValidProjectName(props.projectName)) {
- list = await getUserListFromProject(props.projectName);
- } else {
- list = getUserListFromWorkspace();
- }
-
- return list.filter((user) => {
- if (
- user.userType === UserType.SERVICE_ACCOUNT &&
- !props.includeServiceAccount
- ) {
- return false;
}
-
- if (user.userType === UserType.SYSTEM_BOT && !props.includeSystemBot) {
- return false;
- }
-
- return true;
- });
-}, []);
-
-const combinedUserList = computed(() => {
- let list = [...rawUserList.value];
-
- list.sort((a, b) => {
- return (
- parseInt(extractUserUID(a.name), 10) -
- parseInt(extractUserUID(b.name), 10)
- );
- });
-
- if (props.filter) {
- list = list.filter(props.filter);
- }
-
- if (props.includeSystemBot) {
- const systemBotIndex = list.findIndex(
- (user) => user.name === SYSTEM_BOT_USER_NAME
- );
- if (systemBotIndex >= 0) {
- const systemBotUser = list[systemBotIndex];
- list.splice(systemBotIndex, 1);
- list.unshift(systemBotUser);
- } else {
- list.unshift(userStore.getUserByName(SYSTEM_BOT_USER_NAME)!);
+ if (!search && props.includeAllUsers) {
+ state.rawUserList.unshift(allUsersUser());
}
+ } finally {
+ state.loading = false;
}
- if (props.includeAllUsers) {
- list.unshift(allUsersUser());
- }
- if (props.user === String(UNKNOWN_ID) || props.includeAll) {
- const dummyAll = {
- ...unknownUser(),
- title: t("common.all"),
- };
- list.unshift(dummyAll);
- }
+}, 500);
- return list;
+onMounted(async () => {
+ await handleSearch("");
});
+const filterUsersByProject = async (
+ users: User[],
+ projectName: string
+): Promise<User[]> => {
+ const project = await projectV1Store.getOrFetchProjectByName(projectName);
+ const memberMap = memberMapToRolesInProjectIAM(project.iamPolicy);
+ if (
+ memberMap.get(`${userNamePrefix}${ALL_USERS_USER_EMAIL}`)?.size ??
+ 0 > 0
+ ) {
+ return users;
+ }
+ return users.filter((user) => {
+ return memberMap.get(`${userNamePrefix}${user.email}`)?.size ?? 0 > 0;
+ });
+};
+
const renderAvatar = (user: User) => {
if (user.name === UNKNOWN_USER_NAME) {
return (
@@ -243,10 +205,10 @@ const renderLabel = (user: User) => {
};
const options = computed(() => {
- return combinedUserList.value.map((user) => {
+ return state.rawUserList.map((user) => {
return {
resource: user,
- value: extractUserUID(user.name),
+ value: extractUserId(user.name),
label: user.title,
};
});
@@ -263,16 +225,14 @@ const resetInvalidSelection = () => {
if (!props.autoReset) return;
if (
props.user &&
- !combinedUserList.value.find(
- (user) => extractUserUID(user.name) === props.user
- )
+ !state.rawUserList.find((user) => extractUserId(user.name) === props.user)
) {
emit("update:user", undefined);
}
};
watch(
- [() => props.user, () => props.users, combinedUserList],
+ [() => props.user, () => props.users, state.rawUserList],
resetInvalidSelection,
{
immediate: true,
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 3a235bc080..7ed94068d9 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -727,7 +727,6 @@
"reopened-issue": "reopened issue",
"resolved-issue": "resolved issue",
"canceled-issue": "canceled issue",
- "empty": "",
"changed": "changed",
"canceled": "canceled",
"started": "started",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 34a84177f2..cef92d7c06 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -727,7 +727,6 @@
"reopened-issue": "incidencia reabierta",
"resolved-issue": "incidencia resuelta",
"canceled-issue": "incidencia cancelada",
- "empty": "",
"changed": "cambio",
"canceled": "cancelado",
"started": "iniciado",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index d7c1ec4a9f..501c5a3d2e 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -727,7 +727,6 @@
"reopened-issue": "イシューを再開する",
"resolved-issue": "イシューを完了する",
"canceled-issue": "イシューをキャンセルする",
- "empty": "",
"changed": "改訂",
"canceled": "キャンセル",
"started": "始める",
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index af24423e08..6c122dcd31 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -727,7 +727,6 @@
"reopened-issue": "đã mở lại vấn đề",
"resolved-issue": "đã giải quyết vấn đề",
"canceled-issue": "đã hủy vấn đề",
- "empty": "",
"changed": "đã thay đổi",
"canceled": "đã hủy",
"started": "đã bắt đầu",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index b676475798..45dd4bd0d7 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -727,7 +727,6 @@
"reopened-issue": "重开工单",
"resolved-issue": "完成工单",
"canceled-issue": "取消工单",
- "empty": "",
"changed": "修改",
"canceled": "取消",
"started": "开始",
diff --git a/frontend/src/store/modules/auth.ts b/frontend/src/store/modules/auth.ts
index 1c0ba86a47..8816a6cb32 100644
--- a/frontend/src/store/modules/auth.ts
+++ b/frontend/src/store/modules/auth.ts
@@ -14,8 +14,8 @@ import { useAppFeature, useUserStore, useSettingV1Store } from "@/store";
import { unknownUser } from "@/types";
import type { LoginRequest } from "@/types/proto/v1/auth_service";
import { LoginResponse } from "@/types/proto/v1/auth_service";
-import { User, UserType } from "@/types/proto/v1/user_service";
import { DatabaseChangeMode } from "@/types/proto/v1/setting_service";
+import { User, UserType } from "@/types/proto/v1/user_service";
import { getIntCookie } from "@/utils";
export const useAuthStore = defineStore("auth_v1", () => {
@@ -25,7 +25,9 @@ export const useAuthStore = defineStore("auth_v1", () => {
const currentUser = computed(() => {
if (currentUserId.value) {
- return userStore.getUserById(`${currentUserId.value}`) ?? unknownUser();
+ return (
+ userStore.getUserByIdentifier(`${currentUserId.value}`) ?? unknownUser()
+ );
}
return unknownUser();
});
@@ -152,22 +154,13 @@ export const useAuthStore = defineStore("auth_v1", () => {
const restoreUser = async () => {
currentUserId.value = getUserIdFromCookie();
if (currentUserId.value) {
- await useUserStore().getOrFetchUserById(
+ await useUserStore().getOrFetchUserByIdentifier(
String(currentUserId.value),
true // silent
);
}
};
- const refreshUserIfNeeded = async (name: string) => {
- if (name === currentUser.value.name) {
- await useUserStore().fetchUser(
- name,
- true // silent
- );
- }
- };
-
return {
currentUser,
currentUserId,
@@ -177,7 +170,6 @@ export const useAuthStore = defineStore("auth_v1", () => {
signup,
logout,
restoreUser,
- refreshUserIfNeeded,
requireResetPassword,
setRequireResetPassword,
showLoginModal,
diff --git a/frontend/src/store/modules/release.ts b/frontend/src/store/modules/release.ts
index ffd430970b..0b4b0c69a4 100644
--- a/frontend/src/store/modules/release.ts
+++ b/frontend/src/store/modules/release.ts
@@ -6,9 +6,8 @@ import type { MaybeRef, ComposedRelease, Pagination } from "@/types";
import { isValidReleaseName, unknownRelease, unknownUser } from "@/types";
import { State } from "@/types/proto/v1/common";
import type { DeepPartial, Release } from "@/types/proto/v1/release_service";
-import { extractUserResourceName } from "@/utils";
import { DEFAULT_PAGE_SIZE } from "./common";
-import { useUserStore } from "./user";
+import { useUserStore, batchGetOrFetchUsers } from "./user";
import { useProjectV1Store, batchGetOrFetchProjects } from "./v1";
import { getProjectNameReleaseId, projectNamePrefix } from "./v1/common";
@@ -122,12 +121,14 @@ export const useReleaseByName = (name: MaybeRef<string>) => {
export const batchComposeRelease = async (releaseList: Release[]) => {
const userStore = useUserStore();
+
+ await batchGetOrFetchUsers(releaseList.map((release) => release.creator));
+
const composedReleaseList = releaseList.map((release) => {
const composed = release as ComposedRelease;
composed.project = `${projectNamePrefix}${head(getProjectNameReleaseId(release.name))}`;
composed.creatorEntity =
- userStore.getUserByEmail(extractUserResourceName(composed.creator)) ??
- unknownUser();
+ userStore.getUserByIdentifier(composed.creator) ?? unknownUser();
return composed;
});
diff --git a/frontend/src/store/modules/rollout.ts b/frontend/src/store/modules/rollout.ts
index b299c104c1..92935ebda6 100644
--- a/frontend/src/store/modules/rollout.ts
+++ b/frontend/src/store/modules/rollout.ts
@@ -5,9 +5,8 @@ import { rolloutServiceClient } from "@/grpcweb";
import type { MaybeRef, Pagination, ComposedRollout } from "@/types";
import { isValidRolloutName, unknownRollout, unknownUser } from "@/types";
import type { Rollout } from "@/types/proto/v1/rollout_service";
-import { extractUserResourceName } from "@/utils";
import { DEFAULT_PAGE_SIZE } from "./common";
-import { useUserStore } from "./user";
+import { useUserStore, batchGetOrFetchUsers } from "./user";
import { useProjectV1Store, batchGetOrFetchProjects } from "./v1";
import { getProjectNameRolloutId, projectNamePrefix } from "./v1/common";
@@ -90,12 +89,13 @@ export const useRolloutByName = (name: MaybeRef<string>) => {
export const batchComposeRollout = async (rolloutList: Rollout[]) => {
const userStore = useUserStore();
+ await batchGetOrFetchUsers(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.getUserByEmail(extractUserResourceName(composed.creator)) ??
- unknownUser();
+ userStore.getUserByIdentifier(composed.creator) ?? unknownUser();
return composed;
});
await batchGetOrFetchProjects(
diff --git a/frontend/src/store/modules/sqlEditor/editor.ts b/frontend/src/store/modules/sqlEditor/editor.ts
index 0410d9d229..b0cef24182 100644
--- a/frontend/src/store/modules/sqlEditor/editor.ts
+++ b/frontend/src/store/modules/sqlEditor/editor.ts
@@ -4,7 +4,7 @@ import { computed, ref, watch, watchEffect } from "vue";
import { useDatabaseV1Store } from "@/store";
import type { ComposedDatabase } from "@/types";
import { QueryOption_RedisRunCommandsOn } from "@/types/proto/v1/sql_service";
-import { hasWorkspacePermissionV2 } from "@/utils";
+import { hasWorkspacePermissionV2, getDefaultPagination } from "@/utils";
export const useSQLEditorStore = defineStore("sqlEditor", () => {
const databaseStore = useDatabaseV1Store();
@@ -43,7 +43,7 @@ export const useSQLEditorStore = defineStore("sqlEditor", () => {
try {
const { databases } = await databaseStore.fetchDatabases({
parent: project.value,
- pageSize: 100,
+ pageSize: getDefaultPagination(),
filter: name ? `name.matches("${name}")` : "",
});
databaseList.value = [...databases];
diff --git a/frontend/src/store/modules/sqlEditor/extendedTab.ts b/frontend/src/store/modules/sqlEditor/extendedTab.ts
index 020a769b8e..7078b3a26d 100644
--- a/frontend/src/store/modules/sqlEditor/extendedTab.ts
+++ b/frontend/src/store/modules/sqlEditor/extendedTab.ts
@@ -4,8 +4,8 @@ import PouchDB from "pouchdb";
import PouchDBFind from "pouchdb-find";
import { computed } from "vue";
import type { SQLEditorTab } from "@/types";
-import { extractUserUID } from "@/utils";
import { useCurrentUserV1 } from "../auth";
+import { extractUserId } from "../v1/common";
import { useSQLEditorStore } from "./editor";
export const EXTENDED_TAB_FIELDS = [
@@ -30,7 +30,7 @@ export const useExtendedTabStore = defineStore("sqlEditorExtendedTab", () => {
// context
const { project } = storeToRefs(useSQLEditorStore());
const me = useCurrentUserV1();
- const userUID = computed(() => extractUserUID(me.value.name));
+ const userUID = computed(() => extractUserId(me.value.name));
// stores
const extendedTabDB = new PouchDB<ExtendedTabEntity>(
diff --git a/frontend/src/store/modules/sqlEditor/tab.ts b/frontend/src/store/modules/sqlEditor/tab.ts
index bf3ea1fe62..2847ca5a66 100644
--- a/frontend/src/store/modules/sqlEditor/tab.ts
+++ b/frontend/src/store/modules/sqlEditor/tab.ts
@@ -14,7 +14,6 @@ import {
WebStorageHelper,
defaultSQLEditorTab,
emptySQLEditorConnection,
- extractUserUID,
isDisconnectedSQLEditorTab,
isSimilarSQLEditorTab,
useDynamicLocalStorage,
@@ -25,6 +24,7 @@ import {
useDatabaseV1ByName,
useEnvironmentV1Store,
useInstanceResourceByName,
+ extractUserId,
} from "../v1";
import { useSQLEditorStore } from "./editor";
import {
@@ -63,7 +63,7 @@ export const useSQLEditorTabStore = defineStore("sqlEditorTab", () => {
cleanupExtendedTabs,
} = useExtendedTabStore();
const me = useCurrentUserV1();
- const userUID = computed(() => extractUserUID(me.value.name));
+ const userUID = computed(() => extractUserId(me.value.name));
const keyNamespace = computed(
() => `${LOCAL_STORAGE_KEY_PREFIX}.${userUID.value}`
);
diff --git a/frontend/src/store/modules/user.ts b/frontend/src/store/modules/user.ts
index 206bd78427..afe74953c0 100644
--- a/frontend/src/store/modules/user.ts
+++ b/frontend/src/store/modules/user.ts
@@ -1,16 +1,28 @@
-import { isEqual, isUndefined, orderBy } from "lodash-es";
+import { computedAsync } from "@vueuse/core";
+import { isEqual, isUndefined, uniq } from "lodash-es";
import { defineStore } from "pinia";
import { computed, ref } from "vue";
import { userServiceClient } from "@/grpcweb";
-import { allUsersUser, SYSTEM_BOT_USER_NAME } from "@/types";
+import {
+ allUsersUser,
+ SYSTEM_BOT_USER_NAME,
+ isValidUserName,
+ unknownUser,
+} from "@/types";
import { State } from "@/types/proto/v1/common";
-import type { UpdateUserRequest, User } from "@/types/proto/v1/user_service";
+import type {
+ UpdateUserRequest,
+ User,
+ StatUsersResponse_StatUser,
+} from "@/types/proto/v1/user_service";
import { UserType } from "@/types/proto/v1/user_service";
-import { userNamePrefix, getUserEmailFromIdentifier } from "./v1/common";
+import { ensureUserFullName } from "@/utils";
+import { userNamePrefix, extractUserId } from "./v1/common";
import { usePermissionStore } from "./v1/permission";
export const useUserStore = defineStore("user", () => {
const allUser = computed(() => allUsersUser());
+ const userStats = ref<StatUsersResponse_StatUser[]>([]);
const userRequestCache = new Map<string, Promise<User>>();
const userMapByName = ref<Map<string, User>>(
@@ -23,31 +35,8 @@ export const useUserStore = defineStore("user", () => {
return user;
};
- const userList = computed(() => {
- return orderBy(
- Array.from(userMapByName.value.values()),
- [
- (user) =>
- user.userType === UserType.SYSTEM_BOT
- ? 0
- : user.userType === UserType.SERVICE_ACCOUNT
- ? 1
- : 2,
- ],
- ["asc"]
- );
- });
- // The active user list and exclude allUsers.
- const activeUserList = computed(() => {
- return userList.value.filter(
- (user) => user.state === State.ACTIVE && user.name !== allUser.value.name
- );
- });
-
- const systemBotUser = computed(() => {
- return activeUserList.value.find(
- (user) => user.name === SYSTEM_BOT_USER_NAME
- );
+ const systemBotUser = computedAsync(() => {
+ return getOrFetchUserByIdentifier(SYSTEM_BOT_USER_NAME);
});
const fetchUserList = async (params: {
@@ -65,6 +54,12 @@ export const useUserStore = defineStore("user", () => {
}
return response;
};
+
+ const refreshUserStat = async () => {
+ const { stats } = await userServiceClient.statUsers({});
+ userStats.value = stats;
+ };
+
const fetchUser = async (name: string, silent = false) => {
const user = await userServiceClient.getUser(
{
@@ -76,94 +71,114 @@ export const useUserStore = defineStore("user", () => {
);
return setUser(user);
};
+
const createUser = async (user: User) => {
const createdUser = await userServiceClient.createUser({
user,
});
+ await refreshUserStat();
return setUser(createdUser);
};
+
const updateUser = async (updateUserRequest: UpdateUserRequest) => {
const name = updateUserRequest.user?.name || "";
- const originData = await getOrFetchUserByName(name);
+ const originData = await getOrFetchUserByIdentifier(name);
if (!originData) {
throw new Error(`user with name ${name} not found`);
}
const user = await userServiceClient.updateUser(updateUserRequest);
return setUser(user);
};
- const getOrFetchUserByName = async (name: string, silent = true) => {
- const cachedData = userMapByName.value.get(name);
- if (cachedData) {
- return cachedData;
- }
- const cached = userRequestCache.get(name);
- if (cached) return cached;
- const request = fetchUser(name, silent).then((user) => setUser(user));
- userRequestCache.set(name, request);
- return request;
- };
- const getUserByName = (name: string) => {
- return userMapByName.value.get(name);
- };
- const getOrFetchUserById = async (uid: string, silent = false) => {
- return await getOrFetchUserByName(getUserNameWithUserId(uid), silent);
- };
- const getUserById = (uid: string) => {
- return getUserByName(getUserNameWithUserId(uid));
- };
- const getUserByIdentifier = (identifier: string) => {
- return getUserByEmail(getUserEmailFromIdentifier(identifier));
- };
- const getUserByEmail = (email: string) => {
- return [...userMapByName.value.values()].find(
- (user) => user.email === email
- );
- };
- const getOrFetchUserByEmail = (email: string) =>
- getOrFetchUserByName(getUserNameWithUserId(email));
+
const archiveUser = async (user: User) => {
await userServiceClient.deleteUser({
name: user.name,
});
user.state = State.DELETED;
+ await refreshUserStat();
return user;
};
+
const restoreUser = async (user: User) => {
const restoredUser = await userServiceClient.undeleteUser({
name: user.name,
});
+ await refreshUserStat();
return setUser(restoredUser);
};
+ const getOrFetchUserByIdentifier = async (
+ identifier: string,
+ silent = true
+ ) => {
+ const user = getUserByIdentifier(identifier);
+ if (user) {
+ return user;
+ }
+
+ const fullname = ensureUserFullName(identifier);
+ if (!isValidUserName(fullname)) {
+ return unknownUser();
+ }
+ const cached = userRequestCache.get(fullname);
+ if (cached) return cached;
+ const request = fetchUser(fullname, silent).then((user) => setUser(user));
+ userRequestCache.set(fullname, request);
+ return request;
+ };
+
+ const getUserByIdentifier = (identifier: string) => {
+ if (!identifier) {
+ return;
+ }
+ const id = extractUserId(identifier);
+ if (Number.isNaN(Number(id))) {
+ return [...userMapByName.value.values()].find(
+ (user) => user.email === id
+ );
+ }
+ return userMapByName.value.get(`${userNamePrefix}${id}`);
+ };
+
+ const activeUserCountWithoutBot = computed(() => {
+ return userStats.value.reduce((count, stat) => {
+ if (
+ stat.state === State.ACTIVE &&
+ stat.userType !== UserType.SYSTEM_BOT
+ ) {
+ count += stat.count;
+ }
+ return count;
+ }, 0);
+ });
+
return {
allUser,
- userMapByName,
- userList,
- activeUserList,
+ userStats,
systemBotUser,
fetchUserList,
- fetchUser,
+ refreshUserStat,
createUser,
updateUser,
- getOrFetchUserByName,
- getUserByName,
- getOrFetchUserById,
- getUserById,
+ getOrFetchUserByIdentifier,
getUserByIdentifier,
- getUserByEmail,
- getOrFetchUserByEmail,
archiveUser,
restoreUser,
+ activeUserCountWithoutBot,
};
});
-export const extractUserEmail = (emailResource: string) => {
- const matches = emailResource.match(/^(?:user:|users\/)(.+)$/);
- return matches?.[1] ?? emailResource;
-};
-
-export const getUserNameWithUserId = (userUID: string) => {
- return `${userNamePrefix}${userUID}`;
+export const batchGetOrFetchUsers = async (userNameList: string[]) => {
+ const userStore = useUserStore();
+ const distinctList = uniq(userNameList);
+ await Promise.all(
+ distinctList.map((userName) => {
+ if (!isValidUserName(userName)) {
+ return;
+ }
+ return userStore.getOrFetchUserByIdentifier(userName, true /* silent */);
+ })
+ );
};
export const getUpdateMaskFromUsers = (
@@ -185,14 +200,3 @@ export const getUpdateMaskFromUsers = (
}
return updateMask;
};
-
-// Get all active users, including user and service account.
-export const useActiveUsers = () => {
- const userStore = useUserStore();
- return userStore.userList.filter(
- (user) =>
- user.name !== userStore.allUser.name &&
- user.state === State.ACTIVE &&
- [UserType.USER, UserType.SERVICE_ACCOUNT].includes(user.userType)
- );
-};
diff --git a/frontend/src/store/modules/v1/auditLog.ts b/frontend/src/store/modules/v1/auditLog.ts
index 76c59d0a0d..2d2e15a26e 100644
--- a/frontend/src/store/modules/v1/auditLog.ts
+++ b/frontend/src/store/modules/v1/auditLog.ts
@@ -2,10 +2,8 @@ import dayjs from "dayjs";
import utc from "dayjs/plugin/utc";
import type { BinaryLike } from "node:crypto";
import { defineStore } from "pinia";
-import { reactive } from "vue";
import { auditLogServiceClient } from "@/grpcweb";
import type { SearchAuditLogsParams } from "@/types";
-import type { AuditLog } from "@/types/proto/v1/audit_log_service";
import type { ExportFormat } from "@/types/proto/v1/common";
import { userNamePrefix } from "./common";
@@ -36,8 +34,6 @@ const buildFilter = (search: SearchAuditLogsParams): string => {
};
export const useAuditLogStore = defineStore("audit_log", () => {
- const auditLogList = reactive(new Map<string, AuditLog[]>());
-
const fetchAuditLogs = async (search: SearchAuditLogsParams) => {
const resp = await auditLogServiceClient.searchAuditLogs({
parent: search.parent,
@@ -46,11 +42,6 @@ export const useAuditLogStore = defineStore("audit_log", () => {
pageSize: search.pageSize,
pageToken: search.pageToken,
});
- for (const auditLog of resp.auditLogs) {
- const list = auditLogList.get(auditLog.resource) || [];
- list.push(auditLog);
- auditLogList.set(auditLog.resource, list);
- }
return resp;
};
diff --git a/frontend/src/store/modules/v1/changelist.ts b/frontend/src/store/modules/v1/changelist.ts
index 4952a6a017..625a6cf4d1 100644
--- a/frontend/src/store/modules/v1/changelist.ts
+++ b/frontend/src/store/modules/v1/changelist.ts
@@ -8,10 +8,8 @@ import type {
DeepPartial,
ListChangelistsRequest,
} from "@/types/proto/v1/changelist_service";
-import {
- ResourceComposer,
- isChangelogChangeSource,
-} from "@/utils";
+import { ResourceComposer, isChangelogChangeSource } from "@/utils";
+import { batchGetOrFetchUsers } from "../user";
import { useChangelogStore } from "./changelog";
import { useSheetV1Store } from "./sheet";
@@ -22,6 +20,9 @@ export const useChangelistStore = defineStore("changelist", () => {
changelists: Changelist[],
compose: boolean
) => {
+ await batchGetOrFetchUsers(
+ changelists.map((changelist) => changelist.creator)
+ );
for (let i = 0; i < changelists.length; i++) {
const changelist = changelists[i];
if (compose) {
diff --git a/frontend/src/store/modules/v1/common.ts b/frontend/src/store/modules/v1/common.ts
index 3c0541f3ae..83778b70da 100644
--- a/frontend/src/store/modules/v1/common.ts
+++ b/frontend/src/store/modules/v1/common.ts
@@ -123,8 +123,9 @@ export const getInstanceAndDatabaseId = (name: string): string[] => {
return tokens;
};
-export const getUserEmailFromIdentifier = (identifier: string): string => {
- return identifier.replace(/^(user:|users\/)/, "");
+export const extractUserId = (identifier: string) => {
+ const matches = identifier.match(/^(?:user:|users\/)(.+)$/);
+ return matches?.[1] ?? identifier;
};
export const getIdentityProviderResourceId = (name: string): ResourceId => {
diff --git a/frontend/src/store/modules/v1/experimental-issue.ts b/frontend/src/store/modules/v1/experimental-issue.ts
index 1310ff6b8d..2d1b56e842 100644
--- a/frontend/src/store/modules/v1/experimental-issue.ts
+++ b/frontend/src/store/modules/v1/experimental-issue.ts
@@ -8,6 +8,7 @@ import {
import {
useProjectV1Store,
useUserStore,
+ batchGetOrFetchUsers,
batchGetOrFetchDatabases,
} from "@/store";
import type { ComposedIssue, ComposedProject, ComposedTaskRun } from "@/types";
@@ -22,11 +23,7 @@ import {
import type { Issue } from "@/types/proto/v1/issue_service";
import type { Plan } from "@/types/proto/v1/plan_service";
import { TaskRunLog, type Rollout } from "@/types/proto/v1/rollout_service";
-import {
- extractProjectResourceName,
- extractUserResourceName,
- hasProjectPermissionV2,
-} from "@/utils";
+import { extractProjectResourceName, hasProjectPermissionV2 } from "@/utils";
import { DEFAULT_PAGE_SIZE } from "../common";
export interface ComposeIssueConfig {
@@ -41,12 +38,13 @@ export const composeIssue = async (
const userStore = useUserStore();
const project = `projects/${extractProjectResourceName(rawIssue.name)}`;
- const projectEntity =
- await useProjectV1Store().getOrFetchProjectByName(project);
-
- const creatorEntity =
- userStore.getUserByEmail(extractUserResourceName(rawIssue.creator)) ??
- unknownUser();
+ const [projectEntity, creatorEntity, _] = await Promise.all([
+ useProjectV1Store().getOrFetchProjectByName(project),
+ userStore
+ .getOrFetchUserByIdentifier(rawIssue.creator)
+ .then((user) => user ?? unknownUser()),
+ batchGetOrFetchUsers(rawIssue.subscribers),
+ ]);
const issue: ComposedIssue = {
...rawIssue,
diff --git a/frontend/src/store/modules/v1/group.ts b/frontend/src/store/modules/v1/group.ts
index e2fe0cb5d1..7ec6f016e8 100644
--- a/frontend/src/store/modules/v1/group.ts
+++ b/frontend/src/store/modules/v1/group.ts
@@ -4,6 +4,7 @@ import { computed, reactive } from "vue";
import { groupServiceClient } from "@/grpcweb";
import type { Group } from "@/types/proto/v1/group_service";
import { hasWorkspacePermissionV2 } from "@/utils";
+import { batchGetOrFetchUsers } from "../user";
import { groupNamePrefix } from "./common";
export const extractGroupEmail = (emailResource: string) => {
@@ -11,6 +12,11 @@ export const extractGroupEmail = (emailResource: string) => {
return matches?.[1] ?? emailResource;
};
+const ensureGroupIdentifier = (id: string) => {
+ const email = extractGroupEmail(id);
+ return `${groupNamePrefix}${email}`;
+};
+
export const useGroupStore = defineStore("group", () => {
const groupMapByName = reactive(new Map<string, Group>());
const resetCache = () => {
@@ -26,15 +32,13 @@ export const useGroupStore = defineStore("group", () => {
);
});
- // Actions
- const getGroupName = (email: string) => `${groupNamePrefix}${email}`;
-
- const getGroupByEmail = (email: string) => {
- return groupMapByName.get(getGroupName(email));
+ const composeGroup = async (group: Group) => {
+ await batchGetOrFetchUsers(group.members.map((m) => m.member));
+ groupMapByName.set(group.name, group);
};
const getGroupByIdentifier = (id: string) => {
- return getGroupByEmail(extractGroupEmail(id));
+ return groupMapByName.get(ensureGroupIdentifier(id));
};
const fetchGroupList = async () => {
@@ -45,24 +49,28 @@ export const useGroupStore = defineStore("group", () => {
const { groups } = await groupServiceClient.listGroups({});
resetCache();
for (const group of groups) {
- groupMapByName.set(group.name, group);
+ await composeGroup(group);
}
return groups;
};
- const getOrFetchGroupByEmail = async (email: string) => {
+ const getOrFetchGroupByIdentifier = async (id: string) => {
if (!hasWorkspacePermissionV2("bb.groups.get")) {
return;
}
- if (getGroupByEmail(email)) {
- return getGroupByEmail(email);
+ const existed = getGroupByIdentifier(id);
+ if (existed) {
+ return existed;
}
- const group = await groupServiceClient.getGroup({
- name: getGroupName(email),
- });
- groupMapByName.set(group.name, group);
+ const group = await groupServiceClient.getGroup(
+ {
+ name: ensureGroupIdentifier(id),
+ },
+ { silent: true }
+ );
+ await composeGroup(group);
return group;
};
@@ -76,7 +84,7 @@ export const useGroupStore = defineStore("group", () => {
group,
groupEmail: extractGroupEmail(group.name),
});
- groupMapByName.set(resp.name, resp);
+ await composeGroup(resp);
return resp;
};
@@ -86,16 +94,15 @@ export const useGroupStore = defineStore("group", () => {
updateMask: ["title", "description", "members"],
allowMissing: false,
});
- groupMapByName.set(updated.name, updated);
+ await composeGroup(updated);
return updated;
};
return {
groupList,
fetchGroupList,
- getGroupByEmail,
getGroupByIdentifier,
- getOrFetchGroupByEmail,
+ getOrFetchGroupByIdentifier,
deleteGroup,
updateGroup,
createGroup,
diff --git a/frontend/src/store/modules/v1/index.ts b/frontend/src/store/modules/v1/index.ts
index 3d422f6d6e..e6d2199841 100644
--- a/frontend/src/store/modules/v1/index.ts
+++ b/frontend/src/store/modules/v1/index.ts
@@ -27,3 +27,4 @@ export * from "./workspace";
export * from "./instanceResource";
export * from "./storage";
export * from "./changelog";
+export * from "./common";
diff --git a/frontend/src/store/modules/v1/issue.ts b/frontend/src/store/modules/v1/issue.ts
index a88f0a1ed2..9ebd3371c1 100644
--- a/frontend/src/store/modules/v1/issue.ts
+++ b/frontend/src/store/modules/v1/issue.ts
@@ -6,16 +6,16 @@ import { ref, watch } from "vue";
import { issueServiceClient } from "@/grpcweb";
import type { ComposedIssue, IssueFilter } from "@/types";
import { isValidProjectName, PresetRoleType } from "@/types";
-import { State } from "@/types/proto/v1/common";
import type { ApprovalStep } from "@/types/proto/v1/issue_service";
import {
issueStatusToJSON,
ApprovalNode_Type,
ApprovalNode_GroupValue,
} from "@/types/proto/v1/issue_service";
-import { UserType } from "@/types/proto/v1/user_service";
-import { extractProjectResourceName, memberListInProjectIAM } from "@/utils";
-import { extractUserEmail, useUserStore } from "../user";
+import {
+ extractProjectResourceName,
+ memberMapToRolesInProjectIAM,
+} from "@/utils";
import {
shallowComposeIssue,
type ComposeIssueConfig,
@@ -145,20 +145,14 @@ const convertApprovalNodeGroupToRole = (
return "";
};
+// candidatesOfApprovalStepV1 return user name list in users/{email} format.
+// The list could includs users/ALL_USERS_USER_EMAIL
export const candidatesOfApprovalStepV1 = (
issue: ComposedIssue,
step: ApprovalStep
) => {
- const userStore = useUserStore();
const workspaceStore = useWorkspaceV1Store();
-
- const workspaceMemberList = userStore.activeUserList.filter(
- (user) => user.userType === UserType.USER
- );
const project = issue.projectEntity;
- const projectMemberList = memberListInProjectIAM(project.iamPolicy).filter(
- (member) => member.user.userType === UserType.USER
- );
const candidates = step.nodes.flatMap((node) => {
const {
@@ -174,28 +168,28 @@ export const candidatesOfApprovalStepV1 = (
groupValue === ApprovalNode_GroupValue.PROJECT_OWNER
) {
const targetRole = convertApprovalNodeGroupToRole(groupValue);
- return projectMemberList
- .filter((member) => member.roleList.includes(targetRole))
- .map((member) => member.user);
+ const projectMembersMap = memberMapToRolesInProjectIAM(
+ project.iamPolicy,
+ targetRole
+ );
+ return [...projectMembersMap.keys()];
}
if (
groupValue === ApprovalNode_GroupValue.WORKSPACE_DBA ||
groupValue === ApprovalNode_GroupValue.WORKSPACE_OWNER
) {
- return workspaceMemberList.filter(
- (member) =>
- workspaceStore.emailMapToRoles
- .get(member.email)
- ?.has(convertApprovalNodeGroupToRole(groupValue)) ?? false
- );
+ return [
+ ...(workspaceStore.roleMapToUsers.get(
+ convertApprovalNodeGroupToRole(groupValue)
+ ) ?? new Set()),
+ ];
}
return [];
};
+
const candidatesForCustomRoles = (role: string) => {
- const memberList = memberListInProjectIAM(project.iamPolicy, role);
- return memberList
- .filter((member) => member.user.userType === UserType.USER)
- .map((member) => member.user);
+ const memberMap = memberMapToRolesInProjectIAM(project.iamPolicy, role);
+ return [...memberMap.keys()];
};
if (groupValue !== ApprovalNode_GroupValue.UNRECOGNIZED) {
@@ -208,15 +202,12 @@ export const candidatesOfApprovalStepV1 = (
});
return uniq(
- candidates
- .filter(
- (user) =>
- user.userType === UserType.USER &&
- user.state === State.ACTIVE &&
- (issue.projectEntity.allowSelfApproval ||
- user.email !== extractUserEmail(issue.creator))
- )
- .map((user) => user.name)
+ candidates.filter((user) => {
+ if (!issue.projectEntity.allowSelfApproval) {
+ return user !== issue.creator;
+ }
+ return true;
+ })
);
};
diff --git a/frontend/src/store/modules/v1/plan.ts b/frontend/src/store/modules/v1/plan.ts
index ec96d4dd9a..e6c0f424bb 100644
--- a/frontend/src/store/modules/v1/plan.ts
+++ b/frontend/src/store/modules/v1/plan.ts
@@ -13,7 +13,6 @@ import {
} from "@/types/v1/issue/plan";
import {
extractProjectResourceName,
- extractUserResourceName,
getTsRangeFromSearchParams,
getValueFromSearchParams,
hasProjectPermissionV2,
@@ -80,7 +79,7 @@ export const composePlan = async (rawPlan: Plan): Promise<ComposedPlan> => {
await useProjectV1Store().getOrFetchProjectByName(project);
const creatorEntity =
- userStore.getUserByEmail(extractUserResourceName(rawPlan.creator)) ??
+ (await userStore.getOrFetchUserByIdentifier(rawPlan.creator)) ??
unknownUser();
const plan: ComposedPlan = {
diff --git a/frontend/src/store/modules/v1/project.ts b/frontend/src/store/modules/v1/project.ts
index c641ab1ffe..cdacfca087 100644
--- a/frontend/src/store/modules/v1/project.ts
+++ b/frontend/src/store/modules/v1/project.ts
@@ -184,6 +184,7 @@ export const useProjectV1Store = defineStore("project_v1", () => {
};
});
+// TODO(ed): deprecate it.
export const useProjectV1List = (showDeleted: boolean = false) => {
const listCache = useListCache("project");
const store = useProjectV1Store();
diff --git a/frontend/src/store/modules/v1/projectIamPolicy.ts b/frontend/src/store/modules/v1/projectIamPolicy.ts
index 32cb102b07..d071e120f0 100644
--- a/frontend/src/store/modules/v1/projectIamPolicy.ts
+++ b/frontend/src/store/modules/v1/projectIamPolicy.ts
@@ -3,6 +3,7 @@ import { defineStore } from "pinia";
import { computed, ref, unref, watch } from "vue";
import { projectServiceClient } from "@/grpcweb";
import {
+ ALL_USERS_USER_EMAIL,
QueryPermissionQueryAny,
type ComposedDatabase,
type ComposedProject,
@@ -16,6 +17,7 @@ import { getUserEmailListInBinding } from "@/utils";
import { convertFromExpr } from "@/utils/issue/cel";
import { useCurrentUserV1 } from "../auth";
import { useRoleStore } from "../role";
+import { batchGetOrFetchUsers } from "../user";
import { usePermissionStore } from "./permission";
export const useProjectIamPolicyStore = defineStore(
@@ -24,6 +26,20 @@ export const useProjectIamPolicyStore = defineStore(
const policyMap = ref(new Map<string, IamPolicy>());
const requestCache = new Map<string, Promise<IamPolicy>>();
+ const composeProjectPolicy = async (policy: IamPolicy) => {
+ const members = policy.bindings.reduce((list, binding) => {
+ list.push(...binding.members);
+ return list;
+ }, [] as string[]);
+ await batchGetOrFetchUsers(members);
+ };
+
+ const setIamPolicy = async (project: string, policy: IamPolicy) => {
+ await composeProjectPolicy(policy);
+ policyMap.value.set(project, policy);
+ return policy;
+ };
+
const fetchProjectIamPolicy = async (
project: string,
skipCache = false
@@ -40,8 +56,7 @@ export const useProjectIamPolicyStore = defineStore(
resource: project,
})
.then((policy) => {
- policyMap.value.set(project, policy);
- return policy;
+ return setIamPolicy(project, policy);
});
requestCache.set(project, request);
return request;
@@ -52,11 +67,11 @@ export const useProjectIamPolicyStore = defineStore(
scope: "projects/-",
names: projectList,
});
- response.policyResults.forEach(({ policy, project }) => {
- if (policy) {
- policyMap.value.set(project, policy);
+ for (const item of response.policyResults) {
+ if (item.policy) {
+ await setIamPolicy(item.project, item.policy);
}
- });
+ }
};
const updateProjectIamPolicy = async (
@@ -151,7 +166,10 @@ const checkProjectIAMPolicyWithExpr = (
binding,
ignoreGroup: false,
});
- if (!userEmailList.includes(user.email)) {
+ if (
+ !userEmailList.includes(user.email) &&
+ !userEmailList.includes(ALL_USERS_USER_EMAIL)
+ ) {
continue;
}
// If the role does not have the permission, then skip.
diff --git a/frontend/src/store/modules/v1/worksheet.ts b/frontend/src/store/modules/v1/worksheet.ts
index 5f12e4a572..6c2275232d 100644
--- a/frontend/src/store/modules/v1/worksheet.ts
+++ b/frontend/src/store/modules/v1/worksheet.ts
@@ -17,7 +17,8 @@ import {
} from "@/utils";
import { useCurrentUserV1 } from "../auth";
import { useSQLEditorTabStore } from "../sqlEditor";
-import { getUserEmailFromIdentifier } from "./common";
+import { useUserStore, batchGetOrFetchUsers } from "../user";
+import { extractUserId } from "./common";
import { useDatabaseV1Store, batchGetOrFetchDatabases } from "./database";
import { useProjectV1Store, batchGetOrFetchProjects } from "./project";
@@ -30,6 +31,7 @@ export const useWorkSheetStore = defineStore("worksheet_v1", () => {
);
const projectStore = useProjectV1Store();
const databaseStore = useDatabaseV1Store();
+ const userStore = useUserStore();
// Getters
const worksheetList = computed(() => {
@@ -68,16 +70,18 @@ export const useWorkSheetStore = defineStore("worksheet_v1", () => {
await Promise.all([
projectStore.getOrFetchProjectByName(worksheet.project),
databaseStore.getOrFetchDatabaseByName(worksheet.database),
+ userStore.getOrFetchUserByIdentifier(worksheet.creator),
]);
cacheByUID.setEntity([uid, view], worksheet);
};
const setListCache = async (worksheets: Worksheet[]) => {
- await batchGetOrFetchProjects(
- worksheets.map((worksheet) => worksheet.project)
- );
- await batchGetOrFetchDatabases(
- worksheets.map((worksheet) => worksheet.database)
- );
+ await Promise.all([
+ batchGetOrFetchProjects(worksheets.map((worksheet) => worksheet.project)),
+ batchGetOrFetchDatabases(
+ worksheets.map((worksheet) => worksheet.database)
+ ),
+ batchGetOrFetchUsers(worksheets.map((worksheet) => worksheet.creator)),
+ ]);
for (const worksheet of worksheets) {
await setCache(worksheet, "BASIC");
}
@@ -259,7 +263,7 @@ export const useWorkSheetAndTabStore = defineStore("worksheet_and_tab", () => {
const isCreator = computed(() => {
const worksheet = currentWorksheet.value;
if (!worksheet) return false;
- return getUserEmailFromIdentifier(worksheet.creator) === me.value.email;
+ return extractUserId(worksheet.creator) === me.value.email;
});
const isReadOnly = computed(() => {
diff --git a/frontend/src/store/modules/v1/workspace.ts b/frontend/src/store/modules/v1/workspace.ts
index 3b904f4e57..42f7f94a75 100644
--- a/frontend/src/store/modules/v1/workspace.ts
+++ b/frontend/src/store/modules/v1/workspace.ts
@@ -2,26 +2,48 @@ import { cloneDeep } from "lodash-es";
import { defineStore } from "pinia";
import { ref, computed } from "vue";
import { workspaceServiceClient } from "@/grpcweb";
+import { userNamePrefix } from "@/store/modules/v1/common";
import { groupBindingPrefix, PresetRoleType } from "@/types";
import { IamPolicy, Binding } from "@/types/proto/v1/iam_policy";
import { roleListInIAM, getUserEmailListInBinding } from "@/utils";
-import { extractUserEmail } from "../user";
+import { extractUserId } from "./common";
import { extractGroupEmail } from "./group";
export const useWorkspaceV1Store = defineStore("workspace_v1", () => {
const workspaceIamPolicy = ref<IamPolicy>(IamPolicy.fromPartial({}));
- const emailMapToRoles = computed(() => {
- const map = new Map<string, Set<string>>(); // Map<email, role list>
+ // roleMapToUsers returns Map<roles/{role}, Set<users/{email}>>
+ // the user could includes users/ALL_USERS_USER_EMAIL
+ const roleMapToUsers = computed(() => {
+ const map = new Map<string, Set<string>>();
+ for (const binding of workspaceIamPolicy.value.bindings) {
+ if (!map.has(binding.role)) {
+ map.set(binding.role, new Set());
+ }
+ for (const email of getUserEmailListInBinding({
+ binding,
+ ignoreGroup: false,
+ })) {
+ map.get(binding.role)?.add(`${userNamePrefix}${email}`);
+ }
+ }
+ return map;
+ });
+
+ // userMapToRoles returns Map<users/{email}, Set<roles/{role}>>
+ // the user could includes users/ALL_USERS_USER_EMAIL
+ const userMapToRoles = computed(() => {
+ const map = new Map<string, Set<string>>();
for (const binding of workspaceIamPolicy.value.bindings) {
for (const email of getUserEmailListInBinding({
binding,
ignoreGroup: false,
})) {
- if (!map.has(email)) {
- map.set(email, new Set());
+ const key = `${userNamePrefix}${email}`;
+ if (!map.has(key)) {
+ map.set(key, new Set());
}
- map.get(email)?.add(binding.role);
+ map.get(key)?.add(binding.role);
}
}
return map;
@@ -109,7 +131,7 @@ export const useWorkspaceV1Store = defineStore("workspace_v1", () => {
if (member.startsWith(groupBindingPrefix)) {
email = extractGroupEmail(member);
} else {
- email = extractUserEmail(member);
+ email = extractUserId(member);
}
return roleListInIAM({
policy: workspaceIamPolicy.value,
@@ -120,7 +142,7 @@ export const useWorkspaceV1Store = defineStore("workspace_v1", () => {
const getWorkspaceRolesByEmail = (email: string) => {
return (
- emailMapToRoles.value.get(email) ??
+ userMapToRoles.value.get(`${userNamePrefix}${email}`) ??
new Set<string>([PresetRoleType.WORKSPACE_MEMBER])
);
};
@@ -130,7 +152,8 @@ export const useWorkspaceV1Store = defineStore("workspace_v1", () => {
fetchIamPolicy,
patchIamPolicy,
findRolesByMember,
- emailMapToRoles,
+ userMapToRoles,
+ roleMapToUsers,
getWorkspaceRolesByEmail,
};
});
diff --git a/frontend/src/types/proto/v1/user_service.ts b/frontend/src/types/proto/v1/user_service.ts
index 895252c0d9..6a7107b1de 100644
--- a/frontend/src/types/proto/v1/user_service.ts
+++ b/frontend/src/types/proto/v1/user_service.ts
@@ -83,6 +83,19 @@ export interface GetUserRequest {
name: string;
}
+export interface StatUsersRequest {
+}
+
+export interface StatUsersResponse {
+ stats: StatUsersResponse_StatUser[];
+}
+
+export interface StatUsersResponse_StatUser {
+ userType: UserType;
+ state: State;
+ count: number;
+}
+
export interface ListUsersRequest {
/**
* The maximum number of users to return. The service may return fewer than
@@ -107,14 +120,17 @@ export interface ListUsersRequest {
* - name
* - email
* - user_type
+ * - state
*
* For example:
* name == "ed"
* name.matches("ed")
* email == "[email protected]"
+ * email.matches("ed")
* user_type == "SERVICE_ACCOUNT"
* user_type in ["SERVICE_ACCOUNT", "USER"]
* !(user_type in ["SERVICE_ACCOUNT", "USER"])
+ * state == "DELETED"
*/
filter: string;
}
@@ -270,6 +286,203 @@ export const GetUserRequest: MessageFns<GetUserRequest> = {
},
};
+function createBaseStatUsersRequest(): StatUsersRequest {
+ return {};
+}
+
+export const StatUsersRequest: MessageFns<StatUsersRequest> = {
+ encode(_: StatUsersRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
+ return writer;
+ },
+
+ decode(input: BinaryReader | Uint8Array, length?: number): StatUsersRequest {
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = createBaseStatUsersRequest();
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ }
+ if ((tag & 7) === 4 || tag === 0) {
+ break;
+ }
+ reader.skip(tag & 7);
+ }
+ return message;
+ },
+
+ fromJSON(_: any): StatUsersRequest {
+ return {};
+ },
+
+ toJSON(_: StatUsersRequest): unknown {
+ const obj: any = {};
+ return obj;
+ },
+
+ create(base?: DeepPartial<StatUsersRequest>): StatUsersRequest {
+ return StatUsersRequest.fromPartial(base ?? {});
+ },
+ fromPartial(_: DeepPartial<StatUsersRequest>): StatUsersRequest {
+ const message = createBaseStatUsersRequest();
+ return message;
+ },
+};
+
+function createBaseStatUsersResponse(): StatUsersResponse {
+ return { stats: [] };
+}
+
+export const StatUsersResponse: MessageFns<StatUsersResponse> = {
+ encode(message: StatUsersResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
+ for (const v of message.stats) {
+ StatUsersResponse_StatUser.encode(v!, writer.uint32(10).fork()).join();
+ }
+ return writer;
+ },
+
+ decode(input: BinaryReader | Uint8Array, length?: number): StatUsersResponse {
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = createBaseStatUsersResponse();
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ if (tag !== 10) {
+ break;
+ }
+
+ message.stats.push(StatUsersResponse_StatUser.decode(reader, reader.uint32()));
+ continue;
+ }
+ }
+ if ((tag & 7) === 4 || tag === 0) {
+ break;
+ }
+ reader.skip(tag & 7);
+ }
+ return message;
+ },
+
+ fromJSON(object: any): StatUsersResponse {
+ return {
+ stats: globalThis.Array.isArray(object?.stats)
+ ? object.stats.map((e: any) => StatUsersResponse_StatUser.fromJSON(e))
+ : [],
+ };
+ },
+
+ toJSON(message: StatUsersResponse): unknown {
+ const obj: any = {};
+ if (message.stats?.length) {
+ obj.stats = message.stats.map((e) => StatUsersResponse_StatUser.toJSON(e));
+ }
+ return obj;
+ },
+
+ create(base?: DeepPartial<StatUsersResponse>): StatUsersResponse {
+ return StatUsersResponse.fromPartial(base ?? {});
+ },
+ fromPartial(object: DeepPartial<StatUsersResponse>): StatUsersResponse {
+ const message = createBaseStatUsersResponse();
+ message.stats = object.stats?.map((e) => StatUsersResponse_StatUser.fromPartial(e)) || [];
+ return message;
+ },
+};
+
+function createBaseStatUsersResponse_StatUser(): StatUsersResponse_StatUser {
+ return { userType: UserType.USER_TYPE_UNSPECIFIED, state: State.STATE_UNSPECIFIED, count: 0 };
+}
+
+export const StatUsersResponse_StatUser: MessageFns<StatUsersResponse_StatUser> = {
+ encode(message: StatUsersResponse_StatUser, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
+ if (message.userType !== UserType.USER_TYPE_UNSPECIFIED) {
+ writer.uint32(8).int32(userTypeToNumber(message.userType));
+ }
+ if (message.state !== State.STATE_UNSPECIFIED) {
+ writer.uint32(16).int32(stateToNumber(message.state));
+ }
+ if (message.count !== 0) {
+ writer.uint32(24).int32(message.count);
+ }
+ return writer;
+ },
+
+ decode(input: BinaryReader | Uint8Array, length?: number): StatUsersResponse_StatUser {
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = createBaseStatUsersResponse_StatUser();
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1: {
+ if (tag !== 8) {
+ break;
+ }
+
+ message.userType = userTypeFromJSON(reader.int32());
+ continue;
+ }
+ case 2: {
+ if (tag !== 16) {
+ break;
+ }
+
+ message.state = stateFromJSON(reader.int32());
+ continue;
+ }
+ case 3: {
+ if (tag !== 24) {
+ break;
+ }
+
+ message.count = reader.int32();
+ continue;
+ }
+ }
+ if ((tag & 7) === 4 || tag === 0) {
+ break;
+ }
+ reader.skip(tag & 7);
+ }
+ return message;
+ },
+
+ fromJSON(object: any): StatUsersResponse_StatUser {
+ return {
+ userType: isSet(object.userType) ? userTypeFromJSON(object.userType) : UserType.USER_TYPE_UNSPECIFIED,
+ state: isSet(object.state) ? stateFromJSON(object.state) : State.STATE_UNSPECIFIED,
+ count: isSet(object.count) ? globalThis.Number(object.count) : 0,
+ };
+ },
+
+ toJSON(message: StatUsersResponse_StatUser): unknown {
+ const obj: any = {};
+ if (message.userType !== UserType.USER_TYPE_UNSPECIFIED) {
+ obj.userType = userTypeToJSON(message.userType);
+ }
+ if (message.state !== State.STATE_UNSPECIFIED) {
+ obj.state = stateToJSON(message.state);
+ }
+ if (message.count !== 0) {
+ obj.count = Math.round(message.count);
+ }
+ return obj;
+ },
+
+ create(base?: DeepPartial<StatUsersResponse_StatUser>): StatUsersResponse_StatUser {
+ return StatUsersResponse_StatUser.fromPartial(base ?? {});
+ },
+ fromPartial(object: DeepPartial<StatUsersResponse_StatUser>): StatUsersResponse_StatUser {
+ const message = createBaseStatUsersResponse_StatUser();
+ message.userType = object.userType ?? UserType.USER_TYPE_UNSPECIFIED;
+ message.state = object.state ?? State.STATE_UNSPECIFIED;
+ message.count = object.count ?? 0;
+ return message;
+ },
+};
+
function createBaseListUsersRequest(): ListUsersRequest {
return { pageSize: 0, pageToken: "", showDeleted: false, filter: "" };
}
@@ -1179,6 +1392,26 @@ export const UserServiceDefinition = {
},
},
},
+ /**
+ * Get user stat.
+ * Any authenticated user can get stat.
+ */
+ statUsers: {
+ name: "StatUsers",
+ requestType: StatUsersRequest,
+ requestStream: false,
+ responseType: StatUsersResponse,
+ responseStream: false,
+ options: {
+ _unknownFields: {
+ 8410: [new Uint8Array([6, 112, 97, 114, 101, 110, 116])],
+ 800016: [new Uint8Array([2])],
+ 578365826: [
+ new Uint8Array([19, 58, 1, 42, 34, 14, 47, 118, 49, 47, 117, 115, 101, 114, 115, 58, 115, 116, 97, 116]),
+ ],
+ },
+ },
+ },
/**
* Create a user.
* When Disallow Signup is enabled, only the caller with bb.users.create on the workspace can create a user.
diff --git a/frontend/src/types/review.ts b/frontend/src/types/review.ts
index 82242ec590..5cb6264000 100644
--- a/frontend/src/types/review.ts
+++ b/frontend/src/types/review.ts
@@ -1,4 +1,3 @@
-import { type User } from "@/types/proto/v1/user_service";
import type { ApprovalStep, Issue_Approver } from "./proto/v1/issue_service";
import { ApprovalTemplate } from "./proto/v1/issue_service";
@@ -12,8 +11,8 @@ export type WrappedReviewStep = {
index: number;
step: ApprovalStep;
status: "APPROVED" | "REJECTED" | "CURRENT" | "PENDING";
- approver: User | undefined;
- candidates: User[];
+ approver: string | undefined;
+ candidates: string[];
};
export const emptyFlow = (): ReviewFlow => {
diff --git a/frontend/src/types/v1/user.ts b/frontend/src/types/v1/user.ts
index 56e3a60880..ec52fc12a7 100644
--- a/frontend/src/types/v1/user.ts
+++ b/frontend/src/types/v1/user.ts
@@ -1,7 +1,7 @@
import { SYSTEM_BOT_ID } from "../common";
import { EMPTY_ID, UNKNOWN_ID } from "../const";
-import { User, UserType } from "../proto/v1/user_service";
import { State } from "../proto/v1/common";
+import { User, UserType } from "../proto/v1/user_service";
export const UNKNOWN_USER_NAME = `users/${UNKNOWN_ID}`;
export const SYSTEM_BOT_USER_NAME = `users/${SYSTEM_BOT_ID}`;
@@ -37,17 +37,6 @@ export const allUsersUser = (): User => {
};
};
-export const filterUserListByKeyword = (userList: User[], keyword: string) => {
- keyword = keyword.trim().toLowerCase();
- if (!keyword) return userList;
- return userList.filter((user) => {
- return (
- user.title.toLowerCase().includes(keyword) ||
- user.email.toLowerCase().includes(keyword)
- );
- });
-};
-
export const userBindingPrefix = "user:";
export const getUserEmailInBinding = (email: string) => {
@@ -62,3 +51,13 @@ export const groupBindingPrefix = "group:";
export const getGroupEmailInBinding = (email: string) => {
return `${groupBindingPrefix}${email}`;
};
+
+export const isValidUserName = (name: string) => {
+ return (
+ !!name &&
+ name.startsWith("users/") &&
+ name !== emptyUser().name &&
+ name !== unknownUser().name &&
+ name !== allUsersUser().name
+ );
+};
diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.ts
index 5432d3cba7..2942c9aa64 100644
--- a/frontend/src/utils/index.ts
+++ b/frontend/src/utils/index.ts
@@ -26,3 +26,4 @@ export * from "./useDashboardSidebar";
export * from "./v1";
export * from "./iam";
export * from "./auto-route";
+export * from "./pagination";
diff --git a/frontend/src/utils/pagination.ts b/frontend/src/utils/pagination.ts
new file mode 100644
index 0000000000..66c999669f
--- /dev/null
+++ b/frontend/src/utils/pagination.ts
@@ -0,0 +1,8 @@
+import { useCurrentUserV1 } from "@/store";
+
+export const getDefaultPagination = () => {
+ if (useCurrentUserV1().value.email.endsWith("@bytebase.com")) {
+ return 1;
+ }
+ return 50;
+};
diff --git a/frontend/src/utils/v1/advanced-search/issue/ui-filter.ts b/frontend/src/utils/v1/advanced-search/issue/ui-filter.ts
index eabf630695..0c56969c4f 100644
--- a/frontend/src/utils/v1/advanced-search/issue/ui-filter.ts
+++ b/frontend/src/utils/v1/advanced-search/issue/ui-filter.ts
@@ -3,10 +3,9 @@ import {
releaserCandidatesForIssue,
useWrappedReviewStepsV1,
} from "@/components/IssueV1/logic";
-import { useUserStore } from "@/store";
import type { ComposedIssue } from "@/types";
import { Issue_Approver_Status } from "@/types/proto/v1/issue_service";
-import { extractUserResourceName } from "@/utils/v1/user";
+import { isUserIncludedInList } from "@/utils";
import type { SearchParams } from "../common";
import { getValueFromSearchParams } from "../common";
@@ -40,11 +39,7 @@ export const filterIssueByApprover = (
// Planning to support "approver:[{email_1}, {email_2}, ...]" and
// "approver:roles/{role}" in the future
if (approver.startsWith("users/")) {
- return (
- currentStep.candidates.findIndex(
- (user) => `users/${user.email}` === approver
- ) >= 0
- );
+ return currentStep.candidates.includes(approver);
}
console.error(
@@ -64,18 +59,8 @@ export const filterIssueByReleaser = (
// Planning to support "release:[{email_1}, {email_2}, ...]" and
// "release:roles/{role}" in the future
if (releaser.startsWith("users/")) {
- const user = useUserStore().getUserByEmail(
- extractUserResourceName(releaser)
- );
- if (!user) return false;
-
const candidates = releaserCandidatesForIssue(issue);
- // Otherwise any releasers can rollout the issue.
- if (candidates.findIndex((c) => c.name === user.name) >= 0) {
- return true;
- }
-
- return false;
+ return isUserIncludedInList(releaser, candidates);
}
console.error(
diff --git a/frontend/src/utils/v1/iam.ts b/frontend/src/utils/v1/iam.ts
index 8dd507bf9f..b9aa30ee55 100644
--- a/frontend/src/utils/v1/iam.ts
+++ b/frontend/src/utils/v1/iam.ts
@@ -1,18 +1,11 @@
-import { orderBy, uniq } from "lodash-es";
+import { uniq } from "lodash-es";
+import { extractUserId, useGroupStore, useWorkspaceV1Store } from "@/store";
+import { roleNamePrefix, userNamePrefix } from "@/store/modules/v1/common";
import {
- extractUserEmail,
- useUserStore,
- useGroupStore,
- useWorkspaceV1Store,
-} from "@/store";
-import { roleNamePrefix } from "@/store/modules/v1/common";
-import {
- ALL_USERS_USER_EMAIL,
PresetRoleType,
groupBindingPrefix,
PRESET_WORKSPACE_ROLES,
} from "@/types";
-import type { User } from "@/types/proto/v1/user_service";
import type { IamPolicy, Binding } from "@/types/proto/v1/iam_policy";
import { convertFromExpr } from "@/utils/issue/cel";
@@ -29,6 +22,9 @@ export const isBindingPolicyExpired = (binding: Binding): boolean => {
return false;
};
+// getUserEmailListInBinding will extract users in the IAM policy binding.
+// If the binding is group, will conains all members email in the group.
+// It can also includs ALL_USERS_USER_EMAIL
export const getUserEmailListInBinding = ({
binding,
ignoreGroup,
@@ -41,7 +37,6 @@ export const getUserEmailListInBinding = ({
}
const groupStore = useGroupStore();
- const userStore = useUserStore();
const emailList = [];
for (const member of binding.members) {
@@ -54,29 +49,26 @@ export const getUserEmailListInBinding = ({
continue;
}
- emailList.push(...group.members.map((m) => extractUserEmail(m.member)));
+ emailList.push(...group.members.map((m) => extractUserId(m.member)));
} else {
- const email = extractUserEmail(member);
- if (email === ALL_USERS_USER_EMAIL) {
- return userStore.activeUserList.map((user) => user.email);
- } else {
- emailList.push(email);
- }
+ const email = extractUserId(member);
+ // ATTENTION:
+ // the email can be ALL_USERS_USER_EMAIL
+ emailList.push(email);
}
}
return uniq(emailList);
};
-export const memberListInProjectIAM = (
+// memberMapToRolesInProjectIAM return the Map<users/{email}, Set<roles/{role}>>
+// the user could includes users/ALL_USERS_USER_EMAIL
+export const memberMapToRolesInProjectIAM = (
iamPolicy: IamPolicy,
targetRole?: string
-) => {
- const userStore = useUserStore();
+): Map<string, Set<string>> => {
const workspaceStore = useWorkspaceV1Store();
-
- const emailSet = new Set<string>();
- // rolesMapByEmail is Map<email, role list>
- const rolesMapByEmail = new Map<string, Set<string>>();
+ // Map<users/{email}, Set<roles/{role}>>
+ const rolesMapByName = new Map<string, Set<string>>();
// Handle project level roles.
for (const binding of iamPolicy.bindings) {
@@ -90,58 +82,31 @@ export const memberListInProjectIAM = (
const emails = getUserEmailListInBinding({ binding, ignoreGroup: false });
for (const email of emails) {
- if (!rolesMapByEmail.has(email)) {
- rolesMapByEmail.set(email, new Set());
+ const key = `${userNamePrefix}${email}`;
+ if (!rolesMapByName.has(key)) {
+ rolesMapByName.set(key, new Set());
}
- rolesMapByEmail.get(email)?.add(binding.role);
- emailSet.add(email);
+ rolesMapByName.get(key)?.add(binding.role);
}
}
// Handle workspace level project roles.
- for (const [email, roleSet] of workspaceStore.emailMapToRoles.entries()) {
- emailSet.add(email);
- if (!rolesMapByEmail.has(email)) {
- rolesMapByEmail.set(email, new Set());
- }
- for (const role of roleSet.values()) {
- if (PRESET_WORKSPACE_ROLES.includes(role)) {
- continue;
- }
- if (targetRole && role !== targetRole) {
- continue;
- }
- rolesMapByEmail.get(email)?.add(role);
- }
- }
-
- const composedUserList: {
- user: User;
- roleList: string[];
- }[] = [];
- for (const email of emailSet.values()) {
- const user = userStore.getUserByEmail(email);
- if (!user) {
+ for (const [role, userSet] of workspaceStore.roleMapToUsers.entries()) {
+ if (PRESET_WORKSPACE_ROLES.includes(role)) {
continue;
}
- const roleList = rolesMapByEmail.get(email);
- if (!roleList || roleList.size === 0) {
+ if (targetRole && role !== targetRole) {
continue;
}
- composedUserList.push({
- user,
- roleList: [...roleList],
- });
+ for (const user of userSet.values()) {
+ if (!rolesMapByName.has(user)) {
+ rolesMapByName.set(user, new Set());
+ }
+ rolesMapByName.get(user)?.add(role);
+ }
}
- return orderBy(
- composedUserList,
- [
- (item) => (item.roleList.includes(PresetRoleType.PROJECT_OWNER) ? 0 : 1),
- (item) => item.user.email,
- ],
- ["asc", "asc"]
- );
+ return rolesMapByName;
};
export const roleListInIAM = ({
diff --git a/frontend/src/utils/v1/role.ts b/frontend/src/utils/v1/role.ts
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/frontend/src/utils/v1/user.ts b/frontend/src/utils/v1/user.ts
index 54f109fcee..b16a23b40c 100644
--- a/frontend/src/utils/v1/user.ts
+++ b/frontend/src/utils/v1/user.ts
@@ -1,13 +1,24 @@
-export const extractUserUID = (name: string) => {
- // They are using the same format so we can simply call the method.
- return extractUserResourceName(name);
+import { userNamePrefix, extractUserId } from "@/store/modules/v1/common";
+import { ALL_USERS_USER_EMAIL } from "@/types";
+
+export const ensureUserFullName = (identifier: string) => {
+ const id = extractUserId(identifier);
+ return `${userNamePrefix}${id}`;
};
-/**
- * @param name Format: users/{email}
- */
-export const extractUserResourceName = (name: string) => {
- const pattern = /(?:^|\/)users\/([^/]+)(?:$|\/)/;
- const matches = name.match(pattern);
- return matches?.[1] ?? "";
+export const isUserIncludedInList = (
+ identifier: string,
+ userList: string[]
+) => {
+ const validId = ensureUserFullName(identifier);
+ for (const name of userList) {
+ if (
+ name === ALL_USERS_USER_EMAIL ||
+ name === `${userNamePrefix}${ALL_USERS_USER_EMAIL}` ||
+ name === validId
+ ) {
+ return true;
+ }
+ }
+ return false;
};
diff --git a/frontend/src/utils/v1/worksheet.ts b/frontend/src/utils/v1/worksheet.ts
index d49d2d5f7c..f0b2ce35c6 100644
--- a/frontend/src/utils/v1/worksheet.ts
+++ b/frontend/src/utils/v1/worksheet.ts
@@ -1,5 +1,5 @@
import { useAuthStore, useProjectV1Store } from "@/store";
-import { getUserEmailFromIdentifier } from "@/store/modules/v1/common";
+import { extractUserId } from "@/store/modules/v1/common";
import { UNKNOWN_PROJECT_NAME } from "@/types";
import type { Worksheet } from "@/types/proto/v1/worksheet_service";
import { Worksheet_Visibility } from "@/types/proto/v1/worksheet_service";
@@ -18,9 +18,7 @@ export const extractWorksheetUID = (name: string) => {
export const isWorksheetReadableV1 = (sheet: Worksheet) => {
const authStore = useAuthStore();
- if (
- getUserEmailFromIdentifier(sheet.creator) === authStore.currentUser.email
- ) {
+ if (extractUserId(sheet.creator) === authStore.currentUser.email) {
// Always readable to the creator
return true;
}
@@ -51,9 +49,7 @@ export const isWorksheetReadableV1 = (sheet: Worksheet) => {
export const isWorksheetWritableV1 = (sheet: Worksheet) => {
const authStore = useAuthStore();
- if (
- getUserEmailFromIdentifier(sheet.creator) === authStore.currentUser.email
- ) {
+ if (extractUserId(sheet.creator) === authStore.currentUser.email) {
// Always writable to the creator
return true;
}
diff --git a/frontend/src/views/ProfileDashboard.vue b/frontend/src/views/ProfileDashboard.vue
index 1539cfdca9..c65136e8fc 100644
--- a/frontend/src/views/ProfileDashboard.vue
+++ b/frontend/src/views/ProfileDashboard.vue
@@ -224,7 +224,7 @@
</template>
<script lang="ts" setup>
-import { useTitle } from "@vueuse/core";
+import { computedAsync, useTitle } from "@vueuse/core";
import { cloneDeep, head, isEqual } from "lodash-es";
import type { DropdownOption } from "naive-ui";
import { NButton, NInput, NDropdown, NTag } from "naive-ui";
@@ -341,12 +341,12 @@ const showRegenerateRecoveryCodes = computed(() => {
return user.value.mfaEnabled && user.value.name === currentUserV1.value.name;
});
-const user = computed(() => {
+const user = computedAsync(() => {
if (props.principalEmail) {
- return userStore.getUserByEmail(props.principalEmail) ?? unknownUser();
+ return userStore.getOrFetchUserByIdentifier(props.principalEmail);
}
return currentUserV1.value;
-});
+}, unknownUser());
const userRoles = computed(() => {
return [...workspaceStore.getWorkspaceRolesByEmail(user.value.email)];
@@ -377,12 +377,6 @@ const allowSaveEdit = computed(() => {
);
});
-onMounted(async () => {
- if (props.principalEmail) {
- await useUserStore().getOrFetchUserById(props.principalEmail);
- }
-});
-
const updateUser = <K extends keyof User>(field: K, value: User[K]) => {
if (!state.editingUser) return;
@@ -434,7 +428,6 @@ const saveEdit = async () => {
});
return;
}
- await useAuthStore().refreshUserIfNeeded(currentUserV1.value.name);
state.editingUser = undefined;
state.editing = false;
@@ -483,7 +476,6 @@ const handleDisable2FA = async () => {
updateMask: ["mfa_enabled"],
})
);
- await userStore.fetchUser(user.value.name, true /* slient */);
state.showDisable2FAConfirmModal = false;
pushNotification({
module: "bytebase",
diff --git a/frontend/src/views/SettingWorkspaceAuditLog.vue b/frontend/src/views/SettingWorkspaceAuditLog.vue
index 50957baab5..2c72943c4a 100644
--- a/frontend/src/views/SettingWorkspaceAuditLog.vue
+++ b/frontend/src/views/SettingWorkspaceAuditLog.vue
@@ -54,6 +54,7 @@ import {
featureToRef,
useAuditLogStore,
batchGetOrFetchProjects,
+ batchGetOrFetchUsers,
pushNotification,
} from "@/store";
import { projectNamePrefix } from "@/store/modules/v1/common";
@@ -110,6 +111,7 @@ const fetchAuditLog = async ({
return `${projectNamePrefix}${projectResourceId}`;
})
);
+ await batchGetOrFetchUsers(auditLogs.map((log) => log.user));
return { nextPageToken, list: auditLogs };
};
diff --git a/frontend/src/views/SettingWorkspaceMembers.vue b/frontend/src/views/SettingWorkspaceMembers.vue
index 4fca41e5ae..8619405996 100644
--- a/frontend/src/views/SettingWorkspaceMembers.vue
+++ b/frontend/src/views/SettingWorkspaceMembers.vue
@@ -78,6 +78,7 @@
</template>
<script setup lang="ts">
+import { computedAsync } from "@vueuse/core";
import { NButton, NTabs, NTabPane, useDialog } from "naive-ui";
import { computed, reactive } from "vue";
import { useI18n } from "vue-i18n";
@@ -190,7 +191,7 @@ const revokeMember = async (binding: MemberBinding) => {
});
};
-const memberBindingsByRole = computed(() => {
+const memberBindingsByRole = computedAsync(() => {
return getMemberBindingsByRole({
policies: [
{
@@ -201,7 +202,7 @@ const memberBindingsByRole = computed(() => {
searchText: state.searchText,
ignoreRoles: new Set([PresetRoleType.WORKSPACE_MEMBER]),
});
-});
+}, new Map());
const memberBindings = computed(() => {
return getMemberBindings(memberBindingsByRole.value);
diff --git a/frontend/src/views/SettingWorkspaceSubscription.vue b/frontend/src/views/SettingWorkspaceSubscription.vue
index 7269860db0..5fa217be33 100644
--- a/frontend/src/views/SettingWorkspaceSubscription.vue
+++ b/frontend/src/views/SettingWorkspaceSubscription.vue
@@ -72,7 +72,7 @@
{{ $t("subscription.instance-assignment.used-and-total-user") }}
</div>
<div class="mt-1 text-4xl flex items-center gap-2">
- {{ userCount }}
+ {{ userStore.activeUserCountWithoutBot }}
<span class="font-mono text-gray-500">/</span>
{{ userLimit }}
</div>
@@ -173,7 +173,6 @@ import {
} from "@/store";
import { ENTERPRISE_INQUIRE_LINK } from "@/types";
import { PlanType } from "@/types/proto/v1/subscription_service";
-import { UserType } from "@/types/proto/v1/user_service";
import { hasWorkspacePermissionV2 } from "@/utils";
interface LocalState {
@@ -204,14 +203,6 @@ const disabled = computed((): boolean => {
return state.loading || !state.license;
});
-const userCount = computed(() => {
- return userStore.activeUserList.filter(
- (user) =>
- user.userType === UserType.USER ||
- user.userType === UserType.SERVICE_ACCOUNT
- ).length;
-});
-
const userLimit = computed((): string => {
if (subscriptionStore.userCountLimit === Number.MAX_VALUE) {
return t("subscription.unlimited");
diff --git a/frontend/src/views/SettingWorkspaceUsers.vue b/frontend/src/views/SettingWorkspaceUsers.vue
index 0307c9393d..3f71c98d20 100644
--- a/frontend/src/views/SettingWorkspaceUsers.vue
+++ b/frontend/src/views/SettingWorkspaceUsers.vue
@@ -13,19 +13,28 @@
<p class="text-base font-medium leading-7 text-main">
<span>{{ $t("common.users") }}</span>
<span class="ml-1 font-normal text-control-light">
- ({{ userStore.activeUserList.length }})
+ ({{ activeUserCount }})
</span>
</p>
</div>
</template>
- <UserDataTable
- :show-roles="false"
- :user-list="filteredUserList"
- :on-click-user="onClickUser"
- @update-user="handleUpdateUser"
- @select-group="handleUpdateGroup"
- />
+ <PagedTable
+ ref="userPagedTable"
+ session-key="bb.paged-user-table.active"
+ :fetch-list="fetchUserList"
+ >
+ <template #table="{ list, loading }">
+ <UserDataTable
+ :show-roles="false"
+ :user-list="list"
+ :loading="loading"
+ :on-click-user="onUserClick"
+ @select-group="handleUpdateGroup"
+ @update-user="handleUserUpdated"
+ />
+ </template>
+ </PagedTable>
</NTabPane>
<NTabPane name="GROUPS">
@@ -42,7 +51,7 @@
<UserDataTableByGroup
:groups="filteredGroupList"
- :on-click-user="onClickUser"
+ :on-click-user="onUserClick"
@update-group="handleUpdateGroup"
/>
</NTabPane>
@@ -112,7 +121,7 @@
</NTabs>
<div>
- <div v-if="inactiveUserList.length > 0 && state.typeTab === 'USERS'">
+ <div v-if="state.typeTab === 'USERS'">
<NCheckbox v-model:checked="state.showInactiveUserList">
<span class="textinfolabel">
{{ $t("settings.members.show-inactive") }}
@@ -125,7 +134,7 @@
<p class="text-lg font-medium leading-7">
<span>{{ $t("settings.members.inactive") }}</span>
<span class="ml-1 font-normal text-control-light">
- ({{ inactiveUserList.length }})
+ ({{ inactiveUserCount }})
</span>
</p>
@@ -134,7 +143,20 @@
</div>
</div>
- <UserDataTable :show-roles="false" :user-list="inactiveUserList" />
+ <PagedTable
+ ref="deletedUserPagedTable"
+ session-key="bb.paged-user-table.deleted"
+ :fetch-list="fetchInactiveUserList"
+ >
+ <template #table="{ list, loading }">
+ <UserDataTable
+ :loading="loading"
+ :show-roles="false"
+ :user-list="list"
+ @update-user="handleUserUpdated"
+ />
+ </template>
+ </PagedTable>
</template>
</div>
</div>
@@ -143,6 +165,7 @@
v-if="state.showCreateUserDrawer"
:user="state.editingUser"
@close="state.showCreateUserDrawer = false"
+ @created="handleUserCreated"
/>
<CreateGroupDrawer
v-if="state.showCreateGroupDrawer"
@@ -165,32 +188,33 @@
<script setup lang="ts">
import { PlusIcon, SettingsIcon } from "lucide-vue-next";
import { NButton, NTabs, NTabPane, NPopover, NCheckbox } from "naive-ui";
-import { computed, onMounted, reactive, watch } from "vue";
+import { computed, onMounted, reactive, watch, ref } from "vue";
+import type { ComponentExposed } from "vue-component-type-helpers";
import { useI18n } from "vue-i18n";
import { useRoute, useRouter, RouterLink } from "vue-router";
-import { FeatureAttention } from "@/components/FeatureGuard";
import { FeatureBadge, FeatureModal } from "@/components/FeatureGuard";
+import { FeatureAttention } from "@/components/FeatureGuard";
import AADSyncDrawer from "@/components/User/Settings/AADSyncDrawer.vue";
import CreateGroupDrawer from "@/components/User/Settings/CreateGroupDrawer.vue";
import CreateUserDrawer from "@/components/User/Settings/CreateUserDrawer.vue";
import UserDataTable from "@/components/User/Settings/UserDataTable/index.vue";
import UserDataTableByGroup from "@/components/User/Settings/UserDataTableByGroup/index.vue";
import { SearchBox } from "@/components/v2";
+import PagedTable from "@/components/v2/Model/PagedTable.vue";
import { WORKSPACE_ROUTE_USER_PROFILE } from "@/router/dashboard/workspaceRoutes";
import {
- useSubscriptionV1Store,
useUserStore,
useUIStateStore,
useGroupStore,
useSettingV1Store,
featureToRef,
+ useSubscriptionV1Store,
} from "@/store";
import { groupNamePrefix } from "@/store/modules/v1/common";
-import { ALL_USERS_USER_EMAIL, filterUserListByKeyword } from "@/types";
-import { UserType, type User } from "@/types/proto/v1/user_service";
-import { State } from "@/types/proto/v1/common";
+import { State, stateToJSON } from "@/types/proto/v1/common";
import type { Group } from "@/types/proto/v1/group_service";
import { WorkspaceProfileSetting } from "@/types/proto/v1/setting_service";
+import { type User } from "@/types/proto/v1/user_service";
import { hasWorkspacePermissionV2 } from "@/utils";
const tabList = ["USERS", "GROUPS"] as const;
@@ -211,7 +235,7 @@ type LocalState = {
showFeatureModal: boolean;
};
-defineProps<{
+const props = defineProps<{
onClickUser?: (user: User, event: MouseEvent) => void;
}>();
@@ -232,8 +256,10 @@ const router = useRouter();
const userStore = useUserStore();
const groupStore = useGroupStore();
const uiStateStore = useUIStateStore();
-const subscriptionV1Store = useSubscriptionV1Store();
const settingV1Store = useSettingV1Store();
+const subscriptionV1Store = useSubscriptionV1Store();
+const userPagedTable = ref<ComponentExposed<typeof PagedTable<User>>>();
+const deletedUserPagedTable = ref<ComponentExposed<typeof PagedTable<User>>>();
watch(
() => route.hash,
@@ -257,6 +283,45 @@ watch(
}
);
+const fetchUserList = async ({
+ pageToken,
+ pageSize,
+}: {
+ pageToken: string;
+ pageSize: number;
+}) => {
+ const { users, nextPageToken } = await userStore.fetchUserList({
+ pageToken,
+ pageSize,
+ showDeleted: false,
+ filter: state.activeUserFilterText
+ ? `name.matches("${state.activeUserFilterText}")`
+ : "",
+ });
+ return { list: users, nextPageToken };
+};
+
+watch(
+ () => state.activeUserFilterText,
+ () => userPagedTable.value?.refresh()
+);
+
+const fetchInactiveUserList = async ({
+ pageToken,
+ pageSize,
+}: {
+ pageToken: string;
+ pageSize: number;
+}) => {
+ const { users, nextPageToken } = await userStore.fetchUserList({
+ pageToken,
+ pageSize,
+ showDeleted: true,
+ filter: `state == "${stateToJSON(State.DELETED)}"`,
+ });
+ return { list: users, nextPageToken };
+};
+
const workspaceProfileSetting = computed(() =>
WorkspaceProfileSetting.fromPartial(
settingV1Store.workspaceProfileSetting || {}
@@ -295,19 +360,6 @@ onMounted(() => {
}
});
-const userList = computed(() => {
- return userStore.userList.filter(
- (user) => user.email !== ALL_USERS_USER_EMAIL
- );
-});
-
-const filteredUserList = computed(() => {
- return filterUserListByKeyword(
- userStore.activeUserList,
- state.activeUserFilterText
- );
-});
-
const filteredGroupList = computed(() => {
const keyword = state.activeUserFilterText.trim().toLowerCase();
if (!keyword) return groupStore.groupList;
@@ -319,38 +371,45 @@ const filteredGroupList = computed(() => {
});
});
-const inactiveUserList = computed(() => {
- const list = userList.value.filter(
- (user) =>
- user.state === State.DELETED && user.userType !== UserType.SYSTEM_BOT
- );
- return filterUserListByKeyword(list, state.inactiveUserFilterText);
+const activeUserCount = computed(() => {
+ return userStore.userStats.reduce((count, stat) => {
+ if (stat.state === State.ACTIVE) {
+ count += stat.count;
+ }
+ return count;
+ }, 0);
});
-const endUserList = computed(() => {
- return userStore.activeUserList.filter(
- (user) =>
- user.userType === UserType.USER ||
- user.userType === UserType.SERVICE_ACCOUNT
- );
+const inactiveUserCount = computed(() => {
+ return userStore.userStats.reduce((count, stat) => {
+ if (stat.state === State.DELETED) {
+ count += stat.count;
+ }
+ return count;
+ }, 0);
});
const remainingUserCount = computed((): number => {
return Math.max(
0,
- subscriptionV1Store.userCountLimit - endUserList.value.length
+ subscriptionV1Store.userCountLimit - userStore.activeUserCountWithoutBot
);
});
const userCountAttention = computed((): string => {
- const upgrade = t("dynamic.subscription.features.bb-feature-user-count.upgrade");
+ const upgrade = t(
+ "dynamic.subscription.features.bb-feature-user-count.upgrade"
+ );
let status = "";
if (remainingUserCount.value > 0) {
- status = t("dynamic.subscription.features.bb-feature-user-count.remaining", {
- total: subscriptionV1Store.userCountLimit,
- count: remainingUserCount.value,
- });
+ status = t(
+ "dynamic.subscription.features.bb-feature-user-count.remaining",
+ {
+ total: subscriptionV1Store.userCountLimit,
+ count: remainingUserCount.value,
+ }
+ );
} else {
status = t("dynamic.subscription.features.bb-feature-user-count.runoutof", {
total: subscriptionV1Store.userCountLimit,
@@ -375,7 +434,19 @@ const handleCreateUser = () => {
state.showCreateUserDrawer = true;
};
-const handleUpdateUser = (user: User) => {
+const handleUserCreated = () => {
+ userPagedTable.value?.refresh();
+};
+
+const handleUserUpdated = (_: User) => {
+ userPagedTable.value?.refresh();
+ deletedUserPagedTable.value?.refresh();
+};
+
+const onUserClick = (user: User, event: MouseEvent) => {
+ if (props.onClickUser) {
+ return props.onClickUser(user, event);
+ }
router.push({
name: WORKSPACE_ROUTE_USER_PROFILE,
params: {
diff --git a/frontend/src/views/TwoFactorSetup.vue b/frontend/src/views/TwoFactorSetup.vue
index 839060b29d..1268a00126 100644
--- a/frontend/src/views/TwoFactorSetup.vue
+++ b/frontend/src/views/TwoFactorSetup.vue
@@ -154,7 +154,6 @@ const regenerateTempMfaSecret = async () => {
regenerateTempMfaSecret: true,
})
);
- await authStore.refreshUserIfNeeded(currentUser.value.name);
};
const verifyTOPCode = async () => {
@@ -209,7 +208,6 @@ const tryFinishSetup = async () => {
updateMask: ["mfa_enabled"],
})
);
- await authStore.refreshUserIfNeeded(currentUser.value.name);
pushNotification({
module: "bytebase",
style: "SUCCESS",
diff --git a/frontend/src/views/project/ProjectAuditLogDashboard.vue b/frontend/src/views/project/ProjectAuditLogDashboard.vue
index d278c64f0d..fe7e60a2d7 100644
--- a/frontend/src/views/project/ProjectAuditLogDashboard.vue
+++ b/frontend/src/views/project/ProjectAuditLogDashboard.vue
@@ -55,7 +55,12 @@ import DataExportButton from "@/components/DataExportButton.vue";
import { FeatureAttention } from "@/components/FeatureGuard";
import NoDataPlaceholder from "@/components/misc/NoDataPlaceholder.vue";
import PagedTable from "@/components/v2/Model/PagedTable.vue";
-import { featureToRef, useAuditLogStore, pushNotification } from "@/store";
+import {
+ featureToRef,
+ useAuditLogStore,
+ batchGetOrFetchUsers,
+ pushNotification,
+} from "@/store";
import { type SearchAuditLogsParams } from "@/types";
import type { AuditLog } from "@/types/proto/v1/audit_log_service";
import { ExportFormat } from "@/types/proto/v1/common";
@@ -108,6 +113,7 @@ const fetchAuditLog = async ({
pageToken,
pageSize,
});
+ await batchGetOrFetchUsers(auditLogs.map((log) => log.user));
return { nextPageToken, list: auditLogs };
};
diff --git a/frontend/src/views/sql-editor/Setting/Members/Members.vue b/frontend/src/views/sql-editor/Setting/Members/Members.vue
index 32e64853db..a01b0c45fe 100644
--- a/frontend/src/views/sql-editor/Setting/Members/Members.vue
+++ b/frontend/src/views/sql-editor/Setting/Members/Members.vue
@@ -46,10 +46,10 @@ const handleClickUser = (user: User) => {
state.detail.user = user;
};
-onMounted(() => {
+onMounted(async () => {
const maybeEmail = route.hash.replace(/^#*/g, "");
if (maybeEmail) {
- const user = useUserStore().getUserByEmail(maybeEmail);
+ const user = await useUserStore().getOrFetchUserByIdentifier(maybeEmail);
if (user) {
state.detail.show = true;
state.detail.user = user;
diff --git a/frontend/src/views/sql-editor/Setting/Users/Users.vue b/frontend/src/views/sql-editor/Setting/Users/Users.vue
index 5fe9f54941..7fd44889fe 100644
--- a/frontend/src/views/sql-editor/Setting/Users/Users.vue
+++ b/frontend/src/views/sql-editor/Setting/Users/Users.vue
@@ -43,15 +43,16 @@ const detailTitle = computed(() => {
return `${user.title} (${user.email})`;
});
+// TODO(ed): not use the drawer.
const handleClickUser = (user: User) => {
state.detail.show = true;
state.detail.user = user;
};
-onMounted(() => {
+onMounted(async () => {
const maybeEmail = route.hash.replace(/^#*/g, "");
if (maybeEmail) {
- const user = useUserStore().getUserByEmail(maybeEmail);
+ const user = await useUserStore().getOrFetchUserByIdentifier(maybeEmail);
if (user) {
state.detail.show = true;
state.detail.user = user;
diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yaml
index 7ef032e2f6..270571398c 100644
--- a/proto/gen/grpc-doc/openapi.yaml
+++ b/proto/gen/grpc-doc/openapi.yaml
@@ -7146,14 +7146,17 @@ paths:
- name
- email
- user_type
+ - state
For example:
name == "ed"
name.matches("ed")
email == "[email protected]"
+ email.matches("ed")
user_type == "SERVICE_ACCOUNT"
user_type in ["SERVICE_ACCOUNT", "USER"]
!(user_type in ["SERVICE_ACCOUNT", "USER"])
+ state == "DELETED"
schema:
type: string
responses:
@@ -7334,6 +7337,33 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Status'
+ /v1/users:stat:
+ post:
+ tags:
+ - UserService
+ description: |-
+ Get user stat.
+ Any authenticated user can get stat.
+ operationId: UserService_StatUsers
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/StatUsersRequest'
+ required: true
+ responses:
+ "200":
+ description: OK
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/StatUsersResponse'
+ default:
+ description: Default error response
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Status'
/v1/worksheets:
post:
tags:
@@ -12868,6 +12898,37 @@ components:
type: array
items:
$ref: '#/components/schemas/Task'
+ StatUsersRequest:
+ type: object
+ properties: {}
+ StatUsersResponse:
+ type: object
+ properties:
+ stats:
+ type: array
+ items:
+ $ref: '#/components/schemas/StatUsersResponse_StatUser'
+ StatUsersResponse_StatUser:
+ type: object
+ properties:
+ userType:
+ enum:
+ - USER_TYPE_UNSPECIFIED
+ - USER
+ - SYSTEM_BOT
+ - SERVICE_ACCOUNT
+ type: string
+ format: enum
+ state:
+ enum:
+ - STATE_UNSPECIFIED
+ - ACTIVE
+ - DELETED
+ type: string
+ format: enum
+ count:
+ type: integer
+ format: int32
Status:
type: object
properties:
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index d04eaa3c8d..5717851a1c 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -320,6 +320,9 @@
- [GetUserRequest](#bytebase-v1-GetUserRequest)
- [ListUsersRequest](#bytebase-v1-ListUsersRequest)
- [ListUsersResponse](#bytebase-v1-ListUsersResponse)
+ - [StatUsersRequest](#bytebase-v1-StatUsersRequest)
+ - [StatUsersResponse](#bytebase-v1-StatUsersResponse)
+ - [StatUsersResponse.StatUser](#bytebase-v1-StatUsersResponse-StatUser)
- [UndeleteUserRequest](#bytebase-v1-UndeleteUserRequest)
- [UpdateUserRequest](#bytebase-v1-UpdateUserRequest)
- [User](#bytebase-v1-User)
@@ -5509,9 +5512,9 @@ Metadata about the request.
When paginating, all other parameters provided to `ListUsers` must match the call that provided the page token. |
| show_deleted | [bool](#bool) | | Show deleted users if specified. |
-| filter | [string](#string) | | Filter is used to filter users returned in the list. Supported filter: - name - email - user_type
+| filter | [string](#string) | | Filter is used to filter users returned in the list. Supported filter: - name - email - user_type - state
-For example: name == &#34;ed&#34; name.matches(&#34;ed&#34;) email == &#34;[email protected]&#34; user_type == &#34;SERVICE_ACCOUNT&#34; user_type in [&#34;SERVICE_ACCOUNT&#34;, &#34;USER&#34;] !(user_type in [&#34;SERVICE_ACCOUNT&#34;, &#34;USER&#34;]) |
+For example: name == &#34;ed&#34; name.matches(&#34;ed&#34;) email == &#34;[email protected]&#34; email.matches(&#34;ed&#34;) user_type == &#34;SERVICE_ACCOUNT&#34; user_type in [&#34;SERVICE_ACCOUNT&#34;, &#34;USER&#34;] !(user_type in [&#34;SERVICE_ACCOUNT&#34;, &#34;USER&#34;]) state == &#34;DELETED&#34; |
@@ -5534,6 +5537,48 @@ For example: name == &#34;ed&#34; name.matches(&#34;ed&#34;) email == &#34;ed@by
+<a name="bytebase-v1-StatUsersRequest"></a>
+
+### StatUsersRequest
+
+
+
+
+
+
+
+<a name="bytebase-v1-StatUsersResponse"></a>
+
+### StatUsersResponse
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| stats | [StatUsersResponse.StatUser](#bytebase-v1-StatUsersResponse-StatUser) | repeated | |
+
+
+
+
+
+
+<a name="bytebase-v1-StatUsersResponse-StatUser"></a>
+
+### StatUsersResponse.StatUser
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| user_type | [UserType](#bytebase-v1-UserType) | | |
+| state | [State](#bytebase-v1-State) | | |
+| count | [int32](#int32) | | |
+
+
+
+
+
+
<a name="bytebase-v1-UndeleteUserRequest"></a>
### UndeleteUserRequest
@@ -5642,6 +5687,7 @@ The user&#39;s `name` field is used to identify the user to update. Format: user
| ----------- | ------------ | ------------- | ------------|
| GetUser | [GetUserRequest](#bytebase-v1-GetUserRequest) | [User](#bytebase-v1-User) | Get the user. Any authenticated user can get the user. |
| ListUsers | [ListUsersRequest](#bytebase-v1-ListUsersRequest) | [ListUsersResponse](#bytebase-v1-ListUsersResponse) | List all users. Any authenticated user can list users. |
+| StatUsers | [StatUsersRequest](#bytebase-v1-StatUsersRequest) | [StatUsersResponse](#bytebase-v1-StatUsersResponse) | Get user stat. Any authenticated user can get stat. |
| CreateUser | [CreateUserRequest](#bytebase-v1-CreateUserRequest) | [User](#bytebase-v1-User) | Create a user. When Disallow Signup is enabled, only the caller with bb.users.create on the workspace can create a user. Otherwise, any unauthenticated user can create a user. |
| UpdateUser | [UpdateUserRequest](#bytebase-v1-UpdateUserRequest) | [User](#bytebase-v1-User) | Only the user itself and the user with bb.users.update permission on the workspace can update the user. |
| DeleteUser | [DeleteUserRequest](#bytebase-v1-DeleteUserRequest) | [.google.protobuf.Empty](#google-protobuf-Empty) | Only the user with bb.users.delete permission on the workspace can delete the user. The last remaining workspace admin cannot be deleted. |
diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.html
index 69ec3d39da..3bc9fde910 100644
--- a/proto/gen/grpc-doc/v1/index.html
+++ b/proto/gen/grpc-doc/v1/index.html
@@ -1397,6 +1397,18 @@
<a href="#bytebase.v1.ListUsersResponse"><span class="badge">M</span>ListUsersResponse</a>
</li>
+ <li>
+ <a href="#bytebase.v1.StatUsersRequest"><span class="badge">M</span>StatUsersRequest</a>
+ </li>
+
+ <li>
+ <a href="#bytebase.v1.StatUsersResponse"><span class="badge">M</span>StatUsersResponse</a>
+ </li>
+
+ <li>
+ <a href="#bytebase.v1.StatUsersResponse.StatUser"><span class="badge">M</span>StatUsersResponse.StatUser</a>
+ </li>
+
<li>
<a href="#bytebase.v1.UndeleteUserRequest"><span class="badge">M</span>UndeleteUserRequest</a>
</li>
@@ -15711,14 +15723,17 @@ Supported filter:
- name
- email
- user_type
+- state
For example:
name == &#34;ed&#34;
name.matches(&#34;ed&#34;)
email == &#34;[email protected]&#34;
+email.matches(&#34;ed&#34;)
user_type == &#34;SERVICE_ACCOUNT&#34;
user_type in [&#34;SERVICE_ACCOUNT&#34;, &#34;USER&#34;]
-!(user_type in [&#34;SERVICE_ACCOUNT&#34;, &#34;USER&#34;]) </p></td>
+!(user_type in [&#34;SERVICE_ACCOUNT&#34;, &#34;USER&#34;])
+state == &#34;DELETED&#34; </p></td>
</tr>
</tbody>
@@ -15760,6 +15775,75 @@ If this field is omitted, there are no subsequent pages. </p></td>
+ <h3 id="bytebase.v1.StatUsersRequest">StatUsersRequest</h3>
+ <p></p>
+
+
+
+
+
+ <h3 id="bytebase.v1.StatUsersResponse">StatUsersResponse</h3>
+ <p></p>
+
+
+ <table class="field-table">
+ <thead>
+ <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>stats</td>
+ <td><a href="#bytebase.v1.StatUsersResponse.StatUser">StatUsersResponse.StatUser</a></td>
+ <td>repeated</td>
+ <td><p> </p></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+
+
+
+
+ <h3 id="bytebase.v1.StatUsersResponse.StatUser">StatUsersResponse.StatUser</h3>
+ <p></p>
+
+
+ <table class="field-table">
+ <thead>
+ <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>user_type</td>
+ <td><a href="#bytebase.v1.UserType">UserType</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ <tr>
+ <td>state</td>
+ <td><a href="#bytebase.v1.State">State</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ <tr>
+ <td>count</td>
+ <td><a href="#int32">int32</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+
+
+
+
<h3 id="bytebase.v1.UndeleteUserRequest">UndeleteUserRequest</h3>
<p></p>
@@ -16047,6 +16131,14 @@ Any authenticated user can get the user.</p></td>
Any authenticated user can list users.</p></td>
</tr>
+ <tr>
+ <td>StatUsers</td>
+ <td><a href="#bytebase.v1.StatUsersRequest">StatUsersRequest</a></td>
+ <td><a href="#bytebase.v1.StatUsersResponse">StatUsersResponse</a></td>
+ <td><p>Get user stat.
+Any authenticated user can get stat.</p></td>
+ </tr>
+
<tr>
<td>CreateUser</td>
<td><a href="#bytebase.v1.CreateUserRequest">CreateUserRequest</a></td>
@@ -16118,6 +16210,16 @@ The last remaining workspace admin cannot be deleted.</p></td>
+ <tr>
+ <td>StatUsers</td>
+ <td>POST</td>
+ <td>/v1/users:stat</td>
+ <td>*</td>
+ </tr>
+
+
+
+
<tr>
<td>CreateUser</td>
<td>POST</td>
diff --git a/proto/generated-go/v1/user_service.pb.go b/proto/generated-go/v1/user_service.pb.go
index 9ee8e4da1e..5fc7f7835b 100644
--- a/proto/generated-go/v1/user_service.pb.go
+++ b/proto/generated-go/v1/user_service.pb.go
@@ -123,6 +123,86 @@ func (x *GetUserRequest) GetName() string {
return ""
}
+type StatUsersRequest struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *StatUsersRequest) Reset() {
+ *x = StatUsersRequest{}
+ mi := &file_v1_user_service_proto_msgTypes[1]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *StatUsersRequest) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*StatUsersRequest) ProtoMessage() {}
+
+func (x *StatUsersRequest) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_user_service_proto_msgTypes[1]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use StatUsersRequest.ProtoReflect.Descriptor instead.
+func (*StatUsersRequest) Descriptor() ([]byte, []int) {
+ return file_v1_user_service_proto_rawDescGZIP(), []int{1}
+}
+
+type StatUsersResponse struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Stats []*StatUsersResponse_StatUser `protobuf:"bytes,1,rep,name=stats,proto3" json:"stats,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *StatUsersResponse) Reset() {
+ *x = StatUsersResponse{}
+ mi := &file_v1_user_service_proto_msgTypes[2]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *StatUsersResponse) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*StatUsersResponse) ProtoMessage() {}
+
+func (x *StatUsersResponse) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_user_service_proto_msgTypes[2]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use StatUsersResponse.ProtoReflect.Descriptor instead.
+func (*StatUsersResponse) Descriptor() ([]byte, []int) {
+ return file_v1_user_service_proto_rawDescGZIP(), []int{2}
+}
+
+func (x *StatUsersResponse) GetStats() []*StatUsersResponse_StatUser {
+ if x != nil {
+ return x.Stats
+ }
+ return nil
+}
+
type ListUsersRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
// The maximum number of users to return. The service may return fewer than
@@ -143,14 +223,17 @@ type ListUsersRequest struct {
// - name
// - email
// - user_type
+ // - state
//
// For example:
// name == "ed"
// name.matches("ed")
// email == "[email protected]"
+ // email.matches("ed")
// user_type == "SERVICE_ACCOUNT"
// user_type in ["SERVICE_ACCOUNT", "USER"]
// !(user_type in ["SERVICE_ACCOUNT", "USER"])
+ // state == "DELETED"
Filter string `protobuf:"bytes,4,opt,name=filter,proto3" json:"filter,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
@@ -158,7 +241,7 @@ type ListUsersRequest struct {
func (x *ListUsersRequest) Reset() {
*x = ListUsersRequest{}
- mi := &file_v1_user_service_proto_msgTypes[1]
+ mi := &file_v1_user_service_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -170,7 +253,7 @@ func (x *ListUsersRequest) String() string {
func (*ListUsersRequest) ProtoMessage() {}
func (x *ListUsersRequest) ProtoReflect() protoreflect.Message {
- mi := &file_v1_user_service_proto_msgTypes[1]
+ mi := &file_v1_user_service_proto_msgTypes[3]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -183,7 +266,7 @@ func (x *ListUsersRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use ListUsersRequest.ProtoReflect.Descriptor instead.
func (*ListUsersRequest) Descriptor() ([]byte, []int) {
- return file_v1_user_service_proto_rawDescGZIP(), []int{1}
+ return file_v1_user_service_proto_rawDescGZIP(), []int{3}
}
func (x *ListUsersRequest) GetPageSize() int32 {
@@ -227,7 +310,7 @@ type ListUsersResponse struct {
func (x *ListUsersResponse) Reset() {
*x = ListUsersResponse{}
- mi := &file_v1_user_service_proto_msgTypes[2]
+ mi := &file_v1_user_service_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -239,7 +322,7 @@ func (x *ListUsersResponse) String() string {
func (*ListUsersResponse) ProtoMessage() {}
func (x *ListUsersResponse) ProtoReflect() protoreflect.Message {
- mi := &file_v1_user_service_proto_msgTypes[2]
+ mi := &file_v1_user_service_proto_msgTypes[4]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -252,7 +335,7 @@ func (x *ListUsersResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use ListUsersResponse.ProtoReflect.Descriptor instead.
func (*ListUsersResponse) Descriptor() ([]byte, []int) {
- return file_v1_user_service_proto_rawDescGZIP(), []int{2}
+ return file_v1_user_service_proto_rawDescGZIP(), []int{4}
}
func (x *ListUsersResponse) GetUsers() []*User {
@@ -279,7 +362,7 @@ type CreateUserRequest struct {
func (x *CreateUserRequest) Reset() {
*x = CreateUserRequest{}
- mi := &file_v1_user_service_proto_msgTypes[3]
+ mi := &file_v1_user_service_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -291,7 +374,7 @@ func (x *CreateUserRequest) String() string {
func (*CreateUserRequest) ProtoMessage() {}
func (x *CreateUserRequest) ProtoReflect() protoreflect.Message {
- mi := &file_v1_user_service_proto_msgTypes[3]
+ mi := &file_v1_user_service_proto_msgTypes[5]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -304,7 +387,7 @@ func (x *CreateUserRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use CreateUserRequest.ProtoReflect.Descriptor instead.
func (*CreateUserRequest) Descriptor() ([]byte, []int) {
- return file_v1_user_service_proto_rawDescGZIP(), []int{3}
+ return file_v1_user_service_proto_rawDescGZIP(), []int{5}
}
func (x *CreateUserRequest) GetUser() *User {
@@ -336,7 +419,7 @@ type UpdateUserRequest struct {
func (x *UpdateUserRequest) Reset() {
*x = UpdateUserRequest{}
- mi := &file_v1_user_service_proto_msgTypes[4]
+ mi := &file_v1_user_service_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -348,7 +431,7 @@ func (x *UpdateUserRequest) String() string {
func (*UpdateUserRequest) ProtoMessage() {}
func (x *UpdateUserRequest) ProtoReflect() protoreflect.Message {
- mi := &file_v1_user_service_proto_msgTypes[4]
+ mi := &file_v1_user_service_proto_msgTypes[6]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -361,7 +444,7 @@ func (x *UpdateUserRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use UpdateUserRequest.ProtoReflect.Descriptor instead.
func (*UpdateUserRequest) Descriptor() ([]byte, []int) {
- return file_v1_user_service_proto_rawDescGZIP(), []int{4}
+ return file_v1_user_service_proto_rawDescGZIP(), []int{6}
}
func (x *UpdateUserRequest) GetUser() *User {
@@ -410,7 +493,7 @@ type DeleteUserRequest struct {
func (x *DeleteUserRequest) Reset() {
*x = DeleteUserRequest{}
- mi := &file_v1_user_service_proto_msgTypes[5]
+ mi := &file_v1_user_service_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -422,7 +505,7 @@ func (x *DeleteUserRequest) String() string {
func (*DeleteUserRequest) ProtoMessage() {}
func (x *DeleteUserRequest) ProtoReflect() protoreflect.Message {
- mi := &file_v1_user_service_proto_msgTypes[5]
+ mi := &file_v1_user_service_proto_msgTypes[7]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -435,7 +518,7 @@ func (x *DeleteUserRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use DeleteUserRequest.ProtoReflect.Descriptor instead.
func (*DeleteUserRequest) Descriptor() ([]byte, []int) {
- return file_v1_user_service_proto_rawDescGZIP(), []int{5}
+ return file_v1_user_service_proto_rawDescGZIP(), []int{7}
}
func (x *DeleteUserRequest) GetName() string {
@@ -456,7 +539,7 @@ type UndeleteUserRequest struct {
func (x *UndeleteUserRequest) Reset() {
*x = UndeleteUserRequest{}
- mi := &file_v1_user_service_proto_msgTypes[6]
+ mi := &file_v1_user_service_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -468,7 +551,7 @@ func (x *UndeleteUserRequest) String() string {
func (*UndeleteUserRequest) ProtoMessage() {}
func (x *UndeleteUserRequest) ProtoReflect() protoreflect.Message {
- mi := &file_v1_user_service_proto_msgTypes[6]
+ mi := &file_v1_user_service_proto_msgTypes[8]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -481,7 +564,7 @@ func (x *UndeleteUserRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use UndeleteUserRequest.ProtoReflect.Descriptor instead.
func (*UndeleteUserRequest) Descriptor() ([]byte, []int) {
- return file_v1_user_service_proto_rawDescGZIP(), []int{6}
+ return file_v1_user_service_proto_rawDescGZIP(), []int{8}
}
func (x *UndeleteUserRequest) GetName() string {
@@ -518,7 +601,7 @@ type User struct {
func (x *User) Reset() {
*x = User{}
- mi := &file_v1_user_service_proto_msgTypes[7]
+ mi := &file_v1_user_service_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -530,7 +613,7 @@ func (x *User) String() string {
func (*User) ProtoMessage() {}
func (x *User) ProtoReflect() protoreflect.Message {
- mi := &file_v1_user_service_proto_msgTypes[7]
+ mi := &file_v1_user_service_proto_msgTypes[9]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -543,7 +626,7 @@ func (x *User) ProtoReflect() protoreflect.Message {
// Deprecated: Use User.ProtoReflect.Descriptor instead.
func (*User) Descriptor() ([]byte, []int) {
- return file_v1_user_service_proto_rawDescGZIP(), []int{7}
+ return file_v1_user_service_proto_rawDescGZIP(), []int{9}
}
func (x *User) GetName() string {
@@ -630,6 +713,66 @@ func (x *User) GetProfile() *User_Profile {
return nil
}
+type StatUsersResponse_StatUser struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ UserType UserType `protobuf:"varint,1,opt,name=user_type,json=userType,proto3,enum=bytebase.v1.UserType" json:"user_type,omitempty"`
+ State State `protobuf:"varint,2,opt,name=state,proto3,enum=bytebase.v1.State" json:"state,omitempty"`
+ Count int32 `protobuf:"varint,3,opt,name=count,proto3" json:"count,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *StatUsersResponse_StatUser) Reset() {
+ *x = StatUsersResponse_StatUser{}
+ mi := &file_v1_user_service_proto_msgTypes[10]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *StatUsersResponse_StatUser) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*StatUsersResponse_StatUser) ProtoMessage() {}
+
+func (x *StatUsersResponse_StatUser) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_user_service_proto_msgTypes[10]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use StatUsersResponse_StatUser.ProtoReflect.Descriptor instead.
+func (*StatUsersResponse_StatUser) Descriptor() ([]byte, []int) {
+ return file_v1_user_service_proto_rawDescGZIP(), []int{2, 0}
+}
+
+func (x *StatUsersResponse_StatUser) GetUserType() UserType {
+ if x != nil {
+ return x.UserType
+ }
+ return UserType_USER_TYPE_UNSPECIFIED
+}
+
+func (x *StatUsersResponse_StatUser) GetState() State {
+ if x != nil {
+ return x.State
+ }
+ return State_STATE_UNSPECIFIED
+}
+
+func (x *StatUsersResponse_StatUser) GetCount() int32 {
+ if x != nil {
+ return x.Count
+ }
+ return 0
+}
+
type User_Profile struct {
state protoimpl.MessageState `protogen:"open.v1"`
LastLoginTime *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=last_login_time,json=lastLoginTime,proto3" json:"last_login_time,omitempty"`
@@ -642,7 +785,7 @@ type User_Profile struct {
func (x *User_Profile) Reset() {
*x = User_Profile{}
- mi := &file_v1_user_service_proto_msgTypes[8]
+ mi := &file_v1_user_service_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -654,7 +797,7 @@ func (x *User_Profile) String() string {
func (*User_Profile) ProtoMessage() {}
func (x *User_Profile) ProtoReflect() protoreflect.Message {
- mi := &file_v1_user_service_proto_msgTypes[8]
+ mi := &file_v1_user_service_proto_msgTypes[11]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -667,7 +810,7 @@ func (x *User_Profile) ProtoReflect() protoreflect.Message {
// Deprecated: Use User_Profile.ProtoReflect.Descriptor instead.
func (*User_Profile) Descriptor() ([]byte, []int) {
- return file_v1_user_service_proto_rawDescGZIP(), []int{7, 0}
+ return file_v1_user_service_proto_rawDescGZIP(), []int{9, 0}
}
func (x *User_Profile) GetLastLoginTime() *timestamppb.Timestamp {
@@ -716,144 +859,166 @@ var file_v1_user_service_proto_rawDesc = string([]byte{
0x2e, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x1a, 0xe2,
0x41, 0x01, 0x02, 0xfa, 0x41, 0x13, 0x0a, 0x11, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65,
0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22,
- 0x89, 0x01, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71,
- 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a,
- 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a,
- 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18,
- 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e,
- 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x68, 0x6f, 0x77, 0x5f, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64,
- 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x73, 0x68, 0x6f, 0x77, 0x44, 0x65, 0x6c, 0x65,
- 0x74, 0x65, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x04, 0x20,
- 0x01, 0x28, 0x09, 0x52, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x22, 0x64, 0x0a, 0x11, 0x4c,
- 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
- 0x12, 0x27, 0x0a, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32,
- 0x11, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73,
- 0x65, 0x72, 0x52, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78,
- 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01,
- 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65,
- 0x6e, 0x22, 0x40, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52,
- 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2b, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x01,
- 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e,
- 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52, 0x04, 0x75,
- 0x73, 0x65, 0x72, 0x22, 0xa3, 0x02, 0x0a, 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73,
- 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2b, 0x0a, 0x04, 0x75, 0x73, 0x65,
- 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61,
- 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02,
- 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x12, 0x3b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65,
- 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f,
- 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69,
- 0x65, 0x6c, 0x64, 0x4d, 0x61, 0x73, 0x6b, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d,
- 0x61, 0x73, 0x6b, 0x12, 0x1e, 0x0a, 0x08, 0x6f, 0x74, 0x70, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18,
- 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x07, 0x6f, 0x74, 0x70, 0x43, 0x6f, 0x64, 0x65,
- 0x88, 0x01, 0x01, 0x12, 0x3b, 0x0a, 0x1a, 0x72, 0x65, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74,
- 0x65, 0x5f, 0x74, 0x65, 0x6d, 0x70, 0x5f, 0x6d, 0x66, 0x61, 0x5f, 0x73, 0x65, 0x63, 0x72, 0x65,
- 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x17, 0x72, 0x65, 0x67, 0x65, 0x6e, 0x65, 0x72,
- 0x61, 0x74, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x4d, 0x66, 0x61, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74,
- 0x12, 0x3a, 0x0a, 0x19, 0x72, 0x65, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x5f, 0x72,
- 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x05, 0x20,
- 0x01, 0x28, 0x08, 0x52, 0x17, 0x72, 0x65, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x52,
- 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x73, 0x42, 0x0b, 0x0a, 0x09,
- 0x5f, 0x6f, 0x74, 0x70, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x22, 0x43, 0x0a, 0x11, 0x44, 0x65, 0x6c,
+ 0x12, 0x0a, 0x10, 0x53, 0x74, 0x61, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75,
+ 0x65, 0x73, 0x74, 0x22, 0xd2, 0x01, 0x0a, 0x11, 0x53, 0x74, 0x61, 0x74, 0x55, 0x73, 0x65, 0x72,
+ 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3d, 0x0a, 0x05, 0x73, 0x74, 0x61,
+ 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62,
+ 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73,
+ 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x55, 0x73, 0x65,
+ 0x72, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x73, 0x1a, 0x7e, 0x0a, 0x08, 0x53, 0x74, 0x61, 0x74,
+ 0x55, 0x73, 0x65, 0x72, 0x12, 0x32, 0x0a, 0x09, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x74, 0x79, 0x70,
+ 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61,
+ 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x52, 0x08,
+ 0x75, 0x73, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x28, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74,
+ 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61,
+ 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61,
+ 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28,
+ 0x05, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x89, 0x01, 0x0a, 0x10, 0x4c, 0x69, 0x73,
+ 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a,
+ 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05,
+ 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61,
+ 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09,
+ 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x68, 0x6f,
+ 0x77, 0x5f, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52,
+ 0x0b, 0x73, 0x68, 0x6f, 0x77, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x12, 0x16, 0x0a, 0x06,
+ 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x66, 0x69,
+ 0x6c, 0x74, 0x65, 0x72, 0x22, 0x64, 0x0a, 0x11, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72,
+ 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x05, 0x75, 0x73, 0x65,
+ 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62,
+ 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x05, 0x75, 0x73, 0x65,
+ 0x72, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f,
+ 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78,
+ 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x40, 0x0a, 0x11, 0x43, 0x72,
+ 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
+ 0x2b, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e,
+ 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72,
+ 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x22, 0xa3, 0x02, 0x0a,
+ 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65,
+ 0x73, 0x74, 0x12, 0x2b, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b,
+ 0x32, 0x11, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55,
+ 0x73, 0x65, 0x72, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x12,
+ 0x3b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x18, 0x02,
+ 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72,
+ 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4d, 0x61, 0x73, 0x6b,
+ 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x73, 0x6b, 0x12, 0x1e, 0x0a, 0x08,
+ 0x6f, 0x74, 0x70, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00,
+ 0x52, 0x07, 0x6f, 0x74, 0x70, 0x43, 0x6f, 0x64, 0x65, 0x88, 0x01, 0x01, 0x12, 0x3b, 0x0a, 0x1a,
+ 0x72, 0x65, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x65, 0x6d, 0x70, 0x5f,
+ 0x6d, 0x66, 0x61, 0x5f, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08,
+ 0x52, 0x17, 0x72, 0x65, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x54, 0x65, 0x6d, 0x70,
+ 0x4d, 0x66, 0x61, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x12, 0x3a, 0x0a, 0x19, 0x72, 0x65, 0x67,
+ 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79,
+ 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x17, 0x72, 0x65,
+ 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79,
+ 0x43, 0x6f, 0x64, 0x65, 0x73, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x6f, 0x74, 0x70, 0x5f, 0x63, 0x6f,
+ 0x64, 0x65, 0x22, 0x43, 0x0a, 0x11, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72,
+ 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2e, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18,
+ 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x1a, 0xe2, 0x41, 0x01, 0x02, 0xfa, 0x41, 0x13, 0x0a, 0x11,
+ 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x55, 0x73, 0x65,
+ 0x72, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x45, 0x0a, 0x13, 0x55, 0x6e, 0x64, 0x65, 0x6c,
0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2e,
0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x1a, 0xe2, 0x41,
0x01, 0x02, 0xfa, 0x41, 0x13, 0x0a, 0x11, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e,
- 0x63, 0x6f, 0x6d, 0x2f, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x45,
- 0x0a, 0x13, 0x55, 0x6e, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65,
- 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2e, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20,
- 0x01, 0x28, 0x09, 0x42, 0x1a, 0xe2, 0x41, 0x01, 0x02, 0xfa, 0x41, 0x13, 0x0a, 0x11, 0x62, 0x79,
- 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x55, 0x73, 0x65, 0x72, 0x52,
- 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x8a, 0x05, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x18,
- 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41,
- 0x01, 0x03, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74,
- 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61,
- 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61,
- 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28,
- 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c,
- 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x32,
- 0x0a, 0x09, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28,
- 0x0e, 0x32, 0x15, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e,
- 0x55, 0x73, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x54, 0x79,
- 0x70, 0x65, 0x12, 0x20, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x07,
- 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x04, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73,
- 0x77, 0x6f, 0x72, 0x64, 0x12, 0x25, 0x0a, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f,
- 0x6b, 0x65, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x04, 0x52,
- 0x0a, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x0b, 0x6d,
- 0x66, 0x61, 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08,
- 0x52, 0x0a, 0x6d, 0x66, 0x61, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x1d, 0x0a, 0x0a,
- 0x6d, 0x66, 0x61, 0x5f, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09,
- 0x52, 0x09, 0x6d, 0x66, 0x61, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x72,
- 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x0b, 0x20,
- 0x03, 0x28, 0x09, 0x52, 0x0d, 0x72, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x43, 0x6f, 0x64,
- 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x0c, 0x20, 0x01, 0x28,
- 0x09, 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x12, 0x33, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x66,
- 0x69, 0x6c, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x62, 0x79, 0x74, 0x65,
- 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x2e, 0x50, 0x72, 0x6f,
- 0x66, 0x69, 0x6c, 0x65, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x1a, 0xbc, 0x01,
- 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x42, 0x0a, 0x0f, 0x6c, 0x61, 0x73,
- 0x74, 0x5f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01,
- 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
- 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0d,
- 0x6c, 0x61, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x55, 0x0a,
- 0x19, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x5f, 0x70, 0x61, 0x73,
- 0x73, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b,
- 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
- 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x16, 0x6c, 0x61,
- 0x73, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64,
- 0x54, 0x69, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x03,
- 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x3a, 0x24, 0xea, 0x41,
- 0x21, 0x0a, 0x11, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f,
- 0x55, 0x73, 0x65, 0x72, 0x12, 0x0c, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, 0x7b, 0x75, 0x73, 0x65,
- 0x72, 0x7d, 0x2a, 0x54, 0x0a, 0x08, 0x55, 0x73, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x19,
- 0x0a, 0x15, 0x55, 0x53, 0x45, 0x52, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50,
- 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x55, 0x53, 0x45,
- 0x52, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, 0x5f, 0x42, 0x4f,
- 0x54, 0x10, 0x02, 0x12, 0x13, 0x0a, 0x0f, 0x53, 0x45, 0x52, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x41,
- 0x43, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x10, 0x03, 0x32, 0xb2, 0x05, 0x0a, 0x0b, 0x55, 0x73, 0x65,
- 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x60, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x55,
- 0x73, 0x65, 0x72, 0x12, 0x1b, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76,
- 0x31, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
- 0x1a, 0x11, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55,
- 0x73, 0x65, 0x72, 0x22, 0x25, 0xda, 0x41, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x90, 0xea, 0x30, 0x02,
- 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x12, 0x12, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d,
- 0x65, 0x3d, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0x6a, 0x0a, 0x09, 0x4c, 0x69,
- 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x12, 0x1d, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61,
- 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52,
- 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73,
- 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65,
- 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1e, 0xda, 0x41, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e,
- 0x74, 0x90, 0xea, 0x30, 0x02, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x12, 0x09, 0x2f, 0x76, 0x31,
- 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x12, 0x6b, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65,
- 0x55, 0x73, 0x65, 0x72, 0x12, 0x1e, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e,
- 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71,
- 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e,
- 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x2a, 0xda, 0x41, 0x04, 0x75, 0x73, 0x65, 0x72,
- 0x80, 0xea, 0x30, 0x01, 0x90, 0xea, 0x30, 0x02, 0x98, 0xea, 0x30, 0x01, 0x82, 0xd3, 0xe4, 0x93,
- 0x02, 0x11, 0x3a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x22, 0x09, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73,
- 0x65, 0x72, 0x73, 0x12, 0x81, 0x01, 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73,
+ 0x63, 0x6f, 0x6d, 0x2f, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x8a,
+ 0x05, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18,
+ 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x03, 0x52, 0x04, 0x6e, 0x61, 0x6d,
+ 0x65, 0x12, 0x28, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e,
+ 0x32, 0x12, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53,
+ 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65,
+ 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69,
+ 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09,
+ 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x32, 0x0a, 0x09, 0x75, 0x73, 0x65, 0x72, 0x5f,
+ 0x74, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x62, 0x79, 0x74,
+ 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x54, 0x79, 0x70,
+ 0x65, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x20, 0x0a, 0x08, 0x70,
+ 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xe2,
+ 0x41, 0x01, 0x04, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x25, 0x0a,
+ 0x0b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x08, 0x20, 0x01,
+ 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x04, 0x52, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63,
+ 0x65, 0x4b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x0b, 0x6d, 0x66, 0x61, 0x5f, 0x65, 0x6e, 0x61, 0x62,
+ 0x6c, 0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x6d, 0x66, 0x61, 0x45, 0x6e,
+ 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x66, 0x61, 0x5f, 0x73, 0x65, 0x63,
+ 0x72, 0x65, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6d, 0x66, 0x61, 0x53, 0x65,
+ 0x63, 0x72, 0x65, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x72, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79,
+ 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0d, 0x72, 0x65,
+ 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x70,
+ 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e,
+ 0x65, 0x12, 0x33, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x0d, 0x20, 0x01,
+ 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31,
+ 0x2e, 0x55, 0x73, 0x65, 0x72, 0x2e, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x07, 0x70,
+ 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x1a, 0xbc, 0x01, 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x66, 0x69,
+ 0x6c, 0x65, 0x12, 0x42, 0x0a, 0x0f, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x6c, 0x6f, 0x67, 0x69, 0x6e,
+ 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f,
+ 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69,
+ 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0d, 0x6c, 0x61, 0x73, 0x74, 0x4c, 0x6f, 0x67,
+ 0x69, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x55, 0x0a, 0x19, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x63,
+ 0x68, 0x61, 0x6e, 0x67, 0x65, 0x5f, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x74,
+ 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67,
+ 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65,
+ 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x16, 0x6c, 0x61, 0x73, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x67,
+ 0x65, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x16, 0x0a,
+ 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73,
+ 0x6f, 0x75, 0x72, 0x63, 0x65, 0x3a, 0x24, 0xea, 0x41, 0x21, 0x0a, 0x11, 0x62, 0x79, 0x74, 0x65,
+ 0x62, 0x61, 0x73, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x55, 0x73, 0x65, 0x72, 0x12, 0x0c, 0x75,
+ 0x73, 0x65, 0x72, 0x73, 0x2f, 0x7b, 0x75, 0x73, 0x65, 0x72, 0x7d, 0x2a, 0x54, 0x0a, 0x08, 0x55,
+ 0x73, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x19, 0x0a, 0x15, 0x55, 0x53, 0x45, 0x52, 0x5f,
+ 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44,
+ 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x55, 0x53, 0x45, 0x52, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a,
+ 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, 0x5f, 0x42, 0x4f, 0x54, 0x10, 0x02, 0x12, 0x13, 0x0a, 0x0f,
+ 0x53, 0x45, 0x52, 0x56, 0x49, 0x43, 0x45, 0x5f, 0x41, 0x43, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x10,
+ 0x03, 0x32, 0xa6, 0x06, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
+ 0x65, 0x12, 0x60, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x12, 0x1b, 0x2e, 0x62,
+ 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73,
+ 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x62, 0x79, 0x74, 0x65,
+ 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x25, 0xda, 0x41,
+ 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x90, 0xea, 0x30, 0x02, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x12,
+ 0x12, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x75, 0x73, 0x65, 0x72, 0x73,
+ 0x2f, 0x2a, 0x7d, 0x12, 0x6a, 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73,
+ 0x12, 0x1d, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c,
+ 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
+ 0x1e, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69,
+ 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
+ 0x1e, 0xda, 0x41, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x90, 0xea, 0x30, 0x02, 0x82, 0xd3,
+ 0xe4, 0x93, 0x02, 0x0b, 0x12, 0x09, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x12,
+ 0x72, 0x0a, 0x09, 0x53, 0x74, 0x61, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x12, 0x1d, 0x2e, 0x62,
+ 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x55,
+ 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x62, 0x79,
+ 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x55, 0x73,
+ 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x26, 0xda, 0x41, 0x06,
+ 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x90, 0xea, 0x30, 0x02, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13,
+ 0x3a, 0x01, 0x2a, 0x22, 0x0e, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x3a, 0x73,
+ 0x74, 0x61, 0x74, 0x12, 0x6b, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65,
+ 0x72, 0x12, 0x1e, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e,
+ 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
+ 0x74, 0x1a, 0x11, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e,
+ 0x55, 0x73, 0x65, 0x72, 0x22, 0x2a, 0xda, 0x41, 0x04, 0x75, 0x73, 0x65, 0x72, 0x80, 0xea, 0x30,
+ 0x01, 0x90, 0xea, 0x30, 0x02, 0x98, 0xea, 0x30, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x11, 0x3a,
+ 0x04, 0x75, 0x73, 0x65, 0x72, 0x22, 0x09, 0x2f, 0x76, 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73,
+ 0x12, 0x81, 0x01, 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12,
+ 0x1e, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70,
+ 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
+ 0x11, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73,
+ 0x65, 0x72, 0x22, 0x40, 0xda, 0x41, 0x10, 0x75, 0x73, 0x65, 0x72, 0x2c, 0x75, 0x70, 0x64, 0x61,
+ 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x90, 0xea, 0x30, 0x02, 0x98, 0xea, 0x30, 0x01, 0x82,
+ 0xd3, 0xe4, 0x93, 0x02, 0x1f, 0x3a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x32, 0x17, 0x2f, 0x76, 0x31,
+ 0x2f, 0x7b, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x75, 0x73, 0x65, 0x72,
+ 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0x6f, 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73,
0x65, 0x72, 0x12, 0x1e, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31,
- 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65,
- 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31,
- 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x40, 0xda, 0x41, 0x10, 0x75, 0x73, 0x65, 0x72, 0x2c, 0x75,
- 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x90, 0xea, 0x30, 0x02, 0x98, 0xea,
- 0x30, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1f, 0x3a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x32, 0x17,
- 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x75,
- 0x73, 0x65, 0x72, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0x6f, 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74,
- 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x1e, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65,
- 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65,
- 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70,
- 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x29, 0xda,
- 0x41, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x90, 0xea, 0x30, 0x02, 0x98, 0xea, 0x30, 0x01, 0x82, 0xd3,
- 0xe4, 0x93, 0x02, 0x14, 0x2a, 0x12, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d,
- 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0x73, 0x0a, 0x0c, 0x55, 0x6e, 0x64, 0x65,
- 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x20, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62,
- 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x6e, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55,
- 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x62, 0x79, 0x74,
- 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x2e, 0x90,
- 0xea, 0x30, 0x02, 0x98, 0xea, 0x30, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x20, 0x3a, 0x01, 0x2a,
- 0x22, 0x1b, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x75, 0x73, 0x65, 0x72,
- 0x73, 0x2f, 0x2a, 0x7d, 0x3a, 0x75, 0x6e, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x11, 0x5a,
- 0x0f, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x2d, 0x67, 0x6f, 0x2f, 0x76, 0x31,
- 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+ 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65,
+ 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
+ 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x29, 0xda, 0x41, 0x04, 0x6e,
+ 0x61, 0x6d, 0x65, 0x90, 0xea, 0x30, 0x02, 0x98, 0xea, 0x30, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02,
+ 0x14, 0x2a, 0x12, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x75, 0x73, 0x65,
+ 0x72, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0x73, 0x0a, 0x0c, 0x55, 0x6e, 0x64, 0x65, 0x6c, 0x65, 0x74,
+ 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x20, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65,
+ 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x6e, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72,
+ 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61,
+ 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x2e, 0x90, 0xea, 0x30, 0x02,
+ 0x98, 0xea, 0x30, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x20, 0x3a, 0x01, 0x2a, 0x22, 0x1b, 0x2f,
+ 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, 0x2a,
+ 0x7d, 0x3a, 0x75, 0x6e, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x11, 0x5a, 0x0f, 0x67, 0x65,
+ 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x2d, 0x67, 0x6f, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70,
+ 0x72, 0x6f, 0x74, 0x6f, 0x33,
})
var (
@@ -869,50 +1034,58 @@ func file_v1_user_service_proto_rawDescGZIP() []byte {
}
var file_v1_user_service_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
-var file_v1_user_service_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
+var file_v1_user_service_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
var file_v1_user_service_proto_goTypes = []any{
- (UserType)(0), // 0: bytebase.v1.UserType
- (*GetUserRequest)(nil), // 1: bytebase.v1.GetUserRequest
- (*ListUsersRequest)(nil), // 2: bytebase.v1.ListUsersRequest
- (*ListUsersResponse)(nil), // 3: bytebase.v1.ListUsersResponse
- (*CreateUserRequest)(nil), // 4: bytebase.v1.CreateUserRequest
- (*UpdateUserRequest)(nil), // 5: bytebase.v1.UpdateUserRequest
- (*DeleteUserRequest)(nil), // 6: bytebase.v1.DeleteUserRequest
- (*UndeleteUserRequest)(nil), // 7: bytebase.v1.UndeleteUserRequest
- (*User)(nil), // 8: bytebase.v1.User
- (*User_Profile)(nil), // 9: bytebase.v1.User.Profile
- (*fieldmaskpb.FieldMask)(nil), // 10: google.protobuf.FieldMask
- (State)(0), // 11: bytebase.v1.State
- (*timestamppb.Timestamp)(nil), // 12: google.protobuf.Timestamp
- (*emptypb.Empty)(nil), // 13: google.protobuf.Empty
+ (UserType)(0), // 0: bytebase.v1.UserType
+ (*GetUserRequest)(nil), // 1: bytebase.v1.GetUserRequest
+ (*StatUsersRequest)(nil), // 2: bytebase.v1.StatUsersRequest
+ (*StatUsersResponse)(nil), // 3: bytebase.v1.StatUsersResponse
+ (*ListUsersRequest)(nil), // 4: bytebase.v1.ListUsersRequest
+ (*ListUsersResponse)(nil), // 5: bytebase.v1.ListUsersResponse
+ (*CreateUserRequest)(nil), // 6: bytebase.v1.CreateUserRequest
+ (*UpdateUserRequest)(nil), // 7: bytebase.v1.UpdateUserRequest
+ (*DeleteUserRequest)(nil), // 8: bytebase.v1.DeleteUserRequest
+ (*UndeleteUserRequest)(nil), // 9: bytebase.v1.UndeleteUserRequest
+ (*User)(nil), // 10: bytebase.v1.User
+ (*StatUsersResponse_StatUser)(nil), // 11: bytebase.v1.StatUsersResponse.StatUser
+ (*User_Profile)(nil), // 12: bytebase.v1.User.Profile
+ (*fieldmaskpb.FieldMask)(nil), // 13: google.protobuf.FieldMask
+ (State)(0), // 14: bytebase.v1.State
+ (*timestamppb.Timestamp)(nil), // 15: google.protobuf.Timestamp
+ (*emptypb.Empty)(nil), // 16: google.protobuf.Empty
}
var file_v1_user_service_proto_depIdxs = []int32{
- 8, // 0: bytebase.v1.ListUsersResponse.users:type_name -> bytebase.v1.User
- 8, // 1: bytebase.v1.CreateUserRequest.user:type_name -> bytebase.v1.User
- 8, // 2: bytebase.v1.UpdateUserRequest.user:type_name -> bytebase.v1.User
- 10, // 3: bytebase.v1.UpdateUserRequest.update_mask:type_name -> google.protobuf.FieldMask
- 11, // 4: bytebase.v1.User.state:type_name -> bytebase.v1.State
- 0, // 5: bytebase.v1.User.user_type:type_name -> bytebase.v1.UserType
- 9, // 6: bytebase.v1.User.profile:type_name -> bytebase.v1.User.Profile
- 12, // 7: bytebase.v1.User.Profile.last_login_time:type_name -> google.protobuf.Timestamp
- 12, // 8: bytebase.v1.User.Profile.last_change_password_time:type_name -> google.protobuf.Timestamp
- 1, // 9: bytebase.v1.UserService.GetUser:input_type -> bytebase.v1.GetUserRequest
- 2, // 10: bytebase.v1.UserService.ListUsers:input_type -> bytebase.v1.ListUsersRequest
- 4, // 11: bytebase.v1.UserService.CreateUser:input_type -> bytebase.v1.CreateUserRequest
- 5, // 12: bytebase.v1.UserService.UpdateUser:input_type -> bytebase.v1.UpdateUserRequest
- 6, // 13: bytebase.v1.UserService.DeleteUser:input_type -> bytebase.v1.DeleteUserRequest
- 7, // 14: bytebase.v1.UserService.UndeleteUser:input_type -> bytebase.v1.UndeleteUserRequest
- 8, // 15: bytebase.v1.UserService.GetUser:output_type -> bytebase.v1.User
- 3, // 16: bytebase.v1.UserService.ListUsers:output_type -> bytebase.v1.ListUsersResponse
- 8, // 17: bytebase.v1.UserService.CreateUser:output_type -> bytebase.v1.User
- 8, // 18: bytebase.v1.UserService.UpdateUser:output_type -> bytebase.v1.User
- 13, // 19: bytebase.v1.UserService.DeleteUser:output_type -> google.protobuf.Empty
- 8, // 20: bytebase.v1.UserService.UndeleteUser:output_type -> bytebase.v1.User
- 15, // [15:21] is the sub-list for method output_type
- 9, // [9:15] is the sub-list for method input_type
- 9, // [9:9] is the sub-list for extension type_name
- 9, // [9:9] is the sub-list for extension extendee
- 0, // [0:9] is the sub-list for field type_name
+ 11, // 0: bytebase.v1.StatUsersResponse.stats:type_name -> bytebase.v1.StatUsersResponse.StatUser
+ 10, // 1: bytebase.v1.ListUsersResponse.users:type_name -> bytebase.v1.User
+ 10, // 2: bytebase.v1.CreateUserRequest.user:type_name -> bytebase.v1.User
+ 10, // 3: bytebase.v1.UpdateUserRequest.user:type_name -> bytebase.v1.User
+ 13, // 4: bytebase.v1.UpdateUserRequest.update_mask:type_name -> google.protobuf.FieldMask
+ 14, // 5: bytebase.v1.User.state:type_name -> bytebase.v1.State
+ 0, // 6: bytebase.v1.User.user_type:type_name -> bytebase.v1.UserType
+ 12, // 7: bytebase.v1.User.profile:type_name -> bytebase.v1.User.Profile
+ 0, // 8: bytebase.v1.StatUsersResponse.StatUser.user_type:type_name -> bytebase.v1.UserType
+ 14, // 9: bytebase.v1.StatUsersResponse.StatUser.state:type_name -> bytebase.v1.State
+ 15, // 10: bytebase.v1.User.Profile.last_login_time:type_name -> google.protobuf.Timestamp
+ 15, // 11: bytebase.v1.User.Profile.last_change_password_time:type_name -> google.protobuf.Timestamp
+ 1, // 12: bytebase.v1.UserService.GetUser:input_type -> bytebase.v1.GetUserRequest
+ 4, // 13: bytebase.v1.UserService.ListUsers:input_type -> bytebase.v1.ListUsersRequest
+ 2, // 14: bytebase.v1.UserService.StatUsers:input_type -> bytebase.v1.StatUsersRequest
+ 6, // 15: bytebase.v1.UserService.CreateUser:input_type -> bytebase.v1.CreateUserRequest
+ 7, // 16: bytebase.v1.UserService.UpdateUser:input_type -> bytebase.v1.UpdateUserRequest
+ 8, // 17: bytebase.v1.UserService.DeleteUser:input_type -> bytebase.v1.DeleteUserRequest
+ 9, // 18: bytebase.v1.UserService.UndeleteUser:input_type -> bytebase.v1.UndeleteUserRequest
+ 10, // 19: bytebase.v1.UserService.GetUser:output_type -> bytebase.v1.User
+ 5, // 20: bytebase.v1.UserService.ListUsers:output_type -> bytebase.v1.ListUsersResponse
+ 3, // 21: bytebase.v1.UserService.StatUsers:output_type -> bytebase.v1.StatUsersResponse
+ 10, // 22: bytebase.v1.UserService.CreateUser:output_type -> bytebase.v1.User
+ 10, // 23: bytebase.v1.UserService.UpdateUser:output_type -> bytebase.v1.User
+ 16, // 24: bytebase.v1.UserService.DeleteUser:output_type -> google.protobuf.Empty
+ 10, // 25: bytebase.v1.UserService.UndeleteUser:output_type -> bytebase.v1.User
+ 19, // [19:26] is the sub-list for method output_type
+ 12, // [12:19] is the sub-list for method input_type
+ 12, // [12:12] is the sub-list for extension type_name
+ 12, // [12:12] is the sub-list for extension extendee
+ 0, // [0:12] is the sub-list for field type_name
}
func init() { file_v1_user_service_proto_init() }
@@ -922,14 +1095,14 @@ func file_v1_user_service_proto_init() {
}
file_v1_annotation_proto_init()
file_v1_common_proto_init()
- file_v1_user_service_proto_msgTypes[4].OneofWrappers = []any{}
+ file_v1_user_service_proto_msgTypes[6].OneofWrappers = []any{}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_v1_user_service_proto_rawDesc), len(file_v1_user_service_proto_rawDesc)),
NumEnums: 1,
- NumMessages: 9,
+ NumMessages: 12,
NumExtensions: 0,
NumServices: 1,
},
diff --git a/proto/generated-go/v1/user_service.pb.gw.go b/proto/generated-go/v1/user_service.pb.gw.go
index 2c00ed8b98..4a21ccea75 100644
--- a/proto/generated-go/v1/user_service.pb.gw.go
+++ b/proto/generated-go/v1/user_service.pb.gw.go
@@ -105,6 +105,30 @@ func local_request_UserService_ListUsers_0(ctx context.Context, marshaler runtim
return msg, metadata, err
}
+func request_UserService_StatUsers_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var (
+ protoReq StatUsersRequest
+ metadata runtime.ServerMetadata
+ )
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+ msg, err := client.StatUsers(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+}
+
+func local_request_UserService_StatUsers_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var (
+ protoReq StatUsersRequest
+ metadata runtime.ServerMetadata
+ )
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+ msg, err := server.StatUsers(ctx, &protoReq)
+ return msg, metadata, err
+}
+
func request_UserService_CreateUser_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq CreateUserRequest
@@ -332,6 +356,26 @@ func RegisterUserServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux
}
forward_UserService_ListUsers_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
+ mux.Handle(http.MethodPost, pattern_UserService_StatUsers_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(req.Context())
+ defer cancel()
+ var stream runtime.ServerTransportStream
+ ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.UserService/StatUsers", runtime.WithHTTPPathPattern("/v1/users:stat"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := local_request_UserService_StatUsers_0(annotatedContext, inboundMarshaler, server, req, pathParams)
+ md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ forward_UserService_StatUsers_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+ })
mux.Handle(http.MethodPost, pattern_UserService_CreateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
@@ -486,6 +530,23 @@ func RegisterUserServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux
}
forward_UserService_ListUsers_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
+ mux.Handle(http.MethodPost, pattern_UserService_StatUsers_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(req.Context())
+ defer cancel()
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.UserService/StatUsers", runtime.WithHTTPPathPattern("/v1/users:stat"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := request_UserService_StatUsers_0(annotatedContext, inboundMarshaler, client, req, pathParams)
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ forward_UserService_StatUsers_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+ })
mux.Handle(http.MethodPost, pattern_UserService_CreateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
@@ -560,6 +621,7 @@ func RegisterUserServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux
var (
pattern_UserService_GetUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "users", "name"}, ""))
pattern_UserService_ListUsers_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "users"}, ""))
+ pattern_UserService_StatUsers_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "users"}, "stat"))
pattern_UserService_CreateUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "users"}, ""))
pattern_UserService_UpdateUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "users", "user.name"}, ""))
pattern_UserService_DeleteUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "users", "name"}, ""))
@@ -569,6 +631,7 @@ var (
var (
forward_UserService_GetUser_0 = runtime.ForwardResponseMessage
forward_UserService_ListUsers_0 = runtime.ForwardResponseMessage
+ forward_UserService_StatUsers_0 = runtime.ForwardResponseMessage
forward_UserService_CreateUser_0 = runtime.ForwardResponseMessage
forward_UserService_UpdateUser_0 = runtime.ForwardResponseMessage
forward_UserService_DeleteUser_0 = runtime.ForwardResponseMessage
diff --git a/proto/generated-go/v1/user_service_grpc.pb.go b/proto/generated-go/v1/user_service_grpc.pb.go
index 8bf7378714..3f3dcf8e21 100644
--- a/proto/generated-go/v1/user_service_grpc.pb.go
+++ b/proto/generated-go/v1/user_service_grpc.pb.go
@@ -22,6 +22,7 @@ const _ = grpc.SupportPackageIsVersion9
const (
UserService_GetUser_FullMethodName = "/bytebase.v1.UserService/GetUser"
UserService_ListUsers_FullMethodName = "/bytebase.v1.UserService/ListUsers"
+ UserService_StatUsers_FullMethodName = "/bytebase.v1.UserService/StatUsers"
UserService_CreateUser_FullMethodName = "/bytebase.v1.UserService/CreateUser"
UserService_UpdateUser_FullMethodName = "/bytebase.v1.UserService/UpdateUser"
UserService_DeleteUser_FullMethodName = "/bytebase.v1.UserService/DeleteUser"
@@ -38,6 +39,9 @@ type UserServiceClient interface {
// List all users.
// Any authenticated user can list users.
ListUsers(ctx context.Context, in *ListUsersRequest, opts ...grpc.CallOption) (*ListUsersResponse, error)
+ // Get user stat.
+ // Any authenticated user can get stat.
+ StatUsers(ctx context.Context, in *StatUsersRequest, opts ...grpc.CallOption) (*StatUsersResponse, error)
// Create a user.
// When Disallow Signup is enabled, only the caller with bb.users.create on the workspace can create a user.
// Otherwise, any unauthenticated user can create a user.
@@ -79,6 +83,16 @@ func (c *userServiceClient) ListUsers(ctx context.Context, in *ListUsersRequest,
return out, nil
}
+func (c *userServiceClient) StatUsers(ctx context.Context, in *StatUsersRequest, opts ...grpc.CallOption) (*StatUsersResponse, error) {
+ cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
+ out := new(StatUsersResponse)
+ err := c.cc.Invoke(ctx, UserService_StatUsers_FullMethodName, in, out, cOpts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
func (c *userServiceClient) CreateUser(ctx context.Context, in *CreateUserRequest, opts ...grpc.CallOption) (*User, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(User)
@@ -129,6 +143,9 @@ type UserServiceServer interface {
// List all users.
// Any authenticated user can list users.
ListUsers(context.Context, *ListUsersRequest) (*ListUsersResponse, error)
+ // Get user stat.
+ // Any authenticated user can get stat.
+ StatUsers(context.Context, *StatUsersRequest) (*StatUsersResponse, error)
// Create a user.
// When Disallow Signup is enabled, only the caller with bb.users.create on the workspace can create a user.
// Otherwise, any unauthenticated user can create a user.
@@ -156,6 +173,9 @@ func (UnimplementedUserServiceServer) GetUser(context.Context, *GetUserRequest)
func (UnimplementedUserServiceServer) ListUsers(context.Context, *ListUsersRequest) (*ListUsersResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListUsers not implemented")
}
+func (UnimplementedUserServiceServer) StatUsers(context.Context, *StatUsersRequest) (*StatUsersResponse, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method StatUsers not implemented")
+}
func (UnimplementedUserServiceServer) CreateUser(context.Context, *CreateUserRequest) (*User, error) {
return nil, status.Errorf(codes.Unimplemented, "method CreateUser not implemented")
}
@@ -225,6 +245,24 @@ func _UserService_ListUsers_Handler(srv interface{}, ctx context.Context, dec fu
return interceptor(ctx, in, info, handler)
}
+func _UserService_StatUsers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(StatUsersRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(UserServiceServer).StatUsers(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: UserService_StatUsers_FullMethodName,
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(UserServiceServer).StatUsers(ctx, req.(*StatUsersRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
func _UserService_CreateUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CreateUserRequest)
if err := dec(in); err != nil {
@@ -312,6 +350,10 @@ var UserService_ServiceDesc = grpc.ServiceDesc{
MethodName: "ListUsers",
Handler: _UserService_ListUsers_Handler,
},
+ {
+ MethodName: "StatUsers",
+ Handler: _UserService_StatUsers_Handler,
+ },
{
MethodName: "CreateUser",
Handler: _UserService_CreateUser_Handler,
diff --git a/proto/v1/user_service.proto b/proto/v1/user_service.proto
index a9b2a4c305..3a190c7bb9 100644
--- a/proto/v1/user_service.proto
+++ b/proto/v1/user_service.proto
@@ -31,6 +31,17 @@ service UserService {
option (bytebase.v1.auth_method) = CUSTOM;
}
+ // Get user stat.
+ // Any authenticated user can get stat.
+ rpc StatUsers(StatUsersRequest) returns (StatUsersResponse) {
+ option (google.api.http) = {
+ post: "/v1/users:stat"
+ body: "*"
+ };
+ option (google.api.method_signature) = "parent";
+ option (bytebase.v1.auth_method) = CUSTOM;
+ }
+
// Create a user.
// When Disallow Signup is enabled, only the caller with bb.users.create on the workspace can create a user.
// Otherwise, any unauthenticated user can create a user.
@@ -85,6 +96,18 @@ message GetUserRequest {
];
}
+message StatUsersRequest {}
+
+message StatUsersResponse {
+ message StatUser {
+ UserType user_type = 1;
+ State state = 2;
+ int32 count = 3;
+ }
+
+ repeated StatUser stats = 1;
+}
+
message ListUsersRequest {
// The maximum number of users to return. The service may return fewer than
// this value.
@@ -107,14 +130,17 @@ message ListUsersRequest {
// - name
// - email
// - user_type
+ // - state
//
// For example:
// name == "ed"
// name.matches("ed")
// email == "[email protected]"
+ // email.matches("ed")
// user_type == "SERVICE_ACCOUNT"
// user_type in ["SERVICE_ACCOUNT", "USER"]
// !(user_type in ["SERVICE_ACCOUNT", "USER"])
+ // state == "DELETED"
string filter = 4;
}