Skip to content

a8n/web: Allow users to specify branch name before Campaign creation and provide great default value

Created by: mrnugget

In order to make "updating Campaigns" work I had to change our current code that turns the Campaign's current title into a human-readable branch name. Otherwise, a title update would produce a new branch name.

The obvious solution to this is that we persist the branch name on Campaign creation and don't change it when we update a campaign.

But since @sqs mentioned in his a8n experience notes that, as a user, he'd like to specify a custom branch (or at least see what the branch name will be), we came up with with [a solution for both problems in Slack]:

  • When creating a campaign users can specify the branch name
  • We provide a suggested default value that's derived from currently typed in Campaign's title
  • We add a label to let the user know that this cannot be changed after creating the campaign
  • In draft mode, the user can still change the branch name as long as not a single changeset has been published. If only a single changeset has been published, it's not editable anymore.

From a technical perspective that means

  • We extend CreateCampaignInput with branchName: String!
  • We persist the branch name on the Campaign and use it when creating changesets
  • We keep the branch name stable across Campaign updates
  • When updating a campaign, we validate that updating the branch name is only allowed when the Campaign itself is in draft mode and not a single Changeset has been published yet
  • We have an input field in the frontend to specify the branch name
  • The input field is prepopulated with a branch name that's derived from the campaign title, using a slugify/sanitization technique similar to the one we used in the backend
  • Since a Campaign needs a title, we only need to prepopulate the field when a title has been typed in, otherwise the form would be invalid anyway