@@ -7,6 +7,7 @@ import { Headers } from '../../../types';
7
7
8
8
import { getHeaderDocs } from '../../../model/http/http-docs' ;
9
9
import { AccountStore } from '../../../model/account/account-store' ;
10
+ import { UiStore } from '../../../model/ui/ui-store' ;
10
11
11
12
import { CollapsibleSection } from '../../common/collapsible-section' ;
12
13
import { DocsLink } from '../../common/docs-link' ;
@@ -18,6 +19,21 @@ import {
18
19
19
20
import { CookieHeaderDescription } from './set-cookie-header-description' ;
20
21
import { 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
+ }
21
37
22
38
const HeadersGrid = styled . section `
23
39
display: grid;
@@ -74,13 +90,44 @@ const getHeaderDescription = (
74
90
{ headerDocs }
75
91
</ p >
76
92
} ;
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 : {
79
120
headers : Headers ,
80
121
requestUrl : URL ,
81
- accountStore ?: AccountStore
122
+ accountStore ?: AccountStore ,
123
+ uiStore ?: UiStore ,
124
+ HeadersIncludeExcludeList : IncludeExcludeList < string > ,
82
125
} ) => {
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 ;
84
131
85
132
return headerNames . length === 0 ?
86
133
< BlankContentPlaceholder > (None)</ BlankContentPlaceholder >
@@ -111,8 +158,8 @@ export const HeaderDetails = inject('accountStore')(observer((props: {
111
158
)
112
159
113
160
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 >
116
163
< span > { value } </ span >
117
164
</ HeaderKeyValue >
118
165
@@ -124,5 +171,13 @@ export const HeaderDetails = inject('accountStore')(observer((props: {
124
171
</ HeaderDescriptionContainer > }
125
172
</ CollapsibleSection >
126
173
} ) }
174
+ {
175
+ hiddenCount > 0 ?
176
+ < CollapsibleSection withinGrid = { true } > < HeaderKeyValue >
177
+ < HeaderName > Plus { hiddenCount } hidden...</ HeaderName >
178
+
179
+ </ HeaderKeyValue > </ CollapsibleSection >
180
+ : < BlankContentPlaceholder />
181
+ }
127
182
</ HeadersGrid > ;
128
183
} ) ) ;
0 commit comments