-
Notifications
You must be signed in to change notification settings - Fork 41
/
favorite.ts
45 lines (36 loc) · 1.37 KB
/
favorite.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { flags, SfdxCommand } from '@salesforce/command';
import { FavoriteRequestBody } from '../../../shared/typeDefs';
import { saveFavorite, favoriteFlagsName, favoriteFlagsStart } from '../../../shared/uiApiFavorites';
export default class Favorite extends SfdxCommand {
public static description = 'favorite a tab';
public static aliases = ['shane:tab:favourite'];
public static examples = [
`sfdx shane:tab:favorite -t Tab_API_Name'"
// creates a favorite
`,
`sfdx shane:tab:favorite -t someNamespace__Tab_API_Name'"
// creates a favorite for a tab in a namespace
`
];
protected static flagsConfig = {
name: favoriteFlagsName,
target: flags.string({ char: 't', required: true, description: 'API name of the tab you want to favorite' }),
start: favoriteFlagsStart
};
protected static requiresUsername = true;
public async run(): Promise<any> {
const body: FavoriteRequestBody = {
targetType: 'Tab',
target: this.flags.target,
name: this.flags.name ?? this.flags.target
};
if (this.flags.start) {
body.sortOrder = 1;
}
const result = await saveFavorite({ conn: this.org.getConnection(), body });
if (result.id.startsWith('0MV')) {
this.ux.log('Favorite Created');
}
return result;
}
}