Skip to content
This repository has been archived by the owner on Jul 25, 2022. It is now read-only.

Commit

Permalink
Bump seed to 0.4.0 (#1126)
Browse files Browse the repository at this point in the history
Update Seed to support 0.4.0.

There are many breaking changes.

Signed-off-by: Joe Grund <jgrund@whamcloud.io>
  • Loading branch information
jgrund authored Aug 8, 2019
1 parent 640cf4f commit 465e8fb
Show file tree
Hide file tree
Showing 45 changed files with 567 additions and 545 deletions.
215 changes: 111 additions & 104 deletions iml-wasm-components/Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion iml-wasm-components/bootstrap-components/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["IML Team <iml@whamcloud.com>"]
edition = "2018"

[dependencies]
seed = "=0.3.7"
seed = "=0.4.0"

[lib]
path = "bootstrap.rs"
45 changes: 23 additions & 22 deletions iml-wasm-components/bootstrap-components/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ pub mod bs_button {
attrs
}

pub fn btn<T>(more_attrs: Attrs, children: Vec<El<T>>) -> El<T> {
pub fn btn<T>(more_attrs: Attrs, children: Vec<Node<T>>) -> Node<T> {
button![btn_cfg(more_attrs), children]
}

pub fn btn_group<T>(more_attrs: Attrs, children: Vec<El<T>>) -> El<T> {
pub fn btn_group<T>(more_attrs: Attrs, children: Vec<Node<T>>) -> Node<T> {
let mut attrs = class!["btn-group"];
attrs.merge(more_attrs);

Expand All @@ -67,36 +67,37 @@ pub mod bs_button {
pub mod bs_dropdown {
use super::bs_button;
use seed::{class, div, dom_types::Attrs, i, li, prelude::*, style, ul};
use std::borrow::Cow;

pub const DROPDOWN_MENU_RIGHT: &str = "dropdown_menu_right";
pub const DROPDOWN_TOGGLE: &str = "dropdown-toggle";

pub fn header<T>(label: &str) -> El<T> {
pub fn header<T>(label: &str) -> Node<T> {
li![
class!["dropdown-header"],
style! {"user-select" => "none"},
label
]
}

pub fn btn<T>(btn_name: &str) -> El<T> {
pub fn btn<T>(btn_name: impl Into<Cow<'static, str>>) -> Node<T> {
bs_button::btn(
class![DROPDOWN_TOGGLE],
vec![
El::new_text(btn_name),
Node::new_text(btn_name),
i![class!["fa", "fa-fw", "fa-caret-down", "icon-caret-down"]],
],
)
}

pub fn wrapper<T>(attrs: Attrs, open: bool, children: Vec<El<T>>) -> El<T> {
pub fn wrapper<T>(attrs: Attrs, open: bool, children: Vec<Node<T>>) -> Node<T> {
let mut open = if open { class!["open"] } else { Attrs::empty() };
open.merge(attrs);

div![open, children]
}

pub fn menu<T>(children: Vec<El<T>>) -> El<T> {
pub fn menu<T>(children: Vec<Node<T>>) -> Node<T> {
ul![class!["dropdown-menu"], children]
}
}
Expand All @@ -106,7 +107,7 @@ pub mod popover {
use super::Placement;
use seed::{class, div, h3, prelude::*};

pub fn wrapper<T>(open: bool, placement: &Placement, children: Vec<El<T>>) -> El<T> {
pub fn wrapper<T>(open: bool, placement: &Placement, children: Vec<Node<T>>) -> Node<T> {
if !open {
return seed::empty();
}
Expand All @@ -118,11 +119,11 @@ pub mod popover {
]
}

pub fn title<T>(el: El<T>) -> El<T> {
pub fn title<T>(el: Node<T>) -> Node<T> {
h3![class!["popover-title"], el]
}

pub fn content<T>(el: El<T>) -> El<T> {
pub fn content<T>(el: Node<T>) -> Node<T> {
div![class!["popover-content"], el]
}
}
Expand All @@ -133,50 +134,50 @@ pub mod bs_table {
pub const TABLE_STRIPED: &str = "table-striped";
pub const TABLE_HOVER: &str = "table-hover";

pub fn table<T>(more_attrs: Attrs, children: Vec<El<T>>) -> El<T> {
pub fn table<T>(more_attrs: Attrs, children: Vec<Node<T>>) -> Node<T> {
let mut attrs = class!["table"];
attrs.merge(more_attrs);

table![attrs, children]
}

pub fn table_responsive<T>(el: El<T>) -> El<T> {
pub fn table_responsive<T>(el: Node<T>) -> Node<T> {
div![class!["table-responsive"], el]
}
}

pub mod bs_well {
use seed::{class, div, prelude::*};

pub fn well<T>(children: Vec<El<T>>) -> El<T> {
pub fn well<T>(children: Vec<Node<T>>) -> Node<T> {
div![class!["well"], children]
}
}

pub mod bs_panel {
use seed::{class, div, prelude::*};

pub fn panel<T>(els: Vec<El<T>>) -> El<T> {
pub fn panel<T>(els: Vec<Node<T>>) -> Node<T> {
div![class!["panel", "panel-default"], els]
}

pub fn panel_heading<T>(el: El<T>) -> El<T> {
pub fn panel_heading<T>(el: Node<T>) -> Node<T> {
div![class!["panel-heading"], el]
}

pub fn panel_body<T>(el: El<T>) -> El<T> {
pub fn panel_body<T>(el: Node<T>) -> Node<T> {
div![class!["panel-body"], el]
}

pub fn panel_footer<T>(els: Vec<El<T>>) -> El<T> {
pub fn panel_footer<T>(els: Vec<Node<T>>) -> Node<T> {
div![class!["panel-footer"], els]
}
}

pub mod bs_modal {
use seed::{class, div, prelude::*, style};

pub fn modal<T>(children: Vec<El<T>>) -> El<T> {
pub fn modal<T>(children: Vec<Node<T>>) -> Node<T> {
div![
style! { "display" => "block", "z-index" => "9999" },
class!["modal", "fade", "in"],
Expand All @@ -187,19 +188,19 @@ pub mod bs_modal {
]
}

pub fn header<T>(children: Vec<El<T>>) -> El<T> {
pub fn header<T>(children: Vec<Node<T>>) -> Node<T> {
div![class!["modal-header"], children]
}

pub fn body<T>(children: Vec<El<T>>) -> El<T> {
pub fn body<T>(children: Vec<Node<T>>) -> Node<T> {
div![class!["modal-body"], children]
}

pub fn footer<T>(children: Vec<El<T>>) -> El<T> {
pub fn footer<T>(children: Vec<Node<T>>) -> Node<T> {
div![class!["modal-footer"], children]
}

pub fn backdrop<T>() -> El<T> {
pub fn backdrop<T>() -> Node<T> {
div![
style! { "z-index" => "9998" },
class!["modal-backdrop", "fade", "in"]
Expand Down
2 changes: 1 addition & 1 deletion iml-wasm-components/iml-action-dropdown/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["IML Team <iml@whamcloud.com>"]
edition = "2018"

[dependencies]
seed = "=0.3.7"
seed = "=0.4.0"
serde = { version = "1", features = ['derive'] }
serde_json = "1.0"
futures = "0.1"
Expand Down
16 changes: 9 additions & 7 deletions iml-wasm-components/iml-action-dropdown/src/action_dropdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use seed::{
style, ul,
};

pub fn dropdown_header<T>(label: &str) -> El<T> {
pub fn dropdown_header<T>(label: &str) -> Node<T> {
li![
class!["dropdown-header"],
style! {"user-select" => "none"},
Expand All @@ -19,20 +19,22 @@ pub fn dropdown_header<T>(label: &str) -> El<T> {
}

pub fn dropdown<T>(
btn_classes: &[&str],
btn_classes: &[&'static str],
btn_name: &str,
open: bool,
children: Vec<El<T>>,
) -> El<T> {
children: Vec<Node<T>>,
) -> Node<T> {
let open_class = if open { "open" } else { "" };

let btn = button![
let btn: Node<_> = button![
class!["btn", "dropdown-toggle"],
btn_name,
i![class!["fa", "fa-fw", "fa-caret-down", "icon-caret-down"]]
];

let btn = btn_classes.iter().fold(btn, |btn, x| btn.add_class(x));
let btn = btn_classes
.into_iter()
.fold(btn, |btn, &x| btn.add_class(x));

div![
class!["btn-group", "dropdown", open_class],
Expand All @@ -41,7 +43,7 @@ pub fn dropdown<T>(
]
}

pub fn action_dropdown<T>(open: bool, is_locked: bool, children: Vec<El<T>>) -> El<T> {
pub fn action_dropdown<T>(open: bool, is_locked: bool, children: Vec<Node<T>>) -> Node<T> {
let btn_classes = "btn btn-primary btn-sm";

let el = if is_locked {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use crate::{
action_dropdown::{action_dropdown, dropdown_header},
action_dropdown_error::ActionDropdownError,
dispatch_custom_event::dispatch_custom_event,
model::{
self, composite_ids_to_query_string, sort_actions, ActionMap, ActionRecord,
Expand Down Expand Up @@ -52,7 +51,6 @@ pub enum Msg<T: ActionRecord> {
FetchActions,
WatchChange,
ActionsFetched(FetchObject<model::AvailableActions>),
Error(ActionDropdownError),
Destroy,
Noop,
}
Expand All @@ -63,7 +61,7 @@ pub struct IdMsg<T: Clone + ActionRecord>(pub u32, pub Msg<T>);
pub fn update<T: ActionRecord + 'static>(
msg: IdMsg<T>,
model: &mut Model,
orders: &mut Orders<IdMsg<T>>,
orders: &mut impl Orders<IdMsg<T>>,
) {
if model.destroyed {
return;
Expand All @@ -75,10 +73,6 @@ pub fn update<T: ActionRecord + 'static>(
Msg::Noop => {
orders.skip();
}
Msg::Error(e) => {
log::error!("An error has occurred {}", e);
orders.skip();
}
Msg::WatchChange => model.watching.update(),
Msg::FetchActions => {
model.cancel = None;
Expand All @@ -99,7 +93,8 @@ pub fn update<T: ActionRecord + 'static>(
model.actions = objects;
}
Err(fail_reason) => {
orders.send_msg(IdMsg(id, Msg::Error(fail_reason.into())));
log::error!("An error has occurred {:?}", fail_reason);
orders.skip();
}
}

Expand Down Expand Up @@ -179,7 +174,7 @@ pub fn get_record_els<'a, T: ActionRecord + 'static>(
actions: ActionMap<'a, T>,
flag: &Option<String>,
tooltip_config: &iml_tooltip::Model,
) -> Vec<El<IdMsg<T>>> {
) -> Vec<Node<IdMsg<T>>> {
actions
.into_iter()
.filter(|(_, xs)| !xs.is_empty())
Expand Down Expand Up @@ -213,7 +208,7 @@ pub fn render<'a, T: 'static + ActionRecord>(
id: u32,
model: &Model,
record: &'a T,
) -> El<IdMsg<T>> {
) -> Node<IdMsg<T>> {
let xs = model
.actions
.iter()
Expand All @@ -232,7 +227,7 @@ pub fn render_with_action<'a, T: 'static + ActionRecord>(
id: u32,
model: &Model,
actions: ActionMap<'a, T>,
) -> El<IdMsg<T>> {
) -> Node<IdMsg<T>> {
if model.destroyed {
seed::empty()
} else if model.first_fetch_activated {
Expand All @@ -246,20 +241,12 @@ pub fn render_with_action<'a, T: 'static + ActionRecord>(
]
]
} else if !model.activated {
let mut d = action_dropdown(model.watching.is_open(), model.is_locked, vec![span![]]);

d.listeners
.push(simple_ev(Ev::MouseMove, IdMsg(id, Msg::StartFetch)));

d
action_dropdown(model.watching.is_open(), model.is_locked, vec![span![]])
.add_listener(simple_ev(Ev::MouseMove, IdMsg(id, Msg::StartFetch)))
} else {
let record_els = get_record_els(id, actions, &model.flag, &model.tooltip);

let mut el = action_dropdown(model.watching.is_open(), model.is_locked, record_els);

el.listeners
.push(simple_ev(Ev::Click, IdMsg(id, Msg::WatchChange)));

el
action_dropdown(model.watching.is_open(), model.is_locked, record_els)
.add_listener(simple_ev(Ev::Click, IdMsg(id, Msg::WatchChange)))
}
}
Loading

0 comments on commit 465e8fb

Please sign in to comment.