-
Notifications
You must be signed in to change notification settings - Fork 461
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Decouple the static value 'widget' so we can extend it for enums * Map enum values into the spec, and add the ability to force reading an overriden spec since the spec lives on prod * Missed the custom field for support of openapi spec override * Final changes * Add test coverage to the apex changes * Add some toolchain safety for dev debug settings * Fix bug in check-dev-settings * Added note to say Use_Local_OpenAPI_Spec__c should always be false in prod.
- Loading branch information
Showing
14 changed files
with
1,910 additions
and
30 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
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,59 @@ | ||
#!/bin/bash | ||
# Usage: bin/check-dev-settings | ||
# Purpose: Make sure we didn't leave any developer settings enabled | ||
|
||
cd "$(dirname "$0")/.." | ||
|
||
HAS_ERROR=0 | ||
|
||
echo "🔁 Making sure we don't have any developer settings enabled"; | ||
|
||
# Check local openapi override | ||
CHECK_PATH="force-app/main/default/objects/Setup_Connection_Data__mdt/fields/Use_Local_OpenAPI_Spec__c.field-meta.xml" | ||
CHECK_DEFAULT_VALUE=`grep "defaultValue" $CHECK_PATH | sed "s/.*>\\(.*\\)<.*/\1/"` | ||
if [ "$CHECK_DEFAULT_VALUE" != "false" ]; then | ||
echo "❌ Setup_Connection_Data__mdt.Use_Local_OpenAPI_Spec__c.defaultValue is not false." | ||
HAS_ERROR=1 | ||
else | ||
echo "👍 Setup_Connection_Data__mdt.Use_Local_OpenAPI_Spec__c.defaultValue is false." | ||
fi | ||
|
||
# Check apex debug | ||
CHECK_PATH="force-app/main/default/classes" | ||
CHECK_ENABLE_DEBUG=`grep -R enableDebug $CHECK_PATH | grep true` | ||
|
||
if [ ! -z "$CHECK_ENABLE_DEBUG" ]; then | ||
echo "❌ Debug_Helper is enabled globally." | ||
HAS_ERROR=1 | ||
else | ||
echo "👍 Debug_Helper is disabled globally." | ||
fi | ||
|
||
OLD_IFS=$IFS | ||
IFS=$'\n' | ||
SEEN_FILES="" | ||
CHECK_DEBUG_HELPER=`grep -R Debug_Helper $CHECK_PATH` | ||
for line in $CHECK_DEBUG_HELPER; do | ||
filepath=`echo $line | sed "s/\\(.*\\):.*/\1/"` | ||
code=`echo $line | sed "s/.*:\\(.*\\)/\1/"` | ||
filename=`echo $filepath | sed "s/.*\\///"` | ||
# Skip | ||
if [[ $SEEN_FILES == *$filename* ]]; then | ||
continue | ||
fi | ||
if [[ $filename == *[Tt][Ee][Ss][Tt]* ]]; then | ||
echo "👍 $filename is a test, skipping..." | ||
SEEN_FILES="$SEEN_FILES $filename" | ||
else | ||
if [[ $code == *'Debug_Helper(true'* ]]; then | ||
echo "❌ Debug_Helper is enabled in $filename." | ||
HAS_ERROR=1 | ||
else | ||
echo "👍 Reference in $filename has been cleared." | ||
fi | ||
fi | ||
done | ||
|
||
IFS=$OLD_IFS | ||
|
||
exit $HAS_ERROR |
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
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
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
9 changes: 9 additions & 0 deletions
9
sfdx/force-app/main/default/lwc/dmStaticValue/dmStaticValue.html
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,9 @@ | ||
<!-- | ||
- Created by jmather-c on 5/11/23. | ||
--> | ||
|
||
<!-- Dm Static Value --> | ||
<template> | ||
<lightning-input if:false={isEnum} type="text" label="Salesforce Value" value={field.sfValue} onchange={valueChange} variant="label-hidden" placeholder="Enter Static Value..."></lightning-input> | ||
<lightning-combobox if:true={isEnum} value={field.sfValue} onchange={valueChange} variant="label-hidden" options={enumOptions}></lightning-combobox> | ||
</template> |
40 changes: 40 additions & 0 deletions
40
sfdx/force-app/main/default/lwc/dmStaticValue/dmStaticValue.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,40 @@ | ||
/** | ||
* Created by jmather-c on 5/11/23. | ||
*/ | ||
|
||
import {LightningElement, api} from 'lwc'; | ||
|
||
export default class DmStaticValue extends LightningElement { | ||
@api field; | ||
@api fieldIndex; | ||
@api sectionIndex; | ||
@api valueUpdate; | ||
|
||
get isEnum() { | ||
return this.field.enum !== undefined && this.field.enum instanceof Array; | ||
} | ||
|
||
get enumOptions() { | ||
const options = []; | ||
if (this.isEnum === false) { | ||
return options; | ||
} | ||
|
||
for (let i = 0; i < this.field.enum.length; i++) { | ||
const opt = this.field.enum[i]; | ||
options.push({value: opt, label: opt}); | ||
} | ||
|
||
return options; | ||
} | ||
|
||
valueChange(event) { | ||
this.dispatchEvent(new CustomEvent('update', { | ||
detail: { | ||
value: event.target.value, | ||
sectionIndex: parseInt(this.sectionIndex, 10), | ||
fieldIndex: parseInt(this.fieldIndex, 10), | ||
} | ||
})); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
sfdx/force-app/main/default/lwc/dmStaticValue/dmStaticValue.js-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,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>54.0</apiVersion> | ||
<description>Dm Static Value</description> | ||
<isExposed>false</isExposed> | ||
<masterLabel>Dm Static Value</masterLabel> | ||
</LightningComponentBundle> |
10 changes: 10 additions & 0 deletions
10
...efault/objects/Setup_Connection_Data__mdt/fields/Use_Local_OpenAPI_Spec__c.field-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,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<fullName>Use_Local_OpenAPI_Spec__c</fullName> | ||
<defaultValue>false</defaultValue> | ||
<description>Developer config to target using an openapi.json from Salesforce assets. This should only ever be false in production.</description> | ||
<externalId>false</externalId> | ||
<fieldManageability>DeveloperControlled</fieldManageability> | ||
<label>Use Local OpenAPI Spec</label> | ||
<type>Checkbox</type> | ||
</CustomField> |
6 changes: 6 additions & 0 deletions
6
sfdx/force-app/main/default/staticresources/OpenApiOverride.resource-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,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<StaticResource xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<cacheControl>Public</cacheControl> | ||
<contentType>text/plain</contentType> | ||
<description>OpenApiOverride</description> | ||
</StaticResource> |
Oops, something went wrong.