Skip to content

Commit

Permalink
feat: update table (#1133)
Browse files Browse the repository at this point in the history
* feat: update tables

* fix: title table

* fix: update dependencies
  • Loading branch information
soridalac authored Oct 23, 2024
1 parent a344290 commit 8e3975d
Show file tree
Hide file tree
Showing 8 changed files with 340 additions and 50 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dependencies": {
"@salesforce/core": "^8.6.1",
"@salesforce/kit": "^3.2.2",
"@salesforce/sf-plugins-core": "^11.3.12",
"@salesforce/sf-plugins-core": "^12.0.7",
"@salesforce/ts-types": "^2.0.11"
},
"devDependencies": {
Expand Down
12 changes: 7 additions & 5 deletions src/baseCommands/user/password/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,13 @@ export abstract class UserPasswordGenerateBaseCommand extends SfCommand<Generate
this.log(`${successMsg}${EOL}${viewMsg}`);
} else {
this.log(messages.getMessage('successMultiple', [EOL]));
const columnData = {
username: { header: 'USERNAME' },
password: { header: 'PASSWORD' },
};
this.table(passwordData, columnData);
this.table({
data: passwordData,
columns: [
{ key: 'username', name: 'USERNAME' },
{ key: 'password', name: 'PASSWORD' },
],
});
}
}
}
41 changes: 32 additions & 9 deletions src/baseCommands/user/permset/assign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,41 @@ export abstract class UserPermSetAssignBaseCommand extends SfCommand<PermsetAssi

private print(): void {
if (this.failures.length > 0 && this.successes.length > 0) {
this.styledHeader('Partial Success');
this.styledHeader('Permsets Assigned');
this.table(this.successes, { name: { header: 'Username' }, value: { header: 'Permission Set Assignment' } });
this.table({
data: this.successes,
columns: [
{ key: 'name', name: 'Username' },
{ key: 'value', name: 'Permission Set Assignment' },
],
title: 'Partial Success',
});
this.log('');
this.styledHeader('Failures');
this.table(this.failures, { name: { header: 'Username' }, message: { header: 'Error Message' } });
this.table({
data: this.failures,
columns: [
{ key: 'name', name: 'Username' },
{ key: 'message', name: 'Error Message' },
],
title: 'Failures',
});
} else if (this.successes.length > 0) {
this.styledHeader('Permsets Assigned');
this.table(this.successes, { name: { header: 'Username' }, value: { header: 'Permission Set Assignment' } });
this.table({
data: this.successes,
columns: [
{ key: 'name', name: 'Username' },
{ key: 'value', name: 'Permission Set Assignment' },
],
title: 'Permsets Assigned',
});
} else if (this.failures.length > 0) {
this.styledHeader('Failures');
this.table(this.failures, { name: { header: 'Username' }, message: { header: 'Error Message' } });
this.table({
data: this.failures,
columns: [
{ key: 'name', name: 'Username' },
{ key: 'message', name: 'Error Message' },
],
title: 'Failures',
});
}
}

Expand Down
24 changes: 16 additions & 8 deletions src/baseCommands/user/permsetlicense/assign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export type PSLResult = {

type PermissionSetLicense = {
Id: string;
}
};

export const assignPSL = async ({
conn,
Expand Down Expand Up @@ -83,20 +83,28 @@ export const print = (results: PSLResult): void => {
ux.styledHeader('Partial Success');
}
if (results.successes.length > 0) {
ux.styledHeader('Permset Licenses Assigned');
ux.table(results.successes, {
name: { header: 'Username' },
value: { header: 'Permission Set License Assignment' },
ux.table({
data: results.successes,
columns: [
{ key: 'name', name: 'Username' },
{ key: 'value', name: 'Permission Set License Assignment' },
],
title: 'Permset Licenses Assigned',
});
}

if (results.failures.length > 0) {
if (results.successes.length > 0) {
ux.log('');
}

ux.styledHeader('Failures');
ux.table(results.failures, { name: { header: 'Username' }, message: { header: 'Error Message' } });
ux.table({
data: results.failures,
columns: [
{ key: 'name', name: 'Username' },
{ key: 'message', name: 'Error Message' },
],
title: 'Failures',
});
}
};

Expand Down
10 changes: 8 additions & 2 deletions src/commands/org/create/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,13 @@ export class CreateUserCommand extends SfCommand<CreateUserOutput> {
this.log(userCreatedSuccessMsg);
this.log('');
this.styledHeader('Failures');
this.table(this.failures, { name: { header: 'Action' }, message: { header: 'Error Message' } });
this.table({
data: this.failures,
columns: [
{ key: 'name', name: 'Action' },
{ key: 'message', name: 'Error Message' },
],
});
} else {
this.log(userCreatedSuccessMsg);
}
Expand All @@ -254,7 +260,7 @@ export type CreateUserOutput = {
orgId: string;
permissionSetAssignments: string[];
fields: Record<string, unknown>;
}
};

const lowerFirstLetter = (word: string): string => word[0].toLowerCase() + word.substr(1);

Expand Down
13 changes: 4 additions & 9 deletions src/commands/org/display/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,8 @@ export class DisplayUserCommand extends SfCommand<DisplayUserResult> {
}

private print(result: DisplayUserResult): void {
this.styledHeader('User Description');
this.table(
// to get proper capitalization and spacing, enter th e rows
[
this.table({
data: [
{ key: 'Username', label: result.username ?? 'unknown' },
{ key: 'Profile Name', label: result.profileName },
{ key: 'Id', label: result.id },
Expand All @@ -128,10 +126,7 @@ export class DisplayUserCommand extends SfCommand<DisplayUserResult> {
...(result.alias ? [{ key: 'Alias', label: result.alias }] : []),
...(result.password ? [{ key: 'Password', label: result.password }] : []),
] satisfies Array<{ key: string; label: string }>,
{
key: { header: 'key' },
label: { header: 'label' },
}
);
title: 'User Description',
});
}
}
22 changes: 10 additions & 12 deletions src/commands/org/list/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,16 @@ export class ListUsersCommand extends SfCommand<ListUsers> {
userId: userInfos.get(username)?.Id,
};
});

const columns = {
defaultMarker: { header: 'Default' },
alias: { header: 'Alias' },
username: { header: 'Username' },
profileName: { header: 'Profile Name' },
userId: { header: 'User Id' },
};

this.styledHeader(`Users in org ${flags['target-org']?.getOrgId()}`);
this.table(authList, columns);

this.table({
data: authList.map((authData) => ({
Default: authData.defaultMarker,
Alias: authData.alias,
Username: authData.username,
'Profile Name': authData.profileName,
'User Id': authData.userId,
})),
title: `Users in org ${flags['target-org']?.getOrgId()}`,
});
return authList;
}
}
Expand Down
Loading

0 comments on commit 8e3975d

Please sign in to comment.