Skip to content

Commit

Permalink
Merge pull request #430 from opentable/GPT-567
Browse files Browse the repository at this point in the history
[GPT-567] Registering supported templates on componentPreview view
  • Loading branch information
matteofigus authored Apr 5, 2017
2 parents ab200cf + b869482 commit 012991c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/registry/routes/component-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var _ = require('underscore');
var urlBuilder = require('../domain/url-builder');
var getComponentFallback = require('./helpers/get-component-fallback');

function componentPreview(err, req, res, component) {
function componentPreview(err, req, res, component, templates) {
if(err) {
res.errorDetails = err.registryError || err;
res.errorCode = 'NOT_FOUND';
Expand All @@ -20,7 +20,8 @@ function componentPreview(err, req, res, component) {
component: component,
dependencies: _.keys(component.dependencies),
href: res.conf.baseUrl,
qs: urlBuilder.queryString(req.query)
qs: urlBuilder.queryString(req.query),
templates: templates
});

} else {
Expand All @@ -37,11 +38,11 @@ module.exports = function(conf, repository){

if(registryError && conf.fallbackRegistryUrl) {
return getComponentFallback.getComponentPreview(conf, req, res, registryError, function(fallbackError, fallbackComponent){
componentPreview(fallbackError, req, res, fallbackComponent);
componentPreview(fallbackError, req, res, fallbackComponent, repository.getTemplates());
});
}

componentPreview(registryError, req, res, component);
componentPreview(registryError, req, res, component, repository.getTemplates());

});
};
Expand Down
7 changes: 6 additions & 1 deletion src/registry/views/component-preview.jade
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ html
body
- var baseUrl = href.replace('http\:\/\/', '\/\/').replace('https\:\/\/', '\/\/');
oc-component(href=baseUrl+component.name+'/'+component.version+'/'+qs)
script(src=baseUrl+'oc-client/client.js')
script.
window.oc = window.oc || {};
oc.conf = oc.conf || {};
oc.conf.templates = oc.conf.templates || [];
oc.conf.templates = oc.conf.templates.concat(!{JSON.stringify(templates)});
script(src=baseUrl+'oc-client/client.js')

0 comments on commit 012991c

Please sign in to comment.