[SILO-495] fix: Work item mark as done not marking linked github issue as done (#4073)

* fix work item mark done update issue as closed

* move wi to open if not in completed state
This commit is contained in:
Saurabh Kumar
2025-09-02 19:20:35 +05:30
committed by GitHub
parent f1d7a48e52
commit 0e67823577
2 changed files with 28 additions and 4 deletions

View File

@@ -132,7 +132,17 @@ const createOrUpdateGitHubIssue = async (
const repo = (entityConnection.entity_slug ?? "").split("/")[1];
const issueImagePrefix = imagePrefix + workspaceConnection.workspace_id + "/" + credentials.user_id;
const transformedGithubIssue = await transformPlaneIssue(issue, issueImagePrefix, labels, owner, repo, userMap);
const transformedGithubIssue = await transformPlaneIssue(
issue,
issueImagePrefix,
labels,
owner,
repo,
userMap,
planeClient,
entityConnection.workspace_slug,
entityConnection.project_id ?? ""
);
// Find the credentials for the user
const [userCredential] = await apiClient.workspaceCredential.listWorkspaceCredentials({

View File

@@ -1,4 +1,4 @@
import { ExCycle, ExIssueLabel, ExIssue as PlaneIssue } from "@plane/sdk";
import { Client, ExCycle, ExIssueLabel, ExIssue as PlaneIssue } from "@plane/sdk";
import { GithubIssue, WebhookGitHubLabel, WebhookGitHubMilestone, WebhookGitHubUser } from "../types";
import { ContentParser } from "../helpers/content-parser";
@@ -8,7 +8,10 @@ export const transformPlaneIssue = async (
labels: ExIssueLabel[],
owner: string,
repo: string,
userMap: Record<string, WebhookGitHubUser>
userMap: Record<string, WebhookGitHubUser>,
planeClient: Client,
workspaceSlug: string,
projectId: string
): Promise<Partial<GithubIssue>> => {
const githubIssueNumber = issue.links
?.find((link) => link.name === "Linked GitHub Issue")
@@ -38,6 +41,17 @@ export const transformPlaneIssue = async (
// Convert the cleaned HTML to GitHub markdown using our ContentParser
const githubBody = ContentParser.toMarkdown(cleanHtml, imgSrcPrefix);
let targetState: string | undefined = undefined;
if (issue.state) {
const states = (await planeClient.state.list(workspaceSlug, projectId)).results;
const issueState = states.find((state) => state.id === issue.state);
if (issueState?.group === "completed") {
targetState = "CLOSED";
} else {
targetState = "OPEN";
}
}
return {
id: parseInt(issue.external_id || "0"),
number: parseInt(githubIssueNumber || "0"),
@@ -45,7 +59,7 @@ export const transformPlaneIssue = async (
body: githubBody,
owner: owner,
repo: repo,
state: issue.state === "Done" ? "CLOSED" : "OPEN",
state: targetState,
created_at: issue.created_at,
assignees: assignees as string[],
labels: ghLabels,