summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/work_items_hierarchy/components/app.vue
blob: 621cfe5bace2c47210ab771d14efaa610508b931 (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
<script>
import { GlBanner } from '@gitlab/ui';
import Cookies from 'js-cookie';
import { parseBoolean } from '~/lib/utils/common_utils';
import RESPONSE from '../static_response';
import { WORK_ITEMS_SURVEY_COOKIE_NAME, workItemTypes } from '../constants';
import Hierarchy from './hierarchy.vue';

export default {
  components: {
    GlBanner,
    Hierarchy,
  },
  inject: ['illustrationPath', 'licensePlan'],
  data() {
    return {
      bannerVisible: !parseBoolean(Cookies.get(WORK_ITEMS_SURVEY_COOKIE_NAME)),
      workItemHierarchy: RESPONSE[this.licensePlan],
    };
  },
  computed: {
    hasUnavailableStructure() {
      return this.workItemTypes.unavailable.length > 0;
    },
    workItemTypes() {
      return this.workItemHierarchy.reduce(
        (itemTypes, item) => {
          const skipItem = workItemTypes[item.type].isWorkItem && !window.gon?.features?.workItems;

          if (skipItem) {
            return itemTypes;
          }
          const key = item.available ? 'available' : 'unavailable';
          const nestedTypes = item.nestedTypes?.map((type) => workItemTypes[type]);

          itemTypes[key].push({
            ...item,
            ...workItemTypes[item.type],
            nestedTypes,
          });

          return itemTypes;
        },
        { available: [], unavailable: [] },
      );
    },
  },
  methods: {
    handleClose() {
      Cookies.set(WORK_ITEMS_SURVEY_COOKIE_NAME, 'true', { expires: 365 * 10 });
      this.bannerVisible = false;
    },
  },
};
</script>

<template>
  <div>
    <gl-banner
      v-if="bannerVisible"
      class="gl-mt-4 gl-px-5!"
      :title="s__('Hierarchy|Help us improve work items in GitLab!')"
      :button-text="s__('Hierarchy|Take the work items survey')"
      button-link="https://forms.gle/u1BmRp8rTbwj52iq5"
      :svg-path="illustrationPath"
      @close="handleClose"
    >
      <p>
        {{
          s__(
            'Hierarchy|Is there a framework or type of work item you wish you had access to in GitLab? Give us your feedback and help us build the experiences valuable to you.',
          )
        }}
      </p>
    </gl-banner>
    <h3 class="gl-mt-5!">{{ s__('Hierarchy|Planning hierarchy') }}</h3>
    <p>
      {{
        s__(
          'Hierarchy|Deliver value more efficiently by breaking down necessary work into a hierarchical structure. This structure helps teams understand scope, priorities, and how work cascades up toward larger goals.',
        )
      }}
    </p>

    <div class="gl-font-weight-bold gl-mb-2">{{ s__('Hierarchy|Current structure') }}</div>
    <p class="gl-mb-3!">{{ s__('Hierarchy|You can start using these items now.') }}</p>
    <hierarchy :work-item-types="workItemTypes.available" />

    <div
      v-if="hasUnavailableStructure"
      data-testid="unavailable-structure"
      class="gl-font-weight-bold gl-mt-5 gl-mb-2"
    >
      {{ s__('Hierarchy|Unavailable structure') }}
    </div>
    <p v-if="hasUnavailableStructure" class="gl-mb-3!">
      {{ s__('Hierarchy|These items are unavailable in the current structure.') }}
    </p>
    <hierarchy :work-item-types="workItemTypes.unavailable" />
  </div>
</template>