Skip to content

Commit d65cb84

Browse files
committed
new components
1 parent 9c2b86d commit d65cb84

File tree

13 files changed

+1236
-33
lines changed

13 files changed

+1236
-33
lines changed

components/teamwork/actions/create-user/create-user.mjs

Lines changed: 488 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import app from "../../teamwork.app.mjs";
2+
3+
export default {
4+
key: "teamwork-get-user",
5+
name: "Get User",
6+
description: "Get a user by ID. [See the documentation](https://apidocs.teamwork.com/docs/teamwork/v1/people/get-people-id-json)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
peopleId: {
12+
propDefinition: [
13+
app,
14+
"peopleId",
15+
],
16+
label: "User ID",
17+
description: "The ID of the user/person to get",
18+
},
19+
},
20+
async run({ $ }) {
21+
const user = await this.app.getPerson(this.peopleId, $);
22+
$.export("$summary", `Found user ${user["first-name"]} ${user["last-name"]}`);
23+
return user;
24+
},
25+
};
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import app from "../../teamwork.app.mjs";
2+
3+
export default {
4+
key: "teamwork-list-users",
5+
name: "List Users",
6+
description: "List all users. [See the documentation](https://apidocs.teamwork.com/docs/teamwork/v1/people/get-people-json)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
sort: {
12+
type: "string",
13+
label: "Sort",
14+
description: "The field to sort by",
15+
optional: true,
16+
options: [
17+
"company",
18+
"logincount",
19+
"lastlogin",
20+
"projectlastactive",
21+
"firstName",
22+
"lastName",
23+
"title",
24+
"dateAdded",
25+
],
26+
},
27+
sortDirection: {
28+
type: "string",
29+
label: "Sort Direction",
30+
description: "The direction to sort by",
31+
optional: true,
32+
options: [
33+
"asc",
34+
"desc",
35+
],
36+
},
37+
maxResults: {
38+
type: "integer",
39+
label: "Max Results",
40+
description: "The maximum number of results to return",
41+
optional: true,
42+
default: 100,
43+
},
44+
},
45+
async run({ $ }) {
46+
let total, count = 0, page = 1;;
47+
let users = [];
48+
const params = {
49+
sort: this.sort,
50+
sortOrder: this.sortDirection,
51+
pageSize: 100,
52+
};
53+
do {
54+
const items = await this.app.listPeople(page, $, params);
55+
total = items?.length;
56+
if (!total) {
57+
break;
58+
}
59+
users.push(...items);
60+
count += items.length;
61+
page++;
62+
} while (count < this.maxResults);
63+
64+
if (users.length > this.maxResults) {
65+
users = users.slice(0, this.maxResults);
66+
}
67+
68+
$.export("$summary", `Found ${users.length} user${users.length === 1
69+
? ""
70+
: "s"}`);
71+
return users;
72+
},
73+
};

0 commit comments

Comments
 (0)