Hygiene: remove unused page issues function
Remove getAllIssuesSections(). This is no longer in use and does not appear to be sufficiently general purpose to want to maintain. Bug: T212371 Change-Id: I7ed73408705cba64b26dd318e78ae415b707e687
This commit is contained in:
parent
f54b4e75db
commit
7d4ca12a2e
|
@ -113,31 +113,6 @@
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an array containing the section of each page issue.
|
|
||||||
* In the case that several page issues are grouped in a 'multiple issues' template,
|
|
||||||
* returns the section of those issues as one item.
|
|
||||||
* @param {IssueSummaryMap} allIssues mapping section {number} to {IssueSummary}
|
|
||||||
* @return {number[]}
|
|
||||||
*/
|
|
||||||
function getAllIssuesSections( allIssues ) {
|
|
||||||
return Object.keys( allIssues ).reduce( function ( acc, section ) {
|
|
||||||
if ( allIssues[ section ].length ) {
|
|
||||||
allIssues[ section ].forEach( function ( issue, i ) {
|
|
||||||
var lastIssue = allIssues[ section ][ i - 1 ];
|
|
||||||
// If the last issue belongs to a "Multiple issues" template,
|
|
||||||
// and so does the current one, don't add the current one.
|
|
||||||
if ( lastIssue && lastIssue.grouped && issue.grouped ) {
|
|
||||||
acc[ acc.length - 1 ] = section;
|
|
||||||
} else {
|
|
||||||
acc.push( section );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
return acc;
|
|
||||||
}, [] );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scan an element for any known cleanup templates and replace them with a button
|
* Scan an element for any known cleanup templates and replace them with a button
|
||||||
* that opens them in a mobile friendly overlay.
|
* that opens them in a mobile friendly overlay.
|
||||||
|
@ -219,7 +194,6 @@
|
||||||
M.define( 'skins.minerva.scripts/pageIssues', {
|
M.define( 'skins.minerva.scripts/pageIssues', {
|
||||||
init: initPageIssues,
|
init: initPageIssues,
|
||||||
test: {
|
test: {
|
||||||
getAllIssuesSections: getAllIssuesSections,
|
|
||||||
insertBannersOrNotice: insertBannersOrNotice
|
insertBannersOrNotice: insertBannersOrNotice
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -1,35 +1,8 @@
|
||||||
( function ( M ) {
|
( function ( M ) {
|
||||||
var
|
var
|
||||||
pageIssues = M.require( 'skins.minerva.scripts/pageIssues' ),
|
|
||||||
mobile = M.require( 'mobile.startup' ),
|
mobile = M.require( 'mobile.startup' ),
|
||||||
util = mobile.util,
|
pageIssues = M.require( 'skins.minerva.scripts/pageIssues' ),
|
||||||
insertBannersOrNotice = pageIssues.test.insertBannersOrNotice,
|
insertBannersOrNotice = pageIssues.test.insertBannersOrNotice,
|
||||||
icon = {},
|
|
||||||
MEDIUM_ISSUE = {
|
|
||||||
issue: {
|
|
||||||
severity: 'MEDIUM',
|
|
||||||
icon: icon
|
|
||||||
},
|
|
||||||
iconString: 'i',
|
|
||||||
text: 't'
|
|
||||||
},
|
|
||||||
LOW_ISSUE = {
|
|
||||||
issue: {
|
|
||||||
severity: 'LOW',
|
|
||||||
icon: icon
|
|
||||||
},
|
|
||||||
iconString: 'i',
|
|
||||||
text: 't'
|
|
||||||
},
|
|
||||||
HIGH_ISSUE = {
|
|
||||||
issue: {
|
|
||||||
severity: 'HIGH',
|
|
||||||
icon: icon
|
|
||||||
},
|
|
||||||
iconString: 'i',
|
|
||||||
text: 't'
|
|
||||||
},
|
|
||||||
getAllIssuesSections = pageIssues.test.getAllIssuesSections,
|
|
||||||
OverlayManager = mobile.OverlayManager,
|
OverlayManager = mobile.OverlayManager,
|
||||||
Page = mobile.Page,
|
Page = mobile.Page,
|
||||||
overlayManager = new OverlayManager( require( 'mediawiki.router' ) ),
|
overlayManager = new OverlayManager( require( 'mediawiki.router' ) ),
|
||||||
|
@ -63,61 +36,4 @@
|
||||||
processedAmbox.click();
|
processedAmbox.click();
|
||||||
assert.strictEqual( window.location.hash, '#/issues/' + SECTION );
|
assert.strictEqual( window.location.hash, '#/issues/' + SECTION );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
QUnit.test( 'getAllIssuesSections', function ( assert ) {
|
|
||||||
var multipleIssuesWithDeletion,
|
|
||||||
multipleIssues, allIssuesOldTreatment, allIssuesNewTreatment;
|
|
||||||
allIssuesOldTreatment = {
|
|
||||||
0: [
|
|
||||||
MEDIUM_ISSUE,
|
|
||||||
LOW_ISSUE,
|
|
||||||
MEDIUM_ISSUE
|
|
||||||
]
|
|
||||||
};
|
|
||||||
multipleIssues = {
|
|
||||||
0: [
|
|
||||||
util.extend( {}, MEDIUM_ISSUE, { grouped: true } ),
|
|
||||||
util.extend( {}, LOW_ISSUE, { grouped: true } ),
|
|
||||||
util.extend( {}, MEDIUM_ISSUE, { grouped: true } )
|
|
||||||
]
|
|
||||||
};
|
|
||||||
multipleIssuesWithDeletion = {
|
|
||||||
0: [
|
|
||||||
HIGH_ISSUE,
|
|
||||||
util.extend( {}, MEDIUM_ISSUE, { grouped: true } ),
|
|
||||||
util.extend( {}, LOW_ISSUE, { grouped: true } ),
|
|
||||||
util.extend( {}, MEDIUM_ISSUE, { grouped: true } )
|
|
||||||
]
|
|
||||||
};
|
|
||||||
allIssuesNewTreatment = {
|
|
||||||
0: [
|
|
||||||
HIGH_ISSUE,
|
|
||||||
LOW_ISSUE,
|
|
||||||
MEDIUM_ISSUE
|
|
||||||
],
|
|
||||||
1: [
|
|
||||||
MEDIUM_ISSUE
|
|
||||||
]
|
|
||||||
};
|
|
||||||
assert.propEqual(
|
|
||||||
getAllIssuesSections( allIssuesOldTreatment ),
|
|
||||||
[ '0', '0', '0' ],
|
|
||||||
'section numbers correctly extracted from old treatment'
|
|
||||||
);
|
|
||||||
assert.propEqual(
|
|
||||||
getAllIssuesSections( allIssuesNewTreatment ),
|
|
||||||
[ '0', '0', '0', '1' ],
|
|
||||||
'section numbers correctly extracted from new treatment'
|
|
||||||
);
|
|
||||||
assert.propEqual(
|
|
||||||
getAllIssuesSections( multipleIssues ),
|
|
||||||
[ '0' ],
|
|
||||||
'multiple issues are packed into one entry since there is one box'
|
|
||||||
);
|
|
||||||
assert.propEqual(
|
|
||||||
getAllIssuesSections( multipleIssuesWithDeletion ),
|
|
||||||
[ '0', '0' ],
|
|
||||||
'while multiple issues are grouped, non-multiple issues are still reported'
|
|
||||||
);
|
|
||||||
} );
|
|
||||||
}( mw.mobileFrontend ) );
|
}( mw.mobileFrontend ) );
|
||||||
|
|
Loading…
Reference in New Issue