summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_alert_message.vue
blob: 560a68031ef31fb2d380b11a4f835cded7ece845 (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
<script>
import { GlLink, GlIcon } from '@gitlab/ui';
import { WARNING, DANGER, WARNING_MESSAGE_CLASS, DANGER_MESSAGE_CLASS } from '../constants';

export default {
  name: 'MrWidgetAlertMessage',
  components: {
    GlLink,
    GlIcon,
  },
  props: {
    type: {
      type: String,
      required: false,
      default: DANGER,
      validator: (value) => [WARNING, DANGER].includes(value),
    },
    helpPath: {
      type: String,
      required: false,
      default: undefined,
    },
  },
  computed: {
    messageClass() {
      if (this.type === WARNING) {
        return WARNING_MESSAGE_CLASS;
      } else if (this.type === DANGER) {
        return DANGER_MESSAGE_CLASS;
      }

      return '';
    },
  },
};
</script>

<template>
  <div class="gl-m-3 gl-ml-7" :class="messageClass">
    <slot></slot>
    <gl-link v-if="helpPath" :href="helpPath" target="_blank">
      <gl-icon :size="16" name="question-o" class="align-middle" />
    </gl-link>
  </div>
</template>