Home › Forums › General discussion › Hide Gear Icon on New Experience
Tagged: gear icon, site contents
- This topic has 2 replies, 2 voices, and was last updated 5 years, 6 months ago by Maciek Grischke.
-
AuthorPosts
-
-
June 28, 2019 at 21:25 #25899
This isn’t to do with DFFS, but SharePoint in general.
I managed to hide the Gear icon (settings icon) for non-admin users (via scriptlinks) so that nobody can go to Site Contents page, but my solution is not working on New Experience pages, lists or libraries.
I don’t know how to inject JS/CSS to new experience pages.
I’m talking about the gear icon in the top Nav Bar.
I want to apply this:
#O365_MainLink_Settings { display:none; }
If it’s possible to apply this to non-admin users, that’s great, but even if it’s for all users, including the admin, it’s also great, but I can’t have users to be able to access the Site Contents page.
When the page is loaded, I found this property in the page source: _spPageContextInf=”isSiteAdmin”=true which indicates that I am an admin.
Does anyone know how to resolve this? Or is there another way to stop users from accessing the Site Contents page?
I was unable to find anything online about this.
Thanks in advance.
-
June 29, 2019 at 08:27 #25909
Unfortunately I don’t know how to do this for the “modern look” SharePoint for all pages. I have developed a Modern Content Editor Web Part that can be used to inject JS or CSS in a modern page (not published yet, but I’ll make it available soon), but this would have to be added to every page so this is not a viable option.
My best advise would be to hide all the lists you don’t want them to see – I have added a code snippet you can use here.
Alexander
-
June 29, 2019 at 11:56 #25913
Thanks Alexander.
I tried it, but I am getting this error:
jquery-3.4.1.min.js:2 POST https://xxx.sharepoint.com/_api/Web/Lists/GetById('53eea4ac-f648-4360-8895-508a2940dd54') 415 send @ jquery-3.4.1.min.js:2 ajax @ jquery-3.4.1.min.js:2 toggleVisible @ SiteContentsSettings.aspx:709 onclick @ SiteContentsSettings.aspx:1 SiteContentsSettings.aspx:726 {readyState: 4, getResponseHeader: ƒ, getAllResponseHeaders: ƒ, setRequestHeader: ƒ, overrideMimeType: ƒ, …} abort: ƒ (e) always: ƒ () catch: ƒ (e) done: ƒ () fail: ƒ () getAllResponseHeaders: ƒ () getResponseHeader: ƒ (e) overrideMimeType: ƒ (e) pipe: ƒ () progress: ƒ () promise: ƒ (e) readyState: 4 responseJSON: {error: {…}} responseText: "{"error":{"code":"-1, Microsoft.SharePoint.Client.ClientServiceException","message":{"lang":"en-US","value":"The HTTP header Content-Type is missing or its value is invalid."}}}" setRequestHeader: ƒ (e,t) state: ƒ () status: 415 statusCode: ƒ (e) statusText: "error" then: ƒ (t,n,r) __proto__: Object
I am a site admin / global admin so I assumed I have enough rights?
Also, what I have used so far via scriptlink is:
addCSS("#applist {display:none !important}"); function addCSS(css){ var head = document.getElementsByTagName("head")[0]; var s = document.createElement("style"); s.setAttribute("type", "text/css"); if (s.styleSheet) { s.styleSheet.cssText = css; } else { s.appendChild(document.createTextNode(css)); }; head.appendChild(s); }
which hides everything from the view and if I need to show the list, I paste this in the console:
addCSS("#applist {display:block !important}");
-
-
AuthorPosts
- You must be logged in to reply to this topic.