mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 17:07:15 +02:00
Migrate SoyDoc params involving maps to header param syntax
Soy has historically tolerated map accesses on weakly-typed variables. That is, if a template declared a param $p and then did $p['some_key'] in the template body, Soy would treat $p as a map even if it wasn't statically declared as one. This situation is changing with [] There are now two map types, `map` and `legacy_object_map`. We are trying to migrate every template in [] from `legacy_object_map` to `map`, leaving Soy with one (improved) map type. Because the two map types generate different JS code, Soy can no longer allow map accesses on weakly-typed variables. (If $p['some_key'] occurs in a template and the type of $p is unknown, Soy would not know what code to generate.) Every parameter whose static type is unknown (`?`) but which is inferred to be a `legacy_object_map` needs to be migrated to a `map`. We are developing tools for this in [] However, as a first step, we need to migrate the subset of these params that use the legacy SoyDoc syntax to use header param syntax with a static type of `?`. (All params declared in SoyDoc are typed as unknown, and it is a compilation error to mix SoyDoc and header param syntax in the same template, so any template that declares a SoyDoc param that is inferred to be a map needs to migrate to header param syntax.) This CL was prepared by using the tools in [] to create a list of templates declaring SoyDoc params inferred to be legacy_object_maps. This list was then fed to the existing //third_party/java_src/soy/java/com/google/template/soy/tools:ParamMigrator tool. Since this tool migrates whole files instead of individual templates, the resulting CL is a superset of the migration that is actually required. However, since the SoyDoc param syntax has been deprecated for years, and since there is little risk in migrating from one param style to another, I decided to land the superset. This migration falls under the LSC described at https://docs.google.com/document/d/1dAl-rDMp3oL0Zh_iSTaiHICwtcbLbVIy1FQ0wXSAaHs. Tested: TAP --sample for global presubmit queue [] passed FOSS tests ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=188879980
This commit is contained in:
parent
f1c29633fb
commit
d3f3d3ceb0
9 changed files with 101 additions and 97 deletions
|
@ -35,7 +35,7 @@ goog.forwardDeclare('registry.registrar.Console');
|
|||
registry.registrar.Contact = function(console) {
|
||||
registry.registrar.Contact.base(
|
||||
this, 'constructor',
|
||||
registry.soy.registrar.contact.item,
|
||||
/** @type {function()} */(registry.soy.registrar.contact.item),
|
||||
registry.soy.registrar.contactepp,
|
||||
console);
|
||||
};
|
||||
|
@ -102,7 +102,7 @@ registry.registrar.Contact.prototype.setupEditor = function(objArgs) {
|
|||
addPostalInfoBtn.setAttribute('disabled', true);
|
||||
return null;
|
||||
},
|
||||
registry.soy.registrar.contact.postalInfo,
|
||||
/** @type {function()} */ (registry.soy.registrar.contact.postalInfo),
|
||||
{
|
||||
item: {},
|
||||
localized: true,
|
||||
|
@ -116,12 +116,14 @@ registry.registrar.Contact.prototype.setupEditor = function(objArgs) {
|
|||
/** @override */
|
||||
registry.registrar.Contact.prototype.prepareCreate = function(params) {
|
||||
params.nextId = params.item['contact:id'];
|
||||
return registry.soy.registrar.contactepp.create(params).toString();
|
||||
return registry.soy.registrar.contactepp.create(
|
||||
/** @type {{clTrid: ?, item: ?}} */ (params)).toString();
|
||||
};
|
||||
|
||||
|
||||
/** @override */
|
||||
registry.registrar.Contact.prototype.prepareUpdate = function(params) {
|
||||
params.nextId = params.item['contact:id'];
|
||||
return registry.soy.registrar.contactepp.update(params).toString();
|
||||
return registry.soy.registrar.contactepp.update(
|
||||
/** @type {{clTrid: ?, item: ?}} */(params)).toString();
|
||||
};
|
||||
|
|
|
@ -35,7 +35,7 @@ goog.forwardDeclare('registry.registrar.Console');
|
|||
registry.registrar.Domain = function(console) {
|
||||
registry.registrar.Domain.base(
|
||||
this, 'constructor',
|
||||
registry.soy.registrar.domain.item,
|
||||
/** @type {function()} */ (registry.soy.registrar.domain.item),
|
||||
registry.soy.registrar.domainepp,
|
||||
console);
|
||||
};
|
||||
|
@ -79,9 +79,11 @@ registry.registrar.Domain.prototype.prepareFetch = function(params) {
|
|||
}
|
||||
params.name = idParts[0];
|
||||
params.applicationID = idParts[1];
|
||||
xml = registry.soy.registrar.domainepp.infoSunrush(params);
|
||||
xml = registry.soy.registrar.domainepp.infoSunrush(
|
||||
/** @type {{applicationID: ?, clTrid: ?, name: ?}} */(params));
|
||||
} else {
|
||||
xml = registry.soy.registrar.domainepp.info(params);
|
||||
xml = registry.soy.registrar.domainepp.info(
|
||||
/** @type {{clTrid: ?, id: ?}} */ (params));
|
||||
}
|
||||
return xml.toString();
|
||||
};
|
||||
|
@ -140,7 +142,7 @@ registry.registrar.Domain.prototype.setupEditor = function(objArgs) {
|
|||
goog.bind(function(newFieldName) {
|
||||
return registry.util.renderBeforeRow(
|
||||
'domain-contacts-footer',
|
||||
registry.soy.forms.selectRow, {
|
||||
/** @type {function()} */(registry.soy.forms.selectRow), {
|
||||
label: 'Type',
|
||||
name: newFieldName + '.@type',
|
||||
options: ['admin', 'tech', 'billing']
|
||||
|
@ -165,9 +167,11 @@ registry.registrar.Domain.prototype.prepareCreate = function(params) {
|
|||
}
|
||||
var xml;
|
||||
if (registry.registrar.Domain.SUNRUSH) {
|
||||
xml = registry.soy.registrar.domainepp.createSunrush(params);
|
||||
xml = registry.soy.registrar.domainepp.createSunrush(
|
||||
/** @type {{clTrid:?, item: ?}} */(params));
|
||||
} else {
|
||||
xml = registry.soy.registrar.domainepp.create(params);
|
||||
xml = registry.soy.registrar.domainepp.create(
|
||||
/** @type {{clTrid: ?, item: ?}} */(params));
|
||||
}
|
||||
return xml.toString();
|
||||
};
|
||||
|
@ -190,14 +194,16 @@ registry.registrar.Domain.prototype.prepareUpdate =
|
|||
|
||||
var xml;
|
||||
if (registry.registrar.Domain.SUNRUSH) {
|
||||
xml = registry.soy.registrar.domainepp.updateSunrush(params);
|
||||
xml = registry.soy.registrar.domainepp.updateSunrush(
|
||||
/** @type {{clTrid: ?, item: ?}} */(params));
|
||||
nextId += ':' + form['launch:applicationID'];
|
||||
} else {
|
||||
if (form['domain:ns'] && form['domain:ns']['domain:hostObj']) {
|
||||
this.addRem(form['domain:ns']['domain:hostObj'], 'Hosts', params);
|
||||
}
|
||||
this.addRem(form['domain:contact'], 'Contacts', params);
|
||||
xml = registry.soy.registrar.domainepp.update(params);
|
||||
xml = registry.soy.registrar.domainepp.update(
|
||||
/** @type {{clTrid: ?, item: ?}} */(params));
|
||||
}
|
||||
|
||||
return xml.toString();
|
||||
|
|
|
@ -68,7 +68,8 @@ registry.registrar.Host.prototype.setupEditor = function(objArgs) {
|
|||
/** @override */
|
||||
registry.registrar.Host.prototype.prepareCreate = function(params) {
|
||||
params.nextId = params.item['host:name'];
|
||||
return registry.soy.registrar.hostepp.create(params).toString();
|
||||
return registry.soy.registrar.hostepp.create(
|
||||
/** @type {{clTrid: ?, item: ?}} */(params)).toString();
|
||||
};
|
||||
|
||||
|
||||
|
@ -101,5 +102,6 @@ registry.registrar.Host.prototype.prepareUpdate = function(params) {
|
|||
params.addAddrs = addAddrs;
|
||||
params.remAddrs = remAddrs;
|
||||
params.nextId = form['host:chgName'];
|
||||
return registry.soy.registrar.hostepp.update(params).toString();
|
||||
return registry.soy.registrar.hostepp.update(
|
||||
/** @type {{clTrid: ?, item: ?}} */(params)).toString();
|
||||
};
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
|
||||
/**
|
||||
* Input field.
|
||||
* @param name Input field name.
|
||||
* @param? item This will be used to set default value with $item[$name].
|
||||
* @param? label Input field label.
|
||||
* @param? placeholder Placeholder text.
|
||||
*/
|
||||
{template .inputField}
|
||||
{@param name: ?} /** Input field name. */
|
||||
{@param? item: ?} /** This will be used to set default value with $item[$name]. */
|
||||
{@param? label: ?} /** Input field label. */
|
||||
{@param? placeholder: ?} /** Placeholder text. */
|
||||
<label for="{$name}">
|
||||
{if isNonnull($label)}
|
||||
{$label}
|
||||
|
@ -43,16 +43,16 @@
|
|||
|
||||
/**
|
||||
* Input field in a table row.
|
||||
* @param name Input field name.
|
||||
* @param? item This will be used to set default value with $item[$name].
|
||||
* @param? itemPrefix
|
||||
* @param? namePrefix
|
||||
* @param? label Input field label.
|
||||
* @param? description Input field description.
|
||||
* @param? placeholder Placeholder text.
|
||||
* @param? readonly
|
||||
*/
|
||||
{template .inputFieldRow}
|
||||
{@param name: ?} /** Input field name. */
|
||||
{@param? item: ?} /** This will be used to set default value with $item[$name]. */
|
||||
{@param? itemPrefix: ?}
|
||||
{@param? namePrefix: ?}
|
||||
{@param? label: ?} /** Input field label. */
|
||||
{@param? description: ?} /** Input field description. */
|
||||
{@param? placeholder: ?} /** Placeholder text. */
|
||||
{@param? readonly: ?}
|
||||
<tr class="{css('kd-settings-pane-section')}">
|
||||
<td>
|
||||
<label for="{if isNonnull($namePrefix)}{$namePrefix + $name}{else}{$name}{/if}"
|
||||
|
@ -149,14 +149,14 @@
|
|||
|
||||
/**
|
||||
* Form input row for a table.
|
||||
* @param name Input field name.
|
||||
* @param? item This will be used to set default value with $item[$name].
|
||||
* @param? itemPrefix
|
||||
* @param? namePrefix
|
||||
* @param? label Input field label.
|
||||
* @param? readonly
|
||||
*/
|
||||
{template .textareaFieldRow}
|
||||
{@param name: ?} /** Input field name. */
|
||||
{@param? item: ?} /** This will be used to set default value with $item[$name]. */
|
||||
{@param? itemPrefix: ?}
|
||||
{@param? namePrefix: ?}
|
||||
{@param? label: ?} /** Input field label. */
|
||||
{@param? readonly: ?}
|
||||
<tr>
|
||||
<td>
|
||||
<label for="{if isNonnull($namePrefix)}{$namePrefix + $name}{else}{$name}{/if}">
|
||||
|
@ -187,13 +187,13 @@
|
|||
|
||||
/**
|
||||
* Form input row for a table.
|
||||
* @param name Input field name.
|
||||
* @param value
|
||||
* @param? namePrefix
|
||||
* @param? label Input field label.
|
||||
* @param? readonly
|
||||
*/
|
||||
{template .textareaFieldRowWithValue}
|
||||
{@param name: ?} /** Input field name. */
|
||||
{@param value: ?}
|
||||
{@param? namePrefix: ?}
|
||||
{@param? label: ?} /** Input field label. */
|
||||
{@param? readonly: ?}
|
||||
<tr>
|
||||
<td>
|
||||
<label for="{if isNonnull($namePrefix)}{$namePrefix + $name}{else}{$name}{/if}">
|
||||
|
@ -220,14 +220,14 @@
|
|||
|
||||
/**
|
||||
* Select control.
|
||||
* @param name Input field name.
|
||||
* @param options Items listed in the selector.
|
||||
* @param selected Name of the selected option.
|
||||
* @param? namePrefix
|
||||
* @param? label Input field label.
|
||||
* @param? readonly
|
||||
*/
|
||||
{template .selectRow}
|
||||
{@param name: ?} /** Input field name. */
|
||||
{@param options: ?} /** Items listed in the selector. */
|
||||
{@param selected: ?} /** Name of the selected option. */
|
||||
{@param? namePrefix: ?}
|
||||
{@param? label: ?} /** Input field label. */
|
||||
{@param? readonly: ?}
|
||||
{let $forId: isNonnull($namePrefix) ? $namePrefix + $name : $name /}
|
||||
<tr>
|
||||
<td>
|
||||
|
@ -255,12 +255,10 @@
|
|||
{/template}
|
||||
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* @param values
|
||||
* @param? checkedValue the default checked value.
|
||||
*/
|
||||
{template .inputRadioWithValue}
|
||||
{@param name: ?}
|
||||
{@param values: ?}
|
||||
{@param? checkedValue: ?} /** the default checked value. */
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
{for $value in $values}
|
||||
|
|
|
@ -27,10 +27,10 @@
|
|||
|
||||
/**
|
||||
* Item view for contact.
|
||||
* @param? item
|
||||
* @param? readonly passed through to field rendering.
|
||||
*/
|
||||
{template .item}
|
||||
{@param? item: ?}
|
||||
{@param? readonly: ?} /** passed through to field rendering. */
|
||||
<form name="item" class="{css('item')} {css('contact')}">
|
||||
<h1>
|
||||
{if isNonnull($item['contact:id'])}
|
||||
|
@ -115,11 +115,11 @@
|
|||
|
||||
/**
|
||||
* Postal info.
|
||||
* @param item
|
||||
* @param namePrefix
|
||||
* @param? localized if true, this is the second, localized postalInfo.
|
||||
*/
|
||||
{template .postalInfo}
|
||||
{@param item: ?}
|
||||
{@param namePrefix: ?}
|
||||
{@param? localized: ?} /** if true, this is the second, localized postalInfo. */
|
||||
<table>
|
||||
<tr><th colspan=2>
|
||||
{if $localized}
|
||||
|
|
|
@ -19,10 +19,10 @@
|
|||
* present, for compatibility with the server. */
|
||||
/**
|
||||
* Contact create request.
|
||||
* @param item
|
||||
* @param clTrid
|
||||
*/
|
||||
{template .create stricthtml="false"}
|
||||
{@param item: ?}
|
||||
{@param clTrid: ?}
|
||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<command>
|
||||
<create>
|
||||
|
@ -60,10 +60,10 @@
|
|||
* present, for compatibility with the server. */
|
||||
/**
|
||||
* Contact update request.
|
||||
* @param item
|
||||
* @param clTrid
|
||||
*/
|
||||
{template .update stricthtml="false"}
|
||||
{@param item: ?}
|
||||
{@param clTrid: ?}
|
||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<command>
|
||||
<update>
|
||||
|
@ -101,10 +101,10 @@
|
|||
|
||||
/**
|
||||
* Contact info request.
|
||||
* @param id
|
||||
* @param clTrid
|
||||
*/
|
||||
{template .info stricthtml="false"}
|
||||
{@param id: ?}
|
||||
{@param clTrid: ?}
|
||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<command>
|
||||
<info>
|
||||
|
|
|
@ -27,11 +27,11 @@
|
|||
|
||||
/**
|
||||
* Item view for domain.
|
||||
* @param item
|
||||
* @param? readonly passed through to field rendering.
|
||||
* @param? allowSmd optional flag to allow sunrush smd applications.
|
||||
*/
|
||||
{template .item}
|
||||
{@param item: ?}
|
||||
{@param? readonly: ?} /** passed through to field rendering. */
|
||||
{@param? allowSmd: ?} /** optional flag to allow sunrush smd applications. */
|
||||
{let $isEdit: isNonnull($item['domain:name']) /}
|
||||
<form name="item" class="{css('item')} {css('domain')}">
|
||||
<h1>
|
||||
|
@ -184,9 +184,9 @@
|
|||
/* XXX: Should change support for admin/tech. */
|
||||
/**
|
||||
* Update domain. Includes sunrush applicationId if present.
|
||||
* @param? item
|
||||
*/
|
||||
{template .update}
|
||||
{@param? item: ?}
|
||||
<form name="item" class="{css('item')} {css('domain')}">
|
||||
<h1>{$item['domain:name']['keyValue']}</h1>
|
||||
<table>
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
/* General Availability. Sunrush down below. */
|
||||
/**
|
||||
* Domain create request.
|
||||
* @param item
|
||||
* @param clTrid
|
||||
*/
|
||||
{template .create stricthtml="false"}
|
||||
{@param item: ?}
|
||||
{@param clTrid: ?}
|
||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<command>
|
||||
<create>
|
||||
|
@ -58,10 +58,10 @@
|
|||
|
||||
/**
|
||||
* Domain info request.
|
||||
* @param id
|
||||
* @param clTrid
|
||||
*/
|
||||
{template .info stricthtml="false"}
|
||||
{@param id: ?}
|
||||
{@param clTrid: ?}
|
||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<command>
|
||||
<info>
|
||||
|
@ -77,14 +77,14 @@
|
|||
|
||||
/**
|
||||
* Domain update request.
|
||||
* @param item
|
||||
* @param clTrid
|
||||
* @param? addHosts list of hostObj to add.
|
||||
* @param? remHosts list of hostObj to remove.
|
||||
* @param? addContacts list of contact to add.
|
||||
* @param? remContacts list of contact to remove.
|
||||
*/
|
||||
{template .update stricthtml="false"}
|
||||
{@param item: ?}
|
||||
{@param clTrid: ?}
|
||||
{@param? addHosts: ?} /** list of hostObj to add. */
|
||||
{@param? remHosts: ?} /** list of hostObj to remove. */
|
||||
{@param? addContacts: ?} /** list of contact to add. */
|
||||
{@param? remContacts: ?} /** list of contact to remove. */
|
||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<command>
|
||||
<update>
|
||||
|
@ -118,12 +118,10 @@
|
|||
{/template}
|
||||
|
||||
|
||||
/**
|
||||
* @param isAdd
|
||||
* @param? hosts
|
||||
* @param? contacts
|
||||
*/
|
||||
{template .addRem}
|
||||
{@param isAdd: ?}
|
||||
{@param? hosts: ?}
|
||||
{@param? contacts: ?}
|
||||
{let $tagName: $isAdd ? 'domain:add' : 'domain:rem' /}
|
||||
<{$tagName}>
|
||||
{if isNonnull($hosts)}
|
||||
|
@ -145,10 +143,10 @@
|
|||
/* Sunrush. */
|
||||
/**
|
||||
* Domain create request for sunrush.
|
||||
* @param item
|
||||
* @param clTrid
|
||||
*/
|
||||
{template .createSunrush stricthtml="false"}
|
||||
{@param item: ?}
|
||||
{@param clTrid: ?}
|
||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<command>
|
||||
<create>
|
||||
|
@ -188,11 +186,11 @@
|
|||
|
||||
/**
|
||||
* Domain info request during sunrush.
|
||||
* @param name
|
||||
* @param applicationID
|
||||
* @param clTrid
|
||||
*/
|
||||
{template .infoSunrush stricthtml="false"}
|
||||
{@param name: ?}
|
||||
{@param applicationID: ?}
|
||||
{@param clTrid: ?}
|
||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<command>
|
||||
<info>
|
||||
|
@ -216,10 +214,10 @@
|
|||
|
||||
/**
|
||||
* Domain update request.
|
||||
* @param item
|
||||
* @param clTrid
|
||||
*/
|
||||
{template .updateSunrush stricthtml="false"}
|
||||
{@param item: ?}
|
||||
{@param clTrid: ?}
|
||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<command>
|
||||
<update>
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
|
||||
/**
|
||||
* Host create request.
|
||||
* @param item
|
||||
* @param clTrid
|
||||
*/
|
||||
{template .create stricthtml="false"}
|
||||
{@param item: ?}
|
||||
{@param clTrid: ?}
|
||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<command>
|
||||
<create>
|
||||
|
@ -42,12 +42,12 @@
|
|||
|
||||
/**
|
||||
* Host update request.
|
||||
* @param item
|
||||
* @param clTrid
|
||||
* @param? addAddrs list of addrs to add.
|
||||
* @param? remAddrs list of addrs to remove.
|
||||
*/
|
||||
{template .update stricthtml="false"}
|
||||
{@param item: ?}
|
||||
{@param clTrid: ?}
|
||||
{@param? addAddrs: ?} /** list of addrs to add. */
|
||||
{@param? remAddrs: ?} /** list of addrs to remove. */
|
||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<command>
|
||||
<update>
|
||||
|
@ -76,10 +76,10 @@
|
|||
|
||||
/**
|
||||
* Host info request.
|
||||
* @param clTrid
|
||||
* @param id The hostname (named "id" to preserve component API).
|
||||
*/
|
||||
{template .info stricthtml="false"}
|
||||
{@param clTrid: ?}
|
||||
{@param id: ?} /** The hostname (named "id" to preserve component API). */
|
||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<command>
|
||||
<info>
|
||||
|
@ -93,11 +93,9 @@
|
|||
{/template}
|
||||
|
||||
|
||||
/**
|
||||
* @param isAdd
|
||||
* @param? addrs
|
||||
*/
|
||||
{template .addRem}
|
||||
{@param isAdd: ?}
|
||||
{@param? addrs: ?}
|
||||
{let $tagName: $isAdd ? 'host:add' : 'host:rem' /}
|
||||
{if length($addrs) > 0}
|
||||
<{$tagName}>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue