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

Remove Page::is_active() #1716

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion iml-gui/crate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg, GMsg>)
};
}
Msg::LoadPage => {
if model.loading.loaded() && !model.page.is_active(&model.route) {
if model.loading.loaded() {
model.page = (&model.records, &model.conf, &model.route).into();
orders.send_msg(Msg::UpdatePageTitle);
model.page.init(&model.records, &mut orders.proxy(Msg::Page));
Expand Down
41 changes: 1 addition & 40 deletions iml-gui/crate/src/page/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ pub mod users;
pub mod volume;
pub mod volumes;

use crate::{
components::sfa_overview,
route::{Route, RouteId},
GMsg,
};
use crate::{components::sfa_overview, route::Route, GMsg};
use iml_wire_types::{
warp_drive::{ArcCache, ArcRecord, RecordId},
Conf,
Expand Down Expand Up @@ -230,41 +226,6 @@ impl<'a> From<(&ArcCache, &Conf, &Route<'a>)> for Page {
}

impl Page {
/// Is the given `Route` equivalent to the current page?
pub fn is_active<'a>(&self, route: &Route<'a>) -> bool {
match (route, self) {
(Route::About, Self::About)
| (Route::Filesystems, Self::Filesystems(_))
| (Route::Dashboard, Self::Dashboard(dashboard::Model { .. }))
| (Route::Jobstats, Self::Jobstats)
| (Route::Login, Self::Login(_))
| (Route::Mgt, Self::Mgts(_))
| (Route::NotFound, Self::NotFound)
| (Route::OstPools, Self::OstPools)
| (Route::PowerControl, Self::PowerControl)
| (Route::Servers, Self::Servers(_))
| (Route::Targets, Self::Targets)
| (Route::Users, Self::Users)
| (Route::Volumes, Self::Volumes(_)) => true,
(Route::OstPool(route_id), Self::OstPool(ostpool::Model { id }))
| (Route::Volume(route_id), Self::Volume(volume::Model { id })) => route_id == &RouteId::from(id),
(Route::Server(route_id), Self::Server(x)) => route_id == &RouteId::from(x.server.id),
(Route::User(route_id), Self::User(x)) => route_id == &RouteId::from(x.user.id),
(Route::Filesystem(route_id), Self::Filesystem(x)) => route_id == &RouteId::from(x.fs.id),
(Route::Target(route_id), Self::Target(x)) => route_id == &RouteId::from(x.target.id),
(Route::FsDashboard(route_id), Self::FsDashboard(x)) => {
let fs_dashboard::Model { fs_name, .. } = &**x;
&route_id.to_string() == fs_name
}
(Route::ServerDashboard(route_id), Self::ServerDashboard(server_dashboard::Model { host_name })) => {
&route_id.to_string() == host_name
}
(Route::TargetDashboard(route_id), Self::TargetDashboard(target_dashboard::Model { target_name, .. })) => {
&route_id.to_string() == target_name
}
_ => false,
}
}
/// Initialize the page. This gives a chance to initialize data when a page is switched to.
pub fn init(&mut self, cache: &ArcCache, orders: &mut impl Orders<Msg, GMsg>) {
match self {
Expand Down