-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathgetIssuesStarterModal.ts
More file actions
93 lines (87 loc) · 2.74 KB
/
getIssuesStarterModal.ts
File metadata and controls
93 lines (87 loc) · 2.74 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import {
IHttp,
IModify,
IPersistence,
IRead,
} from "@rocket.chat/apps-engine/definition/accessors";
import { TextObjectType } from "@rocket.chat/apps-engine/definition/uikit/blocks";
import { IUIKitModalViewParam } from "@rocket.chat/apps-engine/definition/uikit/UIKitInteractionResponder";
import { ModalsEnum } from "../enum/Modals";
import { SlashCommandContext } from "@rocket.chat/apps-engine/definition/slashcommands";
import {
UIKitInteractionContext,
} from "@rocket.chat/apps-engine/definition/uikit";
import {
storeInteractionRoomData,
getInteractionRoomData,
} from "../persistance/roomInteraction";
export async function GitHubIssuesStarterModal({
modify,
read,
persistence,
http,
slashcommandcontext,
uikitcontext,
}: {
modify: IModify;
read: IRead;
persistence: IPersistence;
http: IHttp;
slashcommandcontext?: SlashCommandContext;
uikitcontext?: UIKitInteractionContext;
}): Promise<IUIKitModalViewParam> {
const viewId = ModalsEnum.GITHUB_ISSUES_STARTER_VIEW;
const block = modify.getCreator().getBlockBuilder();
const room = slashcommandcontext?.getRoom() || uikitcontext?.getInteractionData().room;
const user = slashcommandcontext?.getSender() || uikitcontext?.getInteractionData().user;
if (user?.id) {
let roomId;
if (room?.id) {
roomId = room.id;
await storeInteractionRoomData(persistence, user.id, roomId);
} else {
roomId = (
await getInteractionRoomData(
read.getPersistenceReader(),
user.id
)
).roomId;
}
block.addInputBlock({
blockId: ModalsEnum.REPO_NAME_INPUT,
label: {
text: ModalsEnum.REPO_NAME_LABEL,
type: TextObjectType.PLAINTEXT,
},
element: block.newPlainTextInputElement({
actionId: ModalsEnum.REPO_NAME_INPUT_ACTION,
placeholder: {
text: ModalsEnum.REPO_NAME_PLACEHOLDER,
type: TextObjectType.PLAINTEXT,
},
}),
});
}
block.addDividerBlock();
return {
id: viewId,
title: {
type: TextObjectType.PLAINTEXT,
text: ModalsEnum.GITHUB_ISSUES_TITLE,
},
close: block.newButtonElement({
text: {
type: TextObjectType.PLAINTEXT,
text: "Close",
},
}),
submit: block.newButtonElement({
text: {
type: TextObjectType.PLAINTEXT,
emoji:true,
text: "Next 🚀",
},
}),
blocks: block.getBlocks(),
};
}