From 0c77aa3a1427a5bf395aa651d4f54022773c6371 Mon Sep 17 00:00:00 2001 From: Jens Reimann Date: Tue, 11 May 2021 18:13:42 +0200 Subject: [PATCH] Add a way to see the refresh token --- console-frontend/src/page.rs | 12 ++++++ console-frontend/src/pages/mod.rs | 2 + console-frontend/src/pages/token.rs | 60 +++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 console-frontend/src/pages/token.rs diff --git a/console-frontend/src/page.rs b/console-frontend/src/page.rs index 115cfd2c7..9d64091a4 100644 --- a/console-frontend/src/page.rs +++ b/console-frontend/src/page.rs @@ -8,6 +8,7 @@ use crate::{ }; use patternfly_yew::*; use yew::prelude::*; +use yew_router::agent::RouteRequest; use yew_router::prelude::*; #[derive(Switch, Debug, Clone, PartialEq)] @@ -18,6 +19,8 @@ pub enum AppRoute { Examples(Examples), #[to = "/keys"] ApiKeys, + #[to = "/token"] + CurrentToken, // Index must come last #[to = "/"] Index, @@ -38,6 +41,7 @@ pub struct AppPage { pub enum Msg { Logout, About, + CurrentToken, } impl Component for AppPage { @@ -60,6 +64,9 @@ impl Component for AppPage { /> }), }), + Msg::CurrentToken => RouteAgentDispatcher::<()>::new().send(RouteRequest::ChangeRoute( + Route::from(AppRoute::CurrentToken), + )), } true } @@ -148,6 +155,7 @@ impl Component for AppPage { // links items.push({ let mut items = Vec::new(); + items.push(html_nested!{{"Current Token"}}); if let Some(account_url) = account_url { items.push(html_nested! { {"Account"} {Icon::ExternalLinkAlt} @@ -182,6 +190,7 @@ impl Component for AppPage { }]; let backend = self.props.backend.clone(); + let token = self.props.token.clone(); return html! { html!{}, + AppRoute::CurrentToken => html!{}, AppRoute::Examples(example) => html!{ diff --git a/console-frontend/src/pages/mod.rs b/console-frontend/src/pages/mod.rs index 6c7d34fe5..2bdf774c9 100644 --- a/console-frontend/src/pages/mod.rs +++ b/console-frontend/src/pages/mod.rs @@ -1,3 +1,5 @@ mod api_keys; +mod token; pub use api_keys::*; +pub use token::*; diff --git a/console-frontend/src/pages/token.rs b/console-frontend/src/pages/token.rs new file mode 100644 index 000000000..57cf48035 --- /dev/null +++ b/console-frontend/src/pages/token.rs @@ -0,0 +1,60 @@ +use crate::backend::Token; +use patternfly_yew::*; +use yew::prelude::*; + +#[derive(Clone, PartialEq, Eq, Properties)] +pub struct Props { + pub token: Token, +} + +pub struct CurrentToken { + props: Props, +} + +impl Component for CurrentToken { + type Message = (); + type Properties = Props; + + fn create(props: Self::Properties, _link: ComponentLink) -> Self { + Self { props } + } + + fn update(&mut self, _msg: Self::Message) -> ShouldRender { + true + } + + fn change(&mut self, props: Self::Properties) -> ShouldRender { + if self.props != props { + self.props = props; + true + } else { + false + } + } + + fn view(&self) -> Html { + let token = self.props.token.refresh_token.as_deref().unwrap_or(""); + + return html! { + <> + + + {"Current API token"} + + + + + + + + + + }; + } +}