Skip to content

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

Missed the place to use returned principal object directly for projectMember

天舟852058c78dcd
diff --git a/backend/api/projectMember.go b/backend/api/projectMember.go
index e0527ecc9a..2ea0c93107 100644
--- a/backend/api/projectMember.go
+++ b/backend/api/projectMember.go
@@ -24,10 +24,10 @@ type ProjectMember struct {
// Standard fields
CreatorId int
- Creator *Principal `jsonapi:"relation,creator"`
+ Creator *Principal `jsonapi:"attr,creator"`
CreatedTs int64 `jsonapi:"attr,createdTs"`
UpdaterId int
- Updater *Principal `jsonapi:"relation,updater"`
+ Updater *Principal `jsonapi:"attr,updater"`
UpdatedTs int64 `jsonapi:"attr,updatedTs"`
WorkspaceId int
@@ -38,7 +38,7 @@ type ProjectMember struct {
// Domain specific fields
Role string `jsonapi:"attr,role"`
PrincipalId int
- Principal *Principal `jsonapi:"relation,principal"`
+ Principal *Principal `jsonapi:"attr,principal"`
}
type ProjectMemberCreate struct {
diff --git a/frontend/src/store/modules/project.ts b/frontend/src/store/modules/project.ts
index 6a1353c068..3715829315 100644
--- a/frontend/src/store/modules/project.ts
+++ b/frontend/src/store/modules/project.ts
@@ -74,49 +74,9 @@ function convertMember(
includedList: ResourceObject[],
rootGetters: any
): ProjectMember {
- const creatorId = (
- projectMember.relationships!.creator.data as ResourceIdentifier
- ).id;
- let creator: Principal = unknown("PRINCIPAL") as Principal;
- creator.id = creatorId;
-
- const updaterId = (
- projectMember.relationships!.updater.data as ResourceIdentifier
- ).id;
- let updater: Principal = unknown("PRINCIPAL") as Principal;
- updater.id = updaterId;
-
- const principalId = (
- projectMember.relationships!.updater.data as ResourceIdentifier
- ).id;
- let principal: Principal = unknown("PRINCIPAL") as Principal;
- principal.id = principalId;
-
- for (const item of includedList || []) {
- if (
- item.type == "principal" &&
- (projectMember.relationships!.creator.data as ResourceIdentifier).id ==
- item.id
- ) {
- creator = rootGetters["principal/convert"](item);
- }
-
- if (
- item.type == "principal" &&
- (projectMember.relationships!.updater.data as ResourceIdentifier).id ==
- item.id
- ) {
- updater = rootGetters["principal/convert"](item);
- }
-
- if (
- item.type == "principal" &&
- (projectMember.relationships!.principal.data as ResourceIdentifier).id ==
- item.id
- ) {
- principal = rootGetters["principal/convert"](item);
- }
- }
+ const creator = projectMember.attributes.creator as Principal;
+ const updater = projectMember.attributes.updater as Principal;
+ const principal = projectMember.attributes.principal as Principal;
const attrs = projectMember.attributes as Omit<
ProjectMember,