Skip to content

Commit

Permalink
Create tab launcher and reorder recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
albarivas committed Jan 9, 2024
1 parent 5c71bc9 commit 637ec00
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<label>LWC Recipes Console App</label>
<navType>Console</navType>
<tabs>Hello</tabs>
<tabs>Data_Service</tabs>
<tabs>Datatable</tabs>
<tabs>Apex</tabs>
<tabs>standard-Contact</tabs>
Expand All @@ -30,7 +29,7 @@
<tabs>Record_Picker</tabs>
<tabs>Misc_Techniques</tabs>
<tabs>X3rd_Party_Libs</tabs>
<tabs>Workspace_API</tabs>
<tabs>Workspace_API_Tab_Launcher</tabs>
<uiType>Lightning</uiType>
<utilityBar>LWC_Recipes_Console_App_UtilityBar</utilityBar>
<workspaceConfig>
Expand All @@ -43,9 +42,6 @@
<mappings>
<tab>Composition</tab>
</mappings>
<mappings>
<tab>Data_Service</tab>
</mappings>
<mappings>
<tab>Datatable</tab>
</mappings>
Expand Down Expand Up @@ -86,7 +82,7 @@
<tab>Wire</tab>
</mappings>
<mappings>
<tab>Workspace_API</tab>
<tab>Workspace_API_Tab_Launcher</tab>
</mappings>
<mappings>
<tab>X3rd_Party_Libs</tab>
Expand Down
28 changes: 14 additions & 14 deletions force-app/main/default/flexipages/Workspace_API.flexipage-meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
<flexiPageRegions>
<itemInstances>
<componentInstance>
<componentName>workspaceAPISetTabLabel</componentName>
<identifier>c_workspaceAPISetTabLabel</identifier>
<componentName>workspaceAPIOpenTab</componentName>
<identifier>c_workspaceAPIOpenTab</identifier>
</componentInstance>
</itemInstances>
<itemInstances>
<componentInstance>
<componentName>workspaceAPIFocusTab</componentName>
<identifier>c_workspaceAPIFocusTab</identifier>
<componentName>workspaceAPISetTabIcon</componentName>
<identifier>c_workspaceAPISetTabIcon</identifier>
</componentInstance>
</itemInstances>
<itemInstances>
<componentInstance>
<componentName>workspaceAPIOpenSubtab</componentName>
<identifier>c_workspaceAPIOpenSubtab</identifier>
<componentName>workspaceAPIDisableTabClose</componentName>
<identifier>c_workspaceAPIDisableTabClose</identifier>
</componentInstance>
</itemInstances>
<name>region1</name>
Expand All @@ -25,14 +25,14 @@
<flexiPageRegions>
<itemInstances>
<componentInstance>
<componentName>workspaceAPISetTabIcon</componentName>
<identifier>c_workspaceAPISetTabIcon</identifier>
<componentName>workspaceAPIOpenSubtab</componentName>
<identifier>c_workspaceAPIOpenSubtab</identifier>
</componentInstance>
</itemInstances>
<itemInstances>
<componentInstance>
<componentName>workspaceAPIDisableTabClose</componentName>
<identifier>c_workspaceAPIDisableTabClose</identifier>
<componentName>workspaceAPIHighlightTab</componentName>
<identifier>c_workspaceAPIHighlightTab</identifier>
</componentInstance>
</itemInstances>
<name>region2</name>
Expand All @@ -41,14 +41,14 @@
<flexiPageRegions>
<itemInstances>
<componentInstance>
<componentName>workspaceAPIHighlightTab</componentName>
<identifier>c_workspaceAPIHighlightTab</identifier>
<componentName>workspaceAPISetTabLabel</componentName>
<identifier>c_workspaceAPISetTabLabel</identifier>
</componentInstance>
</itemInstances>
<itemInstances>
<componentInstance>
<componentName>workspaceAPIOpenTab</componentName>
<identifier>c_workspaceAPIOpenTab</identifier>
<componentName>workspaceAPIFocusTab</componentName>
<identifier>c_workspaceAPIFocusTab</identifier>
</componentInstance>
</itemInstances>
<name>region3</name>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" ?>
<FlexiPage xmlns="http://soap.sforce.com/2006/04/metadata">
<flexiPageRegions>
<itemInstances>
<componentInstance>
<componentName>workspaceAPI</componentName>
<identifier>c_workspaceAPI</identifier>
</componentInstance>
</itemInstances>
<name>region1</name>
<type>Region</type>
</flexiPageRegions>
<masterLabel>Workspace API</masterLabel>
<template>
<name>flexipage:appHomeTemplateThreeColumns</name>
</template>
<type>AppPage</type>
</FlexiPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { createElement } from 'lwc';
import WorkspaceAPI from 'c/workspaceAPI';
import { getNavigateCalledWith } from 'lightning/navigation';

