a8n: Add ability to update Campaign's CampaignPlan in UpdateCampaign
Created by: mrnugget
This PR implements the majority of the implementation proposed in RFC 95 (see rest of ticket for what's missing). It started out as a proof of concept but as I realized that updating a campaign might not be that complicated if we say that updating a Campaign means changing its CampaignPlanID I implemented it "properly" (there's still bits missing, like Bitbucket Server support, see bottom of this description).
That being said: this idea behind updating a Campaign (and the API) still needs to be validated by @eseliger and @felixfbecker. That's what I expect as their review here.
What I want from @tsenart @ryanslade is a "standard" technical review with feedback on APIs and implementation, so I can work on the PR and possibly shift its direction/implementation while @eseliger and @felixfbecker think about the frontend side of this implementation.
What's in here?
It extends the GraphQL API to accept an optional plan: ID in UpdateCampaignArgs. If the ID points to a finished CampaignPlan, the Campaign will be updated to the new CampaignPlan.
Every CampaignJob (changeset in GraphQL) belonging to the new CampaignPlan will then be compared with the existing ChangesetJobs/Changesets pairs (ExternalChangeset in GraphQL) to decide whether to
- detach
ExternalChangesetfromCampaignand close it on codehost - update title/body/diff of
ExternalChangeseton codehost - keep
ExternalChangesetas it is - create new
ExternalChangeseton the codehost
The decision what to do with which changeset happens synchronously in the updateCampaign mutation.
Then, asynchronously, the changesets are updated/created/closed on the codehost.
What's missing?
The update process as described above is implemented in this PR, except:
-
Close detached changesets on the codehosts -
Updating changesets on BitbucketServer. That only works for GitHub now.
But I don't think these need to necessarily be in this PR and can be addressed in follow-ups.