forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1454312 - Display search results when searching across all networ…
…k resources. r=Honza,nchevobbe Differential Revision: https://phabricator.services.mozilla.com/D38164 --HG-- extra : moz-landing-system : lando
- Loading branch information
Showing
10 changed files
with
553 additions
and
1 deletion.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
.network-monitor .monitor-panel .request-list-container .requests-list-scroll { | ||
width: 100% !important; | ||
} | ||
|
||
.search-panel { | ||
display: flex; | ||
flex-direction: column; | ||
overflow: hidden; | ||
} | ||
|
||
.search-panel-content { | ||
width: 100%; | ||
overflow: auto; | ||
} | ||
|
||
/* Custom tree styles for the Search results panel*/ | ||
.search-panel .treeTable .treeLabelCell::after { | ||
content: ""; | ||
} | ||
|
||
/* Color for resource label */ | ||
.search-panel .resourceCell { | ||
color: var(--theme-text-color-inactive); | ||
} | ||
|
||
/* Color for search result label */ | ||
.search-panel .resultCell { | ||
color: var(--table-text-color); | ||
text-overflow: ellipsis; | ||
} | ||
|
||
/* Color for search result label */ | ||
.search-panel .treeLabel.resultLabel { | ||
color: var(--theme-text-color-inactive); | ||
} | ||
|
||
/* Break the column layout and make the search result output more compact */ | ||
.search-panel .treeTable tr { | ||
display: block; | ||
} | ||
|
||
.search-panel .treeTable { | ||
width: 100%; | ||
} | ||
|
||
#devtools-network-search-close::before { | ||
background-image: url("chrome://devtools/skin/images/close.svg"); | ||
} | ||
|
||
#devtools-network-search-close > button { | ||
margin: 0 !important; | ||
border-radius: 0 !important; | ||
position: relative; | ||
min-width: 26px; | ||
} | ||
|
||
/* Color for query matches */ | ||
.search-panel .resultCell .query-match { | ||
background-color: var(--theme-selection-background); | ||
color: white; | ||
padding: 1px 4px; | ||
margin: 0 2px 0 2px; | ||
border-radius: 2px; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
DIRS += [ | ||
'search', | ||
'websockets', | ||
] | ||
|
||
|
136 changes: 136 additions & 0 deletions
136
devtools/client/netmonitor/src/components/search/SearchPanel.js
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,136 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
"use strict"; | ||
|
||
const { | ||
Component, | ||
createRef, | ||
createFactory, | ||
} = require("devtools/client/shared/vendor/react"); | ||
const dom = require("devtools/client/shared/vendor/react-dom-factories"); | ||
const { div, span } = dom; | ||
const Actions = require("devtools/client/netmonitor/src/actions/index"); | ||
const PropTypes = require("devtools/client/shared/vendor/react-prop-types"); | ||
const { | ||
connect, | ||
} = require("devtools/client/shared/redux/visibility-handler-connect"); | ||
const TreeViewClass = require("devtools/client/shared/components/tree/TreeView"); | ||
const TreeView = createFactory(TreeViewClass); | ||
const { SearchProvider } = require("./search-provider"); | ||
const Toolbar = createFactory(require("./Toolbar")); | ||
|
||
/** | ||
* This component is responsible for rendering all search results | ||
* coming from the current search. | ||
*/ | ||
class SearchPanel extends Component { | ||
static get propTypes() { | ||
return { | ||
clearSearchResults: PropTypes.func.isRequired, | ||
openSearch: PropTypes.func.isRequired, | ||
closeSearch: PropTypes.func.isRequired, | ||
search: PropTypes.func.isRequired, | ||
connector: PropTypes.object.isRequired, | ||
addSearchQuery: PropTypes.func.isRequired, | ||
query: PropTypes.string.isRequired, | ||
results: PropTypes.array, | ||
}; | ||
} | ||
|
||
constructor(props) { | ||
super(props); | ||
this.searchboxRef = createRef(); | ||
this.renderValue = this.renderValue.bind(this); | ||
} | ||
|
||
renderTree() { | ||
const { results } = this.props; | ||
return TreeView({ | ||
object: results, | ||
provider: SearchProvider, | ||
expandableStrings: false, | ||
renderValue: this.renderValue, | ||
columns: [ | ||
{ | ||
id: "value", | ||
width: "100%", | ||
}, | ||
], | ||
}); | ||
} | ||
|
||
/** | ||
* Custom tree value rendering. This method is responsible for | ||
* rendering highlighted query string within the search result. | ||
*/ | ||
renderValue(props) { | ||
const member = props.member; | ||
/** | ||
* Handle only second level (zero based) that displays | ||
* the search result. Find the query string inside the | ||
* search result value (`props.object`) and render it | ||
* within a span element with proper class name. | ||
* | ||
* level 0 = resource name | ||
*/ | ||
if (member.level === 1) { | ||
const { query } = this.props; | ||
const indexStart = props.object.indexOf(query); | ||
const indexEnd = indexStart + query.length; | ||
|
||
return span( | ||
{}, | ||
span({}, props.object.substring(0, indexStart)), | ||
span({ className: "query-match" }, query), | ||
span({}, props.object.substring(indexEnd, props.object.length)) | ||
); | ||
} | ||
|
||
return props.object; | ||
} | ||
|
||
render() { | ||
const { | ||
openSearch, | ||
closeSearch, | ||
clearSearchResults, | ||
connector, | ||
addSearchQuery, | ||
search, | ||
} = this.props; | ||
return div( | ||
{ className: "search-panel", style: { width: "100%" } }, | ||
Toolbar({ | ||
searchboxRef: this.searchboxRef, | ||
openSearch, | ||
closeSearch, | ||
clearSearchResults, | ||
addSearchQuery, | ||
search, | ||
connector, | ||
}), | ||
div( | ||
{ className: "search-panel-content", style: { width: "100%" } }, | ||
this.renderTree() | ||
) | ||
); | ||
} | ||
} | ||
|
||
module.exports = connect( | ||
state => ({ | ||
query: state.search.query, | ||
results: state.search.results, | ||
ongoingSearch: state.search.ongoingSearch, | ||
status: state.search.status, | ||
}), | ||
dispatch => ({ | ||
closeSearch: () => dispatch(Actions.closeSearch()), | ||
openSearch: () => dispatch(Actions.openSearch()), | ||
search: () => dispatch(Actions.search()), | ||
clearSearchResults: () => dispatch(Actions.clearSearchResults()), | ||
addSearchQuery: query => dispatch(Actions.addSearchQuery(query)), | ||
}) | ||
)(SearchPanel); |
Oops, something went wrong.