diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
commit | 85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch) | |
tree | 9160f299afd8c80c038f08e1545be119f5e3f1e1 /app/assets/javascripts/incidents | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'app/assets/javascripts/incidents')
4 files changed, 62 insertions, 15 deletions
diff --git a/app/assets/javascripts/incidents/components/incidents_list.vue b/app/assets/javascripts/incidents/components/incidents_list.vue index 46852e4ddd9..670c42cbdac 100644 --- a/app/assets/javascripts/incidents/components/incidents_list.vue +++ b/app/assets/javascripts/incidents/components/incidents_list.vue @@ -23,6 +23,8 @@ import { s__ } from '~/locale'; import { mergeUrlParams, joinPaths, visitUrl } from '~/lib/utils/url_utility'; import getIncidents from '../graphql/queries/get_incidents.query.graphql'; import getIncidentsCountByStatus from '../graphql/queries/get_count_by_status.query.graphql'; +import SeverityToken from '~/sidebar/components/severity/severity.vue'; +import { INCIDENT_SEVERITY } from '~/sidebar/components/severity/constants'; import { I18N, DEFAULT_PAGE_SIZE, INCIDENT_SEARCH_DELAY, INCIDENT_STATUS_TABS } from '../constants'; const TH_TEST_ID = { 'data-testid': 'incident-management-created-at-sort' }; @@ -45,6 +47,12 @@ export default { statusTabs: INCIDENT_STATUS_TABS, fields: [ { + key: 'severity', + label: s__('IncidentManagement|Severity'), + thClass: `gl-pointer-events-none`, + tdClass, + }, + { key: 'title', label: s__('IncidentManagement|Incident'), thClass: `gl-pointer-events-none gl-w-half`, @@ -82,6 +90,7 @@ export default { PublishedCell: () => import('ee_component/incidents/components/published_cell.vue'), GlBadge, GlEmptyState, + SeverityToken, }, directives: { GlTooltip: GlTooltipDirective, @@ -208,6 +217,31 @@ export default { isEmpty() { return !this.incidents.list?.length; }, + showList() { + return !this.isEmpty || this.errored || this.loading; + }, + activeClosedTabHasNoIncidents() { + const { all, closed } = this.incidentsCount || {}; + const isClosedTabActive = this.statusFilter === this.$options.statusTabs[1].filters; + + return isClosedTabActive && all && !closed; + }, + emptyStateData() { + const { + emptyState: { title, emptyClosedTabTitle, description }, + createIncidentBtnLabel, + } = this.$options.i18n; + + if (this.activeClosedTabHasNoIncidents) { + return { title: emptyClosedTabTitle }; + } + return { + title, + description, + btnLink: this.newIncidentPath, + btnText: createIncidentBtnLabel, + }; + }, }, methods: { onInputChange: debounce(function debounceSearch(input) { @@ -255,6 +289,9 @@ export default { this.sort = `${sortingColumn}_${sortingDirection}`; }, + getSeverity(severity) { + return INCIDENT_SEVERITY[severity]; + }, }, }; </script> @@ -279,7 +316,7 @@ export default { </gl-tabs> <gl-button - v-if="!isEmpty" + v-if="!isEmpty || activeClosedTabHasNoIncidents" class="gl-my-3 gl-mr-5 create-incident-button" data-testid="createIncidentBtn" data-qa-selector="create_incident_button" @@ -307,6 +344,7 @@ export default { {{ s__('IncidentManagement|Incidents') }} </h4> <gl-table + v-if="showList" :items="incidents.list || []" :fields="availableFields" :show-empty="true" @@ -322,6 +360,10 @@ export default { @row-clicked="navigateToIncidentDetails" @sort-changed="fetchSortedData" > + <template #cell(severity)="{ item }"> + <severity-token :severity="getSeverity(item.severity)" /> + </template> + <template #cell(title)="{ item }"> <div :class="{ 'gl-display-flex gl-align-items-center': item.state === 'closed' }"> <div class="gl-max-w-full text-truncate" :title="item.title">{{ item.title }}</div> @@ -379,21 +421,20 @@ export default { <gl-loading-icon size="lg" color="dark" class="mt-3" /> </template> - <template #empty> - <gl-empty-state - v-if="!errored" - :title="$options.i18n.emptyState.title" - :svg-path="emptyListSvgPath" - :description="$options.i18n.emptyState.description" - :primary-button-link="newIncidentPath" - :primary-button-text="$options.i18n.createIncidentBtnLabel" - /> - <span v-else> - {{ $options.i18n.noIncidents }} - </span> + <template v-if="errored" #empty> + {{ $options.i18n.noIncidents }} </template> </gl-table> + <gl-empty-state + v-else + :title="emptyStateData.title" + :svg-path="emptyListSvgPath" + :description="emptyStateData.description" + :primary-button-link="emptyStateData.btnLink" + :primary-button-text="emptyStateData.btnText" + /> + <gl-pagination v-if="showPaginationControls" :value="pagination.currentPage" diff --git a/app/assets/javascripts/incidents/constants.js b/app/assets/javascripts/incidents/constants.js index 02d8172533d..289b36d9848 100644 --- a/app/assets/javascripts/incidents/constants.js +++ b/app/assets/javascripts/incidents/constants.js @@ -9,6 +9,7 @@ export const I18N = { searchPlaceholder: __('Search results…'), emptyState: { title: s__('IncidentManagement|Display your incidents in a dedicated view'), + emptyClosedTabTitle: s__('IncidentManagement|There are no closed incidents'), description: s__( 'IncidentManagement|All alerts promoted to incidents will automatically be displayed within the list. You can also create a new incident using the button below.', ), @@ -34,4 +35,4 @@ export const INCIDENT_STATUS_TABS = [ ]; export const INCIDENT_SEARCH_DELAY = 300; -export const DEFAULT_PAGE_SIZE = 10; +export const DEFAULT_PAGE_SIZE = 20; diff --git a/app/assets/javascripts/incidents/graphql/fragments/incident_fields.fragment.graphql b/app/assets/javascripts/incidents/graphql/fragments/incident_fields.fragment.graphql new file mode 100644 index 00000000000..eb2dde14464 --- /dev/null +++ b/app/assets/javascripts/incidents/graphql/fragments/incident_fields.fragment.graphql @@ -0,0 +1,3 @@ +fragment IncidentFields on Issue { + severity +} diff --git a/app/assets/javascripts/incidents/graphql/queries/get_incidents.query.graphql b/app/assets/javascripts/incidents/graphql/queries/get_incidents.query.graphql index 0f56e8640bd..dab130835e2 100644 --- a/app/assets/javascripts/incidents/graphql/queries/get_incidents.query.graphql +++ b/app/assets/javascripts/incidents/graphql/queries/get_incidents.query.graphql @@ -1,3 +1,5 @@ +#import "ee_else_ce/incidents/graphql/fragments/incident_fields.fragment.graphql" + query getIncidents( $projectPath: ID! $issueTypes: [IssueType!] @@ -39,7 +41,7 @@ query getIncidents( webUrl } } - statusPagePublishedIncident + ...IncidentFields } pageInfo { hasNextPage |