Fine tune new exceptor code

Related feedback:
- a91781a495 (commitcomment-93128519)

For instance, do not make exceptor widget available for
exceptions from filter lists.
This commit is contained in:
Raymond Hill 2022-12-15 10:04:59 -05:00
parent e2c3917ecd
commit fa5e4b7769
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 21 additions and 17 deletions

View File

@ -1124,6 +1124,7 @@ const reloadTab = function(ev) {
'csp_report': 'other', 'csp_report': 'other',
}; };
const createdStaticFilters = {}; const createdStaticFilters = {};
const reIsExceptionFilter = /^@@|^[\w.-]*?#@#/;
let dialog = null; let dialog = null;
let targetRow = null; let targetRow = null;
@ -1136,7 +1137,7 @@ const reloadTab = function(ev) {
let targetPageDomain; let targetPageDomain;
let targetFrameDomain; let targetFrameDomain;
const uglyTypeFromSelector = function(pane) { const uglyTypeFromSelector = pane => {
const prettyType = selectValue('select.type.' + pane); const prettyType = selectValue('select.type.' + pane);
if ( pane === 'static' ) { if ( pane === 'static' ) {
return staticFilterTypes[prettyType] || prettyType; return staticFilterTypes[prettyType] || prettyType;
@ -1144,18 +1145,23 @@ const reloadTab = function(ev) {
return uglyRequestTypes[prettyType] || prettyType; return uglyRequestTypes[prettyType] || prettyType;
}; };
const selectNode = function(selector) { const selectNode = selector => {
return qs$(dialog, selector); return qs$(dialog, selector);
}; };
const selectValue = function(selector) { const selectValue = selector => {
return selectNode(selector).value || ''; return selectNode(selector).value || '';
}; };
const staticFilterNode = function() { const staticFilterNode = ( ) => {
return qs$(dialog, 'div.panes > div.static textarea'); return qs$(dialog, 'div.panes > div.static textarea');
}; };
const toExceptionFilter = (filter, extended) => {
if ( reIsExceptionFilter.test(filter) ) { return filter; }
return extended ? filter.replace('##', '#@#') : `@@${filter}`;
};
const onColorsReady = function(response) { const onColorsReady = function(response) {
dom.cl.toggle(dom.body, 'dirty', response.dirty); dom.cl.toggle(dom.body, 'dirty', response.dirty);
for ( const url in response.colors ) { for ( const url in response.colors ) {
@ -1247,12 +1253,9 @@ const reloadTab = function(ev) {
if ( tcl.contains('exceptor') ) { if ( tcl.contains('exceptor') ) {
ev.stopPropagation(); ev.stopPropagation();
const filter = filterFromTargetRow(); const filter = filterFromTargetRow();
const exceptedFilter = dom.cl.has(targetRow, 'extendedRealm')
? `#@#${filter.replace(/^.*?#@?#/, '')}`
: `@@${filter.replace(/^@@/, '')}`;
const status = await messaging.send('loggerUI', { const status = await messaging.send('loggerUI', {
what: 'toggleInMemoryFilter', what: 'toggleInMemoryFilter',
filter: exceptedFilter, filter: toExceptionFilter(filter, dom.cl.has(targetRow, 'extendedRealm')),
}); });
const row = target.closest('div'); const row = target.closest('div');
dom.cl.toggle(row, 'exceptored', status); dom.cl.toggle(row, 'exceptored', status);
@ -1480,16 +1483,17 @@ const reloadTab = function(ev) {
const toSummaryPaneFilterNode = async function(receiver, filter) { const toSummaryPaneFilterNode = async function(receiver, filter) {
receiver.children[1].textContent = filter; receiver.children[1].textContent = filter;
if ( filterAuthorMode !== true ) { return; }
if ( dom.cl.has(targetRow, 'canLookup') === false ) { return; } if ( dom.cl.has(targetRow, 'canLookup') === false ) { return; }
const exceptedFilter = dom.cl.has(targetRow, 'extendedRealm') const isException = reIsExceptionFilter.test(filter);
? `#@#${filter.replace(/^.*?#@?#/, '')}` let isExcepted = false;
: `@@${filter.replace(/^@@/, '')}`; if ( isException ) {
const isTemporaryException = await messaging.send('loggerUI', { isExcepted = await messaging.send('loggerUI', {
what: 'hasInMemoryFilter', what: 'hasInMemoryFilter',
filter: exceptedFilter, filter: toExceptionFilter(filter, dom.cl.has(targetRow, 'extendedRealm')),
}); });
dom.cl.toggle(receiver, 'exceptored', isTemporaryException); }
if ( isException && isExcepted === false ) { return; }
dom.cl.toggle(receiver, 'exceptored', isExcepted);
receiver.children[2].style.visibility = ''; receiver.children[2].style.visibility = '';
}; };