<commit_before><script>
import $ from 'jquery';
import { mapActions } from 'vuex';
import { __ } from '~/locale';
import FileIcon from '~/vue_shared/components/file_icon.vue';
import ChangedFileIcon from '../changed_file_icon.vue';

export default {
  components: {
    FileIcon,
    ChangedFileIcon,
  },
  props: {
    activeFile: {
      type: Object,
      required: true,
    },
  },
  computed: {
    activeButtonText() {
      return this.activeFile.staged ? __('Unstage') : __('Stage');
    },
    isStaged() {
      return !this.activeFile.changed && this.activeFile.staged;
    },
  },
  methods: {
    ...mapActions(['stageChange', 'unstageChange']),
    actionButtonClicked() {
      if (this.activeFile.staged) {
        this.unstageChange(this.activeFile.path);
      } else {
        this.stageChange(this.activeFile.path);
      }
    },
    showDiscardModal() {
      $(document.getElementById(`discard-file-${this.activeFile.path}`)).modal('show');
    },
  },
};
</script>

<template>
  <div class="d-flex ide-commit-editor-header align-items-center">
    <file-icon
      :file-name="activeFile.name"
      :size="16"
      class="mr-2"
    />
    <strong class="mr-2">
      {{ activeFile.path }}
    </strong>
    <changed-file-icon
      :file="activeFile"
    />
    <div class="ml-auto">
      <button
        v-if="!isStaged"
        type="button"
        class="btn btn-remove btn-inverted append-right-8"
        @click="showDiscardModal"
      >
        {{ __('Discard') }}
      </button>
      <button
        :class="{
          'btn-success': !isStaged,
          'btn-warning': isStaged
        }"
        type="button"
        class="btn btn-inverted"
        @click="actionButtonClicked"
      >
        {{ activeButtonText }}
      </button>
    </div>
  </div>
</template><commit_msg>Fixed alignment of changed icon in commit head<commit_after><script>
import $ from 'jquery';
import { mapActions } from 'vuex';
import { __ } from '~/locale';
import FileIcon from '~/vue_shared/components/file_icon.vue';
import ChangedFileIcon from '../changed_file_icon.vue';

export default {
  components: {
    FileIcon,
    ChangedFileIcon,
  },
  props: {
    activeFile: {
      type: Object,
      required: true,
    },
  },
  computed: {
    activeButtonText() {
      return this.activeFile.staged ? __('Unstage') : __('Stage');
    },
    isStaged() {
      return !this.activeFile.changed && this.activeFile.staged;
    },
  },
  methods: {
    ...mapActions(['stageChange', 'unstageChange']),
    actionButtonClicked() {
      if (this.activeFile.staged) {
        this.unstageChange(this.activeFile.path);
      } else {
        this.stageChange(this.activeFile.path);
      }
    },
    showDiscardModal() {
      $(document.getElementById(`discard-file-${this.activeFile.path}`)).modal('show');
    },
  },
};
</script>

<template>
  <div class="d-flex ide-commit-editor-header align-items-center">
    <file-icon
      :file-name="activeFile.name"
      :size="16"
      class="mr-2"
    />
    <strong class="mr-2">
      {{ activeFile.path }}
    </strong>
    <changed-file-icon
      :file="activeFile"
      class="ml-0"
    />
    <div class="ml-auto">
      <button
        v-if="!isStaged"
        type="button"
        class="btn btn-remove btn-inverted append-right-8"
        @click="showDiscardModal"
      >
        {{ __('Discard') }}
      </button>
      <button
        :class="{
          'btn-success': !isStaged,
          'btn-warning': isStaged
        }"
        type="button"
        class="btn btn-inverted"
        @click="actionButtonClicked"
      >
        {{ activeButtonText }}
      </button>
    </div>
  </div>
</template>
{'fraction_non_alphanumeric': 0.1634199134199134, 'fraction_numerical': 0.002976190476190476, 'mean_word_length': 2.3426763110307416, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6079868', 'n_tokens_mistral': 1207, 'n_tokens_neox': 1198, 'n_words': 195}