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.LOCATION;
|
||||||
import static com.google.common.net.HttpHeaders.X_FRAME_OPTIONS;
|
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 google.registry.ui.server.registrar.RegistrarConsoleModule.PARAM_CLIENT_ID;
|
||||||
import static javax.servlet.http.HttpServletResponse.SC_FORBIDDEN;
|
import static javax.servlet.http.HttpServletResponse.SC_FORBIDDEN;
|
||||||
import static javax.servlet.http.HttpServletResponse.SC_MOVED_TEMPORARILY;
|
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.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.collect.ImmutableSetMultimap;
|
import com.google.common.collect.ImmutableSetMultimap;
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import com.google.common.io.Resources;
|
import com.google.common.io.Resources;
|
||||||
import com.google.common.net.MediaType;
|
import com.google.common.net.MediaType;
|
||||||
|
@ -136,12 +133,7 @@ public final class ConsoleUiAction implements Runnable {
|
||||||
data.put("logoutUrl", userService.createLogoutURL(PATH));
|
data.put("logoutUrl", userService.createLogoutURL(PATH));
|
||||||
data.put("xsrfToken", xsrfTokenManager.generateToken(user.getEmail()));
|
data.put("xsrfToken", xsrfTokenManager.generateToken(user.getEmail()));
|
||||||
ImmutableSetMultimap<String, Role> roleMap = registrarAccessor.getAllClientIdWithRoles();
|
ImmutableSetMultimap<String, Role> roleMap = registrarAccessor.getAllClientIdWithRoles();
|
||||||
ImmutableSetMultimap<Role, String> roleMapInverse = roleMap.inverse();
|
data.put("allClientIds", roleMap.keySet());
|
||||||
// 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)));
|
|
||||||
// We set the initual value to the value that will show if guessClientId throws.
|
// We set the initual value to the value that will show if guessClientId throws.
|
||||||
String clientId = "<null>";
|
String clientId = "<null>";
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -23,8 +23,7 @@
|
||||||
{template .main}
|
{template .main}
|
||||||
{@param xsrfToken: string} /** Security token. */
|
{@param xsrfToken: string} /** Security token. */
|
||||||
{@param clientId: string} /** Registrar client identifier. */
|
{@param clientId: string} /** Registrar client identifier. */
|
||||||
{@param ownerClientIds: list<string>}
|
{@param allClientIds: list<string>} /** All registrar client identifiers for the user. */
|
||||||
{@param adminClientIds: list<string>}
|
|
||||||
{@param username: string} /** Arbitrary username to display. */
|
{@param username: string} /** Arbitrary username to display. */
|
||||||
{@param logoutUrl: string} /** Generated URL for logging out of Google. */
|
{@param logoutUrl: string} /** Generated URL for logging out of Google. */
|
||||||
{@param productName: string} /** Name to display for this software product. */
|
{@param productName: string} /** Name to display for this software product. */
|
||||||
|
@ -78,8 +77,7 @@
|
||||||
/** Sidebar nav. Ids on each elt for testing only. */
|
/** Sidebar nav. Ids on each elt for testing only. */
|
||||||
{template .navbar_ visibility="private"}
|
{template .navbar_ visibility="private"}
|
||||||
{@param clientId: string} /** Registrar client identifier. */
|
{@param clientId: string} /** Registrar client identifier. */
|
||||||
{@param ownerClientIds: list<string>}
|
{@param allClientIds: list<string>}
|
||||||
{@param adminClientIds: list<string>}
|
|
||||||
|
|
||||||
<div id="reg-nav" class="{css('kd-content-sidebar')}">
|
<div id="reg-nav" class="{css('kd-content-sidebar')}">
|
||||||
<form>
|
<form>
|
||||||
|
@ -88,20 +86,9 @@
|
||||||
class="{css('kd-button')} {css('kd-button-submit')}"
|
class="{css('kd-button')} {css('kd-button-submit')}"
|
||||||
onchange='this.form.submit()'>
|
onchange='this.form.submit()'>
|
||||||
<option value="">[auto select]</option>
|
<option value="">[auto select]</option>
|
||||||
{if length($ownerClientIds) > 0}
|
{for $id in $allClientIds}
|
||||||
<optgroup label="OWNER">
|
<option value="{$id}" {if $id == $clientId}selected{/if}>{$id}</option>
|
||||||
{for $id in $ownerClientIds}
|
{/for}
|
||||||
<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}
|
|
||||||
</select>
|
</select>
|
||||||
</form>
|
</form>
|
||||||
<ul id="reg-navlist">
|
<ul id="reg-navlist">
|
||||||
|
|
|
@ -62,8 +62,7 @@ registry.registrar.ConsoleTestUtil.renderConsoleMain = function(
|
||||||
logoutUrl: args.logoutUrl || 'https://logout.url.com',
|
logoutUrl: args.logoutUrl || 'https://logout.url.com',
|
||||||
isAdmin: goog.isDefAndNotNull(args.isAdmin) ? args.isAdmin : true,
|
isAdmin: goog.isDefAndNotNull(args.isAdmin) ? args.isAdmin : true,
|
||||||
clientId: args.clientId || 'ignore',
|
clientId: args.clientId || 'ignore',
|
||||||
ownerClientIds: args.ownerClientIds || ['owner'],
|
allClientIds: args.allClientIds || ['clientId1', 'clientId2'],
|
||||||
adminClientIds: args.adminClientIds || ['admin'],
|
|
||||||
logoFilename: args.logoFilename || 'logo.png',
|
logoFilename: args.logoFilename || 'logo.png',
|
||||||
productName: args.productName || 'Nomulus',
|
productName: args.productName || 'Nomulus',
|
||||||
integrationEmail: args.integrationEmail || 'integration@example.com',
|
integrationEmail: args.integrationEmail || 'integration@example.com',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue