feat(core): rename wgCitizenTableNowrapClasses to wgCitizenOverflowNowrapClasses

Allow this config to use for more generic elements in the future
This commit is contained in:
alistair3149 2024-05-27 15:54:26 -04:00
parent 7a4d43392d
commit c17aeab3fd
No known key found for this signature in database
4 changed files with 13 additions and 13 deletions

View file

@ -121,7 +121,7 @@ Name | Description | Values | Default
`$wgCitizenEnableARFonts` | Enable included Noto Naskh Arabic for wikis that serve Arabic | `true` - enable; `false` - disable | `false`
`$wgCitizenEnableCJKFonts` | Enable included Noto Sans CJK for wikis that serves CJK languages | `true` - enable; `false` - disable | `false`
`$wgCitizenEnablePreferences` | Enable the preferences menu | `true` - enable; `false` - disable | `true`
`$wgCitizenTableNowrapClasses` | Defines table css classes ignored by citizen table wrapper | List of css classes. Extend with `$wgCitizenTableNowrapClasses[] = 'my_class';` | `["citizen-table-nowrap", "diff", "mw-changeslist-line", "mw-recentchanges-table", "infobox", "cargoDynamicTable", "dataTable", "srf-datatable", "smw-datatable", "mw-capiunto-infobox" ]`
`$wgCitizenOverflowNowrapClasses` | Defines css classes ignored by the overflow wrapper | List of css classes. Extend with `$wgCitizenOverflowNowrapClasses[] = 'my_class';` | `["citizen-table-nowrap", "diff", "mw-changeslist-line", "mw-recentchanges-table", "infobox", "cargoDynamicTable", "dataTable", "srf-datatable", "smw-datatable", "mw-capiunto-infobox" ]`
### Search suggestions
Name | Description | Values | Default

View file

@ -47,8 +47,8 @@ class ResourceLoaderHooks {
) {
return [
'wgCitizenEnablePreferences' => $config->get( 'CitizenEnablePreferences' ),
'wgCitizenSearchModule' => $config->get( 'CitizenSearchModule' ),
'wgCitizenTableNowrapClasses' => $config->get( 'CitizenTableNowrapClasses' ),
'wgCitizenOverflowNowrapClasses' => $config->get( 'CitizenOverflowNowrapClasses' ),
'wgCitizenSearchModule' => $config->get( 'CitizenSearchModule' )
];
}

View file

@ -78,8 +78,8 @@ class OverflowElement {
/**
* Wraps the element in a div container with the class 'citizen-table-wrapper'.
* Checks if the element or its parent node is null or undefined, logs an error if so.
* Verifies the existence of $wgCitizenTableNowrapClasses in the config and if it is an array, logs an error if not.
* Skips wrapping if the element contains any of the ignored classes specified in $wgCitizenTableNowrapClasses.
* Verifies the existence of $wgCitizenOverflowNowrapClasses in the config and if it is an array, logs an error if not.
* Skips wrapping if the element contains any of the ignored classes specified in $wgCitizenOverflowNowrapClasses.
* Creates a wrapper div element, adds the class 'citizen-table-wrapper' to it.
* Filters and adds inherited classes ('floatleft', 'floatright') from the element to the wrapper.
* Inserts the wrapper before the element in the DOM and appends the element to the wrapper.
@ -95,16 +95,16 @@ class OverflowElement {
}
try {
if (
!config.wgCitizenTableNowrapClasses ||
!Array.isArray( config.wgCitizenTableNowrapClasses )
!config.wgCitizenOverflowNowrapClasses ||
!Array.isArray( config.wgCitizenOverflowNowrapClasses )
) {
mw.log.error( '[Citizen] Invalid or missing $wgCitizenTableNowrapClasses. Cannot proceed with wrapping table.' );
mw.log.error( '[Citizen] Invalid or missing $wgCitizenOverflowNowrapClasses. Cannot proceed with wrapping table.' );
return;
}
const parentNode = this.element.parentNode;
const ignoredClasses = config.wgCitizenTableNowrapClasses;
const ignoredClasses = config.wgCitizenOverflowNowrapClasses;
if ( ignoredClasses.some( ( cls ) => this.element.classList.contains( cls ) ) ) {
return;

View file

@ -19,8 +19,8 @@ class ResourceLoaderHooksTest extends MediaWikiIntegrationTestCase {
public function testCitizenResourceLoaderConfig() {
$this->overrideConfigValues( [
'CitizenEnablePreferences' => false,
'CitizenOverflowNowrapClasses' => false,
'CitizenSearchModule' => false,
'CitizenTableNowrapClasses' => false,
] );
$rlCtxMock = $this->getMockBuilder( Context::class )->disableOriginalConstructor()->getMock();
@ -33,7 +33,7 @@ class ResourceLoaderHooksTest extends MediaWikiIntegrationTestCase {
$this->assertArraySubmapSame( [
'wgCitizenEnablePreferences' => false,
'wgCitizenSearchModule' => false,
'wgCitizenTableNowrapClasses' => false,
'wgCitizenOverflowNowrapClasses' => false,
], $config );
}
@ -44,8 +44,8 @@ class ResourceLoaderHooksTest extends MediaWikiIntegrationTestCase {
public function testCitizenResourceLoaderConfigAllTrue() {
$this->overrideConfigValues( [
'CitizenEnablePreferences' => true,
'CitizenOverflowNowrapClasses' => true,
'CitizenSearchModule' => true,
'CitizenTableNowrapClasses' => true,
] );
$rlCtxMock = $this->getMockBuilder( Context::class )->disableOriginalConstructor()->getMock();
@ -57,8 +57,8 @@ class ResourceLoaderHooksTest extends MediaWikiIntegrationTestCase {
$this->assertArraySubmapSame( [
'wgCitizenEnablePreferences' => true,
'wgCitizenOverflowNowrapClasses' => true,
'wgCitizenSearchModule' => true,
'wgCitizenTableNowrapClasses' => true,
], $config );
}