Disable View, Share and More menu from graph

Guys, any ideas how to disable export data and another not necessary options in current version of grafana?

1 Like

I found a method as belown

In grafana build folder, search js file that contain ‘.show-on-hover’ css style

add ‘display: none’ to ‘。show-on-hover’ and ‘panel-menu’ in js.

clear browser cache, reload again.

2 Likes

to enable only for editors and disable for viewers In grafana 10.3
it’s work for me:

#sudo cd /usr/share/grafana/public/build/ *.js
#sudo grep -Ril “panel-dropdown”

in my case:
/usr/share/grafana/public/build/3964.4eb430604260346eee8b.js

for disable share: edit the file and the lines commented as “// ADD THIS LINE TO SHOW ONLY FOR EDITORS”:

    e.isEditing ||
      R.push({
        text: (0, P.t)("panel.header-menu.view", "View"),
        iconClassName: "eye",
        onClick: t,
        shortcut: "v",
      }),
      n.canEditPanel(e) &&
        !e.isEditing &&
        R.push({
          text: (0, P.t)("panel.header-menu.edit", "Edit"),
          iconClassName: "edit",
          onClick: s,
          shortcut: "e",
        }),
    n.canEditPanel(e) && // ADD THIS LINE TO SHOW ONLY FOR EDITORS
      !e.isEditing &&    // ADD THIS LINE TO SHOW ONLY FOR EDITORS   
      R.push({
        text: (0, P.t)("panel.header-menu.share", "Share"),
        iconClassName: "share-alt",
        onClick: o,
        shortcut: "p s",
      }),
      Ee.contextSrv.hasAccessToExplore() &&
        !(e.plugin && e.plugin.meta.skipDataQuery) &&
        e.datasource?.uid !== Be.oe &&
        R.push({
          text: (0, P.t)("panel.header-menu.explore", "Explore"),
          iconClassName: "compass",
          onClick: V,
          shortcut: "p x",
        });
    const te = [];
    e.plugin &&
      !e.plugin.meta.skipDataQuery &&
      (te.push({
        text: (0, P.t)("panel.header-menu.inspect-data", "Data"),
        onClick: (u) => d(C.q.Data),
      }),
      n.meta.canEdit &&
        te.push({
          text: (0, P.t)("panel.header-menu.query", "Query"),
          onClick: (u) => d(C.q.Query),
        })),
      te.push({
        text: (0, P.t)("panel.header-menu.inspect-json", "Panel JSON"),
        onClick: (u) => d(C.q.JSON),
      }),
      n.canEditPanel(e) && // ADD THIS LINE TO SHOW ONLY FOR EDITORS
      !e.isEditing &&    // ADD THIS LINE TO SHOW ONLY FOR EDITORS
      R.push({
        type: "submenu",
        text: (0, P.t)("panel.header-menu.inspect", "Inspect"),
        iconClassName: "info-circle",
        onClick: (u) => {
          const G = u.currentTarget,
            Y = u.target;
          (Y === G ||
            (Y instanceof HTMLElement &&
              Y.closest('[role="menuitem"]') === G)) &&
            d();
        },
        shortcut: "i",
        subMenu: te,
      });

As we already got some feedback from Grafana’s team and Torkel. Since even if you “hide” the controls, the user still has access to all the endpoints and data involved.

Closing the topic because it already got 4 years old and the version changed a lot for something that always needs some “hacking” on the code.