File tree Expand file tree Collapse file tree 1 file changed +13
-40
lines changed
components/frontapp/actions/list-message-templates Expand file tree Collapse file tree 1 file changed +13
-40
lines changed Original file line number Diff line number Diff line change @@ -8,54 +8,27 @@ export default {
8
8
type : "action" ,
9
9
props : {
10
10
frontApp,
11
- sortBy : {
12
- type : "string" ,
13
- label : "Sort By" ,
14
- description : "Field used to sort the message templates" ,
15
- options : [
16
- "created_at" ,
17
- "updated_at" ,
11
+ maxResults : {
12
+ propDefinition : [
13
+ frontApp ,
14
+ "maxResults" ,
18
15
] ,
19
- optional : true ,
20
- } ,
21
- sortOrder : {
22
- type : "string" ,
23
- label : "Sort Order" ,
24
- description : "Order by which results should be sorted" ,
25
- options : [
26
- {
27
- label : "Ascending" ,
28
- value : "asc" ,
29
- } ,
30
- {
31
- label : "Descending" ,
32
- value : "desc" ,
33
- } ,
34
- ] ,
35
- optional : true ,
36
16
} ,
37
17
} ,
38
18
async run ( { $ } ) {
39
- const {
40
- frontApp,
41
- sortBy,
42
- sortOrder,
43
- } = this ;
44
-
45
- const response = await frontApp . listMessageTemplates ( {
19
+ const items = this . frontApp . paginate ( {
20
+ fn : this . frontApp . listMessageTemplates ,
21
+ maxResults : this . maxResults ,
46
22
$,
47
- params : {
48
- sort_by : sortBy ,
49
- sort_order : sortOrder ,
50
- } ,
51
23
} ) ;
52
24
53
- const templates = response . _results || [ ] ;
54
- const length = templates . length ;
55
- $ . export ( "$summary" , `Successfully retrieved ${ length } message template${ length === 1
25
+ const results = [ ] ;
26
+ for await ( const item of items ) {
27
+ results . push ( item ) ;
28
+ }
29
+ $ . export ( "$summary" , `Successfully retrieved ${ results ?. length } message template${ results ?. length === 1
56
30
? ""
57
31
: "s" } `) ;
58
-
59
- return response ;
32
+ return results ;
60
33
} ,
61
34
} ;
You can’t perform that action at this time.
0 commit comments