-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: initial implementation of auth editor
- Loading branch information
Showing
12 changed files
with
109 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 0 additions & 31 deletions
31
hac-client/src/pages/collection_viewer/request_editor/auth_editor.rs
This file was deleted.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
hac-client/src/pages/collection_viewer/request_editor/auth_editor/auth_editor.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use crate::pages::collection_viewer::collection_store::CollectionStore; | ||
use crate::pages::{Eventful, Renderable}; | ||
|
||
use std::cell::RefCell; | ||
use std::rc::Rc; | ||
|
||
use crossterm::event::KeyEvent; | ||
use ratatui::{layout::Rect, widgets::Paragraph, Frame}; | ||
|
||
#[derive(Debug)] | ||
pub struct AuthEditor<'ae> { | ||
_colors: &'ae hac_colors::colors::Colors, | ||
collection_store: Rc<RefCell<CollectionStore>>, | ||
} | ||
|
||
impl<'ae> AuthEditor<'ae> { | ||
pub fn new( | ||
colors: &'ae hac_colors::colors::Colors, | ||
collection_store: Rc<RefCell<CollectionStore>>, | ||
) -> Self { | ||
AuthEditor { | ||
_colors: colors, | ||
collection_store, | ||
} | ||
} | ||
} | ||
|
||
impl Renderable for AuthEditor<'_> { | ||
fn draw(&mut self, frame: &mut Frame, size: Rect) -> anyhow::Result<()> { | ||
frame.render_widget(Paragraph::new("hello from auth editor").centered(), size); | ||
let store = self.collection_store.borrow(); | ||
|
||
let Some(request) = store.get_selected_request() else { | ||
return Ok(()); | ||
}; | ||
|
||
let request = request.read().unwrap(); | ||
if request.auth_method.is_none() { | ||
return Ok(()); | ||
} | ||
|
||
Ok(()) | ||
} | ||
} | ||
|
||
impl Eventful for AuthEditor<'_> { | ||
type Result = (); | ||
|
||
fn handle_key_event(&mut self, _key_event: KeyEvent) -> anyhow::Result<Option<Self::Result>> { | ||
Ok(None) | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
hac-client/src/pages/collection_viewer/request_editor/auth_editor/auth_kind_prompt.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use crate::pages::{Eventful, Renderable}; | ||
|
||
use crossterm::event::{KeyCode, KeyEvent}; | ||
use ratatui::layout::Rect; | ||
use ratatui::Frame; | ||
|
||
pub enum AuthKindPromptEvent { | ||
Placeholder, | ||
} | ||
|
||
pub struct AuthKindPrompt {} | ||
|
||
impl Renderable for AuthKindPrompt { | ||
fn draw(&mut self, frame: &mut Frame, _: Rect) -> anyhow::Result<()> { | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl Eventful for AuthKindPrompt { | ||
type Result = AuthKindPromptEvent; | ||
|
||
fn handle_key_event(&mut self, key_event: KeyEvent) -> anyhow::Result<Option<Self::Result>> { | ||
match key_event.code { | ||
KeyCode::Enter => {} | ||
KeyCode::Char('h') => {} | ||
_ => {} | ||
} | ||
|
||
Ok(None) | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
hac-client/src/pages/collection_viewer/request_editor/auth_editor/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#[allow(clippy::module_inception)] | ||
mod auth_editor; | ||
mod auth_kind_prompt; | ||
|
||
pub use auth_editor::AuthEditor; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions
6
hac-client/src/pages/collection_viewer/request_editor/headers_editor/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#[allow(clippy::module_inception)] | ||
mod headers_editor; | ||
mod headers_editor_delete_prompt; | ||
mod headers_editor_edit_form; | ||
|
||
pub use headers_editor::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters