Only show OT&E admin actions when not in production environment

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=237061813
This commit is contained in:
jianglai 2019-03-06 09:27:36 -08:00
parent d42eeb3755
commit 204cb8e886
10 changed files with 38 additions and 19 deletions

View file

@ -54,12 +54,15 @@ registry.registrar.AdminSettings.prototype.bindToDom = function(id) {
/** @override */ /** @override */
registry.registrar.AdminSettings.prototype.runAfterRender = function(objArgs) { registry.registrar.AdminSettings.prototype.runAfterRender = function(objArgs) {
goog.events.listen( const oteButton = goog.dom.getElement('btn-ote-status');
goog.dom.getRequiredElement('btn-ote-status'), if (oteButton) {
goog.events.EventType.CLICK, goog.events.listen(
goog.bind( oteButton,
this.oteStatusCheck_, this, objArgs.xsrfToken, objArgs.clientId), goog.events.EventType.CLICK,
false, this); goog.bind(
this.oteStatusCheck_, this, objArgs.xsrfToken, objArgs.clientId),
false, this);
}
}; };
/** @override */ /** @override */

View file

@ -36,11 +36,13 @@ goog.require('registry.registrar.Console');
* @param {string} announcementsEmail * @param {string} announcementsEmail
* @param {string} supportPhoneNumber * @param {string} supportPhoneNumber
* @param {string} technicalDocsUrl * @param {string} technicalDocsUrl
* @param {string} environment
* @export * @export
*/ */
registry.registrar.main = function( registry.registrar.main = function(
xsrfToken, clientId, isAdmin, isOwner, productName, integrationEmail, xsrfToken, clientId, isAdmin, isOwner, productName, integrationEmail,
supportEmail, announcementsEmail, supportPhoneNumber, technicalDocsUrl) { supportEmail, announcementsEmail, supportPhoneNumber, technicalDocsUrl,
environment) {
const console = new registry.registrar.Console({ const console = new registry.registrar.Console({
xsrfToken: xsrfToken, xsrfToken: xsrfToken,
clientId: clientId, clientId: clientId,
@ -51,7 +53,8 @@ registry.registrar.main = function(
supportEmail: supportEmail, supportEmail: supportEmail,
announcementsEmail: announcementsEmail, announcementsEmail: announcementsEmail,
supportPhoneNumber: supportPhoneNumber, supportPhoneNumber: supportPhoneNumber,
technicalDocsUrl: technicalDocsUrl technicalDocsUrl: technicalDocsUrl,
environment: environment,
}); });
console.setUp(); console.setUp();

View file

@ -35,6 +35,7 @@ import com.google.template.soy.data.SoyMapData;
import com.google.template.soy.shared.SoyCssRenamingMap; import com.google.template.soy.shared.SoyCssRenamingMap;
import com.google.template.soy.tofu.SoyTofu; import com.google.template.soy.tofu.SoyTofu;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import google.registry.config.RegistryEnvironment;
import google.registry.request.Action; import google.registry.request.Action;
import google.registry.request.Parameter; import google.registry.request.Parameter;
import google.registry.request.Response; import google.registry.request.Response;
@ -76,6 +77,7 @@ public final class ConsoleUiAction implements Runnable {
@Inject UserService userService; @Inject UserService userService;
@Inject XsrfTokenManager xsrfTokenManager; @Inject XsrfTokenManager xsrfTokenManager;
@Inject AuthResult authResult; @Inject AuthResult authResult;
@Inject RegistryEnvironment environment;
@Inject @Config("logoFilename") String logoFilename; @Inject @Config("logoFilename") String logoFilename;
@Inject @Config("productName") String productName; @Inject @Config("productName") String productName;
@Inject @Config("integrationEmail") String integrationEmail; @Inject @Config("integrationEmail") String integrationEmail;
@ -133,6 +135,7 @@ public final class ConsoleUiAction implements Runnable {
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();
data.put("allClientIds", roleMap.keySet()); data.put("allClientIds", roleMap.keySet());
data.put("environment", environment.toString());
// 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 {

View file

@ -18,6 +18,7 @@
{template .settings} {template .settings}
{@param allowedTlds: list<string>} {@param allowedTlds: list<string>}
{@param type: string} // the registrar type, e.g. REAL, OTE, TEST, etc. {@param type: string} // the registrar type, e.g. REAL, OTE, TEST, etc.
{@param environment: string} // the server environment e.g. PRODUCTION, SANDBOX
<form name="item" class="{css('item')} {css('registrar')}"> <form name="item" class="{css('item')} {css('registrar')}">
<h1>Administrator settings</h1> <h1>Administrator settings</h1>
<table> <table>
@ -42,16 +43,20 @@
class="{css('kd-button')} {css('btn-add')}">Add</button> class="{css('kd-button')} {css('btn-add')}">Add</button>
</div> </div>
</div> </div>
<tr class="{css('kd-settings-pane-section')}"> {if $environment != 'PRODUCTION'}
<td> <tr class="{css('kd-settings-pane-section')}">
<label class="{css('setting-label')}">OT&amp;E setup page</label> <td>
<td class="{css('setting')}"> <label class="{css('setting-label')}">OT&amp;E setup page</label>
<p>Generate new OT&amp;E accounts <a href="/registrar-ote-setup">here</a> <td class="{css('setting')}">
</p></td> <p>Generate new OT&amp;E accounts <a href="/registrar-ote-setup">here</a>
</tr> </p></td>
{call .oteStatus} </tr>
{param registrarType: $type /} {/if}
{/call} {if $type == 'OTE'}
{call .oteStatus}
{param registrarType: $type /}
{/call}
{/if}
<tr class="{css('kd-settings-pane-section')}"> <tr class="{css('kd-settings-pane-section')}">
<td> <td>
<label class="{css('setting-label')}">Create new registrar</label> <label class="{css('setting-label')}">Create new registrar</label>

View file

@ -34,6 +34,7 @@
{@param announcementsEmail: string} {@param announcementsEmail: string}
{@param supportPhoneNumber: string} {@param supportPhoneNumber: string}
{@param technicalDocsUrl: string} {@param technicalDocsUrl: string}
{@param environment: string}
{call registry.soy.console.header} {call registry.soy.console.header}
{param app: 'registrar' /} {param app: 'registrar' /}
@ -82,7 +83,8 @@
{$supportEmail}, {$supportEmail},
{$announcementsEmail}, {$announcementsEmail},
{$supportPhoneNumber}, {$supportPhoneNumber},
{$technicalDocsUrl}); {$technicalDocsUrl},
{$environment});
</script> </script>
{/if} {/if}
{/template} {/template}

View file

@ -60,6 +60,7 @@ registry.registrar.ConsoleTestUtil.renderConsoleMain = function(
announcementsEmail: args.announcementsEmail || 'announcement@example.com', announcementsEmail: args.announcementsEmail || 'announcement@example.com',
supportPhoneNumber: args.supportPhoneNumber || '+1 (888) 555 0123', supportPhoneNumber: args.supportPhoneNumber || '+1 (888) 555 0123',
technicalDocsUrl: args.technicalDocsUrl || 'http://example.com/techdocs', technicalDocsUrl: args.technicalDocsUrl || 'http://example.com/techdocs',
environment: args.environment || 'UNITTEST',
}); });
}; };

