Skip to content

Commit

Permalink
Merge pull request #72 from department-of-veterans-affairs/reassign-g…
Browse files Browse the repository at this point in the history
…ithub-ticket

Reassign GitHub ticket
  • Loading branch information
CBonade authored Jan 10, 2024
2 parents 17e7c96 + 59d2f50 commit be6de38
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
25 changes: 25 additions & 0 deletions src/api/github/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,31 @@ module.exports = (logger) => {
return response;
},

removeLabelsFromIssue: async (issue_number) => {
github.authenticate();

let response = await octokit.rest.issues.removeAllLabels({
owner: process.env.GITHUB_OWNER,
repo: process.env.GITHUB_ISSUE_REPO,
issue_number: issue_number,
})

return response;
},

labelReassignedIssue: async (issue_number, label) => {
github.authenticate();

let response = await octokit.rest.issues.addLabels({
owner: process.env.GITHUB_OWNER,
repo: process.env.GITHUB_ISSUE_REPO,
issue_number: issue_number,
labels: label ? [process.env.GITHUB_SUPPORT_LABEL, label] : [process.env.GITHUB_SUPPORT_LABEL]
})

return response;
},

commentOnIssue: async ( issue_number, body ) => {
github.authenticate();

Expand Down
6 changes: 1 addition & 5 deletions src/logic/form-support.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ module.exports = function (logger) {
id: selectedValue,
title: team.Title,
display: team.Display,
githubLabel: team.GitHubLabel
};
};

Expand Down Expand Up @@ -216,11 +217,6 @@ module.exports = function (logger) {
autoResponse
) => {

console.log(responseBuilder.buildAdditionalPostResponse(
thread,
autoResponse
))
console.log(autoResponse)
const postedMessage = await client.chat.postMessage({
channel: SUPPORT_CHANNEL_ID,
thread_ts: thread,
Expand Down
6 changes: 5 additions & 1 deletion src/logic/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ module.exports = (logger) => {
team = await formSupport.extractReassignFormData(view);

let sheetMessage;

if (!message) return sendErrorMessageToUser();

const onSupportUsers = await routing.getOnCallUser(client, team.id);
Expand All @@ -333,6 +332,11 @@ module.exports = (logger) => {
},
};

const row = await sheets.getMessageByTicketId(ticketId);
if(row && row.messageRow.GithubIssueId) {
github.removeLabelsFromIssue(row.messageRow.GithubIssueId);
github.labelReassignedIssue(row.messageRow.GithubIssueId, team.githubLabel);
};
await slack.updateMessageById(client, message.ts, SUPPORT_CHANNEL_ID, blocks);
await client.chat.postMessage({
channel: process.env.SLACK_SUPPORT_CHANNEL,
Expand Down
6 changes: 3 additions & 3 deletions src/request-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ module.exports = function (app, logger) {
});

/**
* Action: reassign_ticket
* This function gets called when the "Reassign Ticket" button
* is clicked on. It brings up a reassign ticket modal.
* Action: close_ticket
* This function gets called when the "Close Ticket" button
* is clicked on. It closes the GitHub ticket.
*/
app.action('close_ticket', async ({ ack, body, client, payload }) => {
try {
Expand Down

0 comments on commit be6de38

Please sign in to comment.