Fix accept invitation, fix link send to user. Change state of form, display invitations and users
This commit is contained in:
parent
c4cc1b55d6
commit
a4ab4a7a42
@ -153,7 +153,12 @@ pub enum Msg {
|
|||||||
AuthTokenErased,
|
AuthTokenErased,
|
||||||
SignInRequest,
|
SignInRequest,
|
||||||
BindClientRequest,
|
BindClientRequest,
|
||||||
|
|
||||||
|
// users
|
||||||
InviteRequest,
|
InviteRequest,
|
||||||
|
InviteRevokeRequest(InvitationId),
|
||||||
|
InviteApproveRequest(InvitationId),
|
||||||
|
InvitedUserRemove(EmailString),
|
||||||
|
|
||||||
// sign up
|
// sign up
|
||||||
SignUpRequest,
|
SignUpRequest,
|
||||||
|
@ -17,7 +17,7 @@ use crate::{FieldId, Msg};
|
|||||||
pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
||||||
if let Msg::ChangePage(Page::Users) = msg {
|
if let Msg::ChangePage(Page::Users) = msg {
|
||||||
model.page_content = PageContent::Users(Box::new(UsersPage::default()));
|
model.page_content = PageContent::Users(Box::new(UsersPage::default()));
|
||||||
return;
|
// return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let page = match &mut model.page_content {
|
let page = match &mut model.page_content {
|
||||||
@ -28,7 +28,9 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
|||||||
page.user_role_state.update(&msg, orders);
|
page.user_role_state.update(&msg, orders);
|
||||||
|
|
||||||
match msg {
|
match msg {
|
||||||
Msg::WsMsg(WsMsg::AuthorizeLoaded(Ok(_))) | Msg::ChangePage(Page::Users) => {
|
Msg::WsMsg(WsMsg::AuthorizeLoaded(Ok(_))) | Msg::ChangePage(Page::Users)
|
||||||
|
if model.user.is_some() =>
|
||||||
|
{
|
||||||
send_ws_msg(WsMsg::InvitationListRequest);
|
send_ws_msg(WsMsg::InvitationListRequest);
|
||||||
send_ws_msg(WsMsg::InvitedUsersRequest);
|
send_ws_msg(WsMsg::InvitedUsersRequest);
|
||||||
}
|
}
|
||||||
@ -59,6 +61,30 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
|||||||
email: page.email.clone(),
|
email: page.email.clone(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Msg::WsMsg(WsMsg::InvitationRevokeSuccess(id)) => {
|
||||||
|
let mut old = vec![];
|
||||||
|
std::mem::swap(&mut page.invitations, &mut old);
|
||||||
|
for invitation in old {
|
||||||
|
if invitation.id != id {
|
||||||
|
page.invitations.push(invitation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Msg::InviteRevokeRequest(invitation_id) => {
|
||||||
|
send_ws_msg(WsMsg::InvitationRevokeRequest(invitation_id));
|
||||||
|
}
|
||||||
|
Msg::InvitedUserRemove(email) => {
|
||||||
|
send_ws_msg(WsMsg::InvitedUserRemoveRequest(email));
|
||||||
|
}
|
||||||
|
Msg::WsMsg(WsMsg::InvitedUserRemoveSuccess(email)) => {
|
||||||
|
let mut old = vec![];
|
||||||
|
std::mem::swap(&mut page.invited_users, &mut old);
|
||||||
|
for user in old {
|
||||||
|
if user.email != email {
|
||||||
|
page.invited_users.push(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Msg::WsMsg(WsMsg::InvitationSendSuccess) => {
|
Msg::WsMsg(WsMsg::InvitationSendSuccess) => {
|
||||||
send_ws_msg(WsMsg::InvitationListRequest);
|
send_ws_msg(WsMsg::InvitationListRequest);
|
||||||
page.form_state = InvitationFormState::Succeed;
|
page.form_state = InvitationFormState::Succeed;
|
||||||
@ -163,7 +189,12 @@ pub fn view(model: &Model) -> Node<Msg> {
|
|||||||
.invited_users
|
.invited_users
|
||||||
.iter()
|
.iter()
|
||||||
.map(|user| {
|
.map(|user| {
|
||||||
let remove = StyledButton::build().text("Remove").build().into_node();
|
let email = user.email.clone();
|
||||||
|
let remove = StyledButton::build()
|
||||||
|
.text("Remove")
|
||||||
|
.on_click(mouse_ev(Ev::Click, move |_| Msg::InvitedUserRemove(email)))
|
||||||
|
.build()
|
||||||
|
.into_node();
|
||||||
li![
|
li![
|
||||||
class!["user"],
|
class!["user"],
|
||||||
span![user.name],
|
span![user.name],
|
||||||
@ -184,7 +215,12 @@ pub fn view(model: &Model) -> Node<Msg> {
|
|||||||
.invitations
|
.invitations
|
||||||
.iter()
|
.iter()
|
||||||
.map(|invitation| {
|
.map(|invitation| {
|
||||||
let revoke = StyledButton::build().text("Revoke").build().into_node();
|
let id = invitation.id;
|
||||||
|
let revoke = StyledButton::build()
|
||||||
|
.text("Revoke")
|
||||||
|
.on_click(mouse_ev(Ev::Click, move |_| Msg::InviteRevokeRequest(id)))
|
||||||
|
.build()
|
||||||
|
.into_node();
|
||||||
li![
|
li![
|
||||||
class!["invitation"],
|
class!["invitation"],
|
||||||
span![invitation.name],
|
span![invitation.name],
|
||||||
|
@ -706,6 +706,8 @@ pub enum WsMsg {
|
|||||||
//
|
//
|
||||||
InvitationAcceptRequest(InvitationId),
|
InvitationAcceptRequest(InvitationId),
|
||||||
InvitationAcceptSuccess(InvitationId),
|
InvitationAcceptSuccess(InvitationId),
|
||||||
|
InvitedUserRemoveRequest(EmailString),
|
||||||
|
InvitedUserRemoveSuccess(EmailString),
|
||||||
|
|
||||||
// project page
|
// project page
|
||||||
ProjectRequest,
|
ProjectRequest,
|
||||||
|
Loading…
Reference in New Issue
Block a user