summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_merge_request_widget/stores/get_state_key.js
blob: 2bace3311c89511d229abf29f8a1b24bcc17b3bc (plain)
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
import { stateKey } from './state_maps';

export default function deviseState(data) {
  if (data.project_archived) {
    return stateKey.archived;
  } else if (data.branch_missing) {
    return stateKey.missingBranch;
  } else if (!data.commits_count) {
    return stateKey.nothingToMerge;
  } else if (this.mergeStatus === 'unchecked') {
    return stateKey.checking;
  } else if (data.has_conflicts) {
    return stateKey.conflicts;
  } else if (data.work_in_progress) {
    return stateKey.workInProgress;
  } else if (this.onlyAllowMergeIfPipelineSucceeds && this.isPipelineFailed) {
    return stateKey.pipelineFailed;
  } else if (this.hasMergeableDiscussionsState) {
    return stateKey.unresolvedDiscussions;
  } else if (this.isPipelineBlocked) {
    return stateKey.pipelineBlocked;
  } else if (this.hasSHAChanged) {
    return stateKey.shaMismatch;
  } else if (this.mergeWhenPipelineSucceeds) {
    return this.mergeError ? stateKey.autoMergeFailed : stateKey.mergeWhenPipelineSucceeds;
  } else if (!this.canMerge) {
    return stateKey.notAllowedToMerge;
  } else if (this.canBeMerged) {
    return stateKey.readyToMerge;
  }
  return null;
}