Skip to content

Commit 0ecc509

Browse files
Feat: IP on boarding to reports framework (#277)
1 parent 71e5d7d commit 0ecc509

File tree

10 files changed

+471
-183
lines changed

10 files changed

+471
-183
lines changed

src/commands/omnistudio/migration/assess.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ export default class Assess extends OmniStudioBaseCommand {
9494
flexCardAssessmentInfos,
9595
omniAssessmentInfo,
9696
};
97-
await AssessmentReporter.generate(assesmentInfo, conn.instanceUrl);
97+
98+
await AssessmentReporter.generate(assesmentInfo, conn.instanceUrl, orgs);
9899
return assesmentInfo;
99100
}
100101
}

src/migration/omniscript.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,14 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
307307
: '') +
308308
`_${omniscript[this.namespacePrefix + 'Version__c']}`;
309309

310+
const oldName =
311+
`${existingTypeVal.val}_` +
312+
`${existingSubTypeVal.val}` +
313+
(omniscript[this.namespacePrefix + 'Language__c']
314+
? `_${omniscript[this.namespacePrefix + 'Language__c']}`
315+
: '') +
316+
`_${omniscript[this.namespacePrefix + 'Version__c']}`;
317+
310318
if (!existingTypeVal.isNameCleaned()) {
311319
warnings.push(
312320
this.messages.getMessage('changeMessage', [
@@ -342,12 +350,15 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
342350

343351
if (omniProcessType === 'OmniScript') {
344352
const type = omniscript[this.namespacePrefix + 'IsLwcEnabled__c'] ? 'LWC' : 'Angular';
353+
let migrationStatus = 'Can be Automated';
345354
if (type === 'Angular') {
346355
warnings.unshift(this.messages.getMessage('angularOSWarning'));
356+
migrationStatus = 'Need Manual Intervention';
347357
}
348358
const osAssessmentInfo: OSAssessmentInfo = {
349359
name: recordName,
350360
type: type,
361+
oldName: oldName,
351362
id: omniscript['Id'],
352363
dependenciesIP: dependencyIP,
353364
missingIP: [],
@@ -360,12 +371,14 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
360371
infos: [],
361372
warnings: warnings,
362373
errors: [],
374+
migrationStatus: migrationStatus
363375
};
364376
osAssessmentInfos.push(osAssessmentInfo);
365377
} else {
366378
const ipAssessmentInfo: IPAssessmentInfo = {
367379
name: recordName,
368380
id: omniscript['Id'],
381+
oldName: oldName,
369382
dependenciesIP: dependencyIP,
370383
dependenciesDR: dependencyDR,
371384
dependenciesOS: dependencyOS,

src/styles/reportGenerator.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@
101101

102102
.slds-table td,
103103
.slds-table th {
104-
white-space: normal;
105104
position: relative;
106105
max-width: 250px;
106+
text-align: center;
107107
}
108108

109109
.slds-table--bordered,

src/utils/interfaces.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ export interface LWCAssessmentInfo {
2525
export interface OSAssessmentInfo {
2626
name: string;
2727
id: string;
28+
oldName: string;
2829
dependenciesIP: nameLocation[];
2930
missingIP: string[];
3031
dependenciesDR: nameLocation[];
3132
missingDR: string[];
33+
migrationStatus: string;
3234
dependenciesOS: nameLocation[];
3335
missingOS: string[];
3436
dependenciesRemoteAction: nameLocation[];
@@ -42,6 +44,7 @@ export interface OSAssessmentInfo {
4244
export interface IPAssessmentInfo {
4345
name: string;
4446
id: string;
47+
oldName: string;
4548
dependenciesIP: nameLocation[];
4649
dependenciesDR: nameLocation[];
4750
dependenciesOS: nameLocation[];

src/utils/orgUtils/index.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@ interface InstalledPackage {
1010
Name: string;
1111
}
1212

13+
interface OrgDetails {
14+
Name: string;
15+
Id: string;
16+
}
17+
1318
export interface OmnistudioOrgDetails {
1419
packageDetails: PackageDetail[];
1520
omniStudioOrgPermissionEnabled: boolean;
21+
orgDetails: OrgDetails;
22+
dataModel: string;
1623
}
1724

1825
export interface PackageDetail {
@@ -260,6 +267,15 @@ export class OrgUtils {
260267
// Define the object name for querying installed packages
261268
private static readonly objectName = 'Publisher';
262269

270+
271+
// Define the fields to retrieve from the Organization object
272+
private static readonly orgFields = ['Name'];
273+
274+
// Define the object name for querying installed packages
275+
private static readonly orgObjectName = 'Organization';
276+
277+
private static readonly standardDataModel = "Standard";
278+
private static readonly customDataModel = "Custom";
263279
/**
264280
* Fetches package details (version and namespace) for specific installed packages.
265281
*
@@ -269,7 +285,6 @@ export class OrgUtils {
269285
public static async getOrgDetails(connection: Connection, namespace: string): Promise<OmnistudioOrgDetails> {
270286
//Execute apex rest resource to get omnistudio org permission
271287
const omniStudioOrgPermissionEnabled: boolean = await this.isOmniStudioOrgPermissionEnabled(connection, namespace);
272-
273288
// Query all installed packages and cast the result to InstalledPackage[]
274289
const allInstalledPackages = (await QueryTools.queryAll(
275290
connection,
@@ -278,6 +293,13 @@ export class OrgUtils {
278293
this.fields
279294
)) as unknown as InstalledPackage[];
280295

296+
const orgDetails = (await QueryTools.queryAll(
297+
connection,
298+
'',
299+
this.orgObjectName,
300+
this.orgFields
301+
))as unknown as OrgDetails;
302+
281303
const packageDetails: PackageDetail[] = allInstalledPackages
282304
// Filter packages to only include those with a namespace in the predefined list
283305
.filter((pkg) => this.namespaces.has(pkg.NamespacePrefix))
@@ -290,6 +312,8 @@ export class OrgUtils {
290312
return {
291313
packageDetails: packageDetails,
292314
omniStudioOrgPermissionEnabled: omniStudioOrgPermissionEnabled,
315+
orgDetails: orgDetails[0],
316+
dataModel: omniStudioOrgPermissionEnabled ? this.standardDataModel : this.customDataModel
293317
};
294318
}
295319

src/utils/reportGenerator/reportGenerator.ts

Lines changed: 52 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,35 @@
1-
import { Filter, ReportHeader, TableColumn, TableHeaderCell } from './reportInterfaces';
1+
import { Filter, HeaderColumn, ReportHeader, TableColumn, TableHeaderCell } from './reportInterfaces';
22

33
export function generateHtmlTable<T>(
4-
headerRows: TableHeaderCell[][],
4+
headerRows: HeaderColumn[],
55
columns: Array<TableColumn<T>>,
66
rows: T[],
77
reportHeader: ReportHeader[],
88
filters: Filter[] = [],
99
tableClass = 'slds-table slds-table_cell-buffer slds-table_bordered slds-table_striped slds-table_col-bordered',
1010
ariaLabel = ''
1111
): string {
12+
const transformedHeader: TableHeaderCell[][] = transform(headerRows);
13+
1214
const thead = `
1315
<thead>
14-
${headerRows
16+
${transformedHeader
1517
.map(
1618
(row) => `
1719
<tr>
1820
${row
19-
.map(
20-
(cell) => `
21-
<th
22-
${cell.colspan ? `colspan="${cell.colspan}"` : ''}
23-
${cell.rowspan ? `rowspan="${cell.rowspan}"` : ''}
24-
style="width:${cell?.width || 'auto'}"
25-
>
26-
<div class="filter-header">
27-
<span class="filter-label">${cell.label}</span>
28-
</div>
29-
</th>
30-
`
31-
)
21+
.map((cell: TableHeaderCell) => {
22+
const colspanAttr = cell.colspan ? `colspan="${cell.colspan}"` : '';
23+
const rowspanAttr = cell.rowspan ? `rowspan="${cell.rowspan}"` : '';
24+
const styleAttr = `style="${cell.styles ?? 'width:auto;'}"`;
25+
return `
26+
<th ${colspanAttr} ${rowspanAttr} ${styleAttr}>
27+
<div class="filter-header">
28+
<span class="filter-label">${cell.label}</span>
29+
</div>
30+
</th>
31+
`;
32+
})
3233
.join('')}
3334
</tr>
3435
`
@@ -58,7 +59,7 @@ export function generateHtmlTable<T>(
5859
oninput="filterAndSearchTable()"
5960
/>
6061
</div>
61-
62+
6263
<div class="filter-toggle-button" onclick="toggleFilterDropdown()">
6364
Filters
6465
<svg id="chevron-down" class="chevron-icon" xmlns="http://www.w3.org/2000/svg" width="10" height="10" fill="currentColor" viewBox="0 0 16 16">
@@ -118,8 +119,9 @@ export function generateHtmlTable<T>(
118119
const title: string = col.title ? col.title(row) : '';
119120
const value: string = col.filterValue(row).toString();
120121
const cellContent: string = col.cell(row);
122+
const style: string = col.styles ? col.styles(row) : '';
121123
const dataAttr: string = ['name', 'oldName'].includes(key) ? `data-name="${value.toLowerCase()}"` : '';
122-
return `<td ${dataAttr} title="${title}" key="${key}" value="${value}">${cellContent}</td>`;
124+
return `<td ${dataAttr} title="${title}" key="${key}" value="${value}" style="${style}">${cellContent}</td>`;
123125
})
124126
.join('')}
125127
</tr>
@@ -172,3 +174,35 @@ export function generateHtmlTable<T>(
172174
</div>
173175
`;
174176
}
177+
178+
function transform(columnInput): TableHeaderCell[][] {
179+
const row1 = [];
180+
const row2 = [];
181+
182+
columnInput.forEach((item) => {
183+
if (item.subColumn && item.subColumn.length > 0) {
184+
row1.push({
185+
label: item.label,
186+
colspan: item.subColumn.length,
187+
});
188+
189+
item.subColumn.forEach((sub) => {
190+
row2.push({
191+
label: sub.label,
192+
key: sub.key,
193+
});
194+
});
195+
} else {
196+
const row1Entry: TableHeaderCell = {
197+
label: item.label,
198+
};
199+
200+
if (item.rowspan) row1Entry.rowspan = Number(item.rowspan);
201+
if (item.key) row1Entry.key = item.key;
202+
203+
row1.push(row1Entry);
204+
}
205+
});
206+
207+
return [row1, row2] as unknown as TableHeaderCell[][];
208+
}
Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
2-
export interface TableHeaderCell {
3-
label: string;
4-
colspan?: number;
5-
rowspan?: number;
6-
key: string;
7-
width?: string;
8-
}
9-
102
export interface TableColumn<T> {
113
key: string;
124
cell: any;
135
filterValue: any;
146
title?: any;
7+
styles?: any;
158
}
169

1710
export interface Filter {
@@ -24,3 +17,26 @@ export interface ReportHeader {
2417
key: string;
2518
value: string;
2619
}
20+
21+
export interface ReportHeaderFormat {
22+
key: string;
23+
value: string;
24+
}
25+
26+
export interface HeaderColumn {
27+
label: string;
28+
key?: string;
29+
colspan?: number;
30+
rowspan?: number;
31+
styles?: string;
32+
subColumn?: HeaderColumn[]; // Recursive definition
33+
}
34+
35+
export interface TableHeaderCell {
36+
label: string;
37+
colspan?: number;
38+
rowspan?: number;
39+
key?: string;
40+
width?: string;
41+
styles?: string;
42+
}

0 commit comments

Comments
 (0)