Hide settings for User, fix users align

This commit is contained in:
Adrian Wozniak 2020-05-26 09:57:58 +02:00
parent b5e2562f20
commit c5485705a1
9 changed files with 120 additions and 15 deletions

View File

@ -16,6 +16,10 @@
margin-top: 20px; margin-top: 20px;
} }
#users > .usersSection > .usersList > .user > span {
width: 25%;
}
#users > .invitationsSection > .invitationsList > .invitation.revoked { #users > .invitationsSection > .invitationsList > .invitation.revoked {
color: var(--textLight); color: var(--textLight);
} }

View File

@ -501,7 +501,7 @@ impl Model {
sender_id: 2, sender_id: 2,
summary: "You have been invited".to_string(), summary: "You have been invited".to_string(),
description: "You have been invited to project A".to_string(), description: "You have been invited to project A".to_string(),
message_type: "project-invitation".to_string(), message_type: MessageType::ReceivedInvitation,
hyper_link: "/project/1".to_string(), hyper_link: "/project/1".to_string(),
created_at: chrono::NaiveDateTime::from_timestamp(4567890, 123), created_at: chrono::NaiveDateTime::from_timestamp(4567890, 123),
updated_at: chrono::NaiveDateTime::from_timestamp(1234567, 098), updated_at: chrono::NaiveDateTime::from_timestamp(1234567, 098),

View File

@ -42,13 +42,25 @@ pub fn render(model: &Model) -> Node<Msg> {
], ],
], ],
}; };
let mut links = vec![ let mut links = vec![];
if model.current_user_role() > UserRole::User {
links.push(sidebar_link_item(
model,
"Project settings",
Icon::Settings,
Some(Page::ProjectSettings),
));
}
links.extend(vec![
li![divider()],
sidebar_link_item(model, "Releases", Icon::Shipping, None), sidebar_link_item(model, "Releases", Icon::Shipping, None),
sidebar_link_item(model, "Issue and Filters", Icon::Issues, None), sidebar_link_item(model, "Issue and Filters", Icon::Issues, None),
sidebar_link_item(model, "Pages", Icon::Page, None), sidebar_link_item(model, "Pages", Icon::Page, None),
sidebar_link_item(model, "Reports", Icon::Reports, None), sidebar_link_item(model, "Reports", Icon::Reports, None),
sidebar_link_item(model, "Components", Icon::Component, None), sidebar_link_item(model, "Components", Icon::Component, None),
]; ]);
if model.current_user_role() > UserRole::User { if model.current_user_role() > UserRole::User {
links.push(sidebar_link_item( links.push(sidebar_link_item(
@ -64,13 +76,6 @@ pub fn render(model: &Model) -> Node<Msg> {
ul![ ul![
project_info, project_info,
sidebar_link_item(model, "Kanban Board", Icon::Board, Some(Page::Project)), sidebar_link_item(model, "Kanban Board", Icon::Board, Some(Page::Project)),
sidebar_link_item(
model,
"Project settings",
Icon::Settings,
Some(Page::ProjectSettings)
),
li![divider()],
links, links,
] ]
] ]

View File

@ -126,7 +126,7 @@ fn messages_tooltip_popup(model: &Model) -> Node<Msg> {
} = message; } = message;
div![ div![
class!["message"], class!["message"],
class![message_type.as_str()], attrs![At::Class => format!("{}", message_type)],
div![class!["summary"], summary], div![class!["summary"], summary],
div![class!["description"], description], div![class!["description"], description],
div![class!["hyperlink"], hyper_link], div![class!["hyperlink"], hyper_link],

View File

@ -548,6 +548,46 @@ impl From<Issue> for UpdateIssuePayload {
} }
} }
#[cfg_attr(feature = "backend", derive(FromSqlRow, AsExpression))]
#[cfg_attr(feature = "backend", sql_type = "MessageTypeType")]
#[derive(Clone, Copy, Deserialize, Serialize, Debug, PartialOrd, PartialEq, Hash)]
pub enum MessageType {
ReceivedInvitation,
AssignedToIssue,
Mention,
}
impl Into<u32> for MessageType {
fn into(self) -> u32 {
match self {
MessageType::ReceivedInvitation => 0,
MessageType::AssignedToIssue => 1,
MessageType::Mention => 2,
}
}
}
impl Into<MessageType> for u32 {
fn into(self) -> MessageType {
match self {
0 => MessageType::ReceivedInvitation,
1 => MessageType::AssignedToIssue,
2 => MessageType::Mention,
_ => MessageType::Mention,
}
}
}
impl std::fmt::Display for MessageType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
MessageType::ReceivedInvitation => f.write_str("ReceivedInvitation"),
MessageType::AssignedToIssue => f.write_str("AssignedToIssue"),
MessageType::Mention => f.write_str("Mention"),
}
}
}
#[cfg_attr(feature = "backend", derive(Queryable))] #[cfg_attr(feature = "backend", derive(Queryable))]
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct Message { pub struct Message {
@ -556,7 +596,7 @@ pub struct Message {
pub sender_id: UserId, pub sender_id: UserId,
pub summary: String, pub summary: String,
pub description: String, pub description: String,
pub message_type: String, pub message_type: MessageType,
pub hyper_link: String, pub hyper_link: String,
pub created_at: NaiveDateTime, pub created_at: NaiveDateTime,
pub updated_at: NaiveDateTime, pub updated_at: NaiveDateTime,

View File

@ -2,7 +2,9 @@ use std::io::Write;
use diesel::{deserialize::*, pg::*, serialize::*, *}; use diesel::{deserialize::*, pg::*, serialize::*, *};
use crate::{InvitationState, IssuePriority, IssueType, ProjectCategory, TimeTracking, UserRole}; use crate::{
InvitationState, IssuePriority, IssueType, MessageType, ProjectCategory, TimeTracking, UserRole,
};
#[derive(SqlType)] #[derive(SqlType)]
#[postgres(type_name = "IssuePriorityType")] #[postgres(type_name = "IssuePriorityType")]
@ -239,3 +241,43 @@ impl ToSql<TimeTrackingType, Pg> for TimeTracking {
Ok(IsNull::No) Ok(IsNull::No)
} }
} }
#[derive(SqlType)]
#[postgres(type_name = "MessageTypeType")]
pub struct MessageTypeType;
impl diesel::query_builder::QueryId for MessageTypeType {
type QueryId = MessageType;
}
fn message_type_type_from_sql(bytes: Option<&[u8]>) -> deserialize::Result<MessageType> {
match not_none!(bytes) {
b"received_invitation" => Ok(MessageType::ReceivedInvitation),
b"assigned_to_issue" => Ok(MessageType::AssignedToIssue),
b"mention" => Ok(MessageType::Mention),
_ => Ok(MessageType::Mention),
}
}
impl FromSql<MessageTypeType, Pg> for MessageType {
fn from_sql(bytes: Option<&[u8]>) -> deserialize::Result<MessageType> {
message_type_type_from_sql(bytes)
}
}
impl FromSql<sql_types::Text, Pg> for MessageType {
fn from_sql(bytes: Option<&[u8]>) -> deserialize::Result<MessageType> {
message_type_type_from_sql(bytes)
}
}
impl ToSql<MessageTypeType, Pg> for MessageType {
fn to_sql<W: Write>(&self, out: &mut Output<W, Pg>) -> serialize::Result {
match *self {
MessageType::ReceivedInvitation => out.write_all(b"received_invitation")?,
MessageType::AssignedToIssue => out.write_all(b"assigned_to_issue")?,
MessageType::Mention => out.write_all(b"mention")?,
}
Ok(IsNull::No)
}
}

View File

@ -0,0 +1,4 @@
ALTER TABLE messages
ALTER COLUMN message_type
SET DATA TYPE text;
DROP TYPE "MessageTypeType";

View File

@ -0,0 +1,10 @@
CREATE TYPE "MessageTypeType" AS ENUM (
'received_invitation',
'assigned_to_issue',
'mention'
);
ALTER TABLE messages
ALTER COLUMN message_type
SET DATA TYPE "MessageTypeType"
USING message_type::text::"MessageTypeType";

View File

@ -347,10 +347,10 @@ table! {
description -> Text, description -> Text,
/// The `message_type` column of the `messages` table. /// The `message_type` column of the `messages` table.
/// ///
/// Its SQL type is `Text`. /// Its SQL type is `MessageTypeType`.
/// ///
/// (Automatically generated by Diesel.) /// (Automatically generated by Diesel.)
message_type -> Text, message_type -> MessageTypeType,
/// The `hyper_link` column of the `messages` table. /// The `hyper_link` column of the `messages` table.
/// ///
/// Its SQL type is `Text`. /// Its SQL type is `Text`.