All files / app/assets/javascripts/vue_merge_request_widget/stores get_state_key.js

96.55% Statements 28/29
78.84% Branches 41/52
100% Functions 1/1
96.55% Lines 28/29

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52        49x 16x   33x 11x   22x 1x   21x 1x   20x 1x   19x 1x   18x 2x   16x     16x 1x   15x 1x   14x 1x   13x 5x   8x 2x   6x       1x   5x    
import { DETAILED_MERGE_STATUS } from '../constants';
import { stateKey } from './state_maps';
 
export default function deviseState() {
  if (this.detailedMergeStatus === DETAILED_MERGE_STATUS.PREPARING) {
    return stateKey.preparing;
  }
  if (!this.commitsCount) {
    return stateKey.nothingToMerge;
  }
  if (this.projectArchived) {
    return stateKey.archived;
  }
  if (this.branchMissing) {
    return stateKey.missingBranch;
  }
  if (this.detailedMergeStatus === DETAILED_MERGE_STATUS.CHECKING) {
    return stateKey.checking;
  }
  if (this.hasConflicts) {
    return window.gon?.features?.mergeBlockedComponent ? null : stateKey.conflicts;
  }
  if (this.shouldBeRebased) {
    return window.gon?.features?.mergeBlockedComponent ? null : stateKey.rebase;
  }
  Iif (this.hasMergeChecksFailed && !this.autoMergeEnabled) {
    return window.gon?.features?.mergeBlockedComponent ? null : stateKey.mergeChecksFailed;
  }
  if (this.detailedMergeStatus === DETAILED_MERGE_STATUS.CI_MUST_PASS) {
    return window.gon?.features?.mergeBlockedComponent ? null : stateKey.pipelineFailed;
  }
  if (this.detailedMergeStatus === DETAILED_MERGE_STATUS.DRAFT_STATUS) {
    return window.gon?.features?.mergeBlockedComponent ? null : stateKey.draft;
  }
  if (this.detailedMergeStatus === DETAILED_MERGE_STATUS.DISCUSSIONS_NOT_RESOLVED) {
    return window.gon?.features?.mergeBlockedComponent ? null : stateKey.unresolvedDiscussions;
  }
  if (this.canMerge && this.isSHAMismatch) {
    return stateKey.shaMismatch;
  }
  if (this.autoMergeEnabled && !this.mergeError) {
    return window.gon?.features?.mergeBlockedComponent ? null : stateKey.autoMergeEnabled;
  }
  if (
    this.detailedMergeStatus === DETAILED_MERGE_STATUS.MERGEABLE ||
    this.detailedMergeStatus === DETAILED_MERGE_STATUS.CI_STILL_RUNNING
  ) {
    return stateKey.readyToMerge;
  }
  return window.gon?.features?.mergeBlockedComponent ? null : stateKey.checking;
}