Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(projects): keep inherited access when an edit does not move a folder (#8583)
Wolf Mermelsteinabd0eed65ddc
diff --git a/crates/projects/src/domain/service.rs b/crates/projects/src/domain/service.rsindex f54a0be481..7401ad18f0 100644--- a/crates/projects/src/domain/service.rs+++ b/crates/projects/src/domain/service.rs@@ -482,6 +482,7 @@ where}}+ let moving = args.project_parent_id.is_some();let project_uuid = parse_internal_uuid(&project.id, "project ID")?;let old_parent_uuid = project.parent_id@@ -504,21 +505,26 @@ where.await?;self.bump_project_modified(&project.id).await;- let _ = self- .entity_access_management_service- .move_project(- &project_uuid,- old_parent_uuid.as_ref(),- new_parent_uuid.as_ref(),- )- .await- .inspect_err(|error| {- tracing::error!(- error = ?error,- project_id = %project.id,- "unable to update entity access for project"- );- });+ // Only a move changes inherited access: an edit that leaves the parent+ // alone (a rename, a share change) must keep what the project and its+ // contents inherit from the folders above.+ if moving {+ let _ = self+ .entity_access_management_service+ .move_project(+ &project_uuid,+ old_parent_uuid.as_ref(),+ new_parent_uuid.as_ref(),+ )+ .await+ .inspect_err(|error| {+ tracing::error!(+ error = ?error,+ project_id = %project.id,+ "unable to update entity access for project"+ );+ });+ }if let Some(parent_id) = project.parent_id.as_deref() {self.bump_project_modified(parent_id).await;}diff --git a/crates/projects/src/domain/service/tests.rs b/crates/projects/src/domain/service/tests.rsindex 585f30be4b..83b285d089 100644--- a/crates/projects/src/domain/service/tests.rs+++ b/crates/projects/src/domain/service/tests.rs@@ -1323,6 +1323,48 @@ async fn owner_edit_propagates_move_and_updates_all_modified_timestamps() {);}+#[tokio::test]+async fn sharing_a_nested_project_keeps_what_it_inherits_from_its_parent() {+ let project_id = Uuid::new_v4();+ let parent_id = Uuid::new_v4();+ let facts = team_share_facts(project_id, owner_user(), Some(TEAM_ID), 0);+ let mut repo = MockProjectRepo::new();+ repo.expect_get_team_share_facts()+ .return_once(move |_| Box::pin(async move { Ok(facts) }));+ repo.expect_edit_project()+ .withf(|args| !args.update_parent && args.team_share.is_some())+ .return_once(move |_| {+ Box::pin(async move {+ Ok(project(+ &project_id.to_string(),+ "macro|[email protected]",+ Some(&parent_id.to_string()),+ ))+ })+ });+ repo.expect_update_project_modified()+ .times(2)+ .returning(|_| Box::pin(async { Ok(()) }));+ let eam = RecordingEam::default();+ let calls = eam.calls.clone();+ let service = mutation_service(repo, eam, RecordingIndexer::default());++ service+ .edit_project(+ mutation_receipt::<EditAccessLevel>(project_id, AccessLevel::Owner),+ basic_project(project_id, Some(parent_id), false),+ team_share_args(Some(AccessLevel::Edit)),+ )+ .await+ .unwrap();++ assert_eq!(+ *calls.lock().unwrap(),+ Vec::new(),+ "no move, so no inherited access is dropped"+ );+}+#[tokio::test]async fn empty_parent_clears_persistence_and_eam_parent_argument() {let project_id = Uuid::new_v4();