Commit 880fc0db authored by Olena Horal-Koretska's avatar Olena Horal-Koretska

Status icons and tooltips on integrations list

Adds icons and tooltips to status column on alerts integrations list
parent c8aee3ce
<script> <script>
import { GlTable } from '@gitlab/ui'; import { GlTable, GlIcon, GlTooltipDirective } from '@gitlab/ui';
import { s__, __ } from '~/locale'; import { s__, __ } from '~/locale';
export const i18n = { export const i18n = {
title: s__('AlertsIntegrations|Current integrations'), title: s__('AlertsIntegrations|Current integrations'),
emptyState: s__('AlertsIntegrations|No integrations have been added yet'), emptyState: s__('AlertsIntegrations|No integrations have been added yet'),
status: { status: {
enabled: __('Enabled'), enabled: {
disabled: __('Disabled'), name: __('Enabled'),
tooltip: s__('AlertsIntegrations|Alerts will be created through this integration'),
},
disabled: {
name: __('Disabled'),
tooltip: s__('AlertsIntegrations|Alerts will not be created through this integration'),
},
}, },
}; };
...@@ -18,6 +24,10 @@ export default { ...@@ -18,6 +24,10 @@ export default {
i18n, i18n,
components: { components: {
GlTable, GlTable,
GlIcon,
},
directives: {
GlTooltip: GlTooltipDirective,
}, },
props: { props: {
integrations: { integrations: {
...@@ -28,11 +38,8 @@ export default { ...@@ -28,11 +38,8 @@ export default {
}, },
fields: [ fields: [
{ {
key: 'status', key: 'activated',
label: __('Status'), label: __('Status'),
formatter(enabled) {
return enabled ? i18n.status.enabled : i18n.status.disabled;
},
}, },
{ {
key: 'name', key: 'name',
...@@ -63,6 +70,29 @@ export default { ...@@ -63,6 +70,29 @@ export default {
stacked="md" stacked="md"
:tbody-tr-class="tbodyTrClass" :tbody-tr-class="tbodyTrClass"
show-empty show-empty
/> >
<template #cell(activated)="{ item }">
<span v-if="item.activated" data-testid="integration-activated-status">
<gl-icon
v-gl-tooltip
name="check-circle-filled"
:size="16"
class="gl-text-green-500 gl-hover-cursor-pointer gl-mr-3"
:title="$options.i18n.status.enabled.tooltip"
/>
{{ $options.i18n.status.enabled.name }}
</span>
<span v-else data-testid="integration-activated-status">
<gl-icon
v-gl-tooltip
name="warning-solid"
:size="16"
class="gl-text-red-600 gl-hover-cursor-pointer gl-mr-3"
:title="$options.i18n.status.disabled.tooltip"
/>
{{ $options.i18n.status.disabled.name }}
</span>
</template>
</gl-table>
</div> </div>
</template> </template>
...@@ -159,12 +159,12 @@ export default { ...@@ -159,12 +159,12 @@ export default {
{ {
name: s__('AlertSettings|HTTP endpoint'), name: s__('AlertSettings|HTTP endpoint'),
type: s__('AlertsIntegrations|HTTP endpoint'), type: s__('AlertsIntegrations|HTTP endpoint'),
status: this.generic.activated, activated: this.generic.activated,
}, },
{ {
name: s__('AlertSettings|External Prometheus'), name: s__('AlertSettings|External Prometheus'),
type: s__('AlertsIntegrations|Prometheus'), type: s__('AlertsIntegrations|Prometheus'),
status: this.prometheus.activated, activated: this.prometheus.activated,
}, },
]; ];
}, },
......
---
title: Status icons for alerts integratiosn list
merge_request: 44318
author:
type: added
...@@ -2488,6 +2488,12 @@ msgstr "" ...@@ -2488,6 +2488,12 @@ msgstr ""
msgid "Alerts endpoint" msgid "Alerts endpoint"
msgstr "" msgstr ""
msgid "AlertsIntegrations|Alerts will be created through this integration"
msgstr ""
msgid "AlertsIntegrations|Alerts will not be created through this integration"
msgstr ""
msgid "AlertsIntegrations|Current integrations" msgid "AlertsIntegrations|Current integrations"
msgstr "" msgstr ""
......
import { GlTable } from '@gitlab/ui'; import { GlTable, GlIcon } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import AlertIntegrationsList, { import AlertIntegrationsList, {
i18n, i18n,
} from '~/alerts_settings/components/alerts_integrations_list.vue'; } from '~/alerts_settings/components/alerts_integrations_list.vue';
const mockIntegrations = [ const mockIntegrations = [
{ {
status: true, activated: true,
name: 'Integration 1', name: 'Integration 1',
type: 'HTTP endpoint', type: 'HTTP endpoint',
}, },
{ {
status: false, activated: false,
name: 'Integration 2', name: 'Integration 2',
type: 'HTTP endpoint', type: 'HTTP endpoint',
}, },
...@@ -21,11 +21,14 @@ describe('AlertIntegrationsList', () => { ...@@ -21,11 +21,14 @@ describe('AlertIntegrationsList', () => {
let wrapper; let wrapper;
function mountComponent(propsData = {}) { function mountComponent(propsData = {}) {
wrapper = shallowMount(AlertIntegrationsList, { wrapper = mount(AlertIntegrationsList, {
propsData: { propsData: {
integrations: mockIntegrations, integrations: mockIntegrations,
...propsData, ...propsData,
}, },
stubs: {
GlIcon: true,
},
}); });
} }
...@@ -41,9 +44,32 @@ describe('AlertIntegrationsList', () => { ...@@ -41,9 +44,32 @@ describe('AlertIntegrationsList', () => {
}); });
const findTableComponent = () => wrapper.find(GlTable); const findTableComponent = () => wrapper.find(GlTable);
const finsStatusCell = () => wrapper.findAll('[data-testid="integration-activated-status"]');
it('renders a table', () => { it('renders a table', () => {
expect(findTableComponent().exists()).toBe(true); expect(findTableComponent().exists()).toBe(true);
expect(findTableComponent().attributes('empty-text')).toBe(i18n.emptyState); });
it('renders an empty state when no integrations provided', () => {
mountComponent({ integrations: [] });
expect(findTableComponent().text()).toContain(i18n.emptyState);
});
describe('integration status', () => {
it('enabled', () => {
const cell = finsStatusCell().at(0);
const activatedIcon = cell.find(GlIcon);
expect(cell.text()).toBe(i18n.status.enabled.name);
expect(activatedIcon.attributes('name')).toBe('check-circle-filled');
expect(activatedIcon.attributes('title')).toBe(i18n.status.enabled.tooltip);
});
it('disabled', () => {
const cell = finsStatusCell().at(1);
const notActivatedIcon = cell.find(GlIcon);
expect(cell.text()).toBe(i18n.status.disabled.name);
expect(notActivatedIcon.attributes('name')).toBe('warning-solid');
expect(notActivatedIcon.attributes('title')).toBe(i18n.status.disabled.tooltip);
});
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment