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

Commit 8005720

Browse files
committed
Remove Page::is_active()
The purpose of this method is to prevent reloading of the current page if the same URL is clicked. But this has downsides and, probably, no value: * It is easy to forget to update this method. * Needs access to models' fields which better be private. * An opened URL is still clickable but confusingly has no effect. * There is no way to reinitialize a page other than total reload. Signed-off-by: Igor Pashev <[email protected]>
1 parent 2746825 commit 8005720

File tree

2 files changed

+2
-40
lines changed

2 files changed

+2
-40
lines changed

iml-gui/crate/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg, GMsg>)
345345
};
346346
}
347347
Msg::LoadPage => {
348-
if model.loading.loaded() && !model.page.is_active(&model.route) {
348+
if model.loading.loaded() {
349349
model.page = (&model.records, &model.route).into();
350350
model.breadcrumbs.push((model.route.to_href(), model.page.title()));
351351
orders.send_msg(Msg::UpdatePageTitle);

iml-gui/crate/src/page/mod.rs

+1-39
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ pub mod users;
2828
pub mod volume;
2929
pub mod volumes;
3030

31-
use crate::{
32-
route::{Route, RouteId},
33-
GMsg,
34-
};
31+
use crate::{route::Route, GMsg};
3532
use iml_wire_types::warp_drive::{ArcCache, ArcRecord, RecordId};
3633
use seed::prelude::Orders;
3734
use std::sync::Arc;
@@ -198,41 +195,6 @@ impl<'a> From<(&ArcCache, &Route<'a>)> for Page {
198195
}
199196

200197
impl Page {
201-
/// Is the given `Route` equivalent to the current page?
202-
pub fn is_active<'a>(&self, route: &Route<'a>) -> bool {
203-
match (route, self) {
204-
(Route::About, Self::About)
205-
| (Route::Filesystems, Self::Filesystems(_))
206-
| (Route::Dashboard, Self::Dashboard(dashboard::Model { .. }))
207-
| (Route::Jobstats, Self::Jobstats)
208-
| (Route::Login, Self::Login(_))
209-
| (Route::Mgt, Self::Mgts(_))
210-
| (Route::NotFound, Self::NotFound)
211-
| (Route::OstPools, Self::OstPools)
212-
| (Route::PowerControl, Self::PowerControl)
213-
| (Route::Servers, Self::Servers(_))
214-
| (Route::Targets, Self::Targets)
215-
| (Route::Users, Self::Users)
216-
| (Route::Volumes, Self::Volumes(_)) => true,
217-
(Route::OstPool(route_id), Self::OstPool(ostpool::Model { id }))
218-
| (Route::Volume(route_id), Self::Volume(volume::Model { id })) => route_id == &RouteId::from(id),
219-
(Route::Server(route_id), Self::Server(x)) => route_id == &RouteId::from(x.server.id),
220-
(Route::User(route_id), Self::User(x)) => route_id == &RouteId::from(x.user.id),
221-
(Route::Filesystem(route_id), Self::Filesystem(x)) => route_id == &RouteId::from(x.fs.id),
222-
(Route::Target(route_id), Self::Target(x)) => route_id == &RouteId::from(x.target.id),
223-
(Route::FsDashboard(route_id), Self::FsDashboard(x)) => {
224-
let fs_dashboard::Model { fs_name, .. } = &**x;
225-
&route_id.to_string() == fs_name
226-
}
227-
(Route::ServerDashboard(route_id), Self::ServerDashboard(server_dashboard::Model { host_name })) => {
228-
&route_id.to_string() == host_name
229-
}
230-
(Route::TargetDashboard(route_id), Self::TargetDashboard(target_dashboard::Model { target_name, .. })) => {
231-
&route_id.to_string() == target_name
232-
}
233-
_ => false,
234-
}
235-
}
236198
/// Initialize the page. This gives a chance to initialize data when a page is switched to.
237199
pub fn init(&mut self, cache: &ArcCache, orders: &mut impl Orders<Msg, GMsg>) {
238200
match self {

0 commit comments

Comments
 (0)