diff --git a/apps/spruce/src/components/ScheduleTasksModal/index.tsx b/apps/spruce/src/components/ScheduleTasksModal/index.tsx index 75f15ada0..ea26a665e 100644 --- a/apps/spruce/src/components/ScheduleTasksModal/index.tsx +++ b/apps/spruce/src/components/ScheduleTasksModal/index.tsx @@ -81,7 +81,9 @@ export const ScheduleTasksModal: React.FC = ({ loadingTaskData || loadingScheduleTasksMutation || !selectedTasks.size } onConfirm={() => { - scheduleTasks({ variables: { taskIds: Array.from(selectedTasks) } }); + scheduleTasks({ + variables: { taskIds: Array.from(selectedTasks), versionId }, + }); }} > diff --git a/apps/spruce/src/gql/generated/types.ts b/apps/spruce/src/gql/generated/types.ts index 35afa95f6..1d4f15717 100644 --- a/apps/spruce/src/gql/generated/types.ts +++ b/apps/spruce/src/gql/generated/types.ts @@ -5155,6 +5155,7 @@ export type SchedulePatchMutation = { export type ScheduleTasksMutationVariables = Exact<{ taskIds: Array; + versionId: Scalars["String"]["input"]; }>; export type ScheduleTasksMutation = { diff --git a/apps/spruce/src/gql/mutations/schedule-tasks.graphql b/apps/spruce/src/gql/mutations/schedule-tasks.graphql index 7d40446da..0ed65a8d1 100644 --- a/apps/spruce/src/gql/mutations/schedule-tasks.graphql +++ b/apps/spruce/src/gql/mutations/schedule-tasks.graphql @@ -1,7 +1,7 @@ #import "../fragments/baseTask.graphql" -mutation ScheduleTasks($taskIds: [String!]!) { - scheduleTasks(taskIds: $taskIds) { +mutation ScheduleTasks($taskIds: [String!]!, $versionId: String!) { + scheduleTasks(taskIds: $taskIds, versionId: $versionId) { ...BaseTask } } diff --git a/apps/spruce/src/gql/queries/build-variant-stats.graphql b/apps/spruce/src/gql/queries/build-variant-stats.graphql index 7a1fc058a..37a943aa6 100644 --- a/apps/spruce/src/gql/queries/build-variant-stats.graphql +++ b/apps/spruce/src/gql/queries/build-variant-stats.graphql @@ -1,5 +1,5 @@ query BuildVariantStats($id: String!) { - version(id: $id) { + version(versionId: $id) { buildVariantStats(options: {}) { displayName statusCounts { diff --git a/apps/spruce/src/gql/queries/build-variants-with-children.graphql b/apps/spruce/src/gql/queries/build-variants-with-children.graphql index 47e38e0c4..d282409f6 100644 --- a/apps/spruce/src/gql/queries/build-variants-with-children.graphql +++ b/apps/spruce/src/gql/queries/build-variants-with-children.graphql @@ -1,5 +1,5 @@ query BuildVariantsWithChildren($id: String!) { - version(id: $id) { + version(versionId: $id) { buildVariants(options: {}) { displayName tasks { diff --git a/apps/spruce/src/gql/queries/code-changes.graphql b/apps/spruce/src/gql/queries/code-changes.graphql index 95634dcf8..fbed2ba14 100644 --- a/apps/spruce/src/gql/queries/code-changes.graphql +++ b/apps/spruce/src/gql/queries/code-changes.graphql @@ -1,7 +1,7 @@ #import "../fragments/moduleCodeChanges.graphql" query CodeChanges($id: String!) { - patch(id: $id) { + patch(patchId: $id) { id moduleCodeChanges { ...ModuleCodeChange diff --git a/apps/spruce/src/gql/queries/has-version.graphql b/apps/spruce/src/gql/queries/has-version.graphql index 4c2194754..9255c4172 100644 --- a/apps/spruce/src/gql/queries/has-version.graphql +++ b/apps/spruce/src/gql/queries/has-version.graphql @@ -1,3 +1,3 @@ query HasVersion($id: String!) { - hasVersion(id: $id) + hasVersion(patchId: $id) } diff --git a/apps/spruce/src/gql/queries/is-patch-configured.graphql b/apps/spruce/src/gql/queries/is-patch-configured.graphql index cfa48ef15..3ff217a81 100644 --- a/apps/spruce/src/gql/queries/is-patch-configured.graphql +++ b/apps/spruce/src/gql/queries/is-patch-configured.graphql @@ -1,5 +1,5 @@ query IsPatchConfigured($id: String!) { - patch(id: $id) { + patch(patchId: $id) { activated alias id diff --git a/apps/spruce/src/gql/queries/patch-configure.graphql b/apps/spruce/src/gql/queries/patch-configure.graphql index 0a3eb503b..dbed78cf1 100644 --- a/apps/spruce/src/gql/queries/patch-configure.graphql +++ b/apps/spruce/src/gql/queries/patch-configure.graphql @@ -1,7 +1,7 @@ #import "../fragments/basePatch.graphql" query ConfigurePatch($id: String!) { - patch(id: $id) { + patch(patchId: $id) { ...BasePatch childPatchAliases { alias diff --git a/apps/spruce/src/gql/queries/patch-task-statuses.graphql b/apps/spruce/src/gql/queries/patch-task-statuses.graphql index 44ee40ab7..6da995fce 100644 --- a/apps/spruce/src/gql/queries/patch-task-statuses.graphql +++ b/apps/spruce/src/gql/queries/patch-task-statuses.graphql @@ -1,5 +1,5 @@ query PatchTaskStatuses($id: String!) { - patch(id: $id) { + patch(patchId: $id) { baseTaskStatuses id taskStatuses diff --git a/apps/spruce/src/gql/queries/patch.graphql b/apps/spruce/src/gql/queries/patch.graphql index 48eeb5bd8..4eeb247f3 100644 --- a/apps/spruce/src/gql/queries/patch.graphql +++ b/apps/spruce/src/gql/queries/patch.graphql @@ -1,7 +1,7 @@ #import "../fragments/basePatch.graphql" query Patch($id: String!) { - patch(id: $id) { + patch(patchId: $id) { ...BasePatch githash patchNumber diff --git a/apps/spruce/src/gql/queries/repo-event-logs.graphql b/apps/spruce/src/gql/queries/repo-event-logs.graphql index 8fc5d8e3f..57b703dee 100644 --- a/apps/spruce/src/gql/queries/repo-event-logs.graphql +++ b/apps/spruce/src/gql/queries/repo-event-logs.graphql @@ -1,7 +1,7 @@ #import "../fragments/projectSettings/projectEventSettings.graphql" query RepoEventLogs($id: String!, $limit: Int, $before: Time) { - repoEvents(id: $id, limit: $limit, before: $before) { + repoEvents(id: $id, repoId: $id, limit: $limit, before: $before) { count eventLogEntries { after { diff --git a/apps/spruce/src/gql/queries/repo-settings.graphql b/apps/spruce/src/gql/queries/repo-settings.graphql index 465c72d0d..138acaf45 100644 --- a/apps/spruce/src/gql/queries/repo-settings.graphql +++ b/apps/spruce/src/gql/queries/repo-settings.graphql @@ -1,7 +1,7 @@ #import "../fragments/projectSettings/index.graphql" query RepoSettings($repoId: String!) { - repoSettings(id: $repoId) { + repoSettings(id: $repoId, repoId: $repoId) { ...RepoSettingsFields } } diff --git a/apps/spruce/src/gql/queries/task-statuses.graphql b/apps/spruce/src/gql/queries/task-statuses.graphql index 66310aa1c..45b21f9c0 100644 --- a/apps/spruce/src/gql/queries/task-statuses.graphql +++ b/apps/spruce/src/gql/queries/task-statuses.graphql @@ -1,5 +1,5 @@ query TaskStatuses($id: String!) { - version(id: $id) { + version(versionId: $id) { baseTaskStatuses id taskStatuses diff --git a/apps/spruce/src/gql/queries/undispatched-tasks.graphql b/apps/spruce/src/gql/queries/undispatched-tasks.graphql index 9e08e0f8e..ea4402e99 100644 --- a/apps/spruce/src/gql/queries/undispatched-tasks.graphql +++ b/apps/spruce/src/gql/queries/undispatched-tasks.graphql @@ -1,5 +1,5 @@ query UndispatchedTasks($versionId: String!) { - version(id: $versionId) { + version(versionId: $versionId) { id tasks( options: { statuses: ["unscheduled"], includeEmptyActivation: true } diff --git a/apps/spruce/src/gql/queries/version-task-durations.graphql b/apps/spruce/src/gql/queries/version-task-durations.graphql index ea697ca71..db390688e 100644 --- a/apps/spruce/src/gql/queries/version-task-durations.graphql +++ b/apps/spruce/src/gql/queries/version-task-durations.graphql @@ -2,7 +2,7 @@ query VersionTaskDurations( $versionId: String! $taskFilterOptions: TaskFilterOptions! ) { - version(id: $versionId) { + version(versionId: $versionId) { id tasks(options: $taskFilterOptions) { count diff --git a/apps/spruce/src/gql/queries/version-tasks.graphql b/apps/spruce/src/gql/queries/version-tasks.graphql index 6d6f21b59..c583fa9ec 100644 --- a/apps/spruce/src/gql/queries/version-tasks.graphql +++ b/apps/spruce/src/gql/queries/version-tasks.graphql @@ -2,7 +2,7 @@ query VersionTasks( $versionId: String! $taskFilterOptions: TaskFilterOptions! ) { - version(id: $versionId) { + version(versionId: $versionId) { id isPatch tasks(options: $taskFilterOptions) { diff --git a/apps/spruce/src/gql/queries/version.graphql b/apps/spruce/src/gql/queries/version.graphql index 56ab21c20..397dadc0f 100644 --- a/apps/spruce/src/gql/queries/version.graphql +++ b/apps/spruce/src/gql/queries/version.graphql @@ -1,7 +1,7 @@ #import "../fragments/upstreamProject.graphql" query Version($id: String!) { - version(id: $id) { + version(versionId: $id) { activated author authorEmail diff --git a/apps/spruce/src/pages/projectSettings/HeaderButtons.tsx b/apps/spruce/src/pages/projectSettings/HeaderButtons.tsx index 314ef8593..c39c9e607 100644 --- a/apps/spruce/src/pages/projectSettings/HeaderButtons.tsx +++ b/apps/spruce/src/pages/projectSettings/HeaderButtons.tsx @@ -105,7 +105,7 @@ export const HeaderButtons: React.FC = ({ id, projectType, tab }) => { const onClick = () => { const formToGql: FormToGqlFunction = formToGqlMap[tab]; - const newData = formToGql(formData, id); + const newData = formToGql(formData, isRepo, id); const save = (update, section) => isRepo ? saveRepoSection({ diff --git a/apps/spruce/src/pages/projectSettings/tabs/AccessTab/transformers.test.ts b/apps/spruce/src/pages/projectSettings/tabs/AccessTab/transformers.test.ts index acf509fca..1cb23f0cd 100644 --- a/apps/spruce/src/pages/projectSettings/tabs/AccessTab/transformers.test.ts +++ b/apps/spruce/src/pages/projectSettings/tabs/AccessTab/transformers.test.ts @@ -11,7 +11,7 @@ describe("repo data", () => { }); it("correctly converts from a form to GQL", () => { - expect(formToGql(repoForm, "repo")).toStrictEqual(repoResult); + expect(formToGql(repoForm, true, "repo")).toStrictEqual(repoResult); }); }); @@ -21,7 +21,9 @@ describe("project data", () => { }); it("correctly converts from a form to GQL", () => { - expect(formToGql(projectForm, "project")).toStrictEqual(projectResult); + expect(formToGql(projectForm, false, "project")).toStrictEqual( + projectResult, + ); }); }); @@ -34,7 +36,8 @@ const projectForm: AccessFormState = { }, }; -const projectResult: Pick = { +const projectResult: Pick = { + projectId: "project", projectRef: { id: "project", restricted: true, @@ -51,7 +54,8 @@ const repoForm: AccessFormState = { }, }; -const repoResult: Pick = { +const repoResult: Pick = { + repoId: "repo", projectRef: { id: "repo", restricted: true, diff --git a/apps/spruce/src/pages/projectSettings/tabs/AccessTab/transformers.ts b/apps/spruce/src/pages/projectSettings/tabs/AccessTab/transformers.ts index d9b86cd8a..63841e0a6 100644 --- a/apps/spruce/src/pages/projectSettings/tabs/AccessTab/transformers.ts +++ b/apps/spruce/src/pages/projectSettings/tabs/AccessTab/transformers.ts @@ -18,12 +18,12 @@ export const gqlToForm = ((data) => { }; }) satisfies GqlToFormFunction; -export const formToGql = (({ accessSettings, admin }, id) => { +export const formToGql = (({ accessSettings, admin }, isRepo, id) => { const projectRef: ProjectInput = { id, restricted: accessSettings.restricted, admins: admin.admins, }; - return { projectRef }; + return { ...(isRepo ? { repoId: id } : { projectId: id }), projectRef }; }) satisfies FormToGqlFunction; diff --git a/apps/spruce/src/pages/projectSettings/tabs/ContainersTab/transformers.test.ts b/apps/spruce/src/pages/projectSettings/tabs/ContainersTab/transformers.test.ts index 7050c462d..fc13b2b0e 100644 --- a/apps/spruce/src/pages/projectSettings/tabs/ContainersTab/transformers.test.ts +++ b/apps/spruce/src/pages/projectSettings/tabs/ContainersTab/transformers.test.ts @@ -10,7 +10,7 @@ describe("containers", () => { expect(gqlToForm(projectBase)).toStrictEqual(projectFormBase); }); it("correctly converts from a form to GQL", () => { - expect(formToGql(projectFormBase, "spruce")).toStrictEqual( + expect(formToGql(projectFormBase, false, "spruce")).toStrictEqual( projectResultBase, ); }); @@ -29,6 +29,7 @@ const projectFormBase: ContainersFormState = { }; const projectResultBase: ProjectSettingsInput = { + projectId: "spruce", projectRef: { id: "spruce", containerSizeDefinitions: [ diff --git a/apps/spruce/src/pages/projectSettings/tabs/ContainersTab/transformers.ts b/apps/spruce/src/pages/projectSettings/tabs/ContainersTab/transformers.ts index 2f983a4f9..a9e8216c6 100644 --- a/apps/spruce/src/pages/projectSettings/tabs/ContainersTab/transformers.ts +++ b/apps/spruce/src/pages/projectSettings/tabs/ContainersTab/transformers.ts @@ -15,9 +15,10 @@ export const gqlToForm = ((data) => { }; }) satisfies GqlToFormFunction; -export const formToGql = ((formState, id) => { +export const formToGql = ((formState, isRepo, id) => { const { containerSizeDefinitions } = formState; return { + ...(isRepo ? { repoId: id } : { projectId: id }), projectRef: { id, containerSizeDefinitions: containerSizeDefinitions.variables, diff --git a/apps/spruce/src/pages/projectSettings/tabs/GeneralTab/transformers.test.ts b/apps/spruce/src/pages/projectSettings/tabs/GeneralTab/transformers.test.ts index bd8b21c10..6b0e01e8b 100644 --- a/apps/spruce/src/pages/projectSettings/tabs/GeneralTab/transformers.test.ts +++ b/apps/spruce/src/pages/projectSettings/tabs/GeneralTab/transformers.test.ts @@ -14,7 +14,7 @@ describe("repo data", () => { }); it("correctly converts from a form to GQL", () => { - expect(formToGql(repoForm, "repo")).toStrictEqual(repoResult); + expect(formToGql(repoForm, true, "repo")).toStrictEqual(repoResult); }); }); @@ -24,7 +24,9 @@ describe("project data", () => { }); it("correctly converts from a form to GQL", () => { - expect(formToGql(projectForm, "project")).toStrictEqual(projectResult); + expect(formToGql(projectForm, false, "project")).toStrictEqual( + projectResult, + ); }); }); @@ -67,7 +69,8 @@ const repoForm: GeneralFormState = { }, }; -const repoResult: Pick = { +const repoResult: Pick = { + repoId: "repo", projectRef: { id: "repo", owner: "evergreen-ci", @@ -133,7 +136,8 @@ const projectForm: GeneralFormState = { }, }; -const projectResult: Pick = { +const projectResult: Pick = { + projectId: "project", projectRef: { id: "project", enabled: false, diff --git a/apps/spruce/src/pages/projectSettings/tabs/GeneralTab/transformers.ts b/apps/spruce/src/pages/projectSettings/tabs/GeneralTab/transformers.ts index 328ab6dc2..59be18c6d 100644 --- a/apps/spruce/src/pages/projectSettings/tabs/GeneralTab/transformers.ts +++ b/apps/spruce/src/pages/projectSettings/tabs/GeneralTab/transformers.ts @@ -68,6 +68,7 @@ export const formToGql = (( historicalTaskDataCaching: { disabledStatsCache }, projectFlags, }, + isRepo, id, ) => { const projectRef: ProjectInput = { @@ -101,5 +102,5 @@ export const formToGql = (( disabledStatsCache, }; - return { projectRef }; + return { ...(isRepo ? { repoId: id } : { projectId: id }), projectRef }; }) satisfies FormToGqlFunction; diff --git a/apps/spruce/src/pages/projectSettings/tabs/GithubCommitQueueTab/transformers.test.ts b/apps/spruce/src/pages/projectSettings/tabs/GithubCommitQueueTab/transformers.test.ts index 8c19342fb..7f2378cd2 100644 --- a/apps/spruce/src/pages/projectSettings/tabs/GithubCommitQueueTab/transformers.test.ts +++ b/apps/spruce/src/pages/projectSettings/tabs/GithubCommitQueueTab/transformers.test.ts @@ -19,7 +19,7 @@ describe("repo data", () => { }); it("correctly converts from a form to GQL", () => { - expect(formToGql(repoForm, "repo")).toStrictEqual(repoResult); + expect(formToGql(repoForm, true, "repo")).toStrictEqual(repoResult); }); }); @@ -31,7 +31,9 @@ describe("project data", () => { }); it("correctly converts from a form to GQL and omits empty strings", () => { - expect(formToGql(projectForm, "project")).toStrictEqual(projectResult); + expect(formToGql(projectForm, false, "project")).toStrictEqual( + projectResult, + ); }); it("correctly merges project and repo form states", () => { @@ -139,7 +141,11 @@ const projectForm: GCQFormState = { }, }; -const projectResult: Pick = { +const projectResult: Pick< + ProjectSettingsInput, + "projectId" | "projectRef" | "aliases" +> = { + projectId: "project", projectRef: { id: "project", prTestingEnabled: null, @@ -275,37 +281,39 @@ const repoForm: GCQFormState = { }, }; -const repoResult: Pick = { - projectRef: { - id: "repo", - prTestingEnabled: false, - manualPrTestingEnabled: false, - githubChecksEnabled: true, - gitTagVersionsEnabled: false, - gitTagAuthorizedUsers: ["admin"], - gitTagAuthorizedTeams: [], - commitQueue: { - enabled: true, - message: "Commit Queue Message", - mergeMethod: "squash", - mergeQueue: MergeQueue.Github, - }, - }, - aliases: [ - { - id: "2", - alias: "__github_checks", - description: "", - gitTag: "", - remotePath: "", - task: "", - taskTags: ["tTag"], - variant: "", - variantTags: ["vTag"], - parameters: [], +const repoResult: Pick = + { + repoId: "repo", + projectRef: { + id: "repo", + prTestingEnabled: false, + manualPrTestingEnabled: false, + githubChecksEnabled: true, + gitTagVersionsEnabled: false, + gitTagAuthorizedUsers: ["admin"], + gitTagAuthorizedTeams: [], + commitQueue: { + enabled: true, + message: "Commit Queue Message", + mergeMethod: "squash", + mergeQueue: MergeQueue.Github, + }, }, - ], -}; + aliases: [ + { + id: "2", + alias: "__github_checks", + description: "", + gitTag: "", + remotePath: "", + task: "", + taskTags: ["tTag"], + variant: "", + variantTags: ["vTag"], + parameters: [], + }, + ], + }; const mergedForm: GCQFormState = { github: { diff --git a/apps/spruce/src/pages/projectSettings/tabs/GithubCommitQueueTab/transformers.ts b/apps/spruce/src/pages/projectSettings/tabs/GithubCommitQueueTab/transformers.ts index 0243fd7bd..2d23f813c 100644 --- a/apps/spruce/src/pages/projectSettings/tabs/GithubCommitQueueTab/transformers.ts +++ b/apps/spruce/src/pages/projectSettings/tabs/GithubCommitQueueTab/transformers.ts @@ -127,6 +127,7 @@ export const formToGql = (( users: { gitTagAuthorizedUsers, gitTagAuthorizedUsersOverride }, }, }, + isRepo, id, ) => { const projectRef: ProjectInput = { @@ -181,6 +182,7 @@ export const formToGql = (( ]; return { + ...(isRepo ? { repoId: id } : { projectId: id }), projectRef, aliases, }; diff --git a/apps/spruce/src/pages/projectSettings/tabs/NotificationsTab/transformers.test.ts b/apps/spruce/src/pages/projectSettings/tabs/NotificationsTab/transformers.test.ts index ab4e39003..e3990347e 100644 --- a/apps/spruce/src/pages/projectSettings/tabs/NotificationsTab/transformers.test.ts +++ b/apps/spruce/src/pages/projectSettings/tabs/NotificationsTab/transformers.test.ts @@ -20,7 +20,9 @@ describe("project data", () => { }); it("correctly converts from a form to GQL when a banner value exists in the form", () => { - expect(formToGql({ ...projectFormBase, banner }, "spruce")).toStrictEqual({ + expect( + formToGql({ ...projectFormBase, banner }, false, "spruce"), + ).toStrictEqual({ ...projectResultBase, projectRef: { ...projectResultBase.projectRef, @@ -30,7 +32,7 @@ describe("project data", () => { }); it("correctly converts from a form to GQL when the subscriptions field is empty", () => { - expect(formToGql(projectFormBase, "spruce")).toStrictEqual( + expect(formToGql(projectFormBase, false, "spruce")).toStrictEqual( projectResultBase, ); }); @@ -88,7 +90,9 @@ describe("project data", () => { ], }; - expect(formToGql(projectForm, "spruce")).toStrictEqual(projectResult); + expect(formToGql(projectForm, false, "spruce")).toStrictEqual( + projectResult, + ); }); it("handles jira issue subscriptions", () => { @@ -150,7 +154,9 @@ describe("project data", () => { }, ], }; - expect(formToGql(projectForm, "spruce")).toStrictEqual(projectResult); + expect(formToGql(projectForm, false, "spruce")).toStrictEqual( + projectResult, + ); }); it("handles webhook subscriptions", () => { const projectForm = { @@ -230,7 +236,9 @@ describe("project data", () => { ], }; - expect(formToGql(projectForm, "spruce")).toStrictEqual(projectResult); + expect(formToGql(projectForm, false, "spruce")).toStrictEqual( + projectResult, + ); }); }); @@ -242,6 +250,7 @@ const projectFormBase: NotificationsFormState = { }; const projectResultBase: ProjectSettingsInput = { + projectId: "spruce", projectRef: { id: "spruce", notifyOnBuildFailure: null, diff --git a/apps/spruce/src/pages/projectSettings/tabs/NotificationsTab/transformers.ts b/apps/spruce/src/pages/projectSettings/tabs/NotificationsTab/transformers.ts index 6e235bb82..ba2ec5eab 100644 --- a/apps/spruce/src/pages/projectSettings/tabs/NotificationsTab/transformers.ts +++ b/apps/spruce/src/pages/projectSettings/tabs/NotificationsTab/transformers.ts @@ -138,17 +138,18 @@ export const gqlToForm = ((data, { projectType }) => { }; }) satisfies GqlToFormFunction; -export const formToGql = ((formState, projectId) => { +export const formToGql = ((formState, isRepo, id) => { const { banner, buildBreakSettings, subscriptions } = formState; const projectRef: ProjectInput = { - id: projectId, + id, notifyOnBuildFailure: buildBreakSettings.notifyOnBuildFailure, ...(banner && { banner: banner.bannerData }), }; const transformedSubscriptions: SubscriptionInput[] = subscriptions.map( - getGqlPayload(projectId), + getGqlPayload(id), ); return { + ...(isRepo ? { repoId: id } : { projectId: id }), projectRef, subscriptions: transformedSubscriptions, }; diff --git a/apps/spruce/src/pages/projectSettings/tabs/PatchAliasesTab/transformers.test.ts b/apps/spruce/src/pages/projectSettings/tabs/PatchAliasesTab/transformers.test.ts index d9ea5025a..8091d7ef8 100644 --- a/apps/spruce/src/pages/projectSettings/tabs/PatchAliasesTab/transformers.test.ts +++ b/apps/spruce/src/pages/projectSettings/tabs/PatchAliasesTab/transformers.test.ts @@ -15,7 +15,7 @@ describe("repo data", () => { }); it("correctly converts from a form to GQL", () => { - expect(formToGql(repoForm, "repo")).toStrictEqual(repoResult); + expect(formToGql(repoForm, true, "repo")).toStrictEqual(repoResult); }); }); @@ -27,7 +27,9 @@ describe("project data", () => { }); it("correctly converts from a form to GQL and omits empty strings", () => { - expect(formToGql(projectForm, "project")).toStrictEqual(projectResult); + expect(formToGql(projectForm, false, "project")).toStrictEqual( + projectResult, + ); }); }); @@ -42,7 +44,11 @@ const projectForm: PatchAliasesFormState = { }, }; -const projectResult: Pick = { +const projectResult: Pick< + ProjectSettingsInput, + "projectId" | "projectRef" | "aliases" +> = { + projectId: "project", projectRef: { id: "project", patchTriggerAliases: null, @@ -105,43 +111,45 @@ const repoForm: PatchAliasesFormState = { }, }; -const repoResult: Pick = { - projectRef: { - id: "repo", - patchTriggerAliases: [ +const repoResult: Pick = + { + repoId: "repo", + projectRef: { + id: "repo", + patchTriggerAliases: [ + { + alias: "alias1", + childProjectIdentifier: "spruce", + taskSpecifiers: [ + { + patchAlias: "alias2", + taskRegex: "", + variantRegex: "", + }, + { + patchAlias: "", + taskRegex: ".*", + variantRegex: ".*", + }, + ], + status: "success", + parentAsModule: "", + }, + ], + githubTriggerAliases: ["alias1"], + }, + aliases: [ { - alias: "alias1", - childProjectIdentifier: "spruce", - taskSpecifiers: [ - { - patchAlias: "alias2", - taskRegex: "", - variantRegex: "", - }, - { - patchAlias: "", - taskRegex: ".*", - variantRegex: ".*", - }, - ], - status: "success", - parentAsModule: "", + id: "4", + alias: "my alias name", + description: "my description", + gitTag: "", + variant: "", + task: "", + remotePath: "", + parameters: [], + variantTags: ["okay"], + taskTags: ["hi"], }, ], - githubTriggerAliases: ["alias1"], - }, - aliases: [ - { - id: "4", - alias: "my alias name", - description: "my description", - gitTag: "", - variant: "", - task: "", - remotePath: "", - parameters: [], - variantTags: ["okay"], - taskTags: ["hi"], - }, - ], -}; + }; diff --git a/apps/spruce/src/pages/projectSettings/tabs/PatchAliasesTab/transformers.ts b/apps/spruce/src/pages/projectSettings/tabs/PatchAliasesTab/transformers.ts index 54ee14b6f..ed901f86b 100644 --- a/apps/spruce/src/pages/projectSettings/tabs/PatchAliasesTab/transformers.ts +++ b/apps/spruce/src/pages/projectSettings/tabs/PatchAliasesTab/transformers.ts @@ -60,6 +60,7 @@ export const gqlToForm: GqlToFormFunction = ((data, options) => { export const formToGql = (( { patchAliases, patchTriggerAliases: ptaData }, + isRepo, id, ) => { const aliases = transformAliases( @@ -98,6 +99,7 @@ export const formToGql = (( : null; return { + ...(isRepo ? { repoId: id } : { projectId: id }), projectRef: { id, patchTriggerAliases, githubTriggerAliases }, aliases, }; diff --git a/apps/spruce/src/pages/projectSettings/tabs/PeriodicBuildsTab/transformers.test.ts b/apps/spruce/src/pages/projectSettings/tabs/PeriodicBuildsTab/transformers.test.ts index cdf9595e2..e854bf70f 100644 --- a/apps/spruce/src/pages/projectSettings/tabs/PeriodicBuildsTab/transformers.test.ts +++ b/apps/spruce/src/pages/projectSettings/tabs/PeriodicBuildsTab/transformers.test.ts @@ -14,7 +14,9 @@ describe("project data", () => { }); it("correctly converts from a form to GQL and omits empty strings", () => { - expect(formToGql(projectForm, "project")).toStrictEqual(projectResult); + expect(formToGql(projectForm, false, "project")).toStrictEqual( + projectResult, + ); }); }); @@ -26,7 +28,7 @@ describe("repo data", () => { }); it("correctly converts from a form to GQL", () => { - expect(formToGql(repoForm, "repo")).toStrictEqual(repoResult); + expect(formToGql(repoForm, true, "repo")).toStrictEqual(repoResult); }); }); @@ -35,7 +37,8 @@ const projectForm: PeriodicBuildsFormState = { periodicBuilds: [], }; -const projectResult: Pick = { +const projectResult: Pick = { + projectId: "project", projectRef: { id: "project", periodicBuilds: [], @@ -76,7 +79,8 @@ const repoForm: PeriodicBuildsFormState = { ], }; -const repoResult: Pick = { +const repoResult: Pick = { + repoId: "repo", projectRef: { id: "repo", periodicBuilds: [ diff --git a/apps/spruce/src/pages/projectSettings/tabs/PeriodicBuildsTab/transformers.ts b/apps/spruce/src/pages/projectSettings/tabs/PeriodicBuildsTab/transformers.ts index 27f6f2d51..7c35e1fda 100644 --- a/apps/spruce/src/pages/projectSettings/tabs/PeriodicBuildsTab/transformers.ts +++ b/apps/spruce/src/pages/projectSettings/tabs/PeriodicBuildsTab/transformers.ts @@ -65,16 +65,25 @@ export const gqlToForm = ((data, { projectType }) => { export const formToGql = (( { periodicBuilds, periodicBuildsOverride }, - projectId, + isRepo, + id, ) => ({ + ...(isRepo ? { repoId: id } : { projectId: id }), projectRef: { - id: projectId, + id, periodicBuilds: periodicBuildsOverride ? periodicBuilds.map( - ({ alias, configFile, id, interval, message, nextRunTime }) => ({ + ({ alias, configFile, - id: id || "", + id: periodicBuildId, + interval, + message, + nextRunTime, + }) => ({ + alias, + configFile, + id: periodicBuildId || "", message, nextRunTime: new Date(nextRunTime), ...(interval.specifier === IntervalSpecifier.Cron diff --git a/apps/spruce/src/pages/projectSettings/tabs/PluginsTab/transformers.test.ts b/apps/spruce/src/pages/projectSettings/tabs/PluginsTab/transformers.test.ts index 5b6b35dfa..fcb3cbc77 100644 --- a/apps/spruce/src/pages/projectSettings/tabs/PluginsTab/transformers.test.ts +++ b/apps/spruce/src/pages/projectSettings/tabs/PluginsTab/transformers.test.ts @@ -12,7 +12,7 @@ describe("repo data", () => { }); it("correctly converts from a form to GQL", () => { - expect(formToGql(repoForm, "repo")).toStrictEqual(repoResult); + expect(formToGql(repoForm, true, "repo")).toStrictEqual(repoResult); }); }); @@ -22,7 +22,9 @@ describe("project data", () => { }); it("correctly converts from a form to GQL", () => { - expect(formToGql(projectForm, "project")).toStrictEqual(projectResult); + expect(formToGql(projectForm, false, "project")).toStrictEqual( + projectResult, + ); }); }); @@ -63,7 +65,8 @@ const projectForm: PluginsFormState = { ], }; -const projectResult: Pick = { +const projectResult: Pick = { + projectId: "project", projectRef: { id: "project", perfEnabled: true, @@ -135,7 +138,8 @@ const repoForm: PluginsFormState = { ], }; -const repoResult: Pick = { +const repoResult: Pick = { + repoId: "repo", projectRef: { id: "repo", perfEnabled: true, diff --git a/apps/spruce/src/pages/projectSettings/tabs/PluginsTab/transformers.ts b/apps/spruce/src/pages/projectSettings/tabs/PluginsTab/transformers.ts index b1aa4214e..7a0969e0d 100644 --- a/apps/spruce/src/pages/projectSettings/tabs/PluginsTab/transformers.ts +++ b/apps/spruce/src/pages/projectSettings/tabs/PluginsTab/transformers.ts @@ -54,6 +54,7 @@ export const gqlToForm = ((data) => { export const formToGql = (( { buildBaronSettings, externalLinks, performanceSettings }, + isRepo, id, ) => { const projectRef: ProjectInput = { @@ -79,7 +80,7 @@ export const formToGql = (( })) : null, }; - return { projectRef }; + return { ...(isRepo ? { repoId: id } : { projectId: id }), projectRef }; }) satisfies FormToGqlFunction; // conditionally include the buildBaronSettings field based on the useBuildBaron boolean diff --git a/apps/spruce/src/pages/projectSettings/tabs/ProjectTriggersTab/transformers.test.ts b/apps/spruce/src/pages/projectSettings/tabs/ProjectTriggersTab/transformers.test.ts index 4d58bf659..c245e520e 100644 --- a/apps/spruce/src/pages/projectSettings/tabs/ProjectTriggersTab/transformers.test.ts +++ b/apps/spruce/src/pages/projectSettings/tabs/ProjectTriggersTab/transformers.test.ts @@ -14,7 +14,9 @@ describe("project data", () => { }); it("correctly converts from a form to GQL", () => { - expect(formToGql(projectForm, "project")).toStrictEqual(projectResult); + expect(formToGql(projectForm, false, "project")).toStrictEqual( + projectResult, + ); }); }); @@ -26,7 +28,7 @@ describe("repo data", () => { }); it("correctly converts from a form to GQL", () => { - expect(formToGql(repoForm, "repo")).toStrictEqual(repoResult); + expect(formToGql(repoForm, true, "repo")).toStrictEqual(repoResult); }); }); @@ -35,7 +37,8 @@ const projectForm: ProjectTriggersFormState = { triggers: [], }; -const projectResult: Pick = { +const projectResult: Pick = { + projectId: "project", projectRef: { id: "project", triggers: [], @@ -60,7 +63,8 @@ const repoForm: ProjectTriggersFormState = { ], }; -const repoResult: Pick = { +const repoResult: Pick = { + repoId: "repo", projectRef: { id: "repo", triggers: [ diff --git a/apps/spruce/src/pages/projectSettings/tabs/ProjectTriggersTab/transformers.ts b/apps/spruce/src/pages/projectSettings/tabs/ProjectTriggersTab/transformers.ts index c8c77334f..7f6ff7a8e 100644 --- a/apps/spruce/src/pages/projectSettings/tabs/ProjectTriggersTab/transformers.ts +++ b/apps/spruce/src/pages/projectSettings/tabs/ProjectTriggersTab/transformers.ts @@ -37,9 +37,10 @@ export const gqlToForm = ((data, { projectType }) => { }; }) satisfies GqlToFormFunction; -export const formToGql = (({ triggers, triggersOverride }, projectId) => ({ +export const formToGql = (({ triggers, triggersOverride }, isRepo, id) => ({ + ...(isRepo ? { repoId: id } : { projectId: id }), projectRef: { - id: projectId, + id, triggers: triggersOverride ? triggers.map((trigger) => ({ project: trigger.project, diff --git a/apps/spruce/src/pages/projectSettings/tabs/VariablesTab/transformers.test.ts b/apps/spruce/src/pages/projectSettings/tabs/VariablesTab/transformers.test.ts index 4ecf0bcfd..f568e5936 100644 --- a/apps/spruce/src/pages/projectSettings/tabs/VariablesTab/transformers.test.ts +++ b/apps/spruce/src/pages/projectSettings/tabs/VariablesTab/transformers.test.ts @@ -17,6 +17,7 @@ describe("project data", () => { { vars: [...form.vars, {} as Unpacked], }, + false, "project", ), ).toStrictEqual(result); @@ -42,13 +43,15 @@ const form: VariablesFormState = { ], }; -const result: Pick = { - projectRef: { - id: "project", - }, - vars: { - vars: { test_name: "", test_two: "val" }, - privateVarsList: ["test_name"], - adminOnlyVarsList: ["test_name"], - }, -}; +const result: Pick = + { + projectId: "project", + projectRef: { + id: "project", + }, + vars: { + vars: { test_name: "", test_two: "val" }, + privateVarsList: ["test_name"], + adminOnlyVarsList: ["test_name"], + }, + }; diff --git a/apps/spruce/src/pages/projectSettings/tabs/VariablesTab/transformers.ts b/apps/spruce/src/pages/projectSettings/tabs/VariablesTab/transformers.ts index 0292c951c..65e83656d 100644 --- a/apps/spruce/src/pages/projectSettings/tabs/VariablesTab/transformers.ts +++ b/apps/spruce/src/pages/projectSettings/tabs/VariablesTab/transformers.ts @@ -21,7 +21,7 @@ export const gqlToForm = ((data) => { }; }) satisfies GqlToFormFunction; -export const formToGql = (({ vars: varsData }, id) => { +export const formToGql = (({ vars: varsData }, isRepo, id) => { const vars = varsData.reduce( (acc, { isAdminOnly, isDisabled, isPrivate, varName, varValue }) => { if (!varName || !varValue) return acc; @@ -45,6 +45,7 @@ export const formToGql = (({ vars: varsData }, id) => { }, ); return { + ...(isRepo ? { repoId: id } : { projectId: id }), projectRef: { id }, vars, }; diff --git a/apps/spruce/src/pages/projectSettings/tabs/ViewsAndFiltersTab/transformers.test.ts b/apps/spruce/src/pages/projectSettings/tabs/ViewsAndFiltersTab/transformers.test.ts index e078500ba..1659ba86c 100644 --- a/apps/spruce/src/pages/projectSettings/tabs/ViewsAndFiltersTab/transformers.test.ts +++ b/apps/spruce/src/pages/projectSettings/tabs/ViewsAndFiltersTab/transformers.test.ts @@ -18,7 +18,7 @@ describe("repo data", () => { }); it("correctly converts from a form to GQL", () => { - expect(formToGql(repoForm, "repo")).toStrictEqual(repoResult); + expect(formToGql(repoForm, true, "repo")).toStrictEqual(repoResult); }); }); @@ -30,7 +30,9 @@ describe("project data", () => { }); it("correctly converts from a form to GQL", () => { - expect(formToGql(projectForm, "project")).toStrictEqual(projectResult); + expect(formToGql(projectForm, false, "project")).toStrictEqual( + projectResult, + ); }); }); @@ -45,7 +47,8 @@ const repoForm: ViewsFormState = { ], }; -const repoResult: Pick = { +const repoResult: Pick = { + repoId: "repo", projectRef: { id: "repo", parsleyFilters: [ @@ -78,7 +81,8 @@ const projectForm: ViewsFormState = { }, }; -const projectResult: Pick = { +const projectResult: Pick = { + projectId: "project", projectRef: { id: "project", parsleyFilters: [ diff --git a/apps/spruce/src/pages/projectSettings/tabs/ViewsAndFiltersTab/transformers.ts b/apps/spruce/src/pages/projectSettings/tabs/ViewsAndFiltersTab/transformers.ts index ca0ab34a3..af92888c8 100644 --- a/apps/spruce/src/pages/projectSettings/tabs/ViewsAndFiltersTab/transformers.ts +++ b/apps/spruce/src/pages/projectSettings/tabs/ViewsAndFiltersTab/transformers.ts @@ -28,7 +28,8 @@ export const gqlToForm = ((data, { projectType }) => { }; }) satisfies GqlToFormFunction; -export const formToGql = (({ parsleyFilters, view }, id) => ({ +export const formToGql = (({ parsleyFilters, view }, isRepo, id) => ({ + ...(isRepo ? { repoId: id } : { projectId: id }), projectRef: { id, parsleyFilters: parsleyFilters.map( diff --git a/apps/spruce/src/pages/projectSettings/tabs/VirtualWorkstationTab/transformers.test.ts b/apps/spruce/src/pages/projectSettings/tabs/VirtualWorkstationTab/transformers.test.ts index bab83ab5e..3106ef116 100644 --- a/apps/spruce/src/pages/projectSettings/tabs/VirtualWorkstationTab/transformers.test.ts +++ b/apps/spruce/src/pages/projectSettings/tabs/VirtualWorkstationTab/transformers.test.ts @@ -14,7 +14,9 @@ describe("project data", () => { }); it("correctly converts from a form to GQL and omits empty strings", () => { - expect(formToGql(projectForm, "project")).toStrictEqual(projectResult); + expect(formToGql(projectForm, false, "project")).toStrictEqual( + projectResult, + ); }); }); @@ -26,7 +28,7 @@ describe("repo data", () => { }); it("correctly converts from a form to GQL", () => { - expect(formToGql(repoForm, "repo")).toStrictEqual(repoResult); + expect(formToGql(repoForm, true, "repo")).toStrictEqual(repoResult); }); }); @@ -43,7 +45,8 @@ const projectForm: VWFormState = { }, }; -const projectResult: Pick = { +const projectResult: Pick = { + projectId: "project", projectRef: { id: "project", workstationConfig: { @@ -66,7 +69,8 @@ const repoForm: VWFormState = { }, }; -const repoResult: Pick = { +const repoResult: Pick = { + repoId: "repo", projectRef: { id: "repo", workstationConfig: { diff --git a/apps/spruce/src/pages/projectSettings/tabs/VirtualWorkstationTab/transformers.ts b/apps/spruce/src/pages/projectSettings/tabs/VirtualWorkstationTab/transformers.ts index 9976b7877..202389bdf 100644 --- a/apps/spruce/src/pages/projectSettings/tabs/VirtualWorkstationTab/transformers.ts +++ b/apps/spruce/src/pages/projectSettings/tabs/VirtualWorkstationTab/transformers.ts @@ -29,8 +29,10 @@ export const gqlToForm = ((data, options) => { export const formToGql = (( { commands: { setupCommands, setupCommandsOverride }, gitClone }, + isRepo, id, ) => ({ + ...(isRepo ? { repoId: id } : { projectId: id }), projectRef: { id, workstationConfig: { diff --git a/apps/spruce/src/pages/projectSettings/tabs/types.ts b/apps/spruce/src/pages/projectSettings/tabs/types.ts index e5d439c1b..9523ab1d5 100644 --- a/apps/spruce/src/pages/projectSettings/tabs/types.ts +++ b/apps/spruce/src/pages/projectSettings/tabs/types.ts @@ -2,6 +2,7 @@ import { ProjectSettingsTabRoutes } from "constants/routes"; import { ProjectSettingsInput, ProjectSettingsQuery, + RepoSettingsInput, RepoSettingsQuery, } from "gql/generated/types"; import { AccessFormState } from "./AccessTab/types"; @@ -51,8 +52,9 @@ export type GqlToFormFunction = ( export type FormToGqlFunction = ( form: FormStateMap[T], + isRepo: boolean, id?: string, -) => ProjectSettingsInput; +) => ProjectSettingsInput | RepoSettingsInput; const { EventLog, ...WritableProjectSettingsTabs } = ProjectSettingsTabRoutes; export { WritableProjectSettingsTabs }; diff --git a/apps/spruce/src/pages/task/ActionButtons.tsx b/apps/spruce/src/pages/task/ActionButtons.tsx index 0268bbfc1..4c7ae99c0 100644 --- a/apps/spruce/src/pages/task/ActionButtons.tsx +++ b/apps/spruce/src/pages/task/ActionButtons.tsx @@ -70,7 +70,7 @@ export const ActionButtons: React.FC = ({ versionMetadata, } = task || {}; - const { isPatch, order } = versionMetadata || {}; + const { id: versionId, isPatch, order } = versionMetadata || {}; const { identifier: projectIdentifier } = project || {}; const isPatchOnCommitQueue = requester === commitQueueRequester; const allExecutionTasksSucceeded = @@ -88,7 +88,7 @@ export const ActionButtons: React.FC = ({ ScheduleTasksMutation, ScheduleTasksMutationVariables >(SCHEDULE_TASKS, { - variables: { taskIds: [taskId] }, + variables: { taskIds: [taskId], versionId }, onCompleted: () => { dispatchToast.success("Task marked as scheduled"); },