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

issues_dashboard_app.vue « components « dashboard « issues « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 080f1fe222cb215d27d047de24d3e9b62b17e323 (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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<script>
import { GlButton, GlEmptyState, GlTooltipDirective } from '@gitlab/ui';
import * as Sentry from '@sentry/browser';
import getIssuesQuery from 'ee_else_ce/issues/dashboard/queries/get_issues.query.graphql';
import IssueCardStatistics from 'ee_else_ce/issues/list/components/issue_card_statistics.vue';
import IssueCardTimeInfo from 'ee_else_ce/issues/list/components/issue_card_time_info.vue';
import { IssuableStatus } from '~/issues/constants';
import { PAGE_SIZE } from '~/issues/list/constants';
import { getInitialPageParams } from '~/issues/list/utils';
import { scrollUp } from '~/lib/utils/scroll_utils';
import { __ } from '~/locale';
import IssuableList from '~/vue_shared/issuable/list/components/issuable_list_root.vue';
import { IssuableListTabs, IssuableStates } from '~/vue_shared/issuable/list/constants';

export default {
  i18n: {
    calendarButtonText: __('Subscribe to calendar'),
    closed: __('CLOSED'),
    closedMoved: __('CLOSED (MOVED)'),
    downvotes: __('Downvotes'),
    emptyStateTitle: __('Please select at least one filter to see results'),
    errorFetchingIssues: __('An error occurred while loading issues'),
    relatedMergeRequests: __('Related merge requests'),
    rssButtonText: __('Subscribe to RSS feed'),
    searchInputPlaceholder: __('Search or filter results...'),
    upvotes: __('Upvotes'),
  },
  IssuableListTabs,
  components: {
    GlButton,
    GlEmptyState,
    IssuableList,
    IssueCardStatistics,
    IssueCardTimeInfo,
  },
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  inject: [
    'calendarPath',
    'emptyStateSvgPath',
    'hasScopedLabelsFeature',
    'isPublicVisibilityRestricted',
    'isSignedIn',
    'rssPath',
  ],
  data() {
    return {
      issues: [],
      issuesError: null,
      pageInfo: {},
      pageParams: getInitialPageParams(),
      searchTokens: [],
      sortOptions: [],
      state: IssuableStates.Opened,
    };
  },
  apollo: {
    issues: {
      query: getIssuesQuery,
      variables() {
        return {
          hideUsers: this.isPublicVisibilityRestricted && !this.isSignedIn,
          isSignedIn: this.isSignedIn,
          state: this.state,
          ...this.pageParams,
        };
      },
      update(data) {
        return data.issues.nodes ?? [];
      },
      result({ data }) {
        this.pageInfo = data?.issues.pageInfo ?? {};
      },
      error(error) {
        this.issuesError = this.$options.i18n.errorFetchingIssues;
        Sentry.captureException(error);
      },
    },
  },
  computed: {
    showPaginationControls() {
      return this.issues.length > 0 && (this.pageInfo.hasNextPage || this.pageInfo.hasPreviousPage);
    },
  },
  methods: {
    getStatus(issue) {
      if (issue.state === IssuableStatus.Closed && issue.moved) {
        return this.$options.i18n.closedMoved;
      }
      if (issue.state === IssuableStatus.Closed) {
        return this.$options.i18n.closed;
      }
      return undefined;
    },
    handleClickTab(state) {
      if (this.state === state) {
        return;
      }
      this.pageParams = getInitialPageParams();
      this.state = state;
    },
    handleDismissAlert() {
      this.issuesError = null;
    },
    handleNextPage() {
      this.pageParams = {
        afterCursor: this.pageInfo.endCursor,
        firstPageSize: PAGE_SIZE,
      };
      scrollUp();
    },
    handlePreviousPage() {
      this.pageParams = {
        beforeCursor: this.pageInfo.startCursor,
        lastPageSize: PAGE_SIZE,
      };
      scrollUp();
    },
  },
};
</script>

<template>
  <issuable-list
    :current-tab="state"
    :error="issuesError"
    :has-next-page="pageInfo.hasNextPage"
    :has-previous-page="pageInfo.hasPreviousPage"
    :has-scoped-labels-feature="hasScopedLabelsFeature"
    :issuables="issues"
    :issuables-loading="$apollo.queries.issues.loading"
    namespace="dashboard"
    recent-searches-storage-key="issues"
    :search-input-placeholder="$options.i18n.searchInputPlaceholder"
    :search-tokens="searchTokens"
    :show-pagination-controls="showPaginationControls"
    :sort-options="sortOptions"
    :tabs="$options.IssuableListTabs"
    use-keyset-pagination
    @click-tab="handleClickTab"
    @dismiss-alert="handleDismissAlert"
    @next-page="handleNextPage"
    @previous-page="handlePreviousPage"
  >
    <template #nav-actions>
      <gl-button :href="rssPath" icon="rss">
        {{ $options.i18n.rssButtonText }}
      </gl-button>
      <gl-button :href="calendarPath" icon="calendar">
        {{ $options.i18n.calendarButtonText }}
      </gl-button>
    </template>

    <template #timeframe="{ issuable = {} }">
      <issue-card-time-info :issue="issuable" />
    </template>

    <template #status="{ issuable = {} }">
      {{ getStatus(issuable) }}
    </template>

    <template #statistics="{ issuable = {} }">
      <issue-card-statistics :issue="issuable" />
    </template>

    <template #empty-state>
      <gl-empty-state :svg-path="emptyStateSvgPath" :title="$options.i18n.emptyStateTitle" />
    </template>
  </issuable-list>
</template>