Skip to content

Commit e456f7b

Browse files
committed
Don't mark webhook-matched requests as modified
1 parent 0050d8f commit e456f7b

File tree

5 files changed

+19
-18
lines changed

5 files changed

+19
-18
lines changed

src/components/view/http/http-request-card.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { HtkRequest, HttpVersion, HttpExchangeView } from '../../../types';
55

66
import { getSummaryColor } from '../../../model/events/categorization';
77
import { getMethodDocs } from '../../../model/http/http-docs';
8+
import { areStepsModifying } from '../../../model/rules/rules';
89

910
import {
1011
CollapsibleCardHeading,
@@ -29,7 +30,7 @@ import { HttpVersionPill } from '../../common/http-version-pill';
2930
import { HeaderDetails, HeaderHeadingContainer } from './header-details';
3031
import { UrlBreakdown } from '../url-breakdown';
3132
import { StepClassKey } from '../../../model/rules/rules';
32-
import { MatchedRulePill, shouldShowRuleDetails } from './matched-rule-pill';
33+
import { MatchedRulePill } from './matched-rule-pill';
3334

3435
const RawRequestDetails = (p: {
3536
request: HtkRequest,
@@ -114,7 +115,7 @@ export const HttpRequestCard = observer((props: HttpRequestCardProps) => {
114115

115116
return <CollapsibleCard {...props} direction='right'>
116117
<header>
117-
{ shouldShowRuleDetails(matchedRuleData) &&
118+
{ areStepsModifying(matchedRuleData?.stepTypes) &&
118119
<MatchedRulePill
119120
ruleData={matchedRuleData}
120121
onClick={onRuleClicked}

src/components/view/http/matched-rule-pill.tsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,6 @@ export interface MatchedRuleData {
1717
status: 'unchanged' | 'modified-types' | 'deleted';
1818
}
1919

20-
export const shouldShowRuleDetails = (
21-
matchedRuleData: MatchedRuleData | undefined
22-
): matchedRuleData is MatchedRuleData => {
23-
// We never bother showing rule details for pure-passthrough rules
24-
return !!matchedRuleData?.stepTypes.length &&
25-
!matchedRuleData?.stepTypes.every(
26-
type => type === 'passthrough' || type === 'ws-passthrough'
27-
);
28-
}
29-
3020
export const MatchedRulePill = styled(inject('uiStore')((p: {
3121
className?: string,
3222
uiStore?: UiStore,

src/components/view/http/transform-card.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ import { observer } from 'mobx-react-lite';
55
import { styled } from '../../../styles';
66

77
import { ContentPerspective, UiStore } from '../../../model/ui/ui-store';
8+
import { areStepsModifying } from '../../../model/rules/rules';
89

910
import { Pill, PillSelect } from '../../common/pill';
1011
import { MediumCard } from '../../common/card';
11-
import { MatchedRuleData, MatchedRulePill, shouldShowRuleDetails } from './matched-rule-pill';
12+
import { MatchedRuleData, MatchedRulePill } from './matched-rule-pill';
1213

1314
const DropdownContainer = styled.div`
1415
display: inline-block;
@@ -44,9 +45,9 @@ export const TransformCard = (p: {
4445
onRuleClicked: () => void,
4546
uiStore: UiStore
4647
}) => {
47-
const rulePill = shouldShowRuleDetails(p.matchedRuleData)
48+
const rulePill = areStepsModifying(p.matchedRuleData?.stepTypes)
4849
? <MatchedRulePill
49-
ruleData={p.matchedRuleData!}
50+
ruleData={p.matchedRuleData}
5051
onClick={p.onRuleClicked}
5152
/>
5253
// This can happen if e.g. upstream returns a response but

src/components/view/view-event-list.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
RawTunnel
2020
} from '../../types';
2121
import { UiStore } from '../../model/ui/ui-store';
22+
import { areStepsModifying } from '../../model/rules/rules';
2223

2324
import {
2425
getSummaryColor,
@@ -476,9 +477,7 @@ const ExchangeRow = inject('uiStore')(observer(({
476477
/>
477478
{
478479
exchange.matchedRule &&
479-
exchange.matchedRule.stepTypes.some(t =>
480-
t !== 'passthrough' && t !== 'ws-passthrough' && t !== 'rtc-dynamic-proxy'
481-
) &&
480+
areStepsModifying(exchange.matchedRule.stepTypes) &&
482481
<PhosphorIcon
483482
icon='Pencil'
484483
alt={`Handled by ${

src/model/rules/rules.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,16 @@ export const isPaidStepClass = (
410410
return !NonPaidStepClasses.includes(stepClass);
411411
}
412412

413+
export function areStepsModifying(stepTypes: StepClassKey[] | undefined): stepTypes is StepClassKey[] {
414+
// We don't show rule details or edit markers for no-modification rules
415+
return !!stepTypes?.length &&
416+
!stepTypes?.every(
417+
type => type === 'passthrough' ||
418+
type === 'ws-passthrough' ||
419+
type === 'webhook'
420+
);
421+
}
422+
413423
/// --- Rules ---
414424

415425
export type HtkRule = (

0 commit comments

Comments
 (0)