-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] Create Issues from Messages with Action Buttons #88
Open
henit-chobisa
wants to merge
4
commits into
RocketChat:main
Choose a base branch
from
henit-chobisa:Create-Issue-Action-Button
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
340d652
feat: Registered and Added Handler for Action Button
henit-chobisa 982f4ab
feat: Modified Issues Modal to be compatible with Action Fields
henit-chobisa fa23be6
feat: Added Action Handler
henit-chobisa 14d75f5
chore: Modified App Configuration with Added Permission System
henit-chobisa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { IRead, IHttp, IModify, IPersistence } from "@rocket.chat/apps-engine/definition/accessors"; | ||
import { BlockType, IImageBlock, IImageElement, IUIKitResponse, UIKitActionButtonInteractionContext } from "@rocket.chat/apps-engine/definition/uikit"; | ||
import { ModalsEnum } from "../enum/Modals"; | ||
import { GithubApp } from "../GithubApp"; | ||
import { NewIssueModal } from "../modals/newIssueModal"; | ||
|
||
export class ExecuteButtonActionHandler { | ||
constructor( | ||
private readonly app: GithubApp, | ||
private readonly read: IRead, | ||
private readonly http: IHttp, | ||
private readonly modify: IModify, | ||
private readonly persistence: IPersistence | ||
) { } | ||
|
||
public async run( | ||
context: UIKitActionButtonInteractionContext | ||
): Promise<IUIKitResponse>{ | ||
const data = context.getInteractionData(); | ||
|
||
try { | ||
const { actionId } = data; | ||
switch (actionId) { | ||
case ModalsEnum.NEW_ISSUE_ACTION: { | ||
const { message, user, room } = data; | ||
|
||
let modalData; | ||
if (message && (message.text || message.attachments)){ | ||
|
||
// TODO We need to download and upload the files to github first, else rocket.chat won't allow accessing images like below | ||
// const attachmentImageURLs: String[] = [] | ||
// const attachmentVideoURLs: String[] = [] | ||
// const settings = this.read.getEnvironmentReader().getServerSettings(); | ||
// const Site_Url = await settings.getValueById("Site_Url"); | ||
// if (message.attachments){ | ||
// message.attachments.map((attachment) => { | ||
// if (attachment.imageUrl){ | ||
// attachmentImageURLs.push(`### ${attachment.description?.split("|").pop()}\n![image](${Site_Url}/${attachment.imageUrl})`) | ||
// } | ||
// if (attachment.videoUrl){ | ||
// attachmentVideoURLs.push(`### ${attachment.description?.split("|").pop()}\n` + `${Site_Url}/${attachment.videoUrl}`) | ||
// } | ||
// }) | ||
// } | ||
|
||
// if (message.blocks){ | ||
// message.blocks.map((element) => { | ||
// if (element.type === BlockType.IMAGE){ | ||
// element = element as IImageElement | ||
// attachmentImageURLs.push(`### ${element.altText}\n![image](${element.imageUrl})`) | ||
// } | ||
// }) | ||
// } | ||
|
||
// Taking Repository and Body Seperated By Pipe Operator | ||
let pieces = message.text ? message.text.split("|") : [""] | ||
|
||
if (message.text === '' && message.attachments){ | ||
if (message.attachments[0].description){ | ||
pieces = message.attachments[0].description.split("|") | ||
} | ||
} | ||
|
||
|
||
modalData = { | ||
repository: pieces.length === 2 ? pieces[0] : undefined, | ||
template : pieces.length === 2 ? pieces[1] : pieces[0] | ||
// template : (pieces.length === 2 ? pieces[1] : pieces[0]) + (attachmentImageURLs.length !== 0 ? "\n## Screenshots\n" + attachmentImageURLs.join("\n") : "") + (attachmentVideoURLs.length !== 0 ? "\n## Videos\n" + attachmentVideoURLs.join("\n") : "" ) | ||
} | ||
} | ||
|
||
const modal = await NewIssueModal({ | ||
data: modalData, | ||
modify: this.modify, | ||
read: this.read, | ||
persistence: this.persistence, | ||
http: this.http, | ||
user: user, | ||
room: room, | ||
}) | ||
|
||
return context.getInteractionResponder().openModalViewResponse(modal) | ||
} | ||
|
||
} | ||
} catch (error){ | ||
console.log(error) | ||
} | ||
|
||
return context.getInteractionResponder().successResponse() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"cmd_description": "Search, Share, Review, Merge, Subscribe GitHub Resources and do much more from Rocket.Chat." | ||
} | ||
"cmd_description": "Search, Share, Review, Merge, Subscribe GitHub Resources and do much more from Rocket.Chat.", | ||
"open_issue_message": "🎈 Open Github Issue" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@henit-chobisa These comments need to be fixed, either by code or removed completely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure Samad, I am still on my way to find someway for the images to be processed, what should I do in that case remove these comments and make another PR for that ??