I am working on a Community using the latest Napili (Spring 16) Template. I have a page which uses a custom lightning component, that displays a list of keys belonging to the logged in user.
The page was working until the Spring 16 release. We hadn't pushed any changes as we were prepping to launch the Community. Now the page simply never stops loading the user can no longer navigate the Community or even log out.
I have checked the access="global" attribute and the forceCommunity interface, both are included.
MyProduct.cmp:
<aura:component controller="CommunityMyProductsController" implements="forceCommunity:availableForAllPageTypes" access="global">
<aura:attribute name="keys" type="List" access="global"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<!-- Use the Apex model and controller to fetch server side data -->
<ltng:require styles="/resource/SLDS0122/assets/styles/salesforce-lightning-design-system-ltng.css"/>
<div class="slds">
<h2>Active Products</h2>
<div class="slds" style="margin-top:10px;margin-left:10px;">
<table class="slds-table slds-table--bordered slds-table--striped">
<thead>
<tr>
<th scope="col"><span class="slds-truncate">Status</span></th>
<th scope="col"><span class="slds-truncate">Product Line</span></th>
<th scope="col"><span class="slds-truncate">License Activation Key</span></th>
<th scope="col"><span class="slds-truncate">Maintenance Level</span></th>
<th scope="col"><span class="slds-truncate">Start Date</span></th>
<th scope="col"><span class="slds-truncate">License Valid Date</span></th>
<th scope="col"><span class="slds-truncate"></span></th>
</tr>
</thead>
<tbody>
<aura:iteration items="{!v.keys}" var="key">
<tr>
<td>{!key.Status__c}</td>
<td>{!key.Product_Line__c}</td>
<td>{!key.Software_Key__c}</td>
<td>{!key.Maintenance_Level__c}</td>
<td>{!key.Start_Date__c}</td>
<td>{!key.License_Valid_Date__c}</td>
<td><button type="button" class="slds-button slds-button--brand" onclick="{!c.showDetails}" data-data="{!key.Software_Key__c}">New Case</button></td>
</tr>
</aura:iteration>
</tbody>
</table>
</div>
</div>
MyProductsController.js:
({
doInit: function(component, event, helper) {
//Fetch the keys from the Apex controller
helper.getMyProductList(component);
},
showDetails: function(component, event, helper) {
//Get data via "data-data" attribute from button (button itself or icon's parentNode)
var id = event.target.getAttribute("data-data") || event.target.parentNode.getAttribute("data-data")
alert("Please copy the following key to your clipboard: " + id);
},
//Call send renewal email from Apex controller
getKey: function(component, event, helper) {
var key = event.target.getAttribute("data-data");
var action = component.get("c.sendRenewalRequest");
action.setParams({
"keyId": key
});
action.setCallback(this, function(a) {
// display the product to the chrome dev console (for fun)
console.log(a.getReturnValue());
alert("Your request for renewal has been sent");
});
$A.enqueueAction(action);
},
})
And finally the Apex controller MyProductsController.cls:
public with sharing class MyProductsController {
public MyProductsController() {}
@AuraEnabled
public static List<Software_Key__c> getKeys() {
User portalUser = [SELECT Id, username, profile.name, contact.accountid FROM User WHERE Id = :UserInfo.getUserId()];
return [SELECT Id,
Name,
License_Status__c,
Maintenance_Level__c,
Start_Date__c,
Product_Line__c,
License_Valid_Date__c,
Account__c,
Software_Key__c,
License_Type__c,
Status__c,
Product_Name__c
FROM Software_Key__c
WHERE Account__c = :portalUser.contact.accountid
AND Status__c = 'Valid'
ORDER BY Product_Name__c DESC];
}
}