From 6b3ade7bcc3d366a0119788d3e0bdb21b8c7fac9 Mon Sep 17 00:00:00 2001 From: Brendan O'Connell Date: Fri, 15 Nov 2024 10:59:37 +0100 Subject: [PATCH] Run cargo fmt --all to fix formatting errors --- thoth-api/src/graphql/model.rs | 11 +++++--- thoth-app/src/component/locations_form.rs | 31 ++++++++++++++++++----- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/thoth-api/src/graphql/model.rs b/thoth-api/src/graphql/model.rs index 253b7f1f..194da909 100644 --- a/thoth-api/src/graphql/model.rs +++ b/thoth-api/src/graphql/model.rs @@ -1616,7 +1616,8 @@ impl MutationRoot { ) -> FieldResult { context.token.jwt.as_ref().ok_or(ThothError::Unauthorised)?; // Only superusers can create new locations where Location Platform is Thoth - if !context.account_access.is_superuser && data.location_platform == LocationPlatform::Thoth { + if !context.account_access.is_superuser && data.location_platform == LocationPlatform::Thoth + { return Err(ThothError::ThothLocationError.into()); } context @@ -1976,7 +1977,9 @@ impl MutationRoot { context.token.jwt.as_ref().ok_or(ThothError::Unauthorised)?; let location = Location::from_id(&context.db, &data.location_id).unwrap(); // Only superusers can edit locations where Location Platform is Thoth - if !context.account_access.is_superuser && location.location_platform == LocationPlatform::Thoth { + if !context.account_access.is_superuser + && location.location_platform == LocationPlatform::Thoth + { return Err(ThothError::ThothLocationError.into()); } context @@ -2303,7 +2306,9 @@ impl MutationRoot { context.token.jwt.as_ref().ok_or(ThothError::Unauthorised)?; let location = Location::from_id(&context.db, &location_id).unwrap(); // Only superusers can delete locations where Location Platform is Thoth - if !context.account_access.is_superuser && location.location_platform == LocationPlatform::Thoth { + if !context.account_access.is_superuser + && location.location_platform == LocationPlatform::Thoth + { return Err(ThothError::ThothLocationError.into()); } context diff --git a/thoth-app/src/component/locations_form.rs b/thoth-app/src/component/locations_form.rs index 0e18c619..a231861e 100644 --- a/thoth-app/src/component/locations_form.rs +++ b/thoth-app/src/component/locations_form.rs @@ -149,18 +149,30 @@ impl Component for LocationsFormComponent { FetchState::Fetching(_) => vec![], FetchState::Fetched(body) => { // remove Thoth from LocationPlatform enum for non-superusers - if ctx.props().current_user.resource_access.restricted_to().is_some() { - body.data.location_platforms.enum_values + if ctx + .props() + .current_user + .resource_access + .restricted_to() + .is_some() + { + body.data + .location_platforms + .enum_values .clone() .into_iter() - .filter(|platform| *platform != LocationPlatformValues { name: LocationPlatform::Thoth }) + .filter(|platform| { + *platform + != LocationPlatformValues { + name: LocationPlatform::Thoth, + } + }) .collect() } else { body.data.location_platforms.enum_values.clone() } } FetchState::Failed(_, _err) => vec![], - }; true } @@ -478,7 +490,7 @@ impl LocationsFormComponent { ); let mut edit_callback = Some( ctx.link() - .callback(move |_| Msg::ToggleModalFormDisplay(true, Some(location.clone()))) + .callback(move |_| Msg::ToggleModalFormDisplay(true, Some(location.clone()))), ); let mut delete_deactivated = false; let mut edit_deactivated = false; @@ -488,7 +500,14 @@ impl LocationsFormComponent { delete_callback = None; delete_deactivated = true; // Restrict deleting locations with Thoth as location platform to superusers - } else if ctx.props().current_user.resource_access.restricted_to().is_some() && l.location_platform == LocationPlatform::Thoth { + } else if ctx + .props() + .current_user + .resource_access + .restricted_to() + .is_some() + && l.location_platform == LocationPlatform::Thoth + { delete_callback = None; delete_deactivated = true; edit_callback = None;