Commit add1bcb5 by Marcus Andersson Committed by GitHub

Variable: removed __user.name/___.user.email from global variables and added…

Variable: removed __user.name/___.user.email from global variables and added docs for the rest of the __user variable. (#25275)

* added docs for new global variable.

* reverting the name + email so we only expose the bare minumum that should be enough for most cases.
parent 1d9f47b6
...@@ -52,6 +52,12 @@ This variable is only available in the Singlestat panel and can be used in the p ...@@ -52,6 +52,12 @@ This variable is only available in the Singlestat panel and can be used in the p
This variable is the ID of the current organization. This variable is the ID of the current organization.
`${__org.name}` is the name of the current organization. `${__org.name}` is the name of the current organization.
## $__user
> Only available in Grafana v7.1+
`${__user.id}` is the ID of the current user.
`${__user.login}` is the login handle of the current user.
## $__range ## $__range
> Only available in Grafana v5.3+ > Only available in Grafana v5.3+
......
...@@ -15,8 +15,6 @@ export class User { ...@@ -15,8 +15,6 @@ export class User {
timezone: string; timezone: string;
helpFlags1: number; helpFlags1: number;
lightTheme: boolean; lightTheme: boolean;
name?: string;
email?: string;
hasEditPermissionInFolders: boolean; hasEditPermissionInFolders: boolean;
constructor() { constructor() {
......
...@@ -73,9 +73,7 @@ export class VariableSrv { ...@@ -73,9 +73,7 @@ export class VariableSrv {
}); });
this.templateSrv.setGlobalVariable('__user', { this.templateSrv.setGlobalVariable('__user', {
value: { value: {
name: contextSrv.user.name,
login: contextSrv.user.login, login: contextSrv.user.login,
email: contextSrv.user.email,
id: contextSrv.user.id, id: contextSrv.user.id,
toString: function() { toString: function() {
return this.id; return this.id;
......
...@@ -104,9 +104,7 @@ export const completeDashboardTemplating = (dashboard: DashboardModel): ThunkRes ...@@ -104,9 +104,7 @@ export const completeDashboardTemplating = (dashboard: DashboardModel): ThunkRes
}); });
templateSrv.setGlobalVariable('__user', { templateSrv.setGlobalVariable('__user', {
value: { value: {
name: contextSrv.user.name,
login: contextSrv.user.login, login: contextSrv.user.login,
email: contextSrv.user.email,
id: contextSrv.user.id, id: contextSrv.user.id,
toString: function() { toString: function() {
return this.id; return this.id;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment