mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 17:07:15 +02:00
Generate client id menu dynamically instead of hard coding the mapping from
role to client id. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=218913784
This commit is contained in:
parent
b48061b792
commit
21f706bf24
3 changed files with 7 additions and 29 deletions
|
@ -16,8 +16,6 @@ package google.registry.ui.server.registrar;
|
|||
|
||||
import static com.google.common.net.HttpHeaders.LOCATION;
|
||||
import static com.google.common.net.HttpHeaders.X_FRAME_OPTIONS;
|
||||
import static google.registry.ui.server.registrar.AuthenticatedRegistrarAccessor.Role.ADMIN;
|
||||
import static google.registry.ui.server.registrar.AuthenticatedRegistrarAccessor.Role.OWNER;
|
||||
import static google.registry.ui.server.registrar.RegistrarConsoleModule.PARAM_CLIENT_ID;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_FORBIDDEN;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_MOVED_TEMPORARILY;
|
||||
|
@ -28,7 +26,6 @@ import com.google.appengine.api.users.UserService;
|
|||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableSetMultimap;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.io.Resources;
|
||||
import com.google.common.net.MediaType;
|
||||
|
@ -136,12 +133,7 @@ public final class ConsoleUiAction implements Runnable {
|
|||
data.put("logoutUrl", userService.createLogoutURL(PATH));
|
||||
data.put("xsrfToken", xsrfTokenManager.generateToken(user.getEmail()));
|
||||
ImmutableSetMultimap<String, Role> roleMap = registrarAccessor.getAllClientIdWithRoles();
|
||||
ImmutableSetMultimap<Role, String> roleMapInverse = roleMap.inverse();
|
||||
// TODO(guyben):just return all the clientIDs in a single list, and add an "isAdmin" or "roles"
|
||||
// item
|
||||
data.put("ownerClientIds", roleMapInverse.get(OWNER));
|
||||
data.put(
|
||||
"adminClientIds", Sets.difference(roleMapInverse.get(ADMIN), roleMapInverse.get(OWNER)));
|
||||
data.put("allClientIds", roleMap.keySet());
|
||||
// We set the initual value to the value that will show if guessClientId throws.
|
||||
String clientId = "<null>";
|
||||
try {
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
{template .main}
|
||||
{@param xsrfToken: string} /** Security token. */
|
||||
{@param clientId: string} /** Registrar client identifier. */
|
||||
{@param ownerClientIds: list<string>}
|
||||
{@param adminClientIds: list<string>}
|
||||
{@param allClientIds: list<string>} /** All registrar client identifiers for the user. */
|
||||
{@param username: string} /** Arbitrary username to display. */
|
||||
{@param logoutUrl: string} /** Generated URL for logging out of Google. */
|
||||
{@param productName: string} /** Name to display for this software product. */
|
||||
|
@ -78,8 +77,7 @@
|
|||
/** Sidebar nav. Ids on each elt for testing only. */
|
||||
{template .navbar_ visibility="private"}
|
||||
{@param clientId: string} /** Registrar client identifier. */
|
||||
{@param ownerClientIds: list<string>}
|
||||
{@param adminClientIds: list<string>}
|
||||
{@param allClientIds: list<string>}
|
||||
|
||||
<div id="reg-nav" class="{css('kd-content-sidebar')}">
|
||||
<form>
|
||||
|
@ -88,20 +86,9 @@
|
|||
class="{css('kd-button')} {css('kd-button-submit')}"
|
||||
onchange='this.form.submit()'>
|
||||
<option value="">[auto select]</option>
|
||||
{if length($ownerClientIds) > 0}
|
||||
<optgroup label="OWNER">
|
||||
{for $id in $ownerClientIds}
|
||||
<option value="{$id}" {if $id == $clientId}selected{/if}>{$id}</option>
|
||||
{/for}
|
||||
</optgroup>
|
||||
{/if}
|
||||
{if length($adminClientIds) > 0}
|
||||
<optgroup label="ADMIN">
|
||||
{for $id in $adminClientIds}
|
||||
<option value="{$id}" {if $id == $clientId}selected{/if}>{$id}</option>
|
||||
{/for}
|
||||
</optgroup>
|
||||
{/if}
|
||||
{for $id in $allClientIds}
|
||||
<option value="{$id}" {if $id == $clientId}selected{/if}>{$id}</option>
|
||||
{/for}
|
||||
</select>
|
||||
</form>
|
||||
<ul id="reg-navlist">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue