Skip to content

Commit

Permalink
Merge pull request #1468 from SFDO-Community/feature/sprint-feedback-…
Browse files Browse the repository at this point in the history
…2024-04

Feature/sprint feedback 2024 04
  • Loading branch information
aheber authored May 15, 2024
2 parents fbc60fa + b85f907 commit a099af2
Show file tree
Hide file tree
Showing 16 changed files with 672 additions and 530 deletions.
17 changes: 17 additions & 0 deletions dlrs/main/classes/RollupEditorController.cls
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,27 @@ public with sharing class RollupEditorController {
RollupSummaries rollupSummaries = new RollupSummaries(mdtRecords);
rollupSummaries.onValidate();
Map<String, List<String>> errorMap;

for (RollupSummary rollupSummaryRecord : rollupSummaries.Records) {
errorMap = collectErrors(rollupSummaryRecord);
}

LookupRollupSummary2__mdt existing = LookupRollupSummary2__mdt.getInstance(
lookupConfig.DeveloperName
);
if (existing != null && existing.Id != lookupConfig.Id) {
if (errorMap == null) {
errorMap = new Map<String, List<String>>();
}

if (!errorMap.containsKey('developerName')) {
errorMap.put('developerName', new List<String>());
}

errorMap.get('developerName')
.add('API name already in use by ' + existing.Id);
}

return errorMap;
}

Expand Down
2 changes: 1 addition & 1 deletion dlrs/main/classes/RollupEditorControllerTest.cls
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public with sharing class RollupEditorControllerTest {
JSON.serialize(cfg)
);
Assert.areEqual(
'{"rowLimit":["Row Limit is only supported on Last and Concatentate operators."],"parentObject":["Object does not exist."],"childObject":["Object does not exist."]}',
'{"rowLimit":["Row Limit is only supported on Last and Concatenate operators."],"parentObject":["Object does not exist."],"childObject":["Object does not exist."]}',
JSON.serialize(errors)
);
}
Expand Down
2 changes: 1 addition & 1 deletion dlrs/main/classes/RollupSummaries.cls
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ public class RollupSummaries extends fflib_SObjectDomain {
if (!operationsSupportingRowLimit.contains(operation)) {
lookupRollupSummary.Fields.RowLimit.addError(
error(
'Row Limit is only supported on Last and Concatentate operators.',
'Row Limit is only supported on Last and Concatenate operators.',
lookupRollupSummary.Record,
LookupRollupSummary__c.RowLimit__c
)
Expand Down
2 changes: 1 addition & 1 deletion dlrs/main/classes/RollupSummariesTest.cls
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ private class RollupSummariesTest {
fflib_SObjectDomain.triggerHandler(RollupSummaries.class);
System.assertEquals(1, fflib_SObjectDomain.Errors.getAll().size());
System.assertEquals(
'Row Limit is only supported on Last and Concatentate operators.',
'Row Limit is only supported on Last and Concatenate operators.',
fflib_SObjectDomain.Errors.getAll()[0].message
);
System.assertEquals(
Expand Down
12 changes: 10 additions & 2 deletions dlrs/main/lwc/classSchedulerModal/classSchedulerModal.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<template>
<lightning-modal-header label={label}></lightning-modal-header>
<lightning-modal-header label={label}>
<p class="slds-m-top_x-small" lwc:if={description}>{description}</p>
</lightning-modal-header>
<lightning-modal-body>
<lightning-accordion
allow-multiple-sections-open
Expand All @@ -13,7 +15,7 @@
<lightning-layout-item size="12">
<div class="slds-section slds-is-open">
<h3 class="slds-section__title">
Total Scheduled Jobs in the Org
Total Scheduled Jobs
({scheduledJobCount}/{totalAllowedScheduledJobs})
</h3>
<div class="slds-section__content">
Expand Down Expand Up @@ -103,8 +105,14 @@ <h3 class="slds-section__title">New Scheduled Jobs to Add</h3>
<lightning-button
label="Schedule"
onclick={handleSchedule}
disabled={scheduleIsDisabled}
></lightning-button>
</lightning-layout-item>
</lightning-layout>
<lightning-layout horizontal-align="center" lwc:if={errors}>
<lightning-layout-item padding="horizontal-small">
<span style="color: var(--lwc-colorTextError)">Error: {errors}</span>
</lightning-layout-item>
</lightning-layout>
</lightning-modal-footer>
</template>
11 changes: 11 additions & 0 deletions dlrs/main/lwc/classSchedulerModal/classSchedulerModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export default class ClassSchedulerModal extends LightningModal {
// async apex jobs
currentSchedule = [];
isLoadingCurrentSchedule = true;
errors;

currentColumns = [
{
label: "Name",
Expand Down Expand Up @@ -76,6 +78,9 @@ export default class ClassSchedulerModal extends LightningModal {
@api
templates;

@api
description;

connectedCallback() {
this.cronstrue = CronstrueFactory();
// TODO: when LWS is everywhere then we can go back to loading from Static Resource
Expand Down Expand Up @@ -157,6 +162,7 @@ export default class ClassSchedulerModal extends LightningModal {

async handleSchedule() {
try {
this.errors = undefined;
await scheduleJobs({
className: this.className,
newSchedules: this.cronStrings.map((c) => c.cronString)
Expand All @@ -168,10 +174,15 @@ export default class ClassSchedulerModal extends LightningModal {
} catch (error) {
// TODO: handle the error better
console.error(error);
this.errors = error.body.message;
}
}

handleCancel() {
this.close();
}

get scheduleIsDisabled() {
return this.cronStrings.length === 0;
}
}
4 changes: 4 additions & 0 deletions dlrs/main/lwc/cronBuilder/cronBuilder.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ lightning-datatable {
display: block;
overflow-y: auto;
}

.error {
color: var(--lwc-colorTextError);
}
9 changes: 9 additions & 0 deletions dlrs/main/lwc/cronBuilder/cronBuilder.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,15 @@ <h3 class="slds-section__title">Configure New Job Frequencies</h3>
</lightning-layout>
</lightning-tab>
</lightning-tabset>
<div
class="error"
for:each={errors}
for:item="error"
key={error}
if:true={errors.length}
>
{error}
</div>
</div>
</div>
</template>
25 changes: 24 additions & 1 deletion dlrs/main/lwc/cronBuilder/cronBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default class CronBuilder extends LightningElement {
selectedTemplate = "";

enabledSelectors = [];
errors = [];

_templates;
@api
Expand Down Expand Up @@ -305,27 +306,49 @@ export default class CronBuilder extends LightningElement {
}

buildCronStrings() {
this.errors = [];
// for minute input, each variation requires a differen Cron String
// all others can have multiple values
if (this.selectedMonths.length === 0) {
this.errors.push("Must select at least one month");
}
const months =
this.selectedMonths.length === this.allMonths.length
? "*"
: this.selectedMonths.join(",");

if (this.selectedDays.length === 0) {
this.errors.push("Must select at least one day");
}
const daysOfMonth =
this.selectedDays.length === this.allDays.length
? "*"
: this.selectedDays.join(",");

if (this.selectedWeekdays.length === 0) {
this.errors.push("Must select at least one weekday");
}
const daysOfWeek =
this.selectedWeekdays.length === this.allWeekdays.length
? "*"
: this.selectedWeekdays.join(",");

if (this.selectedHours.length === 0) {
this.errors.push("Must select at least one hour");
}
const hours =
this.selectedHours.length === this.allHours.length
? "*"
: this.selectedHours.join(",");
const seconds = "0";
// TODO: error guards
const crons = [];

if (this.selectedMinutes.length === 0) {
this.errors.push("Must select at least one minute");
}
if (this.errors.length > 0) {
return crons;
}
// for every minute
for (let min of this.selectedMinutes) {
crons.push(
Expand Down
4 changes: 4 additions & 0 deletions dlrs/main/lwc/flexiblePath/flexiblePath.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* {
--slds-c-icon-color-foreground-default: white;
}

.slds-path {
min-height: 2rem;
}
45 changes: 13 additions & 32 deletions dlrs/main/lwc/manageRollups/manageRollups.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { NavigationMixin, CurrentPageReference } from "lightning/navigation";
import getAllRollupConfigs from "@salesforce/apex/RollupEditorController.getAllRollupConfigs";
import deleteRollupConfig from "@salesforce/apex/RollupEditorController.deleteRollupConfig";
import USER_ID from "@salesforce/user/Id";
import RollupEditor from "c/rollupEditor";
import RollupEditor, { CLASS_SCHEDULER_CONFIG } from "c/rollupEditor";
import ClassSchedulerModal from "c/classSchedulerModal";

// import so we can get a namespace from it
Expand Down Expand Up @@ -210,7 +210,7 @@ export default class ManageRollups extends NavigationMixin(LightningElement) {
new ShowToastEvent({
title: "Deployment Started",
message:
"Started Metadata Record Upates in Deployment " + result.jobId,
"Started Metadata Record Updates in Deployment " + result.jobId,
variant: "info"
})
);
Expand Down Expand Up @@ -248,31 +248,7 @@ export default class ManageRollups extends NavigationMixin(LightningElement) {
}

async manageRollupJobSchedule() {
await ClassSchedulerModal.open({
label: "Schedule Rollup Job",
description: "Scheduled RollupJob to process Scheduled Items",
className: "RollupJob",
size: "small",
templates: [
{
label: "Once Every Day",
value: "daily",
selectors: ["single-hour"],
presets: { hours: ["3"] }
},
{
label: "Once Every Hour",
value: "hourly",
selectors: ["single-minute"]
},
{
label: "Every 15 minutes",
value: "every15",
selectors: [],
presets: { minutes: ["0", "15", "30", "45"] }
}
]
}).then((results) => {
await ClassSchedulerModal.open(CLASS_SCHEDULER_CONFIG).then((results) => {
if (results) {
try {
const evt = new ShowToastEvent(results);
Expand Down Expand Up @@ -349,11 +325,6 @@ export default class ManageRollups extends NavigationMixin(LightningElement) {
}
break;
case "DeploymentResult":
if (this.pendingSaveRollupName) {
const pendingRollupName = this.pendingSaveRollupName;
this.pendingSaveRollupName = undefined;
this.openEditor(pendingRollupName);
}
if (deploymentData.status === "Succeeded") {
title = "Deployment Completed!";
message = "Metadata saved successfully";
Expand All @@ -379,6 +350,16 @@ export default class ManageRollups extends NavigationMixin(LightningElement) {
variant = "error";
mode = "sticky";
}

if (this.pendingSaveRollupName) {
let pendingRollupName = this.pendingSaveRollupName;
if (deploymentData.status !== "Succeeded") {
// allows for recovery of non-saved rollup editor state
pendingRollupName = "pending-" + pendingRollupName;
}
this.pendingSaveRollupName = undefined;
this.openEditor(pendingRollupName);
}
break;
default:
break;
Expand Down
13 changes: 13 additions & 0 deletions dlrs/main/lwc/rollupEditor/rollupEditor.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
.testcodearea {
--slds-c-textarea-sizing-min-height: 300px;
}

.record-has-errors {
color: var(--lwc-colorTextError);
}

summary {
cursor: pointer;
}

details:not([open]) .summary-down,
details[open] .summary-right {
display: none;
}
Loading

0 comments on commit a099af2

Please sign in to comment.