Web IDE fix commit after first commit on empty repo

(Follow up from !25463 (merged))

Problem

"Commit to master" AND "Start a new MR" are both selected on repetitive commits to a new repo.

How to reproduce

  1. Use the Web IDE on an empty repo by going straight to the Web IDE URL for the empty project
    • e.g. https://gitlab.com/-/ide/project/gitlab-org/<empty project>/edit/master/-/
  2. Create a file, type something in it and commit (creates the first commit)
  3. Make new changes to the file
  4. Go to "Commit" view
  5. "Commit to master" AND "Start a new MR" are both selected (which is wrong and "Start a new MR" shouldn't be selected/shown at all unless "Create a new branch" option is selected):
  1. After clicking the "Commit" button, the user is sent to a "New Merge Request" screen with merge_request[target_branch]=null in the URL and visible error message:
http://127.0.0.1:3000/root/empty-test-4/-/merge_requests/new?merge_request[source_branch]=master&merge_request[target_branch]=null&nav_source=webide

Screenshot_2020-05-26_at_1.02.53_PM

Kapture_2020-05-26_at_12.53.28

Expected behavior

"Start a new merge request" option is not available when "Commit to master branch" option is selected.

Original issue with crossed master branch option

Description

When using the Web IDE on an empty repo, the user is brought back to the file tree. If they make more changes (without refreshing the page) and go to commit, the commit to master will be crossed out (even though they just committed to master):

bug

Expected behavior

The Commit to master branch option should not be crossed out since this is an available action for me.

Analysis

Part of this is because our state tree does not have a SSOT for "canPushToCurrentBranch" and "isOnDefaultBranch".

Edited by Denys Mishunov