Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STENCIL-2922 Change Cornerstone to use "page_type" instead of "template_file" #1050

Merged
merged 5 commits into from
Jul 24, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 43 additions & 45 deletions assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,58 +7,56 @@ import Global from './theme/global';
const getAccount = () => import('./theme/account');
const getLogin = () => import('./theme/auth');
const pageClasses = {
'pages/account/orders/all': getAccount,
'pages/account/orders/details': getAccount,
'pages/account/addresses': getAccount,
'pages/account/add-address': getAccount,
'pages/account/add-return': getAccount,
'pages/account/add-wishlist': () => import('./theme/wishlist'),
'pages/account/recent-items': getAccount,
'pages/account/download-item': getAccount,
'pages/account/edit': getAccount,
'pages/account/inbox': getAccount,
'pages/account/return-saved': getAccount,
'pages/account/returns': getAccount,
'pages/auth/login': getLogin,
'pages/auth/account-created': getLogin,
'pages/auth/create-account': getLogin,
'pages/auth/new-password': getLogin,
'pages/auth/forgot-password': getLogin,
'pages/blog': () => import('./theme/blog'),
'pages/blog-post': () => import('./theme/blog'),
'pages/brand': () => import('./theme/brand'),
'pages/brands': () => import('./theme/brand'),
'pages/cart': () => import('./theme/cart'),
'pages/category': () => import('./theme/category'),
'pages/compare': () => import('./theme/compare'),
'pages/contact-us': () => import('./theme/contact-us'),
'pages/errors': () => import('./theme/errors'),
'pages/errors/404': () => import('./theme/404-error'),
'pages/gift-certificate/purchase': () => import('./theme/gift-certificate'),
'pages/gift-certificate/balance': () => import('./theme/gift-certificate'),
'pages/gift-certificate/redeem': () => import('./theme/gift-certificate'),
'pages/home': () => import('./theme/home'),
'pages/order-complete': () => import('./theme/order-complete'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did notice that this line is removed completely. Is this intentional ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that page does not exist in stencil. I'll remove theme/order-complete.js

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also https://github.com/bigcommerce/cornerstone/blob/master/templates/pages/order-complete.html

'pages/page': () => import('./theme/page'),
'pages/product': () => import('./theme/product'),
'pages/amp/product-options': () => import('./theme/product'),
'pages/search': () => import('./theme/search'),
'pages/rss': () => import('./theme/rss'),
'pages/sitemap': () => import('./theme/sitemap'),
'pages/subscribed': () => import('./theme/subscribe'),
'pages/account/wishlist-details': () => import('./theme/wishlist'),
'pages/account/wishlists': () => import('./theme/wishlist'),
account_orderstatus: getAccount,
account_order: getAccount,
account_addressbook: getAccount,
shippingaddressform: getAccount,
account_new_return: getAccount,
'add-wishlist': () => import('./theme/wishlist'),
account_recentitems: getAccount,
account_downloaditem: getAccount,
editaccount: getAccount,
account_inbox: getAccount,
account_saved_return: getAccount,
account_returns: getAccount,
login: getLogin,
createaccount_thanks: getLogin,
createaccount: getLogin,
getnewpassword: getLogin,
forgotpassword: getLogin,
blog: () => import('./theme/blog'),
blog_post: () => import('./theme/blog'),
brand: () => import('./theme/brand'),
brands: () => import('./theme/brand'),
cart: () => import('./theme/cart'),
category: () => import('./theme/category'),
compare: () => import('./theme/compare'),
page_contact_form: () => import('./theme/contact-us'),
error: () => import('./theme/errors'),
'404': () => import('./theme/404-error'),
giftcertificates: () => import('./theme/gift-certificate'),
giftcertificates_balance: () => import('./theme/gift-certificate'),
giftcertificates_redeem: () => import('./theme/gift-certificate'),
default: () => import('./theme/home'),
page: () => import('./theme/page'),
product: () => import('./theme/product'),
amp_product_options: () => import('./theme/product'),
search: () => import('./theme/search'),
rss: () => import('./theme/rss'),
sitemap: () => import('./theme/sitemap'),
newsletter_subscribe: () => import('./theme/subscribe'),
wishlist: () => import('./theme/wishlist'),
wishlists: () => import('./theme/wishlist'),
};

/**
* This function gets added to the global window and then called
* on page load with the current template loaded and JS Context passed in
* @todo use page_type instead of template_file (STENCIL-2922)
* @param templateFile String
* @param pageType String
* @param contextJSON
* @returns {*}
*/
window.stencilBootstrap = function stencilBootstrap(templateFile, contextJSON = null, loadGlobal = true) {
window.stencilBootstrap = function stencilBootstrap(pageType, contextJSON = null, loadGlobal = true) {
const context = JSON.parse(contextJSON || {});

return {
Expand All @@ -69,7 +67,7 @@ window.stencilBootstrap = function stencilBootstrap(templateFile, contextJSON =
let PageClass;

// Finds the appropriate class from the pageType.
const pageClassImporter = pageClasses[templateFile];
const pageClassImporter = pageClasses[pageType];
if (typeof pageClassImporter === 'function') {
PageClass = (await pageClassImporter()).default;
}
Expand Down
2 changes: 1 addition & 1 deletion templates/components/common/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</a>
{{> components/common/navigation}}

{{#if template '===' 'pages/home'}}
{{#if page_type '===' 'default'}}
<h1 class="header-logo header-logo--{{theme_settings.logo-position}}">
{{> components/common/store-logo}}
</h1>
Expand Down
2 changes: 1 addition & 1 deletion templates/layout/amp-iframe.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

<script>
// Exported in app.js
window.stencilBootstrap("{{template}}", {{ jsContext }}, false).load();
window.stencilBootstrap("{{page_type}}", {{jsContext}}, false).load();
</script>
<script type="text/javascript" charset="utf-8">
function postHeight() {
Expand Down
2 changes: 1 addition & 1 deletion templates/layout/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

<script>
// Exported in app.js
window.stencilBootstrap("{{template}}", {{jsContext}}).load();
window.stencilBootstrap("{{page_type}}", {{jsContext}}).load();
</script>

{{{footer.scripts}}}
Expand Down