Skip to content

Commit

Permalink
feat: rendering request headers onscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
wllfaria committed Jun 5, 2024
1 parent 552f062 commit dbfa1a3
Show file tree
Hide file tree
Showing 88 changed files with 265 additions and 54 deletions.
Empty file modified .github/ISSUE_TEMPLATE/bug_report.md
100644 → 100755
Empty file.
Empty file modified .github/ISSUE_TEMPLATE/feature_request.md
100644 → 100755
Empty file.
Empty file modified .github/PULL_REQUEST_TEMPLATE.md
100644 → 100755
Empty file.
Empty file modified .github/workflows/audit.yml
100644 → 100755
Empty file.
Empty file modified .github/workflows/general.yml
100644 → 100755
Empty file.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified CHANGELOG.md
100644 → 100755
Empty file.
Empty file modified CONTRIBUTING.md
100644 → 100755
Empty file.
Empty file modified Cargo.lock
100644 → 100755
Empty file.
Empty file modified Cargo.toml
100644 → 100755
Empty file.
Empty file modified Justfile
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified TODO.md
100644 → 100755
Empty file.
Empty file modified cliff.toml
100644 → 100755
Empty file.
Binary file added extra/error-request.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extra/new-request.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified extra/preview.gif
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions extra/tapes/create_request.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Output extra/new-request.gif
Hide
Set Shell zsh

Set Theme { "name": "Kanagawa", "cursor": "#DCD7BA", "selection": "#2A2A37", "background": "#181616", "foreground": "#DCD7BA", "black": "#1F1F28", "blue": "#658594", "cyan": "#9CABCA", "green": "#76946A", "magenta": "#957FB8", "red": "#E82424", "white": "#DCD7BA", "yellow": "#FF9E3B", "brightBlack": "#2A2A37", "brightBlue": "#7FB4CA", "brightCyan": "#A3D4D5", "brightGreen": "#98BB6C", "brightMagenta": "#D27E99", "brightRed": "#FF5D62", "brightWhite": "#DCD7BA", "brightYellow": "#E6C384" }

Set FontSize 12
Set Width 1200
Set Height 600

Set Padding 0
Set FontFamily "JetBrains Mono"

Set WindowBar Colorful
Set WindowBarSize 50

# Set Theme "Rose Pine"
Type "cargo run -q -- --dry-run"
Enter
# enter the editor
Sleep 3s
Enter
Sleep 3s
Show
Sleep 2s
# select sidebar
Enter
Sleep 200ms
# enter form
Type "n"
Sleep 1s
Type@100ms "My awesome request"
Sleep 1s
Tab
Sleep 100ms
Tab
Sleep 100ms
Tab
Sleep 100ms
Enter
Sleep 1s
Tab
Sleep 100ms
Tab
Sleep 100ms
Enter
Sleep 3s
97 changes: 97 additions & 0 deletions extra/tapes/error_request.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
Output extra/error-request.gif
Hide
Set Shell zsh

Set Theme { "name": "Kanagawa", "cursor": "#DCD7BA", "selection": "#2A2A37", "background": "#181616", "foreground": "#DCD7BA", "black": "#1F1F28", "blue": "#658594", "cyan": "#9CABCA", "green": "#76946A", "magenta": "#957FB8", "red": "#E82424", "white": "#DCD7BA", "yellow": "#FF9E3B", "brightBlack": "#2A2A37", "brightBlue": "#7FB4CA", "brightCyan": "#A3D4D5", "brightGreen": "#98BB6C", "brightMagenta": "#D27E99", "brightRed": "#FF5D62", "brightWhite": "#DCD7BA", "brightYellow": "#E6C384" }

Set FontSize 12
Set Width 1200
Set Height 600

Set Padding 0
Set FontFamily "JetBrains Mono"

Set WindowBar Colorful
Set WindowBarSize 50

Type "cargo run -q -- --dry-run"
Enter
# enter the editor
Sleep 3s
Enter
Sleep 3s
Show
Sleep 2s
# go to editor tab
Tab
Sleep 200ms
Tab
Sleep 1s
# Enter the editor
Enter
# Edit the message to true
Type@100ms "jj$i"
Sleep 300ms
Backspace
Sleep 100ms
Backspace
Sleep 100ms
Backspace
Sleep 100ms
Backspace
Sleep 100ms
Backspace
Sleep 100ms
Type@100ms "true"
Escape
Sleep 100ms
Escape
# go to the headers
Sleep 1s
Tab
Sleep 200ms
# go to request uri
Tab
Sleep 200ms
Tab
Sleep 1s
# focus and send a request
Enter
Sleep 0.5s
Sleep 100ms
Backspace
Sleep 100ms
Backspace
Sleep 100ms
Backspace
Sleep 100ms
Backspace
Sleep 100ms
Backspace
Sleep 100ms
Backspace
Sleep 100ms
Backspace
Sleep 100ms
Backspace
Sleep 100ms
Backspace
Sleep 100ms
Backspace
Sleep 100ms
Backspace
Sleep 1s
Enter
Sleep 0.5s
Escape
# go to the response
Tab
Sleep 200ms
Tab
Sleep 200ms
Enter
Sleep 1s
Tab
Sleep 1s
Tab
Sleep 3s
74 changes: 40 additions & 34 deletions extra/tapes/preview.tape
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,57 +14,63 @@ Hide
Set WindowBar Colorful
Set WindowBarSize 50

Type "cargo run -q"
Type "cargo run -q -- --dry-run"
Enter
# enter the editor
Sleep 3s
Enter
Sleep 1s
Tab
Tab
Tab
Sleep 3s
Show
Sleep 1s
Enter
Sleep 500ms
Type@200ms "jj"
Enter
Sleep 3s
Sleep 2s
# go to editor tab
Tab
Sleep 1s
Enter
Tab
Sleep 0.5s
Sleep 200ms
Tab
Sleep 0.5s
Enter
Sleep 1s
Type@100ms "jjjjjjjjjj"
# Enter the editor
Enter
# Edit the message to true
Type@100ms "jj$i"
Sleep 300ms
Backspace
Sleep 100ms
Backspace
Sleep 100ms
Backspace
Sleep 100ms
Backspace
Sleep 100ms
Backspace
Sleep 100ms
Type@100ms "true"
Escape
Sleep 100ms
Escape
# go to the headers
Sleep 1s
Tab
Sleep 1s
Sleep 200ms
# go to request uri
Tab
Sleep 200ms
Tab
Sleep 1s
Type@100ms "jjjjjjjjjj"
Sleep 1s
Escape
# focus and send a request
Enter
Sleep 0.5s
Type@100ms "-headers"
Sleep 1s
Tab
Enter
Sleep 0.5s
Escape
# go to the response
Tab
Sleep 0.5s
Sleep 200ms
Tab
Sleep 0.5s
Sleep 200ms
Enter
Type@100ms "jjjj"
Sleep 1s
Type@100ms "wwwww"
Sleep 1s
Type "D"
Sleep 1s
Type "i"
Tab
Sleep 1s
Type@100ms 'hac@is_awesome.com",'
Sleep 0.2s
Escape
Tab
Sleep 3s
Empty file modified flake.lock
100644 → 100755
Empty file.
Empty file modified flake.nix
100644 → 100755
Empty file.
Empty file modified hac-cli/Cargo.toml
100644 → 100755
Empty file.
Empty file modified hac-cli/src/lib.rs
100644 → 100755
Empty file.
Empty file modified hac-client/Cargo.toml
100644 → 100755
Empty file.
Empty file modified hac-client/benches/collection_viewer_bench.rs
100644 → 100755
Empty file.
Empty file modified hac-client/src/app.rs
100644 → 100755
Empty file.
Empty file modified hac-client/src/ascii.rs
100644 → 100755
Empty file.
Empty file modified hac-client/src/event_pool.rs
100644 → 100755
Empty file.
Empty file modified hac-client/src/lib.rs
100644 → 100755
Empty file.
Empty file modified hac-client/src/main.rs
100644 → 100755
Empty file.
Empty file modified hac-client/src/pages.rs
100644 → 100755
Empty file.
Empty file.
Empty file modified hac-client/src/pages/collection_dashboard/collection_list.rs
100644 → 100755
Empty file.
Empty file modified hac-client/src/pages/collection_dashboard/mod.rs
100644 → 100755
Empty file.
Empty file.
7 changes: 6 additions & 1 deletion hac-client/src/pages/collection_viewer/collection_store.rs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl CollectionStore {
let selected_request = collection.requests.as_ref().and_then(|requests| {
requests.read().unwrap().first().and_then(|req| {
if let RequestKind::Single(req) = req {
Some(Arc::clone(req))
Some(req.clone())
} else {
None
}
Expand Down Expand Up @@ -323,6 +323,7 @@ mod tests {
id: "root".to_string(),
method: RequestMethod::Get,
name: "Root1".to_string(),
headers: None,
uri: "/root1".to_string(),
body_type: None,
body: None,
Expand All @@ -335,6 +336,7 @@ mod tests {
method: RequestMethod::Post,
name: "Child1".to_string(),
uri: "/nested1/child1".to_string(),
headers: None,
body_type: None,
body: None,
})))
Expand All @@ -345,6 +347,7 @@ mod tests {
id: "child_two".to_string(),
method: RequestMethod::Put,
name: "Child2".to_string(),
headers: None,
uri: "/nested1/child2".to_string(),
body_type: None,
body: None,
Expand All @@ -356,6 +359,7 @@ mod tests {
id: "not_used".to_string(),
method: RequestMethod::Put,
name: "NotUsed".to_string(),
headers: None,
uri: "/not/used".to_string(),
body_type: None,
body: None,
Expand All @@ -378,6 +382,7 @@ mod tests {
RequestKind::Single(Arc::new(RwLock::new(Request {
id: "root_two".to_string(),
method: RequestMethod::Delete,
headers: None,
name: "Root2".to_string(),
uri: "/root2".to_string(),
body_type: None,
Expand Down
6 changes: 2 additions & 4 deletions hac-client/src/pages/collection_viewer/collection_viewer.rs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -551,19 +551,17 @@ impl<'cv> CollectionViewer<'cv> {

let mut store_mut = self.collection_store.borrow_mut();
if let RequestKind::Single(ref req) = new_request {
self.collection_store
.borrow_mut()
.dispatch(CollectionStoreAction::SetSelectedRequest(Some(req.clone())));
store_mut.dispatch(CollectionStoreAction::SetSelectedRequest(Some(req.clone())));
store_mut.dispatch(CollectionStoreAction::SetHoveredRequest(Some(
new_request.get_id(),
)));
self.sidebar.rebuild_tree_view();
}

store_mut.dispatch(CollectionStoreAction::InsertRequest(new_request));
// dropping the borrow so we can sync the changes
drop(store_mut);

self.sidebar.rebuild_tree_view();
self.create_req_form_state = CreateReqFormState::default();
self.curr_overlay = Overlays::None;

Expand Down
Empty file modified hac-client/src/pages/collection_viewer/mod.rs
100644 → 100755
Empty file.
Empty file modified hac-client/src/pages/collection_viewer/request_editor.rs
100644 → 100755
Empty file.
Empty file.
Empty file.
Loading

0 comments on commit dbfa1a3

Please sign in to comment.