item.vue 1.2 KB
Newer Older
Phil Hughes's avatar
Phil Hughes committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
<script>
import Icon from '../../../vue_shared/components/icon.vue';

export default {
  components: {
    Icon,
  },
  props: {
    item: {
      type: Object,
      required: true,
    },
    currentId: {
      type: String,
      required: true,
    },
17 18 19 20
    currentProjectId: {
      type: String,
      required: true,
    },
Phil Hughes's avatar
Phil Hughes committed
21 22 23
  },
  computed: {
    isActive() {
24 25 26 27
      return (
        this.item.iid === parseInt(this.currentId, 10) &&
        this.currentProjectId === this.item.projectPathWithNamespace
      );
Phil Hughes's avatar
Phil Hughes committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
    },
    pathWithID() {
      return `${this.item.projectPathWithNamespace}!${this.item.iid}`;
    },
  },
  methods: {
    clickItem() {
      this.$emit('click', this.item);
    },
  },
};
</script>

<template>
  <button
    type="button"
44
    class="btn-link d-flex align-items-center"
45
    @click="clickItem"
Phil Hughes's avatar
Phil Hughes committed
46
  >
47
    <span class="d-flex append-right-default ide-merge-request-current-icon">
Phil Hughes's avatar
Phil Hughes committed
48 49 50
      <icon
        v-if="isActive"
        :size="18"
51
        name="mobile-issue-close"
Phil Hughes's avatar
Phil Hughes committed
52 53 54 55 56 57
      />
    </span>
    <span>
      <strong>
        {{ item.title }}
      </strong>
Phil Hughes's avatar
Phil Hughes committed
58
      <span class="ide-merge-request-project-path d-block mt-1">
Phil Hughes's avatar
Phil Hughes committed
59 60 61 62 63
        {{ pathWithID }}
      </span>
    </span>
  </button>
</template>