View file

@ -27,6 +27,7 @@ import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserServiceFactory; import com.google.appengine.api.users.UserServiceFactory;
import com.google.common.collect.ImmutableSetMultimap; import com.google.common.collect.ImmutableSetMultimap;
import com.google.common.net.MediaType; import com.google.common.net.MediaType;
import google.registry.config.RegistryEnvironment;
import google.registry.request.auth.AuthLevel; import google.registry.request.auth.AuthLevel;
import google.registry.request.auth.AuthResult; import google.registry.request.auth.AuthResult;
import google.registry.request.auth.AuthenticatedRegistrarAccessor; import google.registry.request.auth.AuthenticatedRegistrarAccessor;
@ -78,6 +79,7 @@ public class ConsoleUiActionTest {
action.paramClientId = Optional.empty(); action.paramClientId = Optional.empty();
AuthResult authResult = AuthResult.create(AuthLevel.USER, UserAuthInfo.create(user, false)); AuthResult authResult = AuthResult.create(AuthLevel.USER, UserAuthInfo.create(user, false));
action.authResult = authResult; action.authResult = authResult;
action.environment = RegistryEnvironment.UNITTEST;
action.registrarAccessor = action.registrarAccessor =
AuthenticatedRegistrarAccessor.createForTesting( AuthenticatedRegistrarAccessor.createForTesting(

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 49 KiB

Before After
Before After