From 6915cb61aa458e34594543e5d51900e8406396dd Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 28 Oct 2023 11:12:10 +0200 Subject: [PATCH 1/2] Remove current user from list Display "no user" label in case there is no one to select DIsplay "you ned admin rihts" on non-admin users --- .../wwwroot/lang/da-DK.xml | 7 ++-- .../wwwroot/lang/en-US.xml | 7 ++-- .../wwwroot/user.controller.js | 13 +++++--- .../wwwroot/user.html | 32 ++++++++++++++----- 4 files changed, 40 insertions(+), 19 deletions(-) diff --git a/src/Our.Umbraco.Impersonator/wwwroot/lang/da-DK.xml b/src/Our.Umbraco.Impersonator/wwwroot/lang/da-DK.xml index c75d43d..ea3d946 100644 --- a/src/Our.Umbraco.Impersonator/wwwroot/lang/da-DK.xml +++ b/src/Our.Umbraco.Impersonator/wwwroot/lang/da-DK.xml @@ -1,4 +1,4 @@ - + Søren Kottal @@ -15,6 +15,7 @@ Du skal være logget ind i Umbraco for at kunne imitere en anden bruger Den valgte bruger kunne ikke findes Det valgte bruger ID er ikke gyldigt - Du skal have administratorrettigheder for at kunne imitere en anden bruger + Du skal have brugeradministratorrettigheder for at kunne imitere en anden bruger + Der er ingen aktive brugere at imiterer. - \ No newline at end of file + diff --git a/src/Our.Umbraco.Impersonator/wwwroot/lang/en-US.xml b/src/Our.Umbraco.Impersonator/wwwroot/lang/en-US.xml index 070e241..8a3de72 100644 --- a/src/Our.Umbraco.Impersonator/wwwroot/lang/en-US.xml +++ b/src/Our.Umbraco.Impersonator/wwwroot/lang/en-US.xml @@ -1,4 +1,4 @@ - + Søren Kottal @@ -15,6 +15,7 @@ You need to be signed in to Umbraco, to be able to impersonate another user. The selected user could not be found. The selected user id is invalid. - You need administrator rights, to be able to impersonate another user. + You need users administrator rights, to be able to impersonate another user. + There are no active users to impersonate. - \ No newline at end of file + diff --git a/src/Our.Umbraco.Impersonator/wwwroot/user.controller.js b/src/Our.Umbraco.Impersonator/wwwroot/user.controller.js index 221f617..6da182f 100644 --- a/src/Our.Umbraco.Impersonator/wwwroot/user.controller.js +++ b/src/Our.Umbraco.Impersonator/wwwroot/user.controller.js @@ -1,4 +1,4 @@ -(function () { +(function () { "use strict"; function ImpersonatorUserController( @@ -12,7 +12,6 @@ var vm = this; vm.isImpersonating = false; - vm.isLoading = false; vm.users = []; vm.loadingUsers = true; vm.impersonateUserButtonState = "init"; @@ -25,12 +24,12 @@ // Get users usersResource .getPagedResults({ - pageSize: 2147483647, - userStates: ["Active"], + pageSize: 2147483647, + userStates: ["Active"], }) .then( function (data) { - vm.users = data.items; + vm.users = data.items.filter(function (u) { return u.id != user.id }); // remove current user from impersonation list vm.loadingUsers = false; }, function (error) { @@ -38,6 +37,10 @@ } ); } + else { + // No users to load, we're done + vm.loadingUsers = false; + } }); vm.impersonateUser = function () { diff --git a/src/Our.Umbraco.Impersonator/wwwroot/user.html b/src/Our.Umbraco.Impersonator/wwwroot/user.html index dc5c048..3209fac 100644 --- a/src/Our.Umbraco.Impersonator/wwwroot/user.html +++ b/src/Our.Umbraco.Impersonator/wwwroot/user.html @@ -1,10 +1,9 @@ -
- +
+
You are impersonating the current user. + >You are impersonating the current user.
-
+ > +
- +