Skip to content

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

Add updaterId/creatorId to principal/user

天舟ff101f45d1bd
diff --git a/frontend/src/components/MemberInvite.vue b/frontend/src/components/MemberInvite.vue
index 60cd9db227..42d94593b5 100644
--- a/frontend/src/components/MemberInvite.vue
+++ b/frontend/src/components/MemberInvite.vue
@@ -117,7 +117,7 @@
</template>
<script lang="ts">
-import { computed, reactive } from "vue";
+import { computed, ComputedRef, reactive } from "vue";
import { useStore } from "vuex";
import RoleSelect from "../components/RoleSelect.vue";
import { Principal, PrincipalNew, MemberNew, RoleType } from "../types";
@@ -140,6 +140,10 @@ export default {
setup(props, ctx) {
const store = useStore();
+ const currentUser: ComputedRef<Principal> = computed(() =>
+ store.getters["auth/currentUser"]()
+ );
+
const hasAdminFeature = computed(() =>
store.getters["plan/feature"]("bytebase.admin")
);
@@ -216,6 +220,7 @@ export default {
// This could happen if another client has just created the principal
// with this email.
const newPrincipal: PrincipalNew = {
+ creatorId: currentUser.value.id,
name: invite.email.split("@")[0],
email: invite.email,
};
diff --git a/frontend/src/miragejs/factories/user.js b/frontend/src/miragejs/factories/user.js
index a28e56f825..4a5d37ed5c 100644
--- a/frontend/src/miragejs/factories/user.js
+++ b/frontend/src/miragejs/factories/user.js
@@ -1,8 +1,15 @@
import { Factory } from "miragejs";
import faker from "faker";
+import { UNKNOWN_ID } from "../../types";
export default {
user: Factory.extend({
+ creatorId() {
+ return UNKNOWN_ID;
+ },
+ updaterId() {
+ return UNKNOWN_ID;
+ },
createdTs(i) {
return Date.now() - (i + 1) * 1800 * 1000;
},
diff --git a/frontend/src/miragejs/routes/user.js b/frontend/src/miragejs/routes/user.js
index 14cf860a17..d04d9f481c 100644
--- a/frontend/src/miragejs/routes/user.js
+++ b/frontend/src/miragejs/routes/user.js
@@ -1,5 +1,3 @@
-import { FAKE_API_CALLER_ID, WORKSPACE_ID } from "./index";
-
export default function configureUser(route) {
route.get("/user/:id");
@@ -15,9 +13,9 @@ export default function configureUser(route) {
const ts = Date.now();
return schema.users.create({
...attrs,
- creatorId: FAKE_API_CALLER_ID,
- updaterId: FAKE_API_CALLER_ID,
+ creatorId: attrs.creatorId,
createdTs: ts,
+ updaterId: attrs.creatorId,
lastUpdatedTs: ts,
});
});
@@ -39,7 +37,6 @@ export default function configureUser(route) {
const ts = Date.now();
return user.update({
...attrs,
- updaterId: FAKE_API_CALLER_ID,
lastUpdatedTs: ts,
});
});
diff --git a/frontend/src/store/modules/principal.ts b/frontend/src/store/modules/principal.ts
index 6d76738113..05d3e8c422 100644
--- a/frontend/src/store/modules/principal.ts
+++ b/frontend/src/store/modules/principal.ts
@@ -125,6 +125,7 @@ const actions = {
}
) {
const userPatch: UserPatch = {
+ updaterId: principalPatch.updaterId,
name: principalPatch.name,
};
const updatedPrincipal = convert(
diff --git a/frontend/src/types/bytebase.ts b/frontend/src/types/bytebase.ts
index 379a245609..678f25bc71 100644
--- a/frontend/src/types/bytebase.ts
+++ b/frontend/src/types/bytebase.ts
@@ -358,11 +358,13 @@ export type Principal = {
};
export type PrincipalNew = {
+ creatorId: PrincipalId;
name: string;
email: string;
};
export type PrincipalPatch = {
+ updaterId: PrincipalId;
rowStatus?: RowStatus;
name?: string;
};
@@ -375,6 +377,7 @@ export type User = {
};
export type UserPatch = {
+ updaterId: PrincipalId;
name?: string;
};
diff --git a/frontend/src/views/ProfileDashboard.vue b/frontend/src/views/ProfileDashboard.vue
index 8abff28876..dd850cf1b5 100644
--- a/frontend/src/views/ProfileDashboard.vue
+++ b/frontend/src/views/ProfileDashboard.vue
@@ -218,6 +218,7 @@ export default {
const editUser = () => {
const clone = cloneDeep(principal.value);
state.editingPrincipal = {
+ updaterId: currentUser.value.id,
name: clone.name,
};
state.editing = true;