From add1bcb59cd2e0628929c3884185f305089c97c6 Mon Sep 17 00:00:00 2001 From: Marcus Andersson Date: Tue, 2 Jun 2020 12:05:05 +0200 Subject: [PATCH] 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. --- docs/sources/variables/global-variables.md | 6 ++++++ public/app/core/services/context_srv.ts | 2 -- public/app/features/templating/variable_srv.ts | 2 -- public/app/features/variables/state/actions.ts | 2 -- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/sources/variables/global-variables.md b/docs/sources/variables/global-variables.md index 9dc24285757..0d37f77a016 100644 --- a/docs/sources/variables/global-variables.md +++ b/docs/sources/variables/global-variables.md @@ -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. `${__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 > Only available in Grafana v5.3+ diff --git a/public/app/core/services/context_srv.ts b/public/app/core/services/context_srv.ts index e3edac66205..b6a3c8f08cc 100644 --- a/public/app/core/services/context_srv.ts +++ b/public/app/core/services/context_srv.ts @@ -15,8 +15,6 @@ export class User { timezone: string; helpFlags1: number; lightTheme: boolean; - name?: string; - email?: string; hasEditPermissionInFolders: boolean; constructor() { diff --git a/public/app/features/templating/variable_srv.ts b/public/app/features/templating/variable_srv.ts index 10cbd2dcb17..6cbeccda3df 100644 --- a/public/app/features/templating/variable_srv.ts +++ b/public/app/features/templating/variable_srv.ts @@ -73,9 +73,7 @@ export class VariableSrv { }); this.templateSrv.setGlobalVariable('__user', { value: { - name: contextSrv.user.name, login: contextSrv.user.login, - email: contextSrv.user.email, id: contextSrv.user.id, toString: function() { return this.id; diff --git a/public/app/features/variables/state/actions.ts b/public/app/features/variables/state/actions.ts index f00fc37efbb..5ef0915491e 100644 --- a/public/app/features/variables/state/actions.ts +++ b/public/app/features/variables/state/actions.ts @@ -104,9 +104,7 @@ export const completeDashboardTemplating = (dashboard: DashboardModel): ThunkRes }); templateSrv.setGlobalVariable('__user', { value: { - name: contextSrv.user.name, login: contextSrv.user.login, - email: contextSrv.user.email, id: contextSrv.user.id, toString: function() { return this.id;