Skip to content

Commit c1aeecd

Browse files
authored
Automatically select the default field set in LWC relatedLogEntries (#602)
* Added new LoggerParameter__mdt record DefaultLogEntryRelatedListFieldSet to control what LogEntry__c field set is used by default in App Builder * Updated LogEntryFieldSetPicklist to return a default instance of VisualEditor.DataRow, based on LoggerParameter.DEFAULT_LOG_ENTRY_RELATED_LIST_FIELD_SET * Updated sf cli to v2.24.4 to try to (yet again X 100) resolve a pipeline error about the Admin profile being removed (it hasn't, and it's not included in the packages anyway), and commented out the create-managed-package-version stage in build.yml, because the sf cli continues to be endlessly problematic
1 parent b24d1f5 commit c1aeecd

14 files changed

Lines changed: 19783 additions & 11650 deletions

File tree

.github/workflows/build.yml

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -264,46 +264,48 @@ jobs:
264264
runs-on: ubuntu-latest
265265
environment: 'Demo Org'
266266
steps:
267-
- name: 'Checkout source code'
268-
uses: actions/checkout@v3
269-
with:
270-
ref: ${{ github.event.pull_request.head.ref }}
271-
272-
- name: 'Restore node_modules cache'
273-
id: cache-npm
274-
uses: actions/cache@v3
275-
with:
276-
path: node_modules
277-
key: npm-${{ hashFiles('**/package-lock.json') }}
278-
restore-keys: |
279-
npm-${{ env.cache-name }}-
280-
npm-
281-
282-
- name: 'Install npm dependencies'
283-
if: steps.cache-npm.outputs.cache-hit != 'true'
284-
run: npm ci
285-
286-
- name: 'Authorize Dev Hub'
287-
shell: bash
288-
run: |
289-
npx sf version
290-
echo "${{ env.DEV_HUB_JWT_SERVER_KEY }}" > ./jwt-server.key
291-
npx sf org login jwt --instance-url ${{ env.DEV_HUB_AUTH_URL }} --client-id ${{ env.DEV_HUB_CONSUMER_KEY }} --username ${{ env.DEV_HUB_BOT_USERNAME }} --jwt-key-file ./jwt-server.key --set-default-dev-hub
292-
env:
293-
DEV_HUB_AUTH_URL: ${{ secrets.DEV_HUB_AUTH_URL }}
294-
DEV_HUB_BOT_USERNAME: ${{ secrets.DEV_HUB_BOT_USERNAME }}
295-
DEV_HUB_CONSUMER_KEY: ${{ secrets.DEV_HUB_CONSUMER_KEY }}
296-
DEV_HUB_JWT_SERVER_KEY: ${{ secrets.DEV_HUB_JWT_SERVER_KEY }}
297-
298-
# TODO remove this after the plugin @salesforce/packaging has been upgraded
299-
# to a new version that only looks at package directories
300-
- name: 'Temporarily delete problematic metadata'
301-
run: |
302-
rm -rf ./config/experience-cloud/
303-
rm -rf ./nebula-logger/unsorted/main/default/profiles/
304-
305-
- name: 'Create Beta Managed Package Version'
306-
run: npm run package:version:create:managed
267+
# - name: 'Checkout source code'
268+
# uses: actions/checkout@v3
269+
# with:
270+
# ref: ${{ github.event.pull_request.head.ref }}
271+
272+
# - name: 'Restore node_modules cache'
273+
# id: cache-npm
274+
# uses: actions/cache@v3
275+
# with:
276+
# path: node_modules
277+
# key: npm-${{ hashFiles('**/package-lock.json') }}
278+
# restore-keys: |
279+
# npm-${{ env.cache-name }}-
280+
# npm-
281+
282+
# - name: 'Install npm dependencies'
283+
# if: steps.cache-npm.outputs.cache-hit != 'true'
284+
# run: npm ci
285+
286+
# - name: 'Authorize Dev Hub'
287+
# shell: bash
288+
# run: |
289+
# npx sf version
290+
# echo "${{ env.DEV_HUB_JWT_SERVER_KEY }}" > ./jwt-server.key
291+
# npx sf org login jwt --instance-url ${{ env.DEV_HUB_AUTH_URL }} --client-id ${{ env.DEV_HUB_CONSUMER_KEY }} --username ${{ env.DEV_HUB_BOT_USERNAME }} --jwt-key-file ./jwt-server.key --set-default-dev-hub
292+
# env:
293+
# DEV_HUB_AUTH_URL: ${{ secrets.DEV_HUB_AUTH_URL }}
294+
# DEV_HUB_BOT_USERNAME: ${{ secrets.DEV_HUB_BOT_USERNAME }}
295+
# DEV_HUB_CONSUMER_KEY: ${{ secrets.DEV_HUB_CONSUMER_KEY }}
296+
# DEV_HUB_JWT_SERVER_KEY: ${{ secrets.DEV_HUB_JWT_SERVER_KEY }}
297+
298+
# # TODO remove this after the plugin @salesforce/packaging has been upgraded
299+
# # to a new version that only looks at package directories
300+
# - name: 'Temporarily delete problematic metadata'
301+
# run: |
302+
# rm -rf ./config/experience-cloud/
303+
304+
# - name: 'Create Beta Managed Package Version'
305+
# run: npm run package:version:create:managed
306+
307+
- name: 'Placeholder because the sf cli and its plugins are trash'
308+
run: echo hello
307309

308310
create-unlocked-package-release-candidate:
309311
name: 'Create Core Package Release Candidate'

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55

66
The most robust logger for Salesforce. Works with Apex, Lightning Components, Flow, Process Builder & Integrations. Designed for Salesforce admins, developers & architects.
77

8-
## Unlocked Package - v4.12.0
8+
## Unlocked Package - v4.12.2
99

10-
[![Install Unlocked Package in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y000001Mk4bQAC)
11-
[![Install Unlocked Package in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y000001Mk4bQAC)
10+
[![Install Unlocked Package in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y000001Mk55QAC)
11+
[![Install Unlocked Package in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y000001Mk55QAC)
1212
[![View Documentation](./images/btn-view-documentation.png)](https://jongpie.github.io/NebulaLogger/)
1313

14-
`sf package install --wait 20 --security-type AdminsOnly --package 04t5Y000001Mk4bQAC`
14+
`sf package install --wait 20 --security-type AdminsOnly --package 04t5Y000001Mk55QAC`
1515

16-
`sfdx force:package:install --wait 20 --securitytype AdminsOnly --package 04t5Y000001Mk4bQAC`
16+
`sfdx force:package:install --wait 20 --securitytype AdminsOnly --package 04t5Y000001Mk55QAC`
1717

1818
---
1919

docs/apex/Configuration/LoggerParameter.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ Provides a centralized way to load parameters for SObject handlers & plugins
1414

1515
Indicates if Nebula Logger will make an async callout to `https://api.status.salesforce.com` to get additional details about the current org, which is then stored on the Log\_\_c record. Controlled by the custom metadata record `LoggerParameter.CallStatusApi`, or `false` as the default
1616

17+
#### `DEFAULT_LOG_ENTRY_RELATED_LIST_FIELD_SET``String`
18+
19+
The name of the `LogEntry__c` field set to use as the default field set when configuring the LWC `<c-related-log-entries>` within App Builder. Controlled by the custom metadata record `LoggerParameter.DefaultLogEntryRelatedListFieldSet`, or `Related_List_Defaults` as the default
20+
1721
#### `ENABLE_LOG_ENTRY_EVENT_STREAM``Boolean`
1822

1923
Indicates if Nebula Logger's LWC `logEntryEventStream` is enabled. The component uses the Emp API, which counts towards orgs' daily delivery allocations for platform events. To help reduce usage of the daily allocation limit, orgs can disable the LWC. Controlled by the custom metadata record `LoggerParameter.EnableLogEntryEventStream`, or `true` as the default

docs/apex/Log-Management/LogEntryFieldSetPicklist.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Dynamically returns `LogEntry__c` field sets in App Builder when configuring the
1212

1313
#### `getDefaultValue()``VisualEditor.DataRow`
1414

15-
Returns a default value of null - admins must select a field set within App Builder
15+
Returns the default `LogEntry__c` field set, based on the `LoggerParameter_t` record `DefaultLogEntryRelatedListFieldSet`
1616

1717
##### Return
1818

@@ -22,7 +22,7 @@ VisualEditor.DataRow
2222

2323
**Description**
2424

25-
null (no default value)
25+
And instance of `VisualEditor.DataRow` if a valid, matching field set exists, or `null`
2626

2727
#### `getValues()``VisualEditor.DynamicPickListRows`
2828

nebula-logger/core/main/configuration/classes/LoggerParameter.cls

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,23 @@ public class LoggerParameter {
3030
private set;
3131
}
3232

33+
/**
34+
* @description The name of the `LogEntry__c` field set to use as the default field set when configuring
35+
* the LWC `<c-related-log-entries>` within App Builder.
36+
* Controlled by the custom metadata record `LoggerParameter.DefaultLogEntryRelatedListFieldSet`,
37+
* or `Related_List_Defaults` as the default
38+
*/
39+
public static final String DEFAULT_LOG_ENTRY_RELATED_LIST_FIELD_SET {
40+
get {
41+
if (DEFAULT_LOG_ENTRY_RELATED_LIST_FIELD_SET == null) {
42+
String configuredValue = getString('DefaultLogEntryRelatedListFieldSet', 'Related_List_Defaults');
43+
DEFAULT_LOG_ENTRY_RELATED_LIST_FIELD_SET = String.isNotBlank(configuredValue) ? configuredValue : '';
44+
}
45+
return DEFAULT_LOG_ENTRY_RELATED_LIST_FIELD_SET;
46+
}
47+
private set;
48+
}
49+
3350
/**
3451
* @description Indicates if Nebula Logger's LWC `logEntryEventStream` is enabled. The component uses
3552
* the Emp API, which counts towards orgs' daily delivery allocations for platform events.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<CustomMetadata
3+
xmlns="http://soap.sforce.com/2006/04/metadata"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
6+
>
7+
<label>Default Log Entry Related List Field Set</label>
8+
<protected>false</protected>
9+
<values>
10+
<field>Description__c</field>
11+
<value
12+
xsi:type="xsd:string"
13+
>The name of the LogEntry__c field set to use as the default field set when configuring the LWC &lt;c-related-log-entries&gt; within App Builder.
14+
15+
By default, the included field set partition &apos;Related_List_Defaults&apos; is used.</value>
16+
</values>
17+
<values>
18+
<field>Value__c</field>
19+
<value xsi:type="xsd:string">Related_List_Defaults</value>
20+
</values>
21+
</CustomMetadata>

nebula-logger/core/main/log-management/classes/LogEntryFieldSetPicklist.cls

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@
99
*/
1010
public without sharing class LogEntryFieldSetPicklist extends VisualEditor.DynamicPickList {
1111
/**
12-
* @description Returns a default value of null - admins must select a field set within App Builder
13-
* @return null (no default value)
12+
* @description Returns the default `LogEntry__c` field set, based on the `LoggerParameter__mdt` record `DefaultLogEntryRelatedListFieldSet`
13+
* @return And instance of `VisualEditor.DataRow` if a valid, matching field set exists, or `null`
1414
*/
1515
public override VisualEditor.DataRow getDefaultValue() {
16-
return null;
16+
if (String.isBlank(LoggerParameter.DEFAULT_LOG_ENTRY_RELATED_LIST_FIELD_SET)) {
17+
return null;
18+
}
19+
20+
Schema.FieldSet configuredFieldSet = Schema.SObjectType.LogEntry__c.fieldSets.getMap().get(LoggerParameter.DEFAULT_LOG_ENTRY_RELATED_LIST_FIELD_SET);
21+
return configuredFieldSet == null ? null : this.createDataRow(configuredFieldSet);
1722
}
1823

1924
/**
@@ -26,12 +31,14 @@ public without sharing class LogEntryFieldSetPicklist extends VisualEditor.Dynam
2631

2732
List<Schema.FieldSet> fieldSets = Schema.SObjectType.LogEntry__c.fieldSets.getMap().values();
2833
for (Schema.FieldSet fieldSet : fieldSets) {
29-
String namespacePrefix = String.isBlank(fieldSet.getNameSpace()) ? '' : fieldSet.getNameSpace() + '__';
30-
31-
VisualEditor.DataRow picklistRow = new VisualEditor.DataRow(fieldSet.getLabel(), namespacePrefix + fieldSet.getName());
32-
picklistRows.addRow(picklistRow);
34+
picklistRows.addRow(this.createDataRow(fieldSet));
3335
}
3436

3537
return picklistRows;
3638
}
39+
40+
private VisualEditor.DataRow createDataRow(Schema.FieldSet fieldSet) {
41+
String namespacePrefix = String.isBlank(fieldSet.getNameSpace()) ? '' : fieldSet.getNameSpace() + '__';
42+
return new VisualEditor.DataRow(fieldSet.getLabel(), namespacePrefix + fieldSet.getName());
43+
}
3744
}

nebula-logger/core/main/logger-engine/classes/Logger.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
global with sharing class Logger {
1616
// There's no reliable way to get the version number dynamically in Apex
1717
@TestVisible
18-
private static final String CURRENT_VERSION_NUMBER = 'v4.12.0';
18+
private static final String CURRENT_VERSION_NUMBER = 'v4.12.2';
1919
private static final System.LoggingLevel FALLBACK_LOGGING_LEVEL = System.LoggingLevel.DEBUG;
2020
private static final Set<String> IGNORED_APEX_CLASSES = initializeIgnoredApexClasses();
2121
private static final List<LogEntryEventBuilder> LOG_ENTRIES_BUFFER = new List<LogEntryEventBuilder>();

nebula-logger/core/main/logger-engine/lwc/logger/logger.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { LightningElement, api } from 'lwc';
77
import { createLoggerService } from './loggerService';
88

9-
const CURRENT_VERSION_NUMBER = 'v4.12.0';
9+
const CURRENT_VERSION_NUMBER = 'v4.12.2';
1010

1111
export default class Logger extends LightningElement {
1212
#loggerService = createLoggerService();

nebula-logger/core/tests/configuration/classes/LoggerParameter_Tests.cls

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ private class LoggerParameter_Tests {
4646
System.Assert.areEqual(mockValue, returnedValue);
4747
}
4848

49+
@IsTest
50+
static void it_should_return_constant_value_for_default_log_entry_related_list_field_set() {
51+
String mockValue = 'SomeValue';
52+
LoggerParameter__mdt mockParameter = new LoggerParameter__mdt(DeveloperName = 'DefaultLogEntryRelatedListFieldSet', Value__c = mockValue);
53+
LoggerParameter.setMock(mockParameter);
54+
55+
String returnedValue = LoggerParameter.DEFAULT_LOG_ENTRY_RELATED_LIST_FIELD_SET;
56+
57+
System.Assert.areEqual(mockValue, returnedValue);
58+
}
59+
4960
@IsTest
5061
static void it_should_return_constant_value_for_enable_log_entry_event_stream() {
5162
Boolean mockValue = false;

0 commit comments

Comments
 (0)