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

board_blank_state.vue « components « boards « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 55e3e4a6329cc3c67e9c1ffbc900054b8f69b5fd (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<script>
import { GlButton } from '@gitlab/ui';
import Cookies from 'js-cookie';
import { __ } from '~/locale';
import ListLabel from '~/boards/models/label';
import boardsStore from '../stores/boards_store';

export default {
  components: {
    GlButton,
  },
  data() {
    return {
      predefinedLabels: [
        new ListLabel({ title: __('To Do'), color: '#F0AD4E' }),
        new ListLabel({ title: __('Doing'), color: '#5CB85C' }),
      ],
    };
  },
  methods: {
    addDefaultLists() {
      this.clearBlankState();

      this.predefinedLabels.forEach((label, i) => {
        boardsStore.addList({
          title: label.title,
          position: i,
          list_type: 'label',
          label: {
            title: label.title,
            color: label.color,
          },
        });
      });

      const loadListIssues = listObj => {
        const list = boardsStore.findList('title', listObj.title);

        if (!list) {
          return null;
        }

        list.id = listObj.id;
        list.label.id = listObj.label.id;
        return list.getIssues().catch(() => {
          // TODO: handle request error
        });
      };

      // Save the labels
      boardsStore
        .generateDefaultLists()
        .then(res => res.data)
        .then(data => Promise.all(data.map(loadListIssues)))
        .catch(() => {
          boardsStore.removeList(undefined, 'label');
          Cookies.remove('issue_board_welcome_hidden', {
            path: '',
          });
          boardsStore.addBlankState();
        });
    },
    clearBlankState: boardsStore.removeBlankState.bind(boardsStore),
  },
};
</script>

<template>
  <div class="board-blank-state p-3">
    <p>
      {{
        s__('BoardBlankState|Add the following default lists to your Issue Board with one click:')
      }}
    </p>
    <ul class="list-unstyled board-blank-state-list">
      <li v-for="(label, index) in predefinedLabels" :key="index">
        <span
          :style="{ backgroundColor: label.color }"
          class="label-color position-relative d-inline-block rounded"
        ></span>
        {{ label.title }}
      </li>
    </ul>
    <p>
      {{
        s__(
          'BoardBlankState|Starting out with the default set of lists will get you right on the way to making the most of your board.',
        )
      }}
    </p>
    <gl-button
      category="secondary"
      variant="success"
      block="block"
      class="gl-mb-0"
      @click.stop="addDefaultLists"
    >
      {{ s__('BoardBlankState|Add default lists') }}
    </gl-button>
    <gl-button category="secondary" variant="default" block="block" @click.stop="clearBlankState">
      {{ s__("BoardBlankState|Nevermind, I'll use my own") }}
    </gl-button>
  </div>
</template>