Tinacms: UX - validate create branch with spaces

Created on 10 Jul 2020  路  4Comments  路  Source: tinacms/tinacms

Can we ease the creation of branches for editors that don't know about branch naming conventions?

Scenario

Given I type a space in a branch name
When I click on Create Branch
Then nothing happens
And I have no feedback on why

Demo
https://www.loom.com/share/70bf123c26594a319533a270d1119a77

enhancement good first issue ux

Most helpful comment

At the very least I think we should just slugify the branch names in the package though to avoid this presumably common mistake folks will run into.

All 4 comments

If the branch creation fails, there should be a github:error event that fires. The dev can subscribe to the event and then they can provide feedback with an alert or something. I agree more validation would be good there though.

So it's something developers can act upon using events and writing their own Submit function? I have no idea how it's part of the react-tinacms-github package and if this part is extensible 馃槉

Yeah so they can subscribe to events and then use a callback function to invoke whenever the event is fired. They can subscribe to the event in their app, something like:

  React.useEffect(() => {
    cms.events.subscribe("github:error", function handleError(event) {
        console.error(event)
        cms.alerts.error("Something went wrong!")
    })
  }, [])

I should note that the github:error event also fires when a commit fails, and maybe other things. So it's not specific to the branch situation. However, when branch creation is successful, there's a github:branch:create event.

At the very least I think we should just slugify the branch names in the package though to avoid this presumably common mistake folks will run into.

Was this page helpful?
0 / 5 - 0 ratings