Skip to content

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

Disallow access to environment page for developer role

天舟df1f07e1e269
diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts
index d42e63bdae..096844494d 100644
--- a/frontend/src/router/index.ts
+++ b/frontend/src/router/index.ts
@@ -582,21 +582,6 @@ router.beforeEach((to, from, next) => {
}
}
- if (
- to.name === "error.403" ||
- to.name === "error.404" ||
- to.name === "error.500" ||
- to.name === "workspace.home" ||
- to.name === "workspace.inbox" ||
- to.name === "workspace.environment" ||
- to.name === "workspace.project" ||
- to.name === "workspace.database" ||
- to.name?.toString().startsWith("setting")
- ) {
- next();
- return;
- }
-
if (to.name === "workspace.database.create") {
if (
!store.getters["plan/feature"]("bytebase.dba-workflow") ||
@@ -614,6 +599,7 @@ router.beforeEach((to, from, next) => {
if (
to.name === "workspace.archive" ||
+ to.name === "workspace.environment" ||
to.name?.toString().startsWith("workspace.instance")
) {
if (isDBAOrOwner(loginUser.role)) {
@@ -640,6 +626,20 @@ router.beforeEach((to, from, next) => {
}
}
+ if (
+ to.name === "error.403" ||
+ to.name === "error.404" ||
+ to.name === "error.500" ||
+ to.name === "workspace.home" ||
+ to.name === "workspace.inbox" ||
+ to.name === "workspace.project" ||
+ to.name === "workspace.database" ||
+ to.name?.toString().startsWith("setting")
+ ) {
+ next();
+ return;
+ }
+
const routerSlug = store.getters["router/routeSlug"](to);
const environmentSlug = routerSlug.environmentSlug;
const projectSlug = routerSlug.projectSlug;
diff --git a/frontend/src/views/DashboardHeader.vue b/frontend/src/views/DashboardHeader.vue
index 85ce55bd25..48a833dca1 100644
--- a/frontend/src/views/DashboardHeader.vue
+++ b/frontend/src/views/DashboardHeader.vue
@@ -10,20 +10,9 @@
><img class="h-12 w-auto" src="../assets/logo.svg" alt="Bytebase"
/></router-link>
</div>
- <div class="hidden sm:block">
+ <div v-if="showDBAItem" class="hidden sm:block">
<div class="ml-6 flex items-baseline space-x-2">
- <router-link to="/project" class="bar-link px-2 py-2 rounded-md"
- >Projects</router-link
- >
-
- <router-link to="/db" class="bar-link px-2 py-2 rounded-md"
- >Databases</router-link
- >
-
- <router-link
- v-if="showInstanceLink"
- to="/instance"
- class="bar-link px-2 py-2 rounded-md"
+ <router-link to="/instance" class="bar-link px-2 py-2 rounded-md"
>Instances</router-link
>
@@ -170,20 +159,8 @@
Open: "block", closed: "hidden"
-->
<div v-if="state.showMobileMenu" class="block md:hidden">
- <div class="px-2 pt-2 pb-3 space-y-1 sm:px-3">
- <!-- Current: "bg-gray-900 text-white", Default: "text-gray-300 hover:bg-gray-700 hover:text-white" -->
- <router-link to="/project" class="bar-link rounded-md block px-3 py-2"
- >Projects</router-link
- >
-
- <router-link to="/database" class="bar-link rounded-md block px-3 py-2"
- >Databases</router-link
- >
-
- <router-link
- v-if="showInstanceLink"
- to="/instance"
- class="bar-link rounded-md block px-3 py-2"
+ <div v-if="showDBAItem" class="px-2 pt-2 pb-3 space-y-1 sm:px-3">
+ <router-link to="/instance" class="bar-link rounded-md block px-3 py-2"
>Instance</router-link
>
@@ -225,7 +202,7 @@ export default {
const currentPlan = computed(() => store.getters["plan/currentPlan"]());
- const showInstanceLink = computed((): boolean => {
+ const showDBAItem = computed((): boolean => {
return isDBAOrOwner(currentUser.value.role);
});
@@ -266,7 +243,7 @@ export default {
state,
currentUser,
currentPlan,
- showInstanceLink,
+ showDBAItem,
switchToOwner,
switchToDBA,
switchToDeveloper,
diff --git a/frontend/src/views/ProfileDashboard.vue b/frontend/src/views/ProfileDashboard.vue
index cc151238de..bc5de530f5 100644
--- a/frontend/src/views/ProfileDashboard.vue
+++ b/frontend/src/views/ProfileDashboard.vue
@@ -110,9 +110,17 @@
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-control-light">Role</dt>
<dd class="mt-1 text-sm text-main">
- <router-link :to="'/setting/member'" class="normal-link" v-role>
+ <router-link
+ v-if="hasAdminFeature"
+ :to="'/setting/member'"
+ class="normal-link"
+ v-role
+ >
{{ principal.role }}
</router-link>
+ <router-link v-else :to="'/setting/plan'" class="normal-link">
+ Upgrade to Team plan to enable admin management
+ </router-link>
</dd>
</div>
@@ -133,7 +141,7 @@ import { nextTick, computed, onMounted, onUnmounted, reactive, ref } from "vue";
import { useStore } from "vuex";
import cloneDeep from "lodash-es/cloneDeep";
import isEqual from "lodash-es/isEqual";
-import { Principal, PrincipalPatch } from "../types";
+import { PrincipalPatch } from "../types";
interface LocalState {
editing: boolean;
@@ -179,6 +187,10 @@ export default {
const currentUser = computed(() => store.getters["auth/currentUser"]());
+ const hasAdminFeature = computed(() =>
+ store.getters["plan/feature"]("bytebase.admin")
+ );
+
const principal = computed(() => {
if (props.principalId) {
return store.getters["principal/principalById"](props.principalId);
@@ -232,6 +244,7 @@ export default {
return {
editNameTextField,
state,
+ hasAdminFeature,
isCurrentUser,
principal,
valueChanged,
diff --git a/frontend/src/views/SettingSidebar.vue b/frontend/src/views/SettingSidebar.vue
index cb315c938e..67a9313852 100644
--- a/frontend/src/views/SettingSidebar.vue
+++ b/frontend/src/views/SettingSidebar.vue
@@ -110,9 +110,10 @@
</template>
<script lang="ts">
-import { reactive } from "vue";
+import { computed, reactive } from "vue";
import { useStore } from "vuex";
import { useRouter } from "vue-router";
+import { isDBAOrOwner } from "../utils";
interface LocalState {
collapseState: boolean;
@@ -130,6 +131,8 @@ export default {
collapseState: true,
});
+ const currentUser = computed(() => store.getters["auth/currentUser"]());
+
const goBack = () => {
router.push(store.getters["router/backPath"]());
};