@@ -18,6 +18,11 @@ import {
18
18
19
19
import { CookieHeaderDescription } from './set-cookie-header-description' ;
20
20
import { UserAgentHeaderDescription } from './user-agent-header-description' ;
21
+ import { IEList , IncludeExcludeList } from '../../../model/IncludeExcludeList' ;
22
+ import { HeadersContextMenuBuilder } from './headers-context-menu-builder' ;
23
+ import { filterProps } from '../../component-utils' ;
24
+ import { ArrowIcon , Icon , WarningIcon } from '../../../icons' ;
25
+ import { UiStore } from '../../../model/ui/ui-store' ;
21
26
22
27
const HeadersGrid = styled . section `
23
28
display: grid;
@@ -77,12 +82,49 @@ const getHeaderDescription = (
77
82
</ p >
78
83
} ;
79
84
80
- export const HeaderDetails = inject ( 'accountStore' ) ( observer ( ( props : {
85
+
86
+ const RowPin = styled (
87
+ filterProps ( Icon , 'pinned' )
88
+ ) . attrs ( ( p : { pinned : boolean } ) => ( {
89
+ icon : [ 'fas' , 'thumbtack' ] ,
90
+ title : p . pinned ? "This header is pinned, it will appear at the top of the list by default" : ''
91
+ } ) ) `
92
+ font-size: 90%;
93
+ background-color: ${ p => p . theme . containerBackground } ;
94
+ /* Without this, 0 width pins create a large & invisible but still clickable icon */
95
+ overflow: hidden;
96
+ transition: width 0.1s, padding 0.1s, margin 0.1s;
97
+ ${ ( p : { pinned : boolean } ) =>
98
+ p . pinned
99
+ ? `
100
+ width: auto;
101
+ padding: 4px;
102
+ height: 40%;
103
+ && { margin-right: -3px; }
104
+ `
105
+ : `
106
+ padding: 0px 0;
107
+ width: 0 !important;
108
+ margin: 0 !important;
109
+ `
110
+ }
111
+ ` ;
112
+
113
+ export const HeaderDetails = inject ( 'accountStore' , 'uiStore' ) ( observer ( ( props : {
81
114
headers : RawHeaders ,
82
115
requestUrl : URL ,
83
- accountStore ?: AccountStore
116
+ HeadersIncludeExcludeList : IncludeExcludeList < string > ,
117
+ accountStore ?: AccountStore ,
118
+ uiStore ?: UiStore
84
119
} ) => {
85
- const sortedHeaders = _ . sortBy ( props . headers , ( [ key ] ) => key . toLowerCase ( ) ) ;
120
+ const contextMenuBuilder = new HeadersContextMenuBuilder (
121
+ props . accountStore ! ,
122
+ props . uiStore !
123
+ ) ;
124
+ const filtered = props . HeadersIncludeExcludeList . FilterArrayAgainstList ( _ . sortBy ( props . headers , ( [ key ] ) => key . toLowerCase ( ) ) , IEList . Favorite , true , ( [ key ] ) => key ) ;
125
+ const sortedHeaders = Array . from ( props . HeadersIncludeExcludeList . SortArrayAgainstList ( filtered , IEList . Favorite , ( [ key ] ) => key ) ) ;
126
+ let hiddenCount = props . headers . length - sortedHeaders . length ;
127
+
86
128
87
129
return sortedHeaders . length === 0 ?
88
130
< BlankContentPlaceholder > (None)</ BlankContentPlaceholder >
@@ -98,8 +140,8 @@ export const HeaderDetails = inject('accountStore')(observer((props: {
98
140
)
99
141
100
142
return < CollapsibleSection withinGrid = { true } key = { `${ key } -${ i } ` } >
101
- < HeaderKeyValue >
102
- < HeaderName > { key } : </ HeaderName >
143
+ < HeaderKeyValue onContextMenu = { contextMenuBuilder . getContextMenuCallback ( { header_name : key , header_value : [ value ] , HeadersIncludeExcludeList : props . HeadersIncludeExcludeList } ) } >
144
+ < HeaderName > < RowPin pinned = { props . HeadersIncludeExcludeList . IsKeyOnList ( key , IEList . Favorite ) } /> { key } : </ HeaderName >
103
145
< span > { value } </ span >
104
146
</ HeaderKeyValue >
105
147
@@ -111,5 +153,13 @@ export const HeaderDetails = inject('accountStore')(observer((props: {
111
153
</ HeaderDescriptionContainer > }
112
154
</ CollapsibleSection >
113
155
} ) }
156
+ {
157
+ hiddenCount > 0 ?
158
+ < CollapsibleSection withinGrid = { true } > < HeaderKeyValue >
159
+ < HeaderName > Plus { hiddenCount } hidden...</ HeaderName >
160
+
161
+ </ HeaderKeyValue > </ CollapsibleSection >
162
+ : < BlankContentPlaceholder />
163
+ }
114
164
</ HeadersGrid > ;
115
165
} ) ) ;
0 commit comments