Merge "Disable edit icon in read-only mode"
This commit is contained in:
commit
44e59d625d
|
@ -177,4 +177,20 @@ class MinervaHooks {
|
||||||
] );
|
] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* ResourceLoaderGetConfigVars hook handler.
|
||||||
|
* Used for setting JS variables which are pulled in dynamically with RL
|
||||||
|
* instead of embedded directly on the page with a script tag.
|
||||||
|
* These vars have a shorter cache-life than those in `getSkinConfigVariables`.
|
||||||
|
*
|
||||||
|
* @param array &$vars Array of variables to be added into the output of the RL startup module.
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function onResourceLoaderGetConfigVars( &$vars ) {
|
||||||
|
$vars += [
|
||||||
|
'wgMinervaReadOnly' => wfReadOnly()
|
||||||
|
];
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
var
|
var
|
||||||
// see: https://www.mediawiki.org/wiki/Manual:Interface/JavaScript#Page-specific
|
// see: https://www.mediawiki.org/wiki/Manual:Interface/JavaScript#Page-specific
|
||||||
isEditable = mw.config.get( 'wgIsProbablyEditable' ),
|
isReadOnly = mw.config.get( 'wgMinervaReadOnly' ),
|
||||||
|
isEditable = !isReadOnly && mw.config.get( 'wgIsProbablyEditable' ),
|
||||||
blockInfo = mw.config.get( 'wgMinervaUserBlockInfo', false ),
|
blockInfo = mw.config.get( 'wgMinervaUserBlockInfo', false ),
|
||||||
router = require( 'mediawiki.router' ),
|
router = require( 'mediawiki.router' ),
|
||||||
issues = M.require( 'skins.minerva.scripts/cleanuptemplates' ),
|
issues = M.require( 'skins.minerva.scripts/cleanuptemplates' ),
|
||||||
|
@ -25,6 +26,7 @@
|
||||||
name: 'edit-enabled',
|
name: 'edit-enabled',
|
||||||
glyphPrefix: 'minerva'
|
glyphPrefix: 'minerva'
|
||||||
} ),
|
} ),
|
||||||
|
editErrorMessage = isReadOnly ? mw.msg( 'apierror-readonly' ) : mw.msg( 'mobile-frontend-editor-disabled' ),
|
||||||
// TODO: move enabledClass, $caEdit, and disabledClass to locals within
|
// TODO: move enabledClass, $caEdit, and disabledClass to locals within
|
||||||
// updateEditPageButton().
|
// updateEditPageButton().
|
||||||
enabledClass = enabledEditIcon.getGlyphClassName(),
|
enabledClass = enabledEditIcon.getGlyphClassName(),
|
||||||
|
@ -347,7 +349,7 @@
|
||||||
setupEditor( currentPage );
|
setupEditor( currentPage );
|
||||||
} else {
|
} else {
|
||||||
updateEditPageButton( false );
|
updateEditPageButton( false );
|
||||||
showSorryToast( mw.msg( 'mobile-frontend-editor-disabled' ) );
|
showSorryToast( editErrorMessage );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,7 +378,7 @@
|
||||||
} );
|
} );
|
||||||
} else {
|
} else {
|
||||||
updateEditPageButton( false );
|
updateEditPageButton( false );
|
||||||
showSorryToast( mw.msg( 'mobile-frontend-editor-disabled' ) );
|
showSorryToast( editErrorMessage );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,11 @@
|
||||||
],
|
],
|
||||||
"SpecialPageBeforeExecute": [
|
"SpecialPageBeforeExecute": [
|
||||||
"MinervaHooks::onSpecialPageBeforeExecute"
|
"MinervaHooks::onSpecialPageBeforeExecute"
|
||||||
|
],
|
||||||
|
"ResourceLoaderGetConfigVars": [
|
||||||
|
"MinervaHooks::onResourceLoaderGetConfigVars"
|
||||||
]
|
]
|
||||||
|
|
||||||
},
|
},
|
||||||
"MessagesDirs": {
|
"MessagesDirs": {
|
||||||
"MinervaNeue": [
|
"MinervaNeue": [
|
||||||
|
@ -529,7 +533,8 @@
|
||||||
"mobile-frontend-editor-edit",
|
"mobile-frontend-editor-edit",
|
||||||
"mobile-frontend-editor-redlink-create",
|
"mobile-frontend-editor-redlink-create",
|
||||||
"mobile-frontend-editor-redlink-leave",
|
"mobile-frontend-editor-redlink-leave",
|
||||||
"mobile-frontend-editor-redlink-explain"
|
"mobile-frontend-editor-redlink-explain",
|
||||||
|
"apierror-readonly"
|
||||||
],
|
],
|
||||||
"scripts": [
|
"scripts": [
|
||||||
"resources/skins.minerva.editor/init.js"
|
"resources/skins.minerva.editor/init.js"
|
||||||
|
|
Loading…
Reference in New Issue