jenkins-bot has submitted this change and it was merged.
Change subject: Update model#isInspectable
......................................................................
Update model#isInspectable
* Hide items which aren't inspectable from the context completely
* Introduce a new method isEditable which just hides the edit
button from the context
Bug: T106810
Change-Id: I1ba8978dd139de20105a208c9045871b97f3577a
---
M src/dm/ve.dm.Model.js
M src/ui/contexts/ve.ui.LinearContext.js
M src/ui/ve.ui.ContextItem.js
3 files changed, 20 insertions(+), 2 deletions(-)
Approvals:
Catrope: Looks good to me, but someone else must approve
Jforrester: Looks good to me, approved
jenkins-bot: Verified
diff --git a/src/dm/ve.dm.Model.js b/src/dm/ve.dm.Model.js
index 8e96f76..a362ebc 100644
--- a/src/dm/ve.dm.Model.js
+++ b/src/dm/ve.dm.Model.js
@@ -243,7 +243,7 @@
/* Methods */
/**
- * Check whether this node can be inspected by a tool.
+ * Check whether this node can be inspected by a context item.
*
* The default implementation always returns true. If your node type is
uninspectable in certain
* cases, you should override this function.
@@ -255,6 +255,18 @@
};
/**
+ * Check whether this node can be edited by a context item
+ *
+ * The default implementation always returns true. If your node type is
uneditable in certain
+ * cases, you should override this function.
+ *
+ * @returns {boolean} Whether this node is editable
+ */
+ve.dm.Model.prototype.isEditable = function () {
+ return true;
+};
+
+/**
* Get a reference to the linear model element.
*
* @method
diff --git a/src/ui/contexts/ve.ui.LinearContext.js
b/src/ui/contexts/ve.ui.LinearContext.js
index b8f6973..9282308 100644
--- a/src/ui/contexts/ve.ui.LinearContext.js
+++ b/src/ui/contexts/ve.ui.LinearContext.js
@@ -229,6 +229,9 @@
models = [];
items = ve.ui.contextItemFactory.getRelatedItems(
selectedModels );
for ( i = 0, len = items.length; i < len; i++ ) {
+ if ( !items[i].model.isInspectable() ) {
+ continue;
+ }
if ( ve.ui.contextItemFactory.isExclusive(
items[i].name ) ) {
models.push( items[i].model );
}
@@ -241,6 +244,9 @@
}
tools = ve.ui.toolFactory.getRelatedItems(
selectedModels );
for ( i = 0, len = tools.length; i < len; i++ ) {
+ if ( !tools[i].model.isInspectable() ) {
+ continue;
+ }
if ( models.indexOf( tools[i].model ) === -1 ) {
toolClass = ve.ui.toolFactory.lookup(
tools[i].name );
this.relatedSources.push( {
diff --git a/src/ui/ve.ui.ContextItem.js b/src/ui/ve.ui.ContextItem.js
index 9b6c31d..56ce159 100644
--- a/src/ui/ve.ui.ContextItem.js
+++ b/src/ui/ve.ui.ContextItem.js
@@ -156,7 +156,7 @@
* @return {boolean} Item is editable
*/
ve.ui.ContextItem.prototype.isEditable = function () {
- return this.constructor.static.editable;
+ return this.constructor.static.editable && this.model.isEditable();
};
/**
--
To view, visit https://gerrit.wikimedia.org/r/226704
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1ba8978dd139de20105a208c9045871b97f3577a
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits