-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ability to pin or exclude headers from display
Also copy header to value to clipboard
- Loading branch information
1 parent
d164770
commit 923e894
Showing
4 changed files
with
180 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import { action, runInAction } from 'mobx'; | ||
import { copyToClipboard } from '../../util/ui'; | ||
|
||
import { AccountStore } from '../../model/account/account-store'; | ||
import { UiStore } from '../../model/ui/ui-store'; | ||
import { ContextMenuItem } from '../../model/ui/context-menu'; | ||
import { HeaderClickedData,HeadersHeaderClickedData } from './http/header-details'; | ||
import {IEList} from '../../model/IncludeExcludeList'; | ||
|
||
export class HeadersHeaderContextMenuBuilder { | ||
|
||
constructor( | ||
private uiStore: UiStore | ||
) {} | ||
|
||
getContextMenuCallback(event: HeadersHeaderClickedData) { | ||
return (mouseEvent: React.MouseEvent) => { | ||
let excluded = event.HeadersIncludeExcludeList.GetKeysOnList(IEList.Exclude); | ||
|
||
this.uiStore.handleContextMenuEvent(mouseEvent, event, [ | ||
|
||
{ | ||
type: 'submenu', | ||
enabled: excluded.length > 0, | ||
label: `Excluded`, | ||
items: [ | ||
{ | ||
type: 'option', | ||
label: `Clear All Excluded Headers`, | ||
callback: async (data) => data.HeadersIncludeExcludeList.ClearList(IEList.Exclude) | ||
|
||
}, | ||
... | ||
(excluded.map((headerName) => ({ | ||
|
||
type: 'option', | ||
label: `Clear '${headerName}'`, | ||
callback: async (data: HeadersHeaderClickedData) => | ||
data.HeadersIncludeExcludeList.RemoveFromList(headerName,IEList.Exclude) | ||
|
||
|
||
} | ||
)) | ||
) as ContextMenuItem<HeadersHeaderClickedData>[] | ||
] | ||
} | ||
|
||
|
||
] | ||
|
||
); | ||
}; | ||
} | ||
} | ||
|
||
export class HeadersContextMenuBuilder { | ||
|
||
constructor( | ||
private accountStore: AccountStore, | ||
private uiStore: UiStore | ||
) {} | ||
|
||
getContextMenuCallback(event: HeaderClickedData) { | ||
return (mouseEvent: React.MouseEvent) => { | ||
const { isPaidUser } = this.accountStore; | ||
let isPinned = event.HeadersIncludeExcludeList.IsKeyOnList(event.header_name,IEList.Favorite); | ||
|
||
this.uiStore.handleContextMenuEvent(mouseEvent, event, [ | ||
{ | ||
type: 'option', | ||
label: (isPinned ? `Unpin` : `Pin`) + ` This Header`, | ||
callback: async (data) => { | ||
isPinned ? data.HeadersIncludeExcludeList.RemoveFromList(data.header_name,IEList.Favorite) : data.HeadersIncludeExcludeList.AddOrUpdateToList(data.header_name,IEList.Favorite); | ||
} | ||
}, | ||
{ | ||
type: 'option', | ||
label: `Exclude This Header`, | ||
callback: async (data) => { | ||
data.HeadersIncludeExcludeList.AddOrUpdateToList(data.header_name,IEList.Exclude); | ||
} | ||
}, | ||
{ | ||
type: 'option', | ||
label: `Copy Header Value`, | ||
callback: async (data) => | ||
copyToClipboard( data.header_value ) | ||
|
||
|
||
} | ||
|
||
] | ||
|
||
); | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters