From d60f5ab460dd449ccdffddc1a5b8dde8016a4f28 Mon Sep 17 00:00:00 2001 From: Valentin Tolmer Date: Sun, 31 Oct 2021 23:42:19 +0900 Subject: [PATCH] app: Simplify some CommonComponent uses --- app/src/components/add_group_member.rs | 11 +++++------ app/src/components/add_user_to_group.rs | 8 ++++---- app/src/components/delete_group.rs | 10 +++++----- app/src/components/delete_user.rs | 10 +++++----- app/src/components/logout.rs | 2 +- app/src/components/remove_user_from_group.rs | 13 ++++++------- app/src/components/user_details.rs | 8 ++++---- app/src/components/user_details_form.rs | 18 +++++++++--------- 8 files changed, 39 insertions(+), 41 deletions(-) diff --git a/app/src/components/add_group_member.rs b/app/src/components/add_group_member.rs index d963cbc..47dc1e3 100644 --- a/app/src/components/add_group_member.rs +++ b/app/src/components/add_group_member.rs @@ -6,7 +6,6 @@ use anyhow::{Error, Result}; use graphql_client::GraphQLQuery; use std::collections::HashSet; use yew::prelude::*; -use yewtil::NeqAssign; #[derive(GraphQLQuery)] #[graphql( @@ -69,7 +68,7 @@ impl CommonComponent for AddGroupMemberComponent { .expect("Could not get selected user") .clone(); // Remove the user from the dropdown. - self.common.props.on_user_added_to_group.emit(user); + self.common.on_user_added_to_group.emit(user); } Msg::SelectionChanged(option_props) => { let was_some = self.selected_user.is_some(); @@ -105,7 +104,7 @@ impl AddGroupMemberComponent { self.common.call_graphql::( add_user_to_group::Variables { user: user_id, - group: self.common.props.group_id, + group: self.common.group_id, }, Msg::AddMemberResponse, "Error trying to initiate adding the user to a group", @@ -114,7 +113,7 @@ impl AddGroupMemberComponent { } fn get_selectable_user_list(&self, user_list: &[User]) -> Vec { - let user_groups = self.common.props.users.iter().collect::>(); + let user_groups = self.common.users.iter().collect::>(); user_list .iter() .filter(|u| !user_groups.contains(u)) @@ -141,12 +140,12 @@ impl Component for AddGroupMemberComponent { CommonComponentParts::::update_and_report_error( self, msg, - self.common.props.on_error.clone(), + self.common.on_error.clone(), ) } fn change(&mut self, props: Self::Properties) -> ShouldRender { - self.common.props.neq_assign(props) + self.common.change(props) } fn view(&self) -> Html { diff --git a/app/src/components/add_user_to_group.rs b/app/src/components/add_user_to_group.rs index 410a6e7..405481b 100644 --- a/app/src/components/add_user_to_group.rs +++ b/app/src/components/add_user_to_group.rs @@ -82,7 +82,7 @@ impl CommonComponent for AddUserToGroupComponent { .expect("Could not get selected group") .clone(); // Remove the group from the dropdown. - self.common.props.on_user_added_to_group.emit(group); + self.common.on_user_added_to_group.emit(group); } Msg::SelectionChanged(option_props) => { let was_some = self.selected_group.is_some(); @@ -117,7 +117,7 @@ impl AddUserToGroupComponent { }; self.common.call_graphql::( add_user_to_group::Variables { - user: self.common.props.username.clone(), + user: self.common.username.clone(), group: group_id, }, Msg::AddGroupResponse, @@ -127,7 +127,7 @@ impl AddUserToGroupComponent { } fn get_selectable_group_list(&self, group_list: &[Group]) -> Vec { - let user_groups = self.common.props.groups.iter().collect::>(); + let user_groups = self.common.groups.iter().collect::>(); group_list .iter() .filter(|g| !user_groups.contains(g)) @@ -153,7 +153,7 @@ impl Component for AddUserToGroupComponent { CommonComponentParts::::update_and_report_error( self, msg, - self.common.props.on_error.clone(), + self.common.on_error.clone(), ) } diff --git a/app/src/components/delete_group.rs b/app/src/components/delete_group.rs index f6e32f8..22d8551 100644 --- a/app/src/components/delete_group.rs +++ b/app/src/components/delete_group.rs @@ -48,7 +48,7 @@ impl CommonComponent for DeleteGroup { self.update(Msg::DismissModal); self.common.call_graphql::( delete_group_query::Variables { - group_id: self.common.props.group.id, + group_id: self.common.group.id, }, Msg::DeleteGroupResponse, "Error trying to delete group", @@ -63,7 +63,7 @@ impl CommonComponent for DeleteGroup { self.common .props .on_group_deleted - .emit(self.common.props.group.id); + .emit(self.common.group.id); } } Ok(true) @@ -100,7 +100,7 @@ impl Component for DeleteGroup { CommonComponentParts::::update_and_report_error( self, msg, - self.common.props.on_error.clone(), + self.common.on_error.clone(), ) } @@ -128,7 +128,7 @@ impl DeleteGroup { html! {