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 */
registry.registrar.AdminSettings.prototype.runAfterRender = function(objArgs) {
goog.events.listen(
goog.dom.getRequiredElement('btn-ote-status'),
goog.events.EventType.CLICK,
goog.bind(
this.oteStatusCheck_, this, objArgs.xsrfToken, objArgs.clientId),
false, this);
const oteButton = goog.dom.getElement('btn-ote-status');
if (oteButton) {
goog.events.listen(
oteButton,
goog.events.EventType.CLICK,
goog.bind(
this.oteStatusCheck_, this, objArgs.xsrfToken, objArgs.clientId),
false, this);
}
};
/** @override */

View file

@ -36,11 +36,13 @@ goog.require('registry.registrar.Console');
* @param {string} announcementsEmail
* @param {string} supportPhoneNumber
* @param {string} technicalDocsUrl
* @param {string} environment
* @export
*/
registry.registrar.main = function(
xsrfToken, clientId, isAdmin, isOwner, productName, integrationEmail,
supportEmail, announcementsEmail, supportPhoneNumber, technicalDocsUrl) {
supportEmail, announcementsEmail, supportPhoneNumber, technicalDocsUrl,
environment) {
const console = new registry.registrar.Console({
xsrfToken: xsrfToken,
clientId: clientId,
@ -51,7 +53,8 @@ registry.registrar.main = function(
supportEmail: supportEmail,
announcementsEmail: announcementsEmail,
supportPhoneNumber: supportPhoneNumber,
technicalDocsUrl: technicalDocsUrl
technicalDocsUrl: technicalDocsUrl,
environment: environment,
});
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.tofu.SoyTofu;
import google.registry.config.RegistryConfig.Config;
import google.registry.config.RegistryEnvironment;
import google.registry.request.Action;
import google.registry.request.Parameter;
import google.registry.request.Response;
@ -76,6 +77,7 @@ public final class ConsoleUiAction implements Runnable {
@Inject UserService userService;
@Inject XsrfTokenManager xsrfTokenManager;
@Inject AuthResult authResult;
@Inject RegistryEnvironment environment;
@Inject @Config("logoFilename") String logoFilename;
@Inject @Config("productName") String productName;
@Inject @Config("integrationEmail") String integrationEmail;
@ -133,6 +135,7 @@ public final class ConsoleUiAction implements Runnable {
data.put("xsrfToken", xsrfTokenManager.generateToken(user.getEmail()));
ImmutableSetMultimap<String, Role> roleMap = registrarAccessor.getAllClientIdWithRoles();
data.put("allClientIds", roleMap.keySet());
data.put("environment", environment.toString());
// We set the initual value to the value that will show if guessClientId throws.
String clientId = "<null>";
try {

View file

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

View file

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