summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/work_items/components/work_item_detail_modal.vue
blob: a79091fb8b27ef62dbba92d750692488992231ed (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<script>
import { GlAlert, GlButton, GlModal } from '@gitlab/ui';
import WorkItemActions from './work_item_actions.vue';
import WorkItemDetail from './work_item_detail.vue';

export default {
  components: {
    GlAlert,
    GlButton,
    GlModal,
    WorkItemDetail,
    WorkItemActions,
  },
  props: {
    canUpdate: {
      type: Boolean,
      required: false,
      default: false,
    },
    visible: {
      type: Boolean,
      required: true,
    },
    workItemId: {
      type: String,
      required: false,
      default: null,
    },
  },
  emits: ['workItemDeleted', 'close'],
  data() {
    return {
      error: undefined,
    };
  },
  methods: {
    handleWorkItemDeleted() {
      this.$emit('workItemDeleted');
      this.closeModal();
    },
    closeModal() {
      this.error = '';
      this.$emit('close');
    },
    setErrorMessage(message) {
      this.error = message;
    },
  },
};
</script>

<template>
  <gl-modal hide-footer modal-id="work-item-detail-modal" :visible="visible" @hide="closeModal">
    <template #modal-header>
      <div class="gl-w-full gl-display-flex gl-align-items-center gl-justify-content-end">
        <h2 class="modal-title gl-mr-auto">{{ s__('WorkItem|Work Item') }}</h2>
        <work-item-actions
          :work-item-id="workItemId"
          :can-update="canUpdate"
          @workItemDeleted="handleWorkItemDeleted"
          @error="setErrorMessage"
        />
        <gl-button category="tertiary" icon="close" :aria-label="__('Close')" @click="closeModal" />
      </div>
    </template>
    <gl-alert v-if="error" variant="danger" @dismiss="error = false">
      {{ error }}
    </gl-alert>

    <work-item-detail :work-item-id="workItemId" />
  </gl-modal>
</template>

<style>
/* hide the existing close button until we can do it
 * with https://gitlab.com/gitlab-org/gitlab-ui/-/merge_requests/2710
 */
#work-item-detail-modal .modal-header > .gl-button {
  display: none;
}
</style>