Skip to content

Commit

Permalink
add text http status code as tooltip in response
Browse files Browse the repository at this point in the history
  • Loading branch information
Thiht committed Nov 14, 2021
1 parent a0773a8 commit f3283a4
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion client/components/History.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
Typography,
} from "antd";
import dayjs from "dayjs";
import { getReasonPhrase } from "http-status-codes";
import yaml from "js-yaml";
import orderBy from "lodash/orderBy";
import * as React from "react";
Expand Down Expand Up @@ -65,6 +66,16 @@ const EntryComponent = React.memo(
responseStatusColor = "orange";
}
}

let responseStatusTitle = "Unknown HTTP status code";
try {
responseStatusTitle = getReasonPhrase(value.response.status);
} catch {
if (value.response.status >= 600) {
responseStatusTitle = "Smocker error";
}
}

return (
<div className="entry">
<div className="request">
Expand Down Expand Up @@ -104,7 +115,9 @@ const EntryComponent = React.memo(
<div className="response">
<div className="details">
{value.context.mock_type === "proxy" && <Tag>Proxified</Tag>}
<Tag color={responseStatusColor}>{value.response.status}</Tag>
<Tag color={responseStatusColor} title={responseStatusTitle}>
{value.response.status}
</Tag>
{value.response.status > 600 && (
<Typography.Text
className="error"
Expand Down

0 comments on commit f3283a4

Please sign in to comment.