Skip to content

Commit

Permalink
feat: update table
Browse files Browse the repository at this point in the history
  • Loading branch information
soridalac committed Oct 29, 2024
1 parent 3cb702c commit d3afbdb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
10 changes: 3 additions & 7 deletions src/commands/org/list/shape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,13 @@ export class OrgShapeListCommand extends SfCommand<OrgShapeListResult[]> {

this.table({
data: orgShapes.map((shape) => ({
ALIAS: shape.alias ?? '',
USERNAME: shape.username,
'ORG ID': shape.orgId,
USERNAME: shape.username,
ALIAS: shape.alias ?? '',
'Shape ID': shape.shapeId,
'Shape Status': shape.status === 'Active' ? StandardColors.success(shape.status) : shape.status,
'CREATED BY': shape.createdBy,
'CREATED DATE': shape.createdDate,
...(shape.status === 'Active'
? {
STATUS: StandardColors.success(shape.status),
}
: {}),
})),
title: 'Org Shapes',
});
Expand Down
14 changes: 8 additions & 6 deletions src/shared/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,11 @@ export const printSingleRecordTable = (snapshotRecord: OrgSnapshot): void => {
.map(([key, value]: [string, string]) => ({
Name: capitalCase(key),
// format the datetime values
Value: ['LastModifiedDate', 'CreatedDate'].includes(key) ? dateTimeFormatter(value) : value,
}))
// null/undefined becomes empty string
.map((row) => (row.Value ? row : { ...row, Value: '' })),
Value: ['LastModifiedDate', 'CreatedDate'].includes(key) ? dateTimeFormatter(value) : value ?? '',
})),
// null/undefined becomes empty string
// .map((row) => (row.Value ? row : { ...row, Value: '' })),
columns: ['Name', 'Value'],
});
};

Expand All @@ -107,12 +108,13 @@ export const printRecordTable = (snapshotRecords: OrgSnapshot[]): void => {
new Ux().table({
// we know what columns we want, so filter out the other fields
data: snapshotRecords.map((s) => ({
// ...Object.fromEntries(Object.entries(s).filter(([key]) => Object.keys(s).includes(key))),
Id: s.Id,
'Snapshot Name': s.SnapshotName,
Status: s.Status,
'Source Org Id': s.SourceOrg,
CreatedDate: s.CreatedDate,
'Last Modified Date': s.LastModifiedDate,
'Created Date': dateTimeFormatter(s.CreatedDate),
'Last Modified Date': dateTimeFormatter(s.LastModifiedDate),
'Expiration Date': s.ExpirationDate ? new Date(s.ExpirationDate).toLocaleDateString() : '',
})),
title: `Org Snapshots [${snapshotRecords.length}]`,
Expand Down

0 comments on commit d3afbdb

Please sign in to comment.