Welcome to mirror list, hosted at ThFree Co, Russian Federation.

widget_wrapper.vue « components « work_items « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f343f78735817aa3965b5074cacbb04ef589abe3 (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
82
<script>
import { GlAlert, GlButton, GlLink } from '@gitlab/ui';
import { __ } from '~/locale';

export default {
  components: {
    GlAlert,
    GlButton,
    GlLink,
  },
  props: {
    error: {
      type: String,
      required: false,
      default: '',
    },
  },
  data() {
    return {
      isOpen: true,
    };
  },
  computed: {
    toggleIcon() {
      return this.isOpen ? 'chevron-lg-up' : 'chevron-lg-down';
    },
    toggleLabel() {
      return this.isOpen ? __('Collapse') : __('Expand');
    },
    isOpenString() {
      return this.isOpen ? 'true' : 'false';
    },
  },
  methods: {
    hide() {
      this.isOpen = false;
    },
    show() {
      this.isOpen = true;
    },
    toggle() {
      this.isOpen = !this.isOpen;
    },
  },
};
</script>

<template>
  <div id="tasks" class="gl-new-card" :aria-expanded="isOpenString">
    <div class="gl-new-card-header">
      <div class="gl-new-card-title-wrapper">
        <h3 class="gl-new-card-title">
          <gl-link
            id="user-content-tasks-links"
            class="anchor position-absolute gl-text-decoration-none"
            href="#tasks"
            aria-hidden="true"
          />
          <slot name="header"></slot>
        </h3>
        <slot name="header-suffix"></slot>
      </div>
      <slot name="header-right"></slot>
      <div class="gl-new-card-toggle">
        <gl-button
          category="tertiary"
          size="small"
          :icon="toggleIcon"
          :aria-label="toggleLabel"
          data-testid="widget-toggle"
          @click="toggle"
        />
      </div>
    </div>
    <gl-alert v-if="error" variant="danger" @dismiss="$emit('dismissAlert')">
      {{ error }}
    </gl-alert>
    <div v-if="isOpen" class="gl-new-card-body" :class="{ error: error }" data-testid="widget-body">
      <slot name="body"></slot>
    </div>
  </div>
</template>