describe('c-workspace-api', () => {
afterEach(() => {
// The jsdom instance is shared across test cases in a single file so reset the DOM
while (document.body.firstChild) {
document.body.removeChild(document.body.firstChild);
}
// Prevent data saved on mocks from leaking between tests
jest.clearAllMocks();
});

it('navigates to Workspace API page when Take me there! button clicked', async () => {
const API_NAME = 'Workspace_API';
const INPUT_TYPE = 'standard__navItemPage';

// Create component
const element = createElement('c-workspace-api', {
is: WorkspaceAPI
});
document.body.appendChild(element);

// Click button
const buttonEl = element.shadowRoot.querySelector('lightning-button');
buttonEl.click();

// Verify the component under test called the correct navigate event
// type and sent the expected recordId defined above
const { pageReference } = getNavigateCalledWith();
expect(pageReference.type).toBe(INPUT_TYPE);
expect(pageReference.attributes.apiName).toBe(API_NAME);
});

it('is accessible', async () => {
const element = createElement('c-workspace-api', {
is: WorkspaceAPI
});
document.body.appendChild(element);

// Check accessibility
await expect(element).toBeAccessible();
});
});
18 changes: 18 additions & 0 deletions force-app/main/default/lwc/workspaceAPI/workspaceAPI.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<template>
<lightning-card
title="Workspace API"
icon-name="standard:scheduling_workspace"
>
<div class="slds-text-align_center slds-var-m-around_medium">
To see the Workspace API examples in action, you'll need to open the
"LWC Recipes Console App". If you are already there, open the
Workspace API examples on a tab by clicking on this button.
<p class="slds-var-m-around_medium">
<lightning-button
label="Take me there!"
onclick={navigateToWorkspaceAPIExamples}
></lightning-button>
</p>
</div>
</lightning-card>
</template>
16 changes: 16 additions & 0 deletions force-app/main/default/lwc/workspaceAPI/workspaceAPI.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { LightningElement, wire } from 'lwc';
import { NavigationMixin } from 'lightning/navigation';
import getSingleContact from '@salesforce/apex/ContactController.getSingleContact';

export default class Lds extends NavigationMixin(LightningElement) {
@wire(getSingleContact) contact;

navigateToWorkspaceAPIExamples() {
this[NavigationMixin.Navigate]({
type: 'standard__navItemPage',
attributes: {
apiName: 'Workspace_API'
}
});
}
}
10 changes: 10 additions & 0 deletions force-app/main/default/lwc/workspaceAPI/workspaceAPI.js-meta.xml
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>59.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__AppPage</target>
<target>lightning__RecordPage</target>
<target>lightning__HomePage</target>
</targets>
</LightningComponentBundle>
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@
<tab>Workspace_API</tab>
<visibility>Visible</visibility>
</tabSettings>
<tabSettings>
<tab>Workspace_API_Tab_Launcher</tab>
<visibility>Visible</visibility>
</tabSettings>
<tabSettings>
<tab>GraphQL</tab>
<visibility>Visible</visibility>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<CustomTab xmlns="http://soap.sforce.com/2006/04/metadata">
<description>Created by Lightning App Builder</description>
<flexiPage>Workspace_API_Tab_Launcher</flexiPage>
<label>Workspace API Tab Launcher</label>
<motif>Custom37: Bridge</motif>
</CustomTab>

0 comments on commit 637ec00

Please sign in to comment.