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 {
88 type : "action" ,
99 props : {
1010 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" ,
1815 ] ,
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 ,
3616 } ,
3717 } ,
3818 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 ,
4622 $,
47- params : {
48- sort_by : sortBy ,
49- sort_order : sortOrder ,
50- } ,
5123 } ) ;
5224
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
5630 ? ""
5731 : "s" } `) ;
58-
59- return response ;
32+ return results ;
6033 } ,
6134} ;
You can’t perform that action at this time.
0 commit comments