Skip to content

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

chore: revoke bb.users.get permission from workspace member (#18771)

ecmadao13f273a2bfe2
diff --git a/backend/component/iam/acl.yaml b/backend/component/iam/acl.yaml
index e22227552e..2812a78bb1 100644
--- a/backend/component/iam/acl.yaml
+++ b/backend/component/iam/acl.yaml
@@ -237,7 +237,6 @@ roles:
- bb.groups.create
- bb.groups.get
- bb.groups.list
- - bb.users.get
- bb.workspaces.getIamPolicy
- name: roles/projectOwner
title: Project owner
diff --git a/frontend/src/components/IssueV1/components/CurrentApproverV1.vue b/frontend/src/components/IssueV1/components/CurrentApproverV1.vue
index cd2ac01488..da045d5cd1 100644
--- a/frontend/src/components/IssueV1/components/CurrentApproverV1.vue
+++ b/frontend/src/components/IssueV1/components/CurrentApproverV1.vue
@@ -32,12 +32,15 @@
</template>
</NTooltip>
</template>
- <template v-else-if="currentApprover">
- <BBAvatar :size="'SMALL'" :username="currentApprover.title" />
- <span class="truncate">
- {{ currentApprover.title }}
- </span>
- </template>
+ <UserNameCell v-else-if="currentApprover"
+ size="small"
+ :user="currentApprover"
+ :link="false"
+ :allow-edit="false"
+ :show-email="false"
+ :show-mfa-enabled="false"
+ :show-source="false"
+ />
<template v-else>
<span>-</span>
</template>
@@ -48,7 +51,7 @@
import { computedAsync } from "@vueuse/core";
import { NTooltip } from "naive-ui";
import { computed } from "vue";
-import { BBAvatar } from "@/bbkit";
+import { UserNameCell } from "@/components/v2/Model/cells";
import {
candidatesOfApprovalStepV1,
useCurrentUserV1,
diff --git a/frontend/src/components/IssueV1/components/IssueTableV1.vue b/frontend/src/components/IssueV1/components/IssueTableV1.vue
index 7e03f49ae2..8f025d40bb 100644
--- a/frontend/src/components/IssueV1/components/IssueTableV1.vue
+++ b/frontend/src/components/IssueV1/components/IssueTableV1.vue
@@ -45,9 +45,9 @@ import { NDataTable, NPerformantEllipsis } from "naive-ui";
import { computed, h, reactive, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
-import { BBAvatar } from "@/bbkit";
import BatchIssueActionsV1 from "@/components/IssueV1/components/BatchIssueActionsV1.vue";
import CurrentApproverV1 from "@/components/IssueV1/components/CurrentApproverV1.vue";
+import { UserNameCell } from "@/components/v2/Model/cells";
import { useElementVisibilityInScrollParent } from "@/composables/useElementVisibilityInScrollParent";
import { useIssueLayoutVersion } from "@/composables/useIssueLayoutVersion";
import { useUserStore } from "@/store";
@@ -234,12 +234,18 @@ const columnList = computed((): DataTableColumn<ComposedIssue>[] => {
hide: !showExtendedColumns.value,
render: (issue) => {
const creator =
- userStore.getUserByIdentifier(issue.creator) || unknownUser();
+ userStore.getUserByIdentifier(issue.creator) ||
+ unknownUser(issue.creator);
return (
- <div class="flex flex-row items-center overflow-hidden gap-x-2">
- <BBAvatar size="SMALL" username={creator.title} />
- <span class="truncate">{creator.title}</span>
- </div>
+ <UserNameCell
+ user={creator}
+ size="small"
+ link={false}
+ allowEdit={false}
+ showMfaEnabled={false}
+ showSource={false}
+ showEmail={false}
+ />
);
},
},
diff --git a/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/PreBackupSection.vue b/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/PreBackupSection.vue
index 16079ab383..54e53f4861 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/PreBackupSection.vue
+++ b/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/PreBackupSection.vue
@@ -12,15 +12,19 @@ import {
} from "@/components/IssueV1/logic";
import { PreBackupSection } from "@/components/Plan/components/Configuration";
import { providePreBackupSettingContext } from "@/components/Plan/components/Configuration/PreBackupSection/context";
-import { useCurrentProjectV1 } from "@/store";
+import { extractUserId, useCurrentProjectV1, useCurrentUserV1 } from "@/store";
+import { IssueStatus } from "@/types/proto-es/v1/issue_service_pb";
import type { Plan } from "@/types/proto-es/v1/plan_service_pb";
import { TaskRun_Status } from "@/types/proto-es/v1/rollout_service_pb";
-import { databaseForTask } from "@/utils";
+import { databaseForTask, hasProjectPermissionV2 } from "@/utils";
import { ROLLBACK_AVAILABLE_ENGINES } from "./common";
import TaskRollbackSection from "./TaskRollbackSection.vue";
const { isCreating, issue, selectedTask, events } = useIssueContext();
const { project } = useCurrentProjectV1();
+const plan = computed(() => issue.value.planEntity as Plan);
+const currentUser = useCurrentUserV1();
+
const {
shouldShow: shouldShowPreBackupSection,
enabled: preBackupEnabled,
@@ -28,11 +32,33 @@ const {
} = providePreBackupSettingContext({
isCreating,
project,
- plan: computed(() => issue.value.planEntity as Plan),
+ plan,
selectedSpec: computed(() =>
specForTask(issue.value.planEntity as Plan, selectedTask.value)
),
- issue,
+ allowChange: computed(() => {
+ // Allow changes when creating
+ if (isCreating.value) {
+ return true;
+ }
+
+ // Disallow changes if the plan has started rollout.
+ if (plan.value.hasRollout) {
+ return false;
+ }
+
+ // If issue is not open, disallow
+ if (issue?.value && issue.value.status !== IssueStatus.OPEN) {
+ return false;
+ }
+
+ // Allowed to the plan/issue creator.
+ if (currentUser.value.email === extractUserId(plan.value.creator)) {
+ return true;
+ }
+
+ return hasProjectPermissionV2(project.value, "bb.plans.update");
+ }),
});
const database = computed(() =>
diff --git a/frontend/src/components/IssueV1/components/Sidebar/Sidebar.vue b/frontend/src/components/IssueV1/components/Sidebar/Sidebar.vue
index 2dff696594..75acd4dfec 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/Sidebar.vue
+++ b/frontend/src/components/IssueV1/components/Sidebar/Sidebar.vue
@@ -74,13 +74,20 @@ import { GhostSection } from "@/components/Plan/components/Configuration";
import { provideGhostSettingContext } from "@/components/Plan/components/Configuration/GhostSection/context";
import { ApprovalFlowSection } from "@/components/Plan/components/IssueReviewView/Sidebar/ApprovalFlowSection";
import { issueServiceClientConnect } from "@/connect";
-import { pushNotification, useCurrentProjectV1 } from "@/store";
+import {
+ extractUserId,
+ pushNotification,
+ useCurrentProjectV1,
+ useCurrentUserV1,
+} from "@/store";
import {
IssueSchema,
+ IssueStatus,
UpdateIssueRequestSchema,
} from "@/types/proto-es/v1/issue_service_pb";
import type { Plan } from "@/types/proto-es/v1/plan_service_pb";
import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";
+import { hasProjectPermissionV2 } from "@/utils";
import { specForTask, useIssueContext } from "../../logic";
import IssueLabels from "./IssueLabels.vue";
import PreBackupSection from "./PreBackupSection";
@@ -92,6 +99,7 @@ const { isCreating, selectedTask, issue, events, allowChange } =
useIssueContext();
const { project } = useCurrentProjectV1();
const preBackupSectionRef = ref<InstanceType<typeof PreBackupSection>>();
+const currentUser = useCurrentUserV1();
const selectedSpec = computed(() =>
specForTask(issue.value.planEntity as Plan, selectedTask.value)
@@ -105,13 +113,36 @@ const flattenSpecCount = computed(
) || 0
);
+const plan = computed(() => issue.value.planEntity as Plan);
+
const { shouldShow: shouldShowGhostSection, events: ghostEvents } =
provideGhostSettingContext({
isCreating,
- project,
- plan: computed(() => issue.value.planEntity as Plan),
+ plan,
selectedSpec,
- issue,
+ allowChange: computed(() => {
+ // Allow changes when creating
+ if (isCreating.value) {
+ return true;
+ }
+
+ // Disallow changes if the plan has started rollout.
+ if (plan.value.hasRollout) {
+ return false;
+ }
+
+ // If issue is not open, disallow
+ if (issue?.value && issue.value.status !== IssueStatus.OPEN) {
+ return false;
+ }
+
+ // Allowed to the plan/issue creator.
+ if (currentUser.value.email === extractUserId(plan.value.creator)) {
+ return true;
+ }
+
+ return hasProjectPermissionV2(project.value, "bb.plans.update");
+ }),
});
const shouldShowPreBackupSection = computed(() => {
diff --git a/frontend/src/components/Label/LabelListEditor.vue b/frontend/src/components/Label/LabelListEditor.vue
index 7f162ae4a3..55c1f0216f 100644
--- a/frontend/src/components/Label/LabelListEditor.vue
+++ b/frontend/src/components/Label/LabelListEditor.vue
@@ -16,8 +16,8 @@
/>
</div>
- <div v-if="!readonly">
- <NButton size="small" :disabled="!allowAddLabel" @click="handleAdd">
+ <div>
+ <NButton size="small" :disabled="readonly || !allowAddLabel" @click="handleAdd">
<template #icon>
<heroicons:plus />
</template>
diff --git a/frontend/src/components/Plan/components/Configuration/Configuration.vue b/frontend/src/components/Plan/components/Configuration/Configuration.vue
index 8a1f4b2a26..b95fc1356a 100644
--- a/frontend/src/components/Plan/components/Configuration/Configuration.vue
+++ b/frontend/src/components/Plan/components/Configuration/Configuration.vue
@@ -16,7 +16,7 @@
<script lang="ts" setup>
import { computed } from "vue";
-import { useCurrentProjectV1 } from "@/store";
+import { IssueStatus } from "@/types/proto-es/v1/issue_service_pb";
import { usePlanContext } from "../../logic";
import { useSelectedSpec } from "../SpecDetailView/context";
import GhostSection from "./GhostSection";
@@ -30,17 +30,40 @@ import { providePreBackupSettingContext } from "./PreBackupSection/context";
import TransactionModeSection from "./TransactionModeSection";
import { provideTransactionModeSettingContext } from "./TransactionModeSection/context";
-const { project } = useCurrentProjectV1();
-const { isCreating, plan, events, issue, readonly } = usePlanContext();
+const { isCreating, plan, events, issue, readonly, allowEdit, project } =
+ usePlanContext();
const { selectedSpec } = useSelectedSpec();
+const allowChange = computed(() => {
+ // If readonly mode, disallow changes
+ if (readonly?.value) {
+ return false;
+ }
+
+ // Allow changes when creating
+ if (isCreating.value) {
+ return true;
+ }
+
+ // Disallow changes if the plan has started rollout.
+ if (plan.value.hasRollout) {
+ return false;
+ }
+
+ // If issue is not open, disallow
+ if (issue?.value && issue.value.status !== IssueStatus.OPEN) {
+ return false;
+ }
+
+ return allowEdit.value;
+});
+
const providerArgs = {
project,
plan,
selectedSpec,
isCreating,
- issue,
- readonly,
+ allowChange,
};
const { shouldShow: shouldShowTransactionModeSection, events: txEvents } =
diff --git a/frontend/src/components/Plan/components/Configuration/GhostSection/context.ts b/frontend/src/components/Plan/components/Configuration/GhostSection/context.ts
index 7f1c39125a..56d5d42166 100644
--- a/frontend/src/components/Plan/components/Configuration/GhostSection/context.ts
+++ b/frontend/src/components/Plan/components/Configuration/GhostSection/context.ts
@@ -1,14 +1,11 @@
import Emittery from "emittery";
-import type { InjectionKey, Ref } from "vue";
-import { computed, inject, provide, unref } from "vue";
+import type { ComputedRef, InjectionKey, Ref } from "vue";
+import { computed, inject, provide } from "vue";
import { targetsForSpec } from "@/components/Plan/logic";
-import { extractUserId, useCurrentUserV1, useDatabaseV1Store } from "@/store";
+import { useDatabaseV1Store } from "@/store";
import { isValidDatabaseName } from "@/types";
-import type { Issue } from "@/types/proto-es/v1/issue_service_pb";
-import { IssueStatus } from "@/types/proto-es/v1/issue_service_pb";
import type { Plan, Plan_Spec } from "@/types/proto-es/v1/plan_service_pb";
-import type { Project } from "@/types/proto-es/v1/project_service_pb";
-import { hasProjectPermissionV2, isNullOrUndefined } from "@/utils";
+import { isNullOrUndefined } from "@/utils";
import { GHOST_AVAILABLE_ENGINES, getGhostEnabledForSpec } from "./common";
export const KEY = Symbol(
@@ -21,16 +18,13 @@ export const useGhostSettingContext = () => {
export const provideGhostSettingContext = (refs: {
isCreating: Ref<boolean>;
- project: Ref<Project>;
plan: Ref<Plan>;
selectedSpec: Ref<Plan_Spec | undefined>;
- issue?: Ref<Issue | undefined>;
- readonly?: Ref<boolean>;
+ allowChange: ComputedRef<boolean>;
}) => {
- const currentUser = useCurrentUserV1();
const databaseStore = useDatabaseV1Store();
- const { isCreating, project, plan, selectedSpec, issue, readonly } = refs;
+ const { isCreating, plan, selectedSpec, allowChange } = refs;
const events = new Emittery<{
update: never;
@@ -55,40 +49,6 @@ export const provideGhostSettingContext = (refs: {
);
});
- const allowChange = computed(() => {
- // If readonly mode, disallow changes
- if (readonly?.value) {
- return false;
- }
-
- // Allow toggle gh-ost when creating.
- if (isCreating.value) {
- return true;
- }
-
- // Disallow changes if the plan has started rollout.
- if (unref(plan).hasRollout) {
- return false;
- }
-
- // If issue is not open, disallow.
- if (issue?.value && issue.value.status !== IssueStatus.OPEN) {
- return false;
- }
-
- // Allowed to the plan/issue creator.
- if (currentUser.value.email === extractUserId(unref(plan).creator)) {
- return true;
- }
-
- // Allowed to the permission holder.
- if (hasProjectPermissionV2(project.value, "bb.plans.update")) {
- return true;
- }
-
- return false;
- });
-
const enabled = computed(() => {
return (
(selectedSpec.value && getGhostEnabledForSpec(selectedSpec.value)) ||
diff --git a/frontend/src/components/Plan/components/Configuration/InstanceRoleSection/context.ts b/frontend/src/components/Plan/components/Configuration/InstanceRoleSection/context.ts
index 072c36f900..d12c70d9bd 100644
--- a/frontend/src/components/Plan/components/Configuration/InstanceRoleSection/context.ts
+++ b/frontend/src/components/Plan/components/Configuration/InstanceRoleSection/context.ts
@@ -1,12 +1,10 @@
import Emittery from "emittery";
-import type { InjectionKey, Ref } from "vue";
+import type { ComputedRef, InjectionKey, Ref } from "vue";
import { computed, inject, provide, ref } from "vue";
import { targetsForSpec } from "@/components/Plan/logic";
import { useDatabaseV1Store } from "@/store";
import { isValidDatabaseName } from "@/types";
import { Engine } from "@/types/proto-es/v1/common_pb";
-import type { Issue } from "@/types/proto-es/v1/issue_service_pb";
-import { IssueStatus } from "@/types/proto-es/v1/issue_service_pb";
import { type Plan, type Plan_Spec } from "@/types/proto-es/v1/plan_service_pb";
import type { Project } from "@/types/proto-es/v1/project_service_pb";
@@ -23,12 +21,11 @@ export const provideInstanceRoleSettingContext = (refs: {
project: Ref<Project>;
plan: Ref<Plan>;
selectedSpec: Ref<Plan_Spec | undefined>;
- issue?: Ref<Issue | undefined>;
- readonly?: Ref<boolean>;
+ allowChange: ComputedRef<boolean>;
}) => {
const databaseStore = useDatabaseV1Store();
- const { isCreating, plan, selectedSpec, issue, readonly } = refs;
+ const { isCreating, plan, selectedSpec, allowChange } = refs;
const events = new Emittery<{
update: never;
@@ -63,30 +60,6 @@ export const provideInstanceRoleSettingContext = (refs: {
return !config.release;
});
- const allowChange = computed(() => {
- // If readonly mode, disallow changes
- if (readonly?.value) {
- return false;
- }
-
- // Allow changes when creating
- if (isCreating.value) {
- return true;
- }
-
- // Disallow changes if the plan has started rollout.
- if (plan.value.hasRollout) {
- return false;
- }
-
- // If issue is not open, disallow
- if (issue?.value && issue.value.status !== IssueStatus.OPEN) {
- return false;
- }
-
- return true;
- });
-
const context = {
isCreating,
selectedSpec,
diff --git a/frontend/src/components/Plan/components/Configuration/IsolationLevelSection/context.ts b/frontend/src/components/Plan/components/Configuration/IsolationLevelSection/context.ts
index e5a882fbc1..24ee327c7d 100644
--- a/frontend/src/components/Plan/components/Configuration/IsolationLevelSection/context.ts
+++ b/frontend/src/components/Plan/components/Configuration/IsolationLevelSection/context.ts
@@ -1,12 +1,10 @@
import Emittery from "emittery";
-import type { InjectionKey, Ref } from "vue";
+import type { ComputedRef, InjectionKey, Ref } from "vue";
import { computed, inject, provide, ref } from "vue";
import { targetsForSpec } from "@/components/Plan/logic";
import { useDatabaseV1Store } from "@/store";
import { isValidDatabaseName } from "@/types";
import { Engine } from "@/types/proto-es/v1/common_pb";
-import type { Issue } from "@/types/proto-es/v1/issue_service_pb";
-import { IssueStatus } from "@/types/proto-es/v1/issue_service_pb";
import { type Plan, type Plan_Spec } from "@/types/proto-es/v1/plan_service_pb";
import type { Project } from "@/types/proto-es/v1/project_service_pb";
import type { IsolationLevel } from "../../StatementSection/directiveUtils";
@@ -28,12 +26,11 @@ export const provideIsolationLevelSettingContext = (refs: {
project: Ref<Project>;
plan: Ref<Plan>;
selectedSpec: Ref<Plan_Spec | undefined>;
- issue?: Ref<Issue | undefined>;
- readonly?: Ref<boolean>;
+ allowChange: ComputedRef<boolean>;
}) => {
const databaseStore = useDatabaseV1Store();
- const { isCreating, plan, selectedSpec, issue, readonly } = refs;
+ const { isCreating, plan, selectedSpec, allowChange } = refs;
const events = new Emittery<{
update: never;
@@ -69,30 +66,6 @@ export const provideIsolationLevelSettingContext = (refs: {
return !config.release;
});
- const allowChange = computed(() => {
- // If readonly mode, disallow changes
- if (readonly?.value) {
- return false;
- }
-
- // Allow changes when creating
- if (isCreating.value) {
- return true;
- }
-
- // Disallow changes if the plan has started rollout.
- if (plan.value.hasRollout) {
- return false;
- }
-
- // If issue is not open, disallow
- if (issue?.value && issue.value.status !== IssueStatus.OPEN) {
- return false;
- }
-
- return true;
- });
-
const context = {
isCreating,
selectedSpec,
diff --git a/frontend/src/components/Plan/components/Configuration/PreBackupSection/context.ts b/frontend/src/components/Plan/components/Configuration/PreBackupSection/context.ts
index 363d033f46..f28a5c8914 100644
--- a/frontend/src/components/Plan/components/Configuration/PreBackupSection/context.ts
+++ b/frontend/src/components/Plan/components/Configuration/PreBackupSection/context.ts
@@ -2,6 +2,7 @@ import { create } from "@bufbuild/protobuf";
import Emittery from "emittery";
import { cloneDeep } from "lodash-es";
import {
+ type ComputedRef,
computed,
type InjectionKey,
inject,
@@ -11,16 +12,14 @@ import {
} from "vue";
import { isDatabaseChangeSpec, targetsForSpec } from "@/components/Plan/logic";
import { planServiceClientConnect } from "@/connect";
-import { extractUserId, useCurrentUserV1, useDatabaseV1Store } from "@/store";
+import { useDatabaseV1Store } from "@/store";
import { isValidDatabaseName } from "@/types";
-import { type Issue, IssueStatus } from "@/types/proto-es/v1/issue_service_pb";
import {
type Plan,
type Plan_Spec,
UpdatePlanRequestSchema,
} from "@/types/proto-es/v1/plan_service_pb";
import type { Project } from "@/types/proto-es/v1/project_service_pb";
-import { hasProjectPermissionV2 } from "@/utils";
import { BACKUP_AVAILABLE_ENGINES } from "./common";
const KEY = Symbol(
@@ -36,12 +35,10 @@ export const providePreBackupSettingContext = (refs: {
project: Ref<Project>;
plan: Ref<Plan>;
selectedSpec: Ref<Plan_Spec | undefined>;
- issue?: Ref<Issue | undefined>;
- readonly?: Ref<boolean>;
+ allowChange: ComputedRef<boolean>;
}) => {
- const currentUser = useCurrentUserV1();
const databaseStore = useDatabaseV1Store();
- const { isCreating, project, plan, selectedSpec, issue, readonly } = refs;
+ const { isCreating, plan, selectedSpec, allowChange } = refs;
const events = new Emittery<{
update: never;
@@ -76,40 +73,6 @@ export const providePreBackupSettingContext = (refs: {
return true;
});
- const allowChange = computed((): boolean => {
- // If readonly mode, disallow changes
- if (readonly?.value) {
- return false;
- }
-
- // Allow toggle pre-backup when creating.
- if (isCreating.value) {
- return true;
- }
-
- // Disallow changes if the plan has started rollout.
- if (unref(plan).hasRollout) {
- return false;
- }
-
- // If issue is not open, disallow.
- if (issue?.value && issue.value.status !== IssueStatus.OPEN) {
- return false;
- }
-
- // Allowed to the plan/issue creator.
- if (currentUser.value.email === extractUserId(unref(plan).creator)) {
- return true;
- }
-
- // Allowed to the permission holder.
- if (hasProjectPermissionV2(project.value, "bb.plans.update")) {
- return true;
- }
-
- return false;
- });
-
const enabled = computed((): boolean => {
if (selectedSpec.value?.config?.case === "changeDatabaseConfig") {
return Boolean(selectedSpec.value.config.value.enablePriorBackup);
diff --git a/frontend/src/components/Plan/components/Configuration/TransactionModeSection/context.ts b/frontend/src/components/Plan/components/Configuration/TransactionModeSection/context.ts
index 0930c6a147..38ffe26d46 100644
--- a/frontend/src/components/Plan/components/Configuration/TransactionModeSection/context.ts
+++ b/frontend/src/components/Plan/components/Configuration/TransactionModeSection/context.ts
@@ -1,11 +1,9 @@
import Emittery from "emittery";
-import type { InjectionKey, Ref } from "vue";
+import type { ComputedRef, InjectionKey, Ref } from "vue";
import { computed, inject, provide, ref } from "vue";
import { targetsForSpec } from "@/components/Plan/logic";
import { useDatabaseV1Store } from "@/store";
import { isValidDatabaseName } from "@/types";
-import type { Issue } from "@/types/proto-es/v1/issue_service_pb";
-import { IssueStatus } from "@/types/proto-es/v1/issue_service_pb";
import { type Plan, type Plan_Spec } from "@/types/proto-es/v1/plan_service_pb";
import type { Project } from "@/types/proto-es/v1/project_service_pb";
import { instanceV1SupportsTransactionMode } from "@/utils";
@@ -23,12 +21,11 @@ export const provideTransactionModeSettingContext = (refs: {
project: Ref<Project>;
plan: Ref<Plan>;
selectedSpec: Ref<Plan_Spec | undefined>;
- issue?: Ref<Issue | undefined>;
- readonly?: Ref<boolean>;
+ allowChange: ComputedRef<boolean>;
}) => {
const databaseStore = useDatabaseV1Store();
- const { isCreating, plan, selectedSpec, issue, readonly } = refs;
+ const { isCreating, plan, selectedSpec, allowChange } = refs;
const events = new Emittery<{
update: never;
@@ -64,30 +61,6 @@ export const provideTransactionModeSettingContext = (refs: {
return !config.release;
});
- const allowChange = computed(() => {
- // If readonly mode, disallow changes
- if (readonly?.value) {
- return false;
- }
-
- // Allow changes when creating
- if (isCreating.value) {
- return true;
- }
-
- // Disallow changes if the plan has started rollout.
- if (plan.value.hasRollout) {
- return false;
- }
-
- // If issue is not open, disallow
- if (issue?.value && issue.value.status !== IssueStatus.OPEN) {
- return false;
- }
-
- return true;
- });
-
const context = {
isCreating,
selectedSpec,
diff --git a/frontend/src/components/Plan/components/HeaderSection/DescriptionSection.vue b/frontend/src/components/Plan/components/HeaderSection/DescriptionSection.vue
index da165132cc..f7f075e6d6 100644
--- a/frontend/src/components/Plan/components/HeaderSection/DescriptionSection.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/DescriptionSection.vue
@@ -76,17 +76,21 @@ import { computed, reactive, watch } from "vue";
import MarkdownEditor from "@/components/MarkdownEditor";
import { useResourcePoller } from "@/components/Plan/logic/poller";
import { planServiceClientConnect } from "@/connect";
-import { extractUserId, useCurrentProjectV1, useCurrentUserV1 } from "@/store";
+import { useCurrentProjectV1 } from "@/store";
import {
PlanSchema,
UpdatePlanRequestSchema,
} from "@/types/proto-es/v1/plan_service_pb";
-import { hasProjectPermissionV2 } from "@/utils";
import { usePlanContext } from "../../logic";
-const currentUser = useCurrentUserV1();
const { project } = useCurrentProjectV1();
-const { isCreating, plan, readonly, issue } = usePlanContext();
+const {
+ isCreating,
+ plan,
+ readonly,
+ issue,
+ allowEdit: hasPermission,
+} = usePlanContext();
const { refreshResources } = useResourcePoller();
const state = reactive({
@@ -108,13 +112,7 @@ const allowEdit = computed(() => {
if (!issue.value && plan.value.hasRollout) {
return false;
}
- if (extractUserId(plan.value.creator) === currentUser.value.email) {
- return true;
- }
- if (hasProjectPermissionV2(project.value, "bb.plans.update")) {
- return true;
- }
- return false;
+ return hasPermission.value;
});
const handleExpand = (event: MouseEvent) => {
diff --git a/frontend/src/components/Plan/components/HeaderSection/TitleInput.vue b/frontend/src/components/Plan/components/HeaderSection/TitleInput.vue
index cb6ed5c65f..0899c25d47 100644
--- a/frontend/src/components/Plan/components/HeaderSection/TitleInput.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/TitleInput.vue
@@ -46,7 +46,13 @@ type ViewMode = "EDIT" | "VIEW";
const { t } = useI18n();
const currentUser = useCurrentUserV1();
const { project } = useCurrentProjectV1();
-const { isCreating, plan, issue, readonly } = usePlanContext();
+const {
+ isCreating,
+ plan,
+ issue,
+ readonly,
+ allowEdit: hasPermission,
+} = usePlanContext();
const state = reactive({
isEditing: false,
@@ -110,16 +116,7 @@ const allowEdit = computed(() => {
return false;
}
- // For plans without issue, check plan permissions
- // Allowed if current user is the creator.
- if (extractUserId(plan.value.creator) === currentUser.value.email) {
- return true;
- }
- // Allowed if current user has related permission.
- if (hasProjectPermissionV2(project.value, "bb.plans.update")) {
- return true;
- }
- return false;
+ return hasPermission.value;
});
const onBlur = async () => {
diff --git a/frontend/src/components/Plan/components/IssueReviewView/ActivitySection/IssueCommentView/ActionCreator.vue b/frontend/src/components/Plan/components/IssueReviewView/ActivitySection/IssueCommentView/ActionCreator.vue
index 4e634d7261..f19112f1d4 100644
--- a/frontend/src/components/Plan/components/IssueReviewView/ActivitySection/IssueCommentView/ActionCreator.vue
+++ b/frontend/src/components/Plan/components/IssueReviewView/ActivitySection/IssueCommentView/ActionCreator.vue
@@ -1,24 +1,19 @@
<template>
- <component
- :is="'router-link'"
- v-if="userEmail !== userStore.systemBotUser?.email"
- v-bind="bindings"
- class="font-semibold text-gray-900 whitespace-nowrap hover:underline"
- >
- {{ user?.title }}
- </component>
- <div v-else class="inline-flex items-center gap-1">
+ <div v-if="userEmail === userStore.systemBotUser?.email" class="inline-flex items-center gap-1">
<span class="font-medium text-main whitespace-nowrap">
{{ user?.title }}
</span>
<SystemBotTag />
</div>
+ <UserLink v-else-if="user" :title="user.title" :email="user.email" />
+ <span v-else class="font-medium text-main whitespace-nowrap">-</span>
</template>
<script lang="ts" setup>
import { computedAsync } from "@vueuse/core";
import { computed } from "vue";
import SystemBotTag from "@/components/misc/SystemBotTag.vue";
+import { UserLink } from "@/components/v2/Model/cells";
import { extractUserId, useUserStore } from "@/store";
const props = defineProps<{
@@ -35,15 +30,4 @@ const userEmail = computed(() => {
const user = computedAsync(() => {
return userStore.getOrFetchUserByIdentifier(props.creator);
});
-
-const bindings = computed(() => {
- return {
- to: `/users/${userEmail.value}`,
- activeClass: "",
- exactActiveClass: "",
- onClick: (e: MouseEvent) => {
- e.stopPropagation();
- },
- };
-});
</script>
diff --git a/frontend/src/components/Plan/components/IssueReviewView/ActivitySection/IssueCommentView/IssueDescriptionComment.vue b/frontend/src/components/Plan/components/IssueReviewView/ActivitySection/IssueCommentView/IssueDescriptionComment.vue
index 7cc60bc7cb..9b67b44ffe 100644
--- a/frontend/src/components/Plan/components/IssueReviewView/ActivitySection/IssueCommentView/IssueDescriptionComment.vue
+++ b/frontend/src/components/Plan/components/IssueReviewView/ActivitySection/IssueCommentView/IssueDescriptionComment.vue
@@ -77,7 +77,7 @@ import { usePlanContext } from "@/components/Plan/logic";
import UserAvatar from "@/components/User/UserAvatar.vue";
import { issueServiceClientConnect } from "@/connect";
import { useCurrentProjectV1, useCurrentUserV1, useUserStore } from "@/store";
-import { getTimeForPbTimestampProtoEs } from "@/types";
+import { getTimeForPbTimestampProtoEs, unknownUser } from "@/types";
import type { IssueComment } from "@/types/proto-es/v1/issue_service_pb";
import {
IssueSchema,
@@ -111,7 +111,10 @@ const createTime = computed((): Timestamp | undefined => {
});
const creator = computed(() => {
- return userStore.getUserByIdentifier(creatorName.value);
+ return (
+ userStore.getUserByIdentifier(creatorName.value) ??
+ unknownUser(creatorName.value)
+ );
});
const description = computed(() => {
diff --git a/frontend/src/components/Plan/components/IssueReviewView/DatabaseChangeView/OptionsSection.vue b/frontend/src/components/Plan/components/IssueReviewView/DatabaseChangeView/OptionsSection.vue
index b46c7b7f69..0ce87bb050 100644
--- a/frontend/src/components/Plan/components/IssueReviewView/DatabaseChangeView/OptionsSection.vue
+++ b/frontend/src/components/Plan/components/IssueReviewView/DatabaseChangeView/OptionsSection.vue
@@ -34,7 +34,7 @@
<script setup lang="ts">
import { computed } from "vue";
-import { useCurrentProjectV1 } from "@/store";
+import { IssueStatus } from "@/types/proto-es/v1/issue_service_pb";
import { usePlanContext } from "../../../logic";
import { provideGhostSettingContext } from "../../Configuration/GhostSection/context";
import GhostSwitch from "../../Configuration/GhostSection/GhostSwitch.vue";
@@ -48,17 +48,41 @@ import { provideTransactionModeSettingContext } from "../../Configuration/Transa
import TransactionModeSwitch from "../../Configuration/TransactionModeSection/TransactionModeSwitch.vue";
import { useSelectedSpec } from "../../SpecDetailView/context";
-const { project } = useCurrentProjectV1();
-const { isCreating, plan, events, issue, readonly } = usePlanContext();
+const { isCreating, plan, events, issue, readonly, allowEdit, project } =
+ usePlanContext();
const { selectedSpec } = useSelectedSpec();
+const allowChange = computed(() => {
+ // If readonly mode, disallow changes
+ if (readonly?.value) {
+ return false;
+ }
+
+ // Allow changes when creating
+ if (isCreating.value) {
+ return true;
+ }
+
+ // Disallow changes if the plan has started rollout.
+ if (plan.value.hasRollout) {
+ return false;
+ }
+
+ // If issue is not open, disallow
+ if (issue?.value && issue.value.status !== IssueStatus.OPEN) {
+ return false;
+ }
+
+ return allowEdit.value;
+});
+
const providerArgs = {
project,
plan,
selectedSpec,
isCreating,
issue,
- readonly,
+ allowChange,
};
const { shouldShow: shouldShowTransactionModeSection, events: txEvents } =
diff --git a/frontend/src/components/Plan/components/PlanDataTable/PlanDataTable.vue b/frontend/src/components/Plan/components/PlanDataTable/PlanDataTable.vue
index 9e871524c7..a137e7fe35 100644
--- a/frontend/src/components/Plan/components/PlanDataTable/PlanDataTable.vue
+++ b/frontend/src/components/Plan/components/PlanDataTable/PlanDataTable.vue
@@ -18,8 +18,8 @@ import { NDataTable, NPerformantEllipsis, NTag } from "naive-ui";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
-import { BBAvatar } from "@/bbkit";
import Timestamp from "@/components/misc/Timestamp.vue";
+import { UserNameCell } from "@/components/v2/Model/cells";
import { useIssueLayoutVersion } from "@/composables/useIssueLayoutVersion";
import { PROJECT_V1_ROUTE_PLAN_DETAIL } from "@/router/dashboard/projectV1";
import { useUserStore } from "@/store";
@@ -100,12 +100,17 @@ const columnList = computed((): DataTableColumn<Plan>[] => {
width: 128,
render: (plan) => {
const creator =
- userStore.getUserByIdentifier(plan.creator) || unknownUser();
+ userStore.getUserByIdentifier(plan.creator) ||
+ unknownUser(plan.creator);
return (
- <div class="flex flex-row items-center overflow-hidden gap-x-2">
- <BBAvatar size="SMALL" username={creator.title} />
- <span class="truncate">{creator.title}</span>
- </div>
+ <UserNameCell
+ user={creator}
+ size="small"
+ allowEdit={false}
+ showMfaEnabled={false}
+ showSource={false}
+ showEmail={false}
+ />
);
},
},
diff --git a/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue b/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue
index abcf46a783..0a50267f4b 100644
--- a/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue
+++ b/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue
@@ -95,7 +95,7 @@ import { useSelectedSpec } from "./context";
const router = useRouter();
const dialog = useDialog();
const { t } = useI18n();
-const { plan, isCreating } = usePlanContext();
+const { plan, isCreating, allowEdit } = usePlanContext();
const sheetStore = useSheetV1Store();
const { selectedSpec } = useSelectedSpec();
const { project } = useCurrentProjectV1();
@@ -109,7 +109,10 @@ const showAddSpecDrawer = ref(false);
// 2. Plan is being created (isCreating = true), OR plan has no rollout
const canModifySpecs = computed(() => {
if (plan.value.state === State.DELETED) return false;
- return isCreating.value || !plan.value.hasRollout;
+ if (isCreating.value) {
+ return true;
+ }
+ return allowEdit.value && !plan.value.hasRollout;
});
const handleTabChange = (specId: string) => {
diff --git a/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue b/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue
index 1ecd0a6397..3d2b5cc7f1 100644
--- a/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue
+++ b/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue
@@ -80,7 +80,12 @@ import DatabaseGroupTargetDisplay from "./DatabaseGroupTargetDisplay.vue";
import TargetsSelectorDrawer from "./TargetsSelectorDrawer.vue";
const { t } = useI18n();
-const { plan, isCreating, readonly } = usePlanContext();
+const {
+ plan,
+ isCreating,
+ readonly,
+ allowEdit: hasPermission,
+} = usePlanContext();
const { selectedSpec, targets, getDatabaseTargets } = useSelectedSpec();
const dbGroupStore = useDBGroupStore();
const projectStore = useProjectV1Store();
@@ -100,7 +105,12 @@ const project = computed(() => {
// An empty string for `plan.value.hasRollout` indicates that the plan is in a draft or uninitialized state,
// which allows edits to be made.
const allowEdit = computed(() => {
- if (readonly.value) return false;
+ if (readonly.value) {
+ return false;
+ }
+ if (!hasPermission.value) {
+ return false;
+ }
return (isCreating.value || !plan.value.hasRollout) && selectedSpec.value;
});
diff --git a/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue b/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue
index 102e45f489..90c2353e3b 100644
--- a/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue
+++ b/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue
@@ -243,7 +243,8 @@ type LocalState = {
const { t } = useI18n();
const dialog = useDialog();
const { project } = useCurrentProjectV1();
-const { isCreating, plan, planCheckRuns, events, readonly } = usePlanContext();
+const { isCreating, plan, planCheckRuns, events, readonly, allowEdit } =
+ usePlanContext();
const { selectedSpec, getDatabaseTargets, targets } = useSelectedSpec();
const editorState = useEditorState();
@@ -339,7 +340,7 @@ const shouldShowEditButton = computed(() => {
if (plan.value.hasRollout) {
return false;
}
- return true;
+ return allowEdit.value;
});
const allowSaveSQL = computed((): boolean => {
diff --git a/frontend/src/components/Plan/logic/context.ts b/frontend/src/components/Plan/logic/context.ts
index ef1c002ac4..68b3d82b9d 100644
--- a/frontend/src/components/Plan/logic/context.ts
+++ b/frontend/src/components/Plan/logic/context.ts
@@ -1,10 +1,13 @@
import type Emittery from "emittery";
import { v4 as uuidv4 } from "uuid";
import type { ComputedRef, InjectionKey, Ref } from "vue";
-import { inject, provide } from "vue";
+import { computed, inject, provide } from "vue";
+import { useCurrentProjectV1, useCurrentUserV1 } from "@/store";
import type { Issue } from "@/types/proto-es/v1/issue_service_pb";
import type { Plan, PlanCheckRun } from "@/types/proto-es/v1/plan_service_pb";
+import { type Project } from "@/types/proto-es/v1/project_service_pb";
import type { Rollout, TaskRun } from "@/types/proto-es/v1/rollout_service_pb";
+import { hasProjectPermissionV2 } from "@/utils";
import type {
IssueReviewAction,
IssueStatusAction,
@@ -32,11 +35,16 @@ export type PlanContext = {
taskRuns: Ref<TaskRun[]>;
readonly: ComputedRef<boolean>;
+ allowEdit: ComputedRef<boolean>;
+ project: ComputedRef<Project>;
+ isCreator: ComputedRef<boolean>;
// UI events
events: PlanEvents;
};
+type InitPlanContext = Omit<PlanContext, "allowEdit" | "project" | "isCreator">;
+
const KEY = Symbol(`bb.plan.context.${uuidv4()}`) as InjectionKey<PlanContext>;
export const usePlanContext = () => {
@@ -76,7 +84,28 @@ export const usePlanContextWithRollout = () => {
};
};
-export const providePlanContext = (context: PlanContext) => {
- provide(KEY, context as PlanContext);
- return context as PlanContext;
+export const providePlanContext = (context: InitPlanContext) => {
+ const isCreator = computed(() => {
+ const currentUser = useCurrentUserV1();
+ return context.plan.value.creator === currentUser.value.name;
+ });
+
+ const { project } = useCurrentProjectV1();
+
+ const allowEdit = computed(() => {
+ if (isCreator.value) {
+ return true;
+ }
+ return hasProjectPermissionV2(project.value, "bb.plans.update");
+ });
+
+ const planContext = {
+ ...context,
+ isCreator,
+ project,
+ allowEdit,
+ } as PlanContext;
+
+ provide(KEY, planContext);
+ return planContext;
};
diff --git a/frontend/src/components/ProjectMember/ProjectMemberRolePanel/index.vue b/frontend/src/components/ProjectMember/ProjectMemberRolePanel/index.vue
index 6b27bd0270..e5ce2a3d10 100644
--- a/frontend/src/components/ProjectMember/ProjectMemberRolePanel/index.vue
+++ b/frontend/src/components/ProjectMember/ProjectMemberRolePanel/index.vue
@@ -159,7 +159,12 @@ import {
useProjectIamPolicyStore,
useUserStore,
} from "@/store";
-import { type DatabaseResource, PRESET_ROLES, PresetRoleType } from "@/types";
+import {
+ type DatabaseResource,
+ PRESET_ROLES,
+ PresetRoleType,
+ unknownUser,
+} from "@/types";
import { State } from "@/types/proto-es/v1/common_pb";
import type { Binding } from "@/types/proto-es/v1/iam_policy_pb";
import { BindingSchema } from "@/types/proto-es/v1/iam_policy_pb";
@@ -641,10 +646,9 @@ const groupMembers = computedAsync(async () => {
const resp = [];
for (const member of members) {
- const user = userStore.getUserByIdentifier(member.member);
- if (!user) {
- continue;
- }
+ const user =
+ userStore.getUserByIdentifier(member.member) ??
+ unknownUser(member.member);
resp.push({
user,
role: member.role,
diff --git a/frontend/src/components/v2/Model/cells/UserLink.vue b/frontend/src/components/v2/Model/cells/UserLink.vue
index 8c497f9059..af6e8b7b48 100644
--- a/frontend/src/components/v2/Model/cells/UserLink.vue
+++ b/frontend/src/components/v2/Model/cells/UserLink.vue
@@ -15,7 +15,7 @@
<script lang="tsx" setup>
import { computed } from "vue";
import { HighlightLabelText } from "@/components/v2";
-import { usePermissionStore } from "@/store";
+import { hasWorkspacePermissionV2 } from "@/utils";
const props = withDefaults(
defineProps<{
@@ -29,9 +29,7 @@ const props = withDefaults(
}
);
-const permissionStore = usePermissionStore();
-
const isLink = computed(
- () => props.link && !permissionStore.onlyWorkspaceMember
+ () => props.link && hasWorkspacePermissionV2("bb.users.get")
);
</script>
\ No newline at end of file
diff --git a/frontend/src/router/dashboard/projectV1.ts b/frontend/src/router/dashboard/projectV1.ts
index 97bf3f40eb..6c986b1626 100644
--- a/frontend/src/router/dashboard/projectV1.ts
+++ b/frontend/src/router/dashboard/projectV1.ts
@@ -160,10 +160,7 @@ const projectV1Routes: RouteRecordRaw[] = [
path: "masking-exemption",
meta: {
title: () => t("project.masking-exemption.self"),
- requiredPermissionList: () => [
- "bb.databases.list",
- "bb.policies.get",
- ],
+ requiredPermissionList: () => ["bb.databases.get", "bb.policies.get"],
},
props: true,
children: [
@@ -181,7 +178,10 @@ const projectV1Routes: RouteRecordRaw[] = [
import("@/views/project/ProjectMaskingExemptionCreate.vue"),
props: true,
meta: {
- requiredPermissionList: () => ["bb.policies.create"],
+ requiredPermissionList: () => [
+ "bb.policies.create",
+ "bb.databases.list",
+ ],
},
},
],
diff --git a/frontend/src/store/modules/user.ts b/frontend/src/store/modules/user.ts
index 39b16e532a..a09eb96809 100644
--- a/frontend/src/store/modules/user.ts
+++ b/frontend/src/store/modules/user.ts
@@ -189,14 +189,21 @@ export const useUserStore = defineStore("user", () => {
return validList.map(getUserByIdentifier);
}
- const request = create(BatchGetUsersRequestSchema, {
- names: pendingFetch,
- });
- const response = await userServiceClientConnect.batchGetUsers(request);
- for (const user of response.users) {
- setUser(user);
+ try {
+ const request = create(BatchGetUsersRequestSchema, {
+ names: pendingFetch,
+ });
+ const response = await userServiceClientConnect.batchGetUsers(request, {
+ contextValues: createContextValues().set(silentContextKey, true),
+ });
+ for (const user of response.users) {
+ setUser(user);
+ }
+ } finally {
+ return validList.map(
+ (name) => getUserByIdentifier(name) ?? unknownUser(name)
+ );
}
- return validList.map((name) => getUserByIdentifier(name));
};
const getOrFetchUserByIdentifier = async (
@@ -214,7 +221,9 @@ export const useUserStore = defineStore("user", () => {
}
const cached = userRequestCache.get(fullname);
if (cached) return cached;
- const request = fetchUser(fullname, silent).then((user) => setUser(user));
+ const request = fetchUser(fullname, silent)
+ .then((user) => setUser(user))
+ .catch(() => unknownUser(fullname));
userRequestCache.set(fullname, request);
return request;
};
diff --git a/frontend/src/store/modules/v1/permission.ts b/frontend/src/store/modules/v1/permission.ts
index a4d236a085..3834285172 100644
--- a/frontend/src/store/modules/v1/permission.ts
+++ b/frontend/src/store/modules/v1/permission.ts
@@ -1,11 +1,7 @@
import { uniq } from "lodash-es";
import { defineStore } from "pinia";
import { computed, shallowReactive } from "vue";
-import {
- type Permission,
- PRESET_WORKSPACE_ROLES,
- PresetRoleType,
-} from "@/types";
+import { type Permission, PRESET_WORKSPACE_ROLES } from "@/types";
import type { Project } from "@/types/proto-es/v1/project_service_pb";
import { type User } from "@/types/proto-es/v1/user_service_pb";
import { bindingListInIAM } from "@/utils";
@@ -28,13 +24,6 @@ export const usePermissionStore = defineStore("permission", () => {
return workspaceStore.getWorkspaceRolesByEmail(currentUser.value.email);
});
- const onlyWorkspaceMember = computed(
- () =>
- currentRolesInWorkspace.value.size === 0 ||
- (currentRolesInWorkspace.value.size === 1 &&
- currentRolesInWorkspace.value.has(PresetRoleType.WORKSPACE_MEMBER))
- );
-
const currentPermissions = computed(() => {
return new Set(
[...currentRolesInWorkspace.value]
@@ -121,7 +110,6 @@ export const usePermissionStore = defineStore("permission", () => {
return {
currentPermissions,
currentRolesInWorkspace,
- onlyWorkspaceMember,
currentRoleListInProjectV1,
currentPermissionsInProjectV1,
invalidCacheByProject,
diff --git a/frontend/src/types/v1/user.ts b/frontend/src/types/v1/user.ts
index e533926a19..01a95bf692 100644
--- a/frontend/src/types/v1/user.ts
+++ b/frontend/src/types/v1/user.ts
@@ -1,5 +1,6 @@
import { create } from "@bufbuild/protobuf";
import { t } from "@/plugins/i18n";
+import { extractUserId } from "@/store/modules/v1/common";
import { SYSTEM_BOT_EMAIL } from "../common";
import { EMPTY_ID, UNKNOWN_ID } from "../const";
import { State } from "../proto-es/v1/common_pb";
@@ -19,12 +20,18 @@ export const emptyUser = (): User => {
});
};
-export const unknownUser = (): User => {
- return {
- ...emptyUser(),
- name: UNKNOWN_USER_NAME,
- title: "<<Unknown user>>",
- };
+export const unknownUser = (name: string = ""): User => {
+ const empty = emptyUser();
+ if (name) {
+ empty.name = name;
+ const email = extractUserId(name);
+ empty.email = email;
+ empty.title = email;
+ } else {
+ empty.name = UNKNOWN_USER_NAME;
+ empty.title = "<<Unknown user>>";
+ }
+ return empty;
};
export const ALL_USERS_USER_EMAIL = "allUsers";
diff --git a/frontend/src/views/ProfileDashboard.vue b/frontend/src/views/ProfileDashboard.vue
index 6c143f1f29..7071220fec 100644
--- a/frontend/src/views/ProfileDashboard.vue
+++ b/frontend/src/views/ProfileDashboard.vue
@@ -4,8 +4,9 @@
tabindex="0"
>
<NoPermissionPlaceholder
- v-if="permissionStore.onlyWorkspaceMember && !isSelf"
- class="py-6"
+ v-if="!allowGet"
+ class="px-4"
+ :permissions="['bb.users.get']"
/>
<div v-else>
<!-- Profile header -->
@@ -245,7 +246,6 @@ import {
pushNotification,
useActuatorV1Store,
useCurrentUserV1,
- usePermissionStore,
useSettingV1Store,
useUserStore,
useWorkspaceV1Store,
@@ -284,7 +284,6 @@ const settingV1Store = useSettingV1Store();
const currentUser = useCurrentUserV1();
const userStore = useUserStore();
const workspaceStore = useWorkspaceV1Store();
-const permissionStore = usePermissionStore();
const state = reactive<LocalState>({
editing: false,
@@ -345,6 +344,10 @@ const userRoles = computed(() => {
const isSelf = computed(() => currentUser.value.name === user.value.name);
+const allowGet = computed(
+ () => isSelf.value || hasWorkspacePermissionV2("bb.users.get")
+);
+
// User can change her own info.
// Besides, owner can also change anyone's info. This is for resetting password in case user forgets.
const allowEdit = computed(() => {
@@ -358,7 +361,7 @@ const allowEdit = computed(() => {
if (user.value.state !== State.ACTIVE) {
return false;
}
- return isSelf.value || hasWorkspacePermissionV2("bb.policies.update");
+ return isSelf.value || hasWorkspacePermissionV2("bb.users.update");
});
// Only users with bb.users.updateEmail permission can change email.