Skip to content

Commit 792ced1

Browse files
committed
new components
1 parent 68a3ffe commit 792ced1

File tree

10 files changed

+534
-22
lines changed

10 files changed

+534
-22
lines changed
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
import common from "../common/base.mjs";
2+
3+
export default {
4+
key: "miro_custom_app-create-card-item",
5+
name: "Create Card Item",
6+
description: "Creates a card item on a Miro board. [See the documentation](https://developers.miro.com/reference/create-card-item).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
...common.props,
11+
title: {
12+
propDefinition: [
13+
common.props.app,
14+
"cardTitle",
15+
],
16+
},
17+
assigneeId: {
18+
propDefinition: [
19+
common.props.app,
20+
"userId",
21+
(c) => ({
22+
boardId: c.boardId,
23+
}),
24+
],
25+
label: "Assignee ID",
26+
description: "The ID of the user to assign the card to",
27+
optional: true,
28+
},
29+
description: {
30+
propDefinition: [
31+
common.props.app,
32+
"cardDescription",
33+
],
34+
},
35+
dueDate: {
36+
propDefinition: [
37+
common.props.app,
38+
"dueDate",
39+
],
40+
},
41+
cardTheme: {
42+
propDefinition: [
43+
common.props.app,
44+
"cardTheme",
45+
],
46+
},
47+
x: {
48+
propDefinition: [
49+
common.props.app,
50+
"x",
51+
],
52+
optional: true,
53+
},
54+
y: {
55+
propDefinition: [
56+
common.props.app,
57+
"y",
58+
],
59+
optional: true,
60+
},
61+
height: {
62+
propDefinition: [
63+
common.props.app,
64+
"height",
65+
],
66+
},
67+
rotation: {
68+
propDefinition: [
69+
common.props.app,
70+
"rotation",
71+
],
72+
},
73+
width: {
74+
propDefinition: [
75+
common.props.app,
76+
"width",
77+
],
78+
},
79+
parent: {
80+
propDefinition: [
81+
common.props.app,
82+
"itemId",
83+
(c) => ({
84+
boardId: c.boardId,
85+
type: "frame",
86+
}),
87+
],
88+
label: "Parent ID",
89+
description: "The ID of the parent frame for the item",
90+
optional: true,
91+
},
92+
},
93+
async run({ $: step }) {
94+
const response = await this.app.createCardItem({
95+
step,
96+
boardId: this.boardId,
97+
data: {
98+
data: {
99+
title: this.title,
100+
assigneeId: this.assigneeId,
101+
description: this.description,
102+
dueDate: this.dueDate,
103+
},
104+
style: {
105+
cardTheme: this.cardTheme,
106+
},
107+
position: {
108+
x: this.x,
109+
y: this.y,
110+
},
111+
geometry: {
112+
height: this.height,
113+
rotation: this.rotation,
114+
width: this.width,
115+
},
116+
parent: {
117+
id: this.parent,
118+
},
119+
},
120+
});
121+
step.export("$summary", `Successfully created card item with ID \`${response.id}\``);
122+
return response;
123+
},
124+
};
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
import common from "../common/base.mjs";
2+
3+
export default {
4+
key: "miro_custom_app-update-card-item",
5+
name: "Update Card Item",
6+
description: "Updates a card item on a Miro board. [See the documentation](https://developers.miro.com/reference/update-card-item).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
...common.props,
11+
itemId: {
12+
propDefinition: [
13+
common.props.app,
14+
"itemId",
15+
(c) => ({
16+
boardId: c.boardId,
17+
type: "card",
18+
}),
19+
],
20+
},
21+
title: {
22+
propDefinition: [
23+
common.props.app,
24+
"cardTitle",
25+
],
26+
},
27+
assigneeId: {
28+
propDefinition: [
29+
common.props.app,
30+
"userId",
31+
(c) => ({
32+
boardId: c.boardId,
33+
}),
34+
],
35+
label: "Assignee ID",
36+
description: "The ID of the user to assign the card to",
37+
optional: true,
38+
},
39+
description: {
40+
propDefinition: [
41+
common.props.app,
42+
"cardDescription",
43+
],
44+
},
45+
dueDate: {
46+
propDefinition: [
47+
common.props.app,
48+
"dueDate",
49+
],
50+
},
51+
cardTheme: {
52+
propDefinition: [
53+
common.props.app,
54+
"cardTheme",
55+
],
56+
},
57+
x: {
58+
propDefinition: [
59+
common.props.app,
60+
"x",
61+
],
62+
optional: true,
63+
},
64+
y: {
65+
propDefinition: [
66+
common.props.app,
67+
"y",
68+
],
69+
optional: true,
70+
},
71+
height: {
72+
propDefinition: [
73+
common.props.app,
74+
"height",
75+
],
76+
},
77+
rotation: {
78+
propDefinition: [
79+
common.props.app,
80+
"rotation",
81+
],
82+
},
83+
width: {
84+
propDefinition: [
85+
common.props.app,
86+
"width",
87+
],
88+
},
89+
parent: {
90+
propDefinition: [
91+
common.props.app,
92+
"itemId",
93+
(c) => ({
94+
boardId: c.boardId,
95+
type: "frame",
96+
}),
97+
],
98+
label: "Parent ID",
99+
description: "The ID of the parent frame for the item",
100+
optional: true,
101+
},
102+
},
103+
async run({ $: step }) {
104+
const response = await this.app.updateCardItem({
105+
step,
106+
boardId: this.boardId,
107+
itemId: this.itemId,
108+
data: {
109+
data: {
110+
title: this.title,
111+
assigneeId: this.assigneeId,
112+
description: this.description,
113+
dueDate: this.dueDate,
114+
},
115+
style: {
116+
cardTheme: this.cardTheme,
117+
},
118+
position: {
119+
x: this.x,
120+
y: this.y,
121+
},
122+
geometry: {
123+
height: this.height,
124+
rotation: this.rotation,
125+
width: this.width,
126+
},
127+
parent: {
128+
id: this.parent,
129+
},
130+
},
131+
});
132+
step.export("$summary", `Successfully updated card item with ID \`${response.id}\``);
133+
return response;
134+
},
135+
};

