@@ -7,6 +7,7 @@ import { Headers } from '../../../types';
77
88import { getHeaderDocs } from '../../../model/http/http-docs' ;
99import { AccountStore } from '../../../model/account/account-store' ;
10+ import { UiStore } from '../../../model/ui/ui-store' ;
1011
1112import { CollapsibleSection } from '../../common/collapsible-section' ;
1213import { DocsLink } from '../../common/docs-link' ;
@@ -18,6 +19,21 @@ import {
1819
1920import { CookieHeaderDescription } from './set-cookie-header-description' ;
2021import { UserAgentHeaderDescription } from './user-agent-header-description' ;
22+ import { IEList , IncludeExcludeList } from '../../../model/IncludeExcludeList' ;
23+ import { ArrowIcon , Icon , WarningIcon } from '../../../icons' ;
24+ import { filterProps } from '../../component-utils' ;
25+ import { HeadersContextMenuBuilder } from '../headers-context-menu-builder' ;
26+
27+ //the header itself over the headers section
28+ export interface HeadersHeaderClickedData {
29+ HeadersIncludeExcludeList : IncludeExcludeList < string >
30+ }
31+
32+ export interface HeaderClickedData {
33+ HeadersIncludeExcludeList : IncludeExcludeList < string > ,
34+ header_name : string ;
35+ header_value : string ;
36+ }
2137
2238const HeadersGrid = styled . section `
2339 display: grid;
@@ -74,13 +90,44 @@ const getHeaderDescription = (
7490 { headerDocs }
7591 </ p >
7692} ;
77-
78- export const HeaderDetails = inject ( 'accountStore' ) ( observer ( ( props : {
93+ const RowPin = styled (
94+ filterProps ( Icon , 'pinned' )
95+ ) . attrs ( ( p : { pinned : boolean } ) => ( {
96+ icon : [ 'fas' , 'thumbtack' ] ,
97+ title : p . pinned ? "This header is pinned, it will appear at the top of the list by default" : ''
98+ } ) ) `
99+ font-size: 90%;
100+ background-color: ${ p => p . theme . containerBackground } ;
101+ /* Without this, 0 width pins create a large & invisible but still clickable icon */
102+ overflow: hidden;
103+ transition: width 0.1s, padding 0.1s, margin 0.1s;
104+ ${ ( p : { pinned : boolean } ) =>
105+ p . pinned
106+ ? `
107+ width: auto;
108+ padding: 4px;
109+ height: 40%;
110+ && { margin-right: -3px; }
111+ `
112+ : `
113+ padding: 0px 0;
114+ width: 0 !important;
115+ margin: 0 !important;
116+ `
117+ }
118+ ` ;
119+ export const HeaderDetails = inject ( 'accountStore' , 'uiStore' ) ( observer ( ( props : {
79120 headers : Headers ,
80121 requestUrl : URL ,
81- accountStore ?: AccountStore
122+ accountStore ?: AccountStore ,
123+ uiStore ?: UiStore ,
124+ HeadersIncludeExcludeList : IncludeExcludeList < string > ,
82125} ) => {
83- const headerNames = Object . keys ( props . headers ) . sort ( ) ;
126+ let contextMenuBuilder = new HeadersContextMenuBuilder ( props . accountStore ! , props . uiStore ! ) ;
127+ let all_headers = Object . keys ( props . headers ) ;
128+ const filtered = props . HeadersIncludeExcludeList . FilterArrayAgainstList ( all_headers . sort ( ) , IEList . Favorite , true ) ;
129+ const headerNames = Array . from ( props . HeadersIncludeExcludeList . SortArrayAgainstList ( filtered , IEList . Favorite ) ) ;
130+ let hiddenCount = all_headers . length - headerNames . length ;
84131
85132 return headerNames . length === 0 ?
86133 < BlankContentPlaceholder > (None)</ BlankContentPlaceholder >
@@ -111,8 +158,8 @@ export const HeaderDetails = inject('accountStore')(observer((props: {
111158 )
112159
113160 return < CollapsibleSection withinGrid = { true } key = { key } >
114- < HeaderKeyValue >
115- < HeaderName > { name } : </ HeaderName >
161+ < HeaderKeyValue onContextMenu = { contextMenuBuilder . getContextMenuCallback ( { header_name : name , header_value : value , HeadersIncludeExcludeList : props . HeadersIncludeExcludeList } ) } >
162+ < HeaderName > < RowPin pinned = { props . HeadersIncludeExcludeList . IsKeyOnList ( name , IEList . Favorite ) } /> { name } : </ HeaderName >
116163 < span > { value } </ span >
117164 </ HeaderKeyValue >
118165
@@ -124,5 +171,13 @@ export const HeaderDetails = inject('accountStore')(observer((props: {
124171 </ HeaderDescriptionContainer > }
125172 </ CollapsibleSection >
126173 } ) }
174+ {
175+ hiddenCount > 0 ?
176+ < CollapsibleSection withinGrid = { true } > < HeaderKeyValue >
177+ < HeaderName > Plus { hiddenCount } hidden...</ HeaderName >
178+
179+ </ HeaderKeyValue > </ CollapsibleSection >
180+ : < BlankContentPlaceholder />
181+ }
127182 </ HeadersGrid > ;
128183} ) ) ;
0 commit comments