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

Added features for permission-based recipe #322

Merged
merged 2 commits into from
Jul 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<CustomPermission xmlns="http://soap.sforce.com/2006/04/metadata">
<description
>For use in toggling UI features in the wireCustomPermission recipe.</description>
<label>Access Restricted UI Permission</label>
</CustomPermission>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<template>
<lightning-card title="MiscPermissionBasedUI" icon-name="custom:custom77">
<div class="slds-var-m-around_medium">
<template if:true={isRestrictedUIAccessible}>
<p>The permission set is assigned</p>
</template>
<template if:false={isRestrictedUIAccessible}>
<p>The permission set is not assigned</p>
</template>
</div>
<c-view-source source="lwc/miscPermissionBasedUI" slot="footer">
Use custom permission to conditionally render UI. To change the
rendered UI assign the
<strong>Access_Restricted_UI</strong> permission set to this user
and refresh the page.
</c-view-source>
</lightning-card>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { LightningElement } from 'lwc';

// import the permission from userPermission (standard Salesforce permissions) or
// customPermission (custom org-defined permissions)
import hasAccessRestrictedUI from '@salesforce/customPermission/accessRestrictedUIPermission';

export default class MiscPermissionBasedUI extends LightningElement {
// surface imported permission to HTML template with getter
get isRestrictedUIAccessible() {
return hasAccessRestrictedUI;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>49.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__AppPage</target>
Copy link
Contributor

Choose a reason for hiding this comment

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

Across all recipes we set all three targets: App, Home, and Record.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I fixed this. But I'd like to ask: why?

Copy link
Contributor

Choose a reason for hiding this comment

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

Simple showcase on how to set multiple targets. Also enables the learner to easily use/play with any of the components on any of the most relevant LEX experiences.

<target>lightning__RecordPage</target>
<target>lightning__HomePage</target>
</targets>
</LightningComponentBundle>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<PermissionSet xmlns="http://soap.sforce.com/2006/04/metadata">
<customPermissions>
<enabled>true</enabled>
<name>accessRestrictedUIPermission</name>
</customPermissions>
<hasActivationRequired>false</hasActivationRequired>
<label>Access_Restricted_UI</label>
</PermissionSet>