components/miro_custom_app/miro_custom_app.app.mjs

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,48 @@ export default {
4444
description: "The `team_id` for which you want to retrieve the list of boards.",
4545
optional: true,
4646
},
47+
cardTitle: {
48+
type: "string",
49+
label: "Title",
50+
description: "A short text header for the card",
51+
optional: true,
52+
},
53+
cardDescription: {
54+
type: "string",
55+
label: "Description",
56+
description: "The description of the card",
57+
optional: true,
58+
},
59+
dueDate: {
60+
type: "string",
61+
label: "Due Date",
62+
description: "The date when the task or activity described in the card is due to be completed. Example: `2023-10-12T22:00:55.000Z`",
63+
optional: true,
64+
},
65+
cardTheme: {
66+
type: "string",
67+
label: "Card Theme",
68+
description: "Hex value of the border color of the card. Default: `#2d9bf0`",
69+
optional: true,
70+
},
71+
height: {
72+
type: "string",
73+
label: "Height",
74+
description: "The height of the card in pixels",
75+
optional: true,
76+
},
77+
rotation: {
78+
type: "string",
79+
label: "Rotation",
80+
description: "Rotation angle of an item, in degrees, relative to the board. You can rotate items clockwise (right) and counterclockwise (left) by specifying positive and negative values, respectively.",
81+
optional: true,
82+
},
83+
width: {
84+
type: "string",
85+
label: "Width",
86+
description: "The width of the card in pixels",
87+
optional: true,
88+
},
4789
boardId: {
4890
type: "string",
4991
label: "Board ID",
@@ -98,7 +140,38 @@ export default {
98140
const options = data.map(({
99141
id: value, type, data,
100142
}) => ({
101-
label: data.content || data[type] || type,
143+
label: data?.content || data?.title || data?.[type] || type,
144+
value,
145+
}));
146+
return {
147+
options,
148+
context: {
149+
offset,
150+
},
151+
};
152+
},
153+
},
154+
userId: {
155+
type: "string",
156+
label: "User ID",
157+
description: "The ID of a user",
158+
async options({
159+
boardId, prevContext,
160+
}) {
161+
const {
162+
data,
163+
offset,
164+
} = await this.listBoardMembers({
165+
boardId,
166+
params: {
167+
limit: constants.DEFAULT_LIMIT,
168+
offset: prevContext.offset,
169+
},
170+
});
171+
const options = data.map(({
172+
id: value, name: label,
173+
}) => ({
174+
label,
102175
value,
103176
}));
104177
return {
@@ -167,6 +240,15 @@ export default {
167240
...args,
168241
});
169242
},
243+
createCardItem({
244+
boardId, ...args
245+
} = {}) {
246+
return this.makeRequest({
247+
method: "post",
248+
path: `/boards/${boardId}/cards`,
249+
...args,
250+
});
251+
},
170252
deleteBoard({
171253
boardId, ...args
172254
} = {}) {
@@ -215,6 +297,14 @@ export default {
215297
...args,
216298
});
217299
},
300+
listBoardMembers({
301+
boardId, ...args
302+
} = {}) {
303+
return this.makeRequest({
304+
path: `/boards/${boardId}/members`,
305+
...args,
306+
});
307+
},
218308
updateBoard({
219309
boardId, ...args
220310
} = {}) {
@@ -242,5 +332,14 @@ export default {
242332
...args,
243333
});
244334
},
335+
updateCardItem({
336+
boardId, itemId, ...args
337+
} = {}) {
338+
return this.makeRequest({
339+
method: "patch",
340+
path: `/boards/${boardId}/cards/${itemId}`,
341+
...args,
342+
});
343+
},
245344
},
246345
};

0 commit comments

Comments
 (0)