From 5b455d346627f951ad401493ea1481dafb5d05b3 Mon Sep 17 00:00:00 2001 From: Sophie Stadler Date: Wed, 20 Sep 2023 14:41:38 -0400 Subject: [PATCH] Add JIRA user info --- src/gql/generated/types.ts | 6 +++++- src/gql/queries/spruce-config.graphql | 1 + .../tabs/PluginsTab/PluginsTab.tsx | 6 +++++- .../{getFormSchema.ts => getFormSchema.tsx} | 21 ++++++++++++++++--- 4 files changed, 29 insertions(+), 5 deletions(-) rename src/pages/projectSettings/tabs/PluginsTab/{getFormSchema.ts => getFormSchema.tsx} (93%) diff --git a/src/gql/generated/types.ts b/src/gql/generated/types.ts index f5bbd7f1b5..c3e0b3fdbf 100644 --- a/src/gql/generated/types.ts +++ b/src/gql/generated/types.ts @@ -7981,7 +7981,11 @@ export type SpruceConfigQuery = { port: number; }>; } | null; - jira?: { __typename?: "JiraConfig"; host?: string | null } | null; + jira?: { + __typename?: "JiraConfig"; + email?: string | null; + host?: string | null; + } | null; keys: Array<{ __typename?: "SSHKey"; location: string; name: string }>; providers?: { __typename?: "CloudProviderConfig"; diff --git a/src/gql/queries/spruce-config.graphql b/src/gql/queries/spruce-config.graphql index 1b770adeba..a5f57b7529 100644 --- a/src/gql/queries/spruce-config.graphql +++ b/src/gql/queries/spruce-config.graphql @@ -11,6 +11,7 @@ query SpruceConfig { } } jira { + email host } keys { diff --git a/src/pages/projectSettings/tabs/PluginsTab/PluginsTab.tsx b/src/pages/projectSettings/tabs/PluginsTab/PluginsTab.tsx index 020db66836..a24b86c1bb 100644 --- a/src/pages/projectSettings/tabs/PluginsTab/PluginsTab.tsx +++ b/src/pages/projectSettings/tabs/PluginsTab/PluginsTab.tsx @@ -1,6 +1,7 @@ import { useMemo } from "react"; import { ValidateProps } from "components/SpruceForm"; import { ProjectSettingsTabRoutes } from "constants/routes"; +import { useSpruceConfig } from "hooks"; import { BaseTab } from "../BaseTab"; import { ProjectType } from "../utils"; import { getFormSchema } from "./getFormSchema"; @@ -14,13 +15,16 @@ export const PluginsTab: React.FC = ({ repoData, }) => { const initialFormState = projectData || repoData; + const spruceConfig = useSpruceConfig(); + const jiraEmail = spruceConfig?.jira?.email; const formSchema = useMemo( () => getFormSchema( + jiraEmail, projectType === ProjectType.AttachedProject ? repoData : null ), - [projectType, repoData] + [jiraEmail, projectType, repoData] ); return ( diff --git a/src/pages/projectSettings/tabs/PluginsTab/getFormSchema.ts b/src/pages/projectSettings/tabs/PluginsTab/getFormSchema.tsx similarity index 93% rename from src/pages/projectSettings/tabs/PluginsTab/getFormSchema.ts rename to src/pages/projectSettings/tabs/PluginsTab/getFormSchema.tsx index 7f4f9e2b5e..80a3915422 100644 --- a/src/pages/projectSettings/tabs/PluginsTab/getFormSchema.ts +++ b/src/pages/projectSettings/tabs/PluginsTab/getFormSchema.tsx @@ -1,3 +1,4 @@ +import { InlineCode } from "@leafygreen-ui/typography"; import { GetFormSchema } from "components/SpruceForm"; import { CardFieldTemplate } from "components/SpruceForm/FieldTemplates"; import widgets from "components/SpruceForm/Widgets"; @@ -30,6 +31,7 @@ const requesters = [ ]; export const getFormSchema = ( + jiraEmail?: string, repoData?: PluginsFormState ): ReturnType => ({ fields: {}, @@ -228,7 +230,7 @@ export const getFormSchema = ( }, ticketSearchProjects: { "ui:description": - "Specify an existing JIRA project to search for tickets related to a failing task", + "Specify an existing JIRA project to search for tickets related to a failing task.", "ui:addButtonText": "Add Search Project", "ui:orderable": false, items: { @@ -236,8 +238,21 @@ export const getFormSchema = ( }, }, ticketCreateProject: { - "ui:description": - "Specify an existing JIRA project to create tickets in when the File Ticket button is clicked on a failing task.", + "ui:description": ( + <> + Specify an existing JIRA project to create tickets in when the File + Ticket button is clicked on a failing task. + {jiraEmail && ( + <> + {" "} + This project must include + {jiraEmail} + {" "} + as a user with create permissions. + + )} + + ), }, fileTicketWebhook: { "ui:description":