-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from tsalb/message-service-enhancements
Message service enhancements
- Loading branch information
Showing
30 changed files
with
741 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,22 +4,23 @@ | |
"path": "utils-core", | ||
"default": true, | ||
"package": "LWC Utils", | ||
"versionName": "ver 1.5.4", | ||
"versionNumber": "1.5.4.NEXT", | ||
"versionName": "ver 1.6.0", | ||
"versionNumber": "1.6.0.NEXT", | ||
"postInstallUrl": "https://github.com/tsalb/lwc-utils/releases", | ||
"releaseNotesUrl": "https://github.com/tsalb/lwc-utils/releases" | ||
}, | ||
{ | ||
"path": "utils-recipes", | ||
"default": false, | ||
"package": "LWC Utils Recipes", | ||
"versionName": "ver 1.5.4", | ||
"versionNumber": "1.5.4.NEXT", | ||
"versionName": "ver 1.6.0", | ||
"versionNumber": "1.6.0.NEXT", | ||
"postInstallUrl": "https://github.com/tsalb/lwc-utils/releases", | ||
"releaseNotesUrl": "https://github.com/tsalb/lwc-utils/releases", | ||
"dependencies": [ | ||
{ | ||
"package": "LWC [email protected]" | ||
"package": "LWC Utils", | ||
"versionNumber": "1.6.0.LATEST" | ||
} | ||
] | ||
} | ||
|
@@ -29,10 +30,9 @@ | |
"sourceApiVersion": "51.0", | ||
"packageAliases": { | ||
"LWC Utils Recipes": "0Ho1Q000000blJnSAI", | ||
"LWC Utils Recipes@1.5.4-1": "04t1Q000001Qi2jQAC", | ||
"LWC Utils Recipes@1.6.0-1": "04t1Q000001MRpjQAG", | ||
"LWC Utils": "0Ho1Q000000blJiSAI", | ||
"LWC [email protected]": "04t1Q000001QhyDQAS", | ||
"LWC [email protected]": "04t1Q000001Qi0sQAC", | ||
"LWC [email protected]": "04t1Q000001Qi2eQAC" | ||
"LWC [email protected]": "04t1Q000001Qi2eQAC", | ||
"LWC [email protected]": "04t1Q000001MRpeQAG" | ||
} | ||
} |
20 changes: 17 additions & 3 deletions
20
utils-core/main/default/aura/MessageServiceHandler/MessageServiceHandler.cmp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,19 @@ | ||
<aura:component implements="flexipage:availableForAllPageTypes, lightning:utilityItem" access="global"> | ||
<c:DialogService aura:id="dialogService" /> | ||
<c:messageService aura:id="messageService" onopendialog="{! c.handleDialogService }" /> | ||
<aura:component | ||
implements="flexipage:availableForAllPageTypes,forceCommunity:availableForAllPageTypes,lightning:utilityItem,force:hasRecordId" | ||
access="global" | ||
> | ||
<c:messageService | ||
aura:id="messageService" | ||
onopendialog="{! c.handleDialogService }" | ||
onworkspaceapi="{! c.handleWorkspaceApi }" | ||
onrecordedit="{! c.handleRecordEdit }" | ||
onrecordcreate="{! c.handleRecordCreate }" | ||
/> | ||
|
||
<c:singleton aura:id="singleton" /> | ||
<c:dialogService aura:id="dialogService" /> | ||
<c:workspaceService aura:id="workspaceService" /> | ||
|
||
<aura:attribute name="customBoundary" type="String" /> | ||
<aura:handler name="init" value="{! this }" action="{! c.doInit }" /> | ||
</aura:component> |
7 changes: 7 additions & 0 deletions
7
utils-core/main/default/aura/MessageServiceHandler/MessageServiceHandler.design
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<design:component label="Message Service Handler"> | ||
<design:attribute | ||
name="customBoundary" | ||
label="Custom Boundary" | ||
description="Use any String or $recordId (if available, otherwise it will be null). Useful if you want granular control of which boundaries this handler can listen to." | ||
/> | ||
</design:component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
utils-core/main/default/aura/WorkspaceService/WorkspaceService.cmp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<aura:component> | ||
<c:messageService aura:id="messageService"></c:messageService> | ||
<c:singleton aura:id="singleton" /> | ||
<lightning:workspaceAPI aura:id="workspaceApi" /> | ||
|
||
<aura:method name="openTab" action="{! c.handleOpenTab }"> | ||
<aura:attribute name="config" type="Object" /> | ||
</aura:method> | ||
|
||
<aura:method name="openSubtab" action="{! c.handleOpenSubtab }"> | ||
<aura:attribute name="config" type="Object" /> | ||
</aura:method> | ||
|
||
<aura:method name="closeTabByTitle" action="{! c.handleCloseTabByTitle }"> | ||
<aura:attribute name="config" type="Object" /> | ||
</aura:method> | ||
</aura:component> |
5 changes: 5 additions & 0 deletions
5
utils-core/main/default/aura/WorkspaceService/WorkspaceService.cmp-meta.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<AuraDefinitionBundle xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>51.0</apiVersion> | ||
<description>A Lightning Component Bundle</description> | ||
</AuraDefinitionBundle> |
3 changes: 3 additions & 0 deletions
3
utils-core/main/default/aura/WorkspaceService/WorkspaceService.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.THIS { | ||
display: none; | ||
} |
102 changes: 102 additions & 0 deletions
102
utils-core/main/default/aura/WorkspaceService/WorkspaceServiceController.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/** | ||
* BSD 3-Clause License | ||
* | ||
* Copyright (c) 2021, [email protected] | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* - Redistributions of source code must retain the above copyright notice, this | ||
* list of conditions and the following disclaimer. | ||
* | ||
* - Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* | ||
* - Neither the name of the copyright holder nor the names of its | ||
* contributors may be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
({ | ||
handleOpenTab: function (component, event, helper) { | ||
const params = event.getParam('arguments'); | ||
const messageService = helper.messageService(component); | ||
const singleton = helper.singleton(component); | ||
const workspace = helper.workspaceApi(component); | ||
|
||
workspace | ||
.openTab(params.config) | ||
.then(tabId => { | ||
const successPayload = { | ||
tabId: tabId | ||
}; | ||
messageService.publish({ key: 'opentabresolve', value: successPayload }); | ||
}) | ||
.catch(err => { | ||
console.error(err); | ||
const errorPayload = { | ||
error: err | ||
}; | ||
messageService.publish({ key: 'opentabresolve', value: errorPayload }); | ||
}); | ||
|
||
singleton.setIsMessaging(false); | ||
}, | ||
handleOpenSubtab: function (component, event, helper) { | ||
const params = event.getParam('arguments'); | ||
const messageService = helper.messageService(component); | ||
const singleton = helper.singleton(component); | ||
const workspace = helper.workspaceApi(component); | ||
|
||
// Try to open subtab from current tab | ||
if (!params.config.parentTabId) { | ||
workspace.getEnclosingTabId().then(result => { | ||
params.config.parentTabId = result; | ||
}); | ||
} | ||
workspace | ||
.openSubtab(params.config) | ||
.then(tabId => { | ||
const successPayload = { | ||
tabId: tabId | ||
}; | ||
messageService.publish({ key: 'opensubtabresolve', value: successPayload }); | ||
}) | ||
.catch(err => { | ||
console.error(err); | ||
const errorPayload = { | ||
error: err | ||
}; | ||
messageService.publish({ key: 'opensubtabresolve', value: errorPayload }); | ||
}); | ||
|
||
singleton.setIsMessaging(false); | ||
}, | ||
handleCloseTabByTitle: function (component, event, helper) { | ||
const params = event.getParam('arguments'); | ||
const singleton = helper.singleton(component); | ||
const workspace = helper.workspaceApi(component); | ||
|
||
workspace.getAllTabInfo().then(allTabInfo => { | ||
for (let tab of allTabInfo) { | ||
if (tab.title === params.config.title) { | ||
workspace.closeTab({ tabId: tab.tabId }); | ||
} | ||
} | ||
}); | ||
singleton.setIsMessaging(false); | ||
} | ||
}); |
43 changes: 43 additions & 0 deletions
43
utils-core/main/default/aura/WorkspaceService/WorkspaceServiceHelper.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* BSD 3-Clause License | ||
* | ||
* Copyright (c) 2021, [email protected] | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* - Redistributions of source code must retain the above copyright notice, this | ||
* list of conditions and the following disclaimer. | ||
* | ||
* - Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* | ||
* - Neither the name of the copyright holder nor the names of its | ||
* contributors may be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
({ | ||
messageService: function (component) { | ||
return component.find('messageService'); | ||
}, | ||
singleton: function (component) { | ||
return component.find('singleton'); | ||
}, | ||
workspaceApi: function (component) { | ||
return component.find('workspaceApi'); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.