Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/shridhar-tl/jira-assistant
Browse files Browse the repository at this point in the history
… into package
  • Loading branch information
shridhar-tl committed Jan 8, 2025
2 parents b441b0e + 8851501 commit 6966e2f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
2 changes: 2 additions & 0 deletions manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ modules:
function: sprint-started-handler
events:
- avi:jira-software:started:sprint
- avi:jira-software:closed:sprint
filter:
ignoreSelf: true
onError: RECEIVE_AND_LOG
Expand Down Expand Up @@ -85,6 +86,7 @@ permissions:
- read:project:jira
- read:issue-meta:jira
- read:avatar:jira
- read:board-scope.admin:jira-software
- read:issue.changelog:jira
- write:jira-work
- write:sprint:jira-software
Expand Down
27 changes: 24 additions & 3 deletions src/jcloud-events.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
import { asApp, route } from '@forge/api'

export async function onSprintStarted(event) {
if (event.eventType !== "avi:jira-software:started:sprint") {
console.error("Invalid event type received", event.eventType);
const eventsHandlerMap = {
"avi:jira-software:started:sprint": onSprintStarted,
"avi:jira-software:closed:sprint": onSprintClosed
};

export async function onSprintAction(event) {
const handler = eventsHandlerMap[event.eventType];

if (handler) {
handler(event);
} else {
console.error("Unhandled event type received:", event.eventType);
}
}

async function onSprintStarted(event) {
const sprintId = event.sprint.id;

if (!sprintId) {
console.error("onSprintStarted: Sprint id unavailable", sprintId);
return;
}

const customFieldsResponse = await asApp().requestJira(route`/rest/api/3/field`);
Expand Down Expand Up @@ -56,4 +68,13 @@ export async function onSprintStarted(event) {
} else {
console.error("Failed to store issue keys within sprint of id:", sprintId, saveRequest.status, await saveRequest.text());
}
}

async function onSprintClosed(event) {
const sprintId = event.sprint.id;

if (!sprintId) {
console.error("onSprintClosed: Sprint id unavailable", sprintId);
return;
}
}

0 comments on commit 6966e2f

Please sign in to comment.