Have a resource component receive the "registrar resource" instead of creating it

We have several "consoles" ("views" in the registrar console). They all affect the same resource - the registrar itself.

Currently, each view creates its own "RESTful resource", even though it's the same resource for all of them, meaning we have copied code and copied "URL endpoint" across multiple files.

I assume this was made so that IF one day we have a "view" to another resource, we can easily add it. But we currently don't have any such view, nor plans to add any.

So according to the YAGNI paradigm, it's better to move the resource creation outside of the console.

Also, IF we do add a view to a different resource - it'll still be more readable to have a map from the "view" to the "resource URL endpoint" alongside the existing map from the "view" to the "console"...

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213992967
This commit is contained in:
guyben 2018-09-21 09:00:45 -07:00 committed by jianglai
parent ae2c1071f1
commit 89c942b0d9
6 changed files with 26 additions and 46 deletions

View file

@ -14,7 +14,6 @@
goog.provide('registry.registrar.SecuritySettings');
goog.require('goog.Uri');
goog.require('goog.array');
goog.require('goog.dom');
goog.require('goog.dom.classlist');
@ -32,19 +31,15 @@ goog.forwardDeclare('registry.registrar.Console');
/**
* Security Settings page.
* @param {!registry.registrar.Console} console
* @param {string} xsrfToken Security token to pass back to the server.
* @param {!registry.Resource} resource the RESTful resource for the registrar.
* @constructor
* @extends {registry.ResourceComponent}
* @final
*/
registry.registrar.SecuritySettings = function(console, xsrfToken) {
registry.registrar.SecuritySettings = function(console, resource) {
registry.registrar.SecuritySettings.base(
this,
'constructor',
console,
new registry.Resource(new goog.Uri('/registrar-settings'), xsrfToken),
registry.soy.registrar.security.settings,
null);
this, 'constructor', console, resource,
registry.soy.registrar.security.settings, null);
};
goog.inherits(registry.registrar.SecuritySettings, registry.ResourceComponent);