2024-03-24 20:53:43 +00:00
|
|
|
const Overlay = require( 'mobile.startup' ).Overlay;
|
|
|
|
const IssueList = require( './IssueList.js' );
|
|
|
|
const KEYWORD_ALL_SECTIONS = 'all';
|
2024-04-14 09:47:39 +00:00
|
|
|
const namespaceIds = mw.config.get( 'wgNamespaceIds' );
|
|
|
|
const NS_MAIN = namespaceIds[ '' ];
|
|
|
|
const NS_CATEGORY = namespaceIds.category;
|
2018-08-16 19:00:38 +00:00
|
|
|
|
2023-11-07 16:29:17 +00:00
|
|
|
/**
|
|
|
|
* Overlay for displaying page issues
|
|
|
|
*
|
2024-06-26 13:23:40 +00:00
|
|
|
* @ignore
|
|
|
|
* @param {IssueSummary[]} issues List of page issue
|
|
|
|
* summaries for display.
|
2023-11-07 16:29:17 +00:00
|
|
|
* @param {string} section
|
|
|
|
* @param {number} namespaceID
|
|
|
|
* @return {Overlay}
|
|
|
|
*/
|
|
|
|
function pageIssuesOverlay( issues, section, namespaceID ) {
|
2024-03-24 20:53:43 +00:00
|
|
|
// Note only the main namespace is expected to make use of section issues, so the
|
|
|
|
// heading will always be minerva-meta-data-issues-section-header regardless of
|
|
|
|
// namespace.
|
|
|
|
const headingText = section === '0' || section === KEYWORD_ALL_SECTIONS ?
|
|
|
|
getNamespaceHeadingText( namespaceID ) :
|
|
|
|
mw.msg( 'minerva-meta-data-issues-section-header' );
|
2018-08-17 19:00:57 +00:00
|
|
|
|
2024-12-05 01:26:20 +00:00
|
|
|
return Overlay.make( {
|
2023-11-07 16:29:17 +00:00
|
|
|
className: 'overlay overlay-issues',
|
2024-12-05 01:26:20 +00:00
|
|
|
heading: `<strong>${ headingText }</strong>`
|
|
|
|
}, new IssueList( issues ) );
|
2023-11-07 16:29:17 +00:00
|
|
|
}
|
2018-08-17 19:00:57 +00:00
|
|
|
|
2023-11-07 16:29:17 +00:00
|
|
|
/**
|
|
|
|
* Obtain a suitable heading for the issues overlay based on the namespace
|
|
|
|
*
|
2024-06-26 13:23:40 +00:00
|
|
|
* @private
|
2023-11-07 16:29:17 +00:00
|
|
|
* @param {number} namespaceID is the namespace to generate heading for
|
|
|
|
* @return {string} heading for overlay
|
|
|
|
*/
|
|
|
|
function getNamespaceHeadingText( namespaceID ) {
|
|
|
|
switch ( namespaceID ) {
|
|
|
|
case NS_CATEGORY:
|
|
|
|
return mw.msg( 'mobile-frontend-meta-data-issues-categories' );
|
|
|
|
case NS_MAIN:
|
|
|
|
return mw.msg( 'mobile-frontend-meta-data-issues' );
|
|
|
|
default:
|
|
|
|
return '';
|
2018-08-17 19:00:57 +00:00
|
|
|
}
|
2023-11-07 16:29:17 +00:00
|
|
|
}
|
2018-08-17 19:00:57 +00:00
|
|
|
|
2023-11-07 16:29:17 +00:00
|
|
|
module.exports = pageIssuesOverlay;
|