Skip to content

Commit

Permalink
DEVPROD-937: Allow settings Jira ticket type in Project Settings (eve…
Browse files Browse the repository at this point in the history
  • Loading branch information
SupaJoon authored Nov 22, 2023
1 parent ecacc78 commit 48ed54c
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/Notifications/form/notification.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { FieldRow } from "components/SpruceForm/FieldTemplates";
import { SpruceFormProps } from "components/SpruceForm/types";
import { JiraTicketType } from "types/jira";
import {
SubscriptionMethodOption,
NotificationMethods,
Expand Down Expand Up @@ -193,7 +194,7 @@ export const getNotificationSchema = (
"ui:data-cy": "project-input",
},
issueInput: {
"ui:placeholder": "Build Failure",
"ui:placeholder": JiraTicketType.BuildFailure,
"ui:data-cy": "issue-input",
},
},
Expand Down
2 changes: 2 additions & 0 deletions src/gql/fragments/projectSettings/plugins.graphql
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
fragment ProjectPluginsSettings on Project {
buildBaronSettings {
ticketCreateIssueType
ticketCreateProject
ticketSearchProjects
}
Expand All @@ -23,6 +24,7 @@ fragment ProjectPluginsSettings on Project {

fragment RepoPluginsSettings on RepoRef {
buildBaronSettings {
ticketCreateIssueType
ticketCreateProject
ticketSearchProjects
}
Expand Down
11 changes: 11 additions & 0 deletions src/gql/generated/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3676,6 +3676,7 @@ export type ProjectSettingsFieldsFragment = {
}> | null;
buildBaronSettings: {
__typename?: "BuildBaronSettings";
ticketCreateIssueType: string;
ticketCreateProject: string;
ticketSearchProjects?: Array<string> | null;
};
Expand Down Expand Up @@ -3875,6 +3876,7 @@ export type RepoSettingsFieldsFragment = {
}> | null;
buildBaronSettings: {
__typename?: "BuildBaronSettings";
ticketCreateIssueType: string;
ticketCreateProject: string;
ticketSearchProjects?: Array<string> | null;
};
Expand Down Expand Up @@ -4135,6 +4137,7 @@ export type ProjectPluginsSettingsFragment = {
perfEnabled?: boolean | null;
buildBaronSettings: {
__typename?: "BuildBaronSettings";
ticketCreateIssueType: string;
ticketCreateProject: string;
ticketSearchProjects?: Array<string> | null;
};
Expand Down Expand Up @@ -4164,6 +4167,7 @@ export type RepoPluginsSettingsFragment = {
perfEnabled: boolean;
buildBaronSettings: {
__typename?: "BuildBaronSettings";
ticketCreateIssueType: string;
ticketCreateProject: string;
ticketSearchProjects?: Array<string> | null;
};
Expand Down Expand Up @@ -4272,6 +4276,7 @@ export type ProjectEventSettingsFragment = {
}> | null;
buildBaronSettings: {
__typename?: "BuildBaronSettings";
ticketCreateIssueType: string;
ticketCreateProject: string;
ticketSearchProjects?: Array<string> | null;
};
Expand Down Expand Up @@ -6733,6 +6738,7 @@ export type ProjectEventLogsQuery = {
}> | null;
buildBaronSettings: {
__typename?: "BuildBaronSettings";
ticketCreateIssueType: string;
ticketCreateProject: string;
ticketSearchProjects?: Array<string> | null;
};
Expand Down Expand Up @@ -6944,6 +6950,7 @@ export type ProjectEventLogsQuery = {
}> | null;
buildBaronSettings: {
__typename?: "BuildBaronSettings";
ticketCreateIssueType: string;
ticketCreateProject: string;
ticketSearchProjects?: Array<string> | null;
};
Expand Down Expand Up @@ -7237,6 +7244,7 @@ export type ProjectSettingsQuery = {
}> | null;
buildBaronSettings: {
__typename?: "BuildBaronSettings";
ticketCreateIssueType: string;
ticketCreateProject: string;
ticketSearchProjects?: Array<string> | null;
};
Expand Down Expand Up @@ -7487,6 +7495,7 @@ export type RepoEventLogsQuery = {
}> | null;
buildBaronSettings: {
__typename?: "BuildBaronSettings";
ticketCreateIssueType: string;
ticketCreateProject: string;
ticketSearchProjects?: Array<string> | null;
};
Expand Down Expand Up @@ -7698,6 +7707,7 @@ export type RepoEventLogsQuery = {
}> | null;
buildBaronSettings: {
__typename?: "BuildBaronSettings";
ticketCreateIssueType: string;
ticketCreateProject: string;
ticketSearchProjects?: Array<string> | null;
};
Expand Down Expand Up @@ -7914,6 +7924,7 @@ export type RepoSettingsQuery = {
}> | null;
buildBaronSettings: {
__typename?: "BuildBaronSettings";
ticketCreateIssueType: string;
ticketCreateProject: string;
ticketSearchProjects?: Array<string> | null;
};
Expand Down
1 change: 1 addition & 0 deletions src/pages/projectSettings/CopyProjectModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ const projectSettingsMock: ApolloMock<
ticketCreateProject: "suv",
ticketSearchProjects: ["suv"],
__typename: "BuildBaronSettings",
ticketCreateIssueType: "",
},
taskAnnotationSettings: {
jiraCustomFields: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ const projectEventsQuery: ProjectEventLogsQuery = {
ticketCreateProject: "EVG",
ticketSearchProjects: ["EVG"],
__typename: "BuildBaronSettings",
ticketCreateIssueType: "",
},
taskAnnotationSettings: {
jiraCustomFields: null,
Expand Down Expand Up @@ -198,6 +199,7 @@ const projectEventsQuery: ProjectEventLogsQuery = {
ticketCreateProject: "EVG",
ticketSearchProjects: ["EVG"],
__typename: "BuildBaronSettings",
ticketCreateIssueType: "",
},
taskAnnotationSettings: {
jiraCustomFields: null,
Expand Down
25 changes: 25 additions & 0 deletions src/pages/projectSettings/tabs/PluginsTab/getFormSchema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { InlineCode } from "@leafygreen-ui/typography";
import { GetFormSchema } from "components/SpruceForm";
import { CardFieldTemplate } from "components/SpruceForm/FieldTemplates";
import widgets from "components/SpruceForm/Widgets";
import { JiraTicketType } from "types/jira";
import { form } from "../utils";
import { PluginsFormState } from "./types";

Expand Down Expand Up @@ -128,6 +129,23 @@ export const getFormSchema = (
},
},
},
ticketCreateIssueType: {
type: "object" as "object",
title: "Ticket Create Issue Type",
properties: {
issueType: {
type: "string" as "string",
title: "",
oneOf: Object.values(JiraTicketType).map(
(r: string) => ({
type: "string" as "string",
title: r,
enum: [r],
})
),
},
},
},
},
},
{
Expand Down Expand Up @@ -237,6 +255,13 @@ export const getFormSchema = (
"ui:label": false,
},
},
ticketCreateIssueType: {
"ui:description":
"Specify a JIRA issue type for tickets created by the File Ticket button.",
issueType: {
"ui:allowDeselect": false,
},
},
ticketCreateProject: {
"ui:description": (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ const projectForm: PluginsFormState = {
ticketCreateProject: {
createProject: null,
},
ticketCreateIssueType: {
issueType: "Epic",
},
ticketSearchProjects: [],
useBuildBaron: false,
taskAnnotationSettings: {
Expand Down Expand Up @@ -87,6 +90,9 @@ const repoForm: PluginsFormState = {
ticketCreateProject: {
createProject: "EVG",
},
ticketCreateIssueType: {
issueType: "Epic",
},
useBuildBaron: false,
taskAnnotationSettings: {
jiraCustomFields: [
Expand Down
9 changes: 9 additions & 0 deletions src/pages/projectSettings/tabs/PluginsTab/transformers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ProjectSettingsTabRoutes } from "constants/routes";
import { ProjectInput } from "gql/generated/types";
import { JiraTicketType } from "types/jira";
import { FormToGqlFunction, GqlToFormFunction } from "../types";

type Tab = ProjectSettingsTabRoutes.Plugins;
Expand Down Expand Up @@ -32,6 +33,11 @@ export const gqlToForm = ((data) => {
ticketCreateProject: {
createProject: projectRef?.buildBaronSettings?.ticketCreateProject,
},
ticketCreateIssueType: {
issueType:
projectRef?.buildBaronSettings?.ticketCreateIssueType ||
JiraTicketType.BuildFailure,
},
fileTicketWebhook: {
endpoint:
projectRef?.taskAnnotationSettings?.fileTicketWebhook?.endpoint,
Expand Down Expand Up @@ -82,6 +88,9 @@ export const buildBaronIf = (useBuildBaron: boolean, buildBaronSettings: any) =>
ticketSearchProjects: buildBaronSettings.ticketSearchProjects
.map(({ searchProject }) => searchProject)
.filter((str) => !!str),
ticketCreateIssueType:
buildBaronSettings.ticketCreateIssueType?.issueType ||
JiraTicketType.BuildFailure,
},
};

Expand Down
3 changes: 3 additions & 0 deletions src/pages/projectSettings/tabs/PluginsTab/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export interface PluginsFormState {
ticketCreateProject: {
createProject: string;
};
ticketCreateIssueType: {
issueType: string;
};
fileTicketWebhook: {
endpoint: string;
secret: string;
Expand Down
3 changes: 3 additions & 0 deletions src/pages/projectSettings/tabs/testData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
RepoSettingsQuery,
MergeQueue,
} from "gql/generated/types";
import { JiraTicketType } from "types/jira";

const projectBase: ProjectSettingsQuery["projectSettings"] = {
githubWebhooksEnabled: true,
Expand Down Expand Up @@ -69,6 +70,7 @@ const projectBase: ProjectSettingsQuery["projectSettings"] = {
buildBaronSettings: {
ticketCreateProject: null,
ticketSearchProjects: [],
ticketCreateIssueType: JiraTicketType.Epic,
},
taskAnnotationSettings: {
jiraCustomFields: [],
Expand Down Expand Up @@ -196,6 +198,7 @@ const repoBase: RepoSettingsQuery["repoSettings"] = {
buildBaronSettings: {
ticketCreateProject: "EVG",
ticketSearchProjects: ["EVG"],
ticketCreateIssueType: JiraTicketType.Epic,
},
taskAnnotationSettings: {
jiraCustomFields: [
Expand Down
8 changes: 8 additions & 0 deletions src/types/jira.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export enum JiraTicketType {
Investigation = "Investigation",
Bug = "Bug",
Task = "Task",
BuildFailure = "Build Failure",
Epic = "Epic",
Incident = "Incident",
}

0 comments on commit 48ed54c

Please sign in to comment.