From c574669466e3e2db4d18e6b585095431edae54ad Mon Sep 17 00:00:00 2001 From: Miguel Vazquez Date: Tue, 14 Oct 2014 21:20:36 -0400 Subject: [PATCH] HPCC-12234 Should warn if admin is removed Whenever an administrator removes themselves from being a member of "Administrators" they can potentially lock themselves out of the group due to a auto save feature within ECL Watch. Now they will receive a confirm warning them that they are about to lock themselves out of the admin group. Signed-off-by: Miguel Vazquez --- esp/src/eclwatch/MemberOfWidget.js | 20 +++++++++++++++++++- esp/src/eclwatch/nls/es/hpcc.js | 2 ++ esp/src/eclwatch/nls/hpcc.js | 2 ++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/esp/src/eclwatch/MemberOfWidget.js b/esp/src/eclwatch/MemberOfWidget.js index 73462f957f6..bc91e3f1ba3 100644 --- a/esp/src/eclwatch/MemberOfWidget.js +++ b/esp/src/eclwatch/MemberOfWidget.js @@ -25,17 +25,19 @@ define([ "hpcc/GridDetailsWidget", "hpcc/ws_access", + "hpcc/ws_account", "hpcc/ESPUtil" ], function (declare, lang, i18n, nlsHPCC, registry, editor, - GridDetailsWidget, WsAccess, ESPUtil) { + GridDetailsWidget, WsAccess, WsAccount, ESPUtil) { return declare("MemberOfWidget", [GridDetailsWidget], { i18n: nlsHPCC, gridTitle: nlsHPCC.title_MemberOf, idProperty: "__hpcc_id", + currentUser: null, // Hitched Actions --- _onRefresh: function (args) { @@ -44,11 +46,27 @@ define([ // Implementation --- init: function (params) { + var context = this; if (this.inherited(arguments)) return; + WsAccount.MyAccount({ + }).then(function (response) { + if (lang.exists("MyAccountResponse.username", response)) { + context.currentUser = response.MyAccountResponse.username; + } + }); + this.store = WsAccess.CreateGroupsStore(params.username, false); this.grid.setStore(this.store); + this.grid.on("dgrid-datachange", function(event){ + if (dojoConfig.isAdmin && params.username === context.currentUser && event.oldValue === true) { + var msg = confirm(context.i18n.RemoveUser + " " + event.rowId + ". " + context.i18n.ConfirmRemoval); + if (!msg){ + event.preventDefault(); + } + } + }); this._refreshActionState(); }, diff --git a/esp/src/eclwatch/nls/es/hpcc.js b/esp/src/eclwatch/nls/es/hpcc.js index e24e4740e6c..34f18d98cd0 100644 --- a/esp/src/eclwatch/nls/es/hpcc.js +++ b/esp/src/eclwatch/nls/es/hpcc.js @@ -65,6 +65,7 @@ define( Compressed: "Comprimido", Configuration: "Configuracion", ConfirmPassword: "Confirme la Contraseña", + ConfirmRemoval: "¿Seguro que quieres hacer esto?", Content: "Contenido", Contents: "Contenidos", ContentType: "Tipo de Contenido", @@ -359,6 +360,7 @@ define( RemoteDali: "Dali remoto", RemoteDaliIP: "Remote Dali IP Address", Remove: "Remover", + RemoveUser: "Esta apunto de excluirse del grupo:", Rename: "Renombrar", RenderedSVG: "SVG creado", RenderSVG: "Crear SVG", diff --git a/esp/src/eclwatch/nls/hpcc.js b/esp/src/eclwatch/nls/hpcc.js index 78f4441d2a2..405768fbd67 100644 --- a/esp/src/eclwatch/nls/hpcc.js +++ b/esp/src/eclwatch/nls/hpcc.js @@ -62,6 +62,7 @@ define({root: Compressed: "Compressed", Configuration: "Configuration", ConfirmPassword: "Confirm Password", + ConfirmRemoval: "Are you sure you want to do this?", Content: "Content", Contents: "Contents", ContentType: "Content Type", @@ -363,6 +364,7 @@ define({root: RemoteDali: "Remote Dali", RemoteDaliIP: "Remote Dali IP Address", Remove: "Remove", + RemoveUser: "You are about to remove yourself from the group:", Rename: "Rename", RenderedSVG: "Rendered SVG", RenderSVG: "Render SVG",