2021-11-24 12:10:21 +00:00
|
|
|
import { EXTENSION_ICONS } from '~/vue_merge_request_widget/constants';
|
|
|
|
|
2022-03-24 12:07:26 +00:00
|
|
|
export const workingExtension = (shouldCollapse = true) => ({
|
2021-11-24 12:10:21 +00:00
|
|
|
name: 'WidgetTestExtension',
|
|
|
|
props: ['targetProjectFullPath'],
|
|
|
|
expandEvent: 'test_expand_event',
|
|
|
|
computed: {
|
|
|
|
summary({ count, targetProjectFullPath }) {
|
|
|
|
return `Test extension summary count: ${count} & ${targetProjectFullPath}`;
|
|
|
|
},
|
|
|
|
statusIcon({ count }) {
|
|
|
|
return count > 0 ? EXTENSION_ICONS.warning : EXTENSION_ICONS.success;
|
|
|
|
},
|
2022-03-24 12:07:26 +00:00
|
|
|
shouldCollapse() {
|
|
|
|
return shouldCollapse;
|
|
|
|
},
|
2021-11-24 12:10:21 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
fetchCollapsedData({ targetProjectFullPath }) {
|
|
|
|
return Promise.resolve({ targetProjectFullPath, count: 1 });
|
|
|
|
},
|
|
|
|
fetchFullData() {
|
|
|
|
return Promise.resolve([
|
|
|
|
{
|
|
|
|
id: 1,
|
|
|
|
text: 'Hello world',
|
|
|
|
icon: {
|
|
|
|
name: EXTENSION_ICONS.failed,
|
|
|
|
},
|
|
|
|
badge: {
|
|
|
|
text: 'Closed',
|
|
|
|
},
|
|
|
|
link: {
|
|
|
|
href: 'https://gitlab.com',
|
|
|
|
text: 'GitLab.com',
|
|
|
|
},
|
|
|
|
actions: [{ text: 'Full report', href: 'https://gitlab.com', target: '_blank' }],
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
},
|
|
|
|
},
|
2022-03-24 12:07:26 +00:00
|
|
|
});
|
2021-11-24 12:10:21 +00:00
|
|
|
|
|
|
|
export const collapsedDataErrorExtension = {
|
|
|
|
name: 'WidgetTestCollapsedErrorExtension',
|
|
|
|
props: ['targetProjectFullPath'],
|
|
|
|
expandEvent: 'test_expand_event',
|
|
|
|
computed: {
|
|
|
|
summary({ count, targetProjectFullPath }) {
|
|
|
|
return `Test extension summary count: ${count} & ${targetProjectFullPath}`;
|
|
|
|
},
|
|
|
|
statusIcon({ count }) {
|
|
|
|
return count > 0 ? EXTENSION_ICONS.warning : EXTENSION_ICONS.success;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
fetchCollapsedData() {
|
|
|
|
return Promise.reject(new Error('Fetch error'));
|
|
|
|
},
|
|
|
|
fetchFullData() {
|
|
|
|
return Promise.resolve([
|
|
|
|
{
|
|
|
|
id: 1,
|
|
|
|
text: 'Hello world',
|
|
|
|
icon: {
|
|
|
|
name: EXTENSION_ICONS.failed,
|
|
|
|
},
|
|
|
|
badge: {
|
|
|
|
text: 'Closed',
|
|
|
|
},
|
|
|
|
link: {
|
|
|
|
href: 'https://gitlab.com',
|
|
|
|
text: 'GitLab.com',
|
|
|
|
},
|
|
|
|
actions: [{ text: 'Full report', href: 'https://gitlab.com', target: '_blank' }],
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
export const fullDataErrorExtension = {
|
|
|
|
name: 'WidgetTestCollapsedErrorExtension',
|
|
|
|
props: ['targetProjectFullPath'],
|
|
|
|
expandEvent: 'test_expand_event',
|
|
|
|
computed: {
|
|
|
|
summary({ count, targetProjectFullPath }) {
|
|
|
|
return `Test extension summary count: ${count} & ${targetProjectFullPath}`;
|
|
|
|
},
|
|
|
|
statusIcon({ count }) {
|
|
|
|
return count > 0 ? EXTENSION_ICONS.warning : EXTENSION_ICONS.success;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
fetchCollapsedData({ targetProjectFullPath }) {
|
|
|
|
return Promise.resolve({ targetProjectFullPath, count: 1 });
|
|
|
|
},
|
|
|
|
fetchFullData() {
|
|
|
|
return Promise.reject(new Error('Fetch error'));
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2022-01-11 18:16:38 +00:00
|
|
|
|
|
|
|
export const pollingExtension = {
|
2022-03-24 12:07:26 +00:00
|
|
|
...workingExtension(),
|
2022-01-11 18:16:38 +00:00
|
|
|
enablePolling: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
export const pollingErrorExtension = {
|
|
|
|
...collapsedDataErrorExtension,
|
|
|
|
enablePolling: true,
|
|
|
|
};
|