{"action":"created","issue":{"url":"https://api.github.com/repos/Majr-/SpriteEdit/issues/2","labels_url":"https://api.github.com/repos/Majr-/SpriteEdit/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/Majr-/SpriteEdit/issues/2/comments","events_url":"https://api.github.com/repos/Majr-/SpriteEdit/issues/2/events","html_url":"https://github.com/Majr-/SpriteEdit/issues/2","id":105711384,"number":2,"title":"Sprite edit tab should hide if the sprite sheet data page/image is protected","user":{"login":"KnightMiner","id":12155288,"avatar_url":"https://avatars.githubusercontent.com/u/12155288?v=3","gravatar_id":"","url":"https://api.github.com/users/KnightMiner","html_url":"https://github.com/KnightMiner","followers_url":"https://api.github.com/users/KnightMiner/followers","following_url":"https://api.github.com/users/KnightMiner/following{/other_user}","gists_url":"https://api.github.com/users/KnightMiner/gists{/gist_id}","starred_url":"https://api.github.com/users/KnightMiner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KnightMiner/subscriptions","organizations_url":"https://api.github.com/users/KnightMiner/orgs","repos_url":"https://api.github.com/users/KnightMiner/repos","events_url":"https://api.github.com/users/KnightMiner/events{/privacy}","received_events_url":"https://api.github.com/users/KnightMiner/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-10T00:55:48Z","updated_at":"2015-09-11T15:42:25Z","closed_at":null,"body":"While we don't have any fully protected sprite sheets on the Minecraft Wiki, there are a few protected by cascading protection (like ItemSprite), and it would be better if the \"Edit sprite\" tab was simply removed if the user cannot edit the sprite sheet page, rather than relying on the \"cannot edit page\" error at the end."},"comment":{"url":"https://api.github.com/repos/Majr-/SpriteEdit/issues/comments/139580490","html_url":"https://github.com/Majr-/SpriteEdit/issues/2#issuecomment-139580490","issue_url":"https://api.github.com/repos/Majr-/SpriteEdit/issues/2","id":139580490,"user":{"login":"Majr-","id":880296,"avatar_url":"https://avatars.githubusercontent.com/u/880296?v=3","gravatar_id":"","url":"https://api.github.com/users/Majr-","html_url":"https://github.com/Majr-","followers_url":"https://api.github.com/users/Majr-/followers","following_url":"https://api.github.com/users/Majr-/following{/other_user}","gists_url":"https://api.github.com/users/Majr-/gists{/gist_id}","starred_url":"https://api.github.com/users/Majr-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Majr-/subscriptions","organizations_url":"https://api.github.com/users/Majr-/orgs","repos_url":"https://api.github.com/users/Majr-/repos","events_url":"https://api.github.com/users/Majr-/events{/privacy}","received_events_url":"https://api.github.com/users/Majr-/received_events","type":"User","site_admin":false},"created_at":"2015-09-11T15:42:25Z","updated_at":"2015-09-11T15:42:25Z","body":"That would be ideal. Unfortunately, MediaWiki doesn't make it easy to find out if you can perform an action on a title. Instead of simply asking the API \"can I X page Y\", you have to:\r\n\r\n1. Query the API for the list of rights the user has.\r\n2. Query the API for the list of protection levels the page has.\r\n3. Don't forget, of course, that the `autoconfirmed` and `sysop` protection levels aren't actually rights like any other protection level. They remain as aliases for \"backwards compatibility\" to the `editsemiprotected` and `editprotected` rights, respectively, and have nothing to do with the groups (a page that is `editprotected` is shown as `sysop` protected regardless of which groups have the `editprotected` right). So you have to translate those first.\r\n4. Finally loop through the protection levels for the action you want to perform and check the user has all the necessary rights.\r\n5. If there are cascading protection levels, also check the user has the `protect` right.\r\n\r\nFortunately in this instance, we can skip step 2 by using `mw.title.protectionLevels` and `mw.title.cascadingProtection` in lua (or the equivalent magic words), and outputting them as data attributes for JS to read.\r\n\r\nBecause of all that, it isn't practical to implement in the loader script (and regardless, delaying showing the tab with an API request isn't ideal), so instead the tab will have to remain, and the protection check will be done when the editor loads.\r\n\r\nUltimately, I'd prefer to still allow editing and instead save the changes to an editcopy page to be merged in by whoever can edit the main page.\r\nThe real difficulty there is how to handle merging in the editor. It would have to show some sort of notification that there are X unapproved changes, with a list of revisions that you can view diffs of and manually revert unwanted changes and \"approve\" the rest. That's getting rather more complicated, and would require proper human-readable diffs. If you edit without approving the editcopy changes, then you later need to handle merging those changes in, probably as if they were editconflicts.\r\n\r\n\r\nSide note: even VE doesn't bother preventing you from editing protected pages, and just errors out on saving. VE *does* hide the edit tab on directly protected pages (although directly navigating to the `veaction=edit` url will still let you edit). But on cascading protected pages, it (and the normal wikitext editing button) still act as if you can edit it. The wikitext editor at least makes the textarea read-only if you try to edit, but VE happily lets you edit a page you can't save, with the only indication of this being a small tooltip containing basically all the clutter that goes above the normal wikitext editor, which you will probably ignore (and even if you skim over it, the \"you can't edit this\" text is pretty unnoticeable underneath the bright yellow notice boxes)."}}