Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/button-to-close-flow-details-view #6734

Merged
merged 13 commits into from
Mar 25, 2024
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
([#6747](https://github.com/mitmproxy/mitmproxy/pull/6747), @jlaine)
* Fix a bug where async `client_connected` handlers would crash mitmproxy.
([#6749](https://github.com/mitmproxy/mitmproxy/pull/6749), @mhils)
* Add button to close flow details panel
([#6734](https://github.com/mitmproxy/mitmproxy/pull/6734), @lups2000)

## 07 March 2024: mitmproxy 10.2.4

Expand Down
13 changes: 13 additions & 0 deletions web/src/css/flowdetail.less
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@
}
}

.close-button {
margin-top: 2px;
padding-left: 10px;
padding-right: 7px;
color: grey;
font-size: 15px;
border: none;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are still some leftovers here. For example, cursor: pointer; is unnecessary for a button.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, just cursor and font-weight, the others are necessary I think

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now?


.close-button:hover {
color: black;
}

.first-line {
font-family: @font-family-monospace;
background-color: #428bca;
Expand Down
16 changes: 16 additions & 0 deletions web/src/js/__tests__/components/FlowViewSpec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import FlowView from "../../components/FlowView";
import * as flowActions from "../../ducks/flows";
import fetchMock, { enableFetchMocks } from "jest-fetch-mock";
import { fireEvent } from "@testing-library/react";
import { TStore } from "../ducks/tutils";
import { Provider } from "react-redux";

enableFetchMocks();

Expand Down Expand Up @@ -58,3 +60,17 @@ test("FlowView", async () => {
fireEvent.click(screen.getByText("Error"));
expect(asFragment()).toMatchSnapshot();
});

test("FlowView close button", async () => {
const store = TStore();

const { getByTestId } = render(
<Provider store={store}>
<FlowView />
</Provider>
);
fireEvent.click(getByTestId("close-button-id"));
expect(store.getActions()).toEqual([
{ flowIds: [], type: flowActions.SELECT },
]);
});
112 changes: 112 additions & 0 deletions web/src/js/__tests__/components/__snapshots__/FlowViewSpec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ exports[`FlowView 1`] = `
<nav
class="nav-tabs nav-tabs-sm"
>
<button
class="close-button"
data-testid="close-button-id"
>
<i
class="fa fa-times-circle"
/>
</button>
<a
class="active"
href="#"
Expand Down Expand Up @@ -192,6 +200,14 @@ exports[`FlowView 2`] = `
<nav
class="nav-tabs nav-tabs-sm"
>
<button
class="close-button"
data-testid="close-button-id"
>
<i
class="fa fa-times-circle"
/>
</button>
<a
class=""
href="#"
Expand Down Expand Up @@ -374,6 +390,14 @@ exports[`FlowView 3`] = `
<nav
class="nav-tabs nav-tabs-sm"
>
<button
class="close-button"
data-testid="close-button-id"
>
<i
class="fa fa-times-circle"
/>
</button>
<a
class=""
href="#"
Expand Down Expand Up @@ -476,6 +500,14 @@ exports[`FlowView 4`] = `
<nav
class="nav-tabs nav-tabs-sm"
>
<button
class="close-button"
data-testid="close-button-id"
>
<i
class="fa fa-times-circle"
/>
</button>
<a
class=""
href="#"
Expand Down Expand Up @@ -763,6 +795,14 @@ exports[`FlowView 5`] = `
<nav
class="nav-tabs nav-tabs-sm"
>
<button
class="close-button"
data-testid="close-button-id"
>
<i
class="fa fa-times-circle"
/>
</button>
<a
class=""
href="#"
Expand Down Expand Up @@ -969,6 +1009,14 @@ exports[`FlowView 6`] = `
<nav
class="nav-tabs nav-tabs-sm"
>
<button
class="close-button"
data-testid="close-button-id"
>
<i
class="fa fa-times-circle"
/>
</button>
<a
class=""
href="#"
Expand Down Expand Up @@ -1038,6 +1086,14 @@ exports[`FlowView 7`] = `
<nav
class="nav-tabs nav-tabs-sm"
>
<button
class="close-button"
data-testid="close-button-id"
>
<i
class="fa fa-times-circle"
/>
</button>
<a
class=""
href="#"
Expand Down Expand Up @@ -1107,6 +1163,14 @@ exports[`FlowView 8`] = `
<nav
class="nav-tabs nav-tabs-sm"
>
<button
class="close-button"
data-testid="close-button-id"
>
<i
class="fa fa-times-circle"
/>
</button>
<a
class="active"
href="#"
Expand Down Expand Up @@ -1183,6 +1247,14 @@ exports[`FlowView 9`] = `
<nav
class="nav-tabs nav-tabs-sm"
>
<button
class="close-button"
data-testid="close-button-id"
>
<i
class="fa fa-times-circle"
/>
</button>
<a
class=""
href="#"
Expand Down Expand Up @@ -1240,6 +1312,14 @@ exports[`FlowView 10`] = `
<nav
class="nav-tabs nav-tabs-sm"
>
<button
class="close-button"
data-testid="close-button-id"
>
<i
class="fa fa-times-circle"
/>
</button>
<a
class="active"
href="#"
Expand Down Expand Up @@ -1346,6 +1426,14 @@ exports[`FlowView 11`] = `
<nav
class="nav-tabs nav-tabs-sm"
>
<button
class="close-button"
data-testid="close-button-id"
>
<i
class="fa fa-times-circle"
/>
</button>
<a
class=""
href="#"
Expand Down Expand Up @@ -1508,6 +1596,14 @@ exports[`FlowView 12`] = `
<nav
class="nav-tabs nav-tabs-sm"
>
<button
class="close-button"
data-testid="close-button-id"
>
<i
class="fa fa-times-circle"
/>
</button>
<a
class=""
href="#"
Expand Down Expand Up @@ -1571,6 +1667,14 @@ exports[`FlowView 13`] = `
<nav
class="nav-tabs nav-tabs-sm"
>
<button
class="close-button"
data-testid="close-button-id"
>
<i
class="fa fa-times-circle"
/>
</button>
<a
class="active"
href="#"
Expand Down Expand Up @@ -1647,6 +1751,14 @@ exports[`FlowView 14`] = `
<nav
class="nav-tabs nav-tabs-sm"
>
<button
class="close-button"
data-testid="close-button-id"
>
<i
class="fa fa-times-circle"
/>
</button>
<a
class=""
href="#"
Expand Down
8 changes: 8 additions & 0 deletions web/src/js/components/FlowView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { Flow } from "../flow";
import classnames from "classnames";
import TcpMessages from "./FlowView/TcpMessages";
import UdpMessages from "./FlowView/UdpMessages";
import * as flowsActions from "../ducks/flows";

type TabProps = {
flow: Flow;
Expand Down Expand Up @@ -85,6 +86,13 @@ export default function FlowView() {
return (
<div className="flow-detail">
<nav className="nav-tabs nav-tabs-sm">
<button
data-testid="close-button-id"
className="close-button"
onClick={() => dispatch(flowsActions.select(undefined))}
>
<i className="fa fa-times-circle"></i>
</button>
{tabs.map((tabId) => (
<a
key={tabId}
Expand Down