2020-10-27 12:08:33 +00:00
|
|
|
/* eslint-disable */
|
2021-09-29 12:11:22 +00:00
|
|
|
import { EXTENSION_ICONS } from '../constants';
|
2020-10-27 12:08:33 +00:00
|
|
|
import issuesCollapsedQuery from './issues_collapsed.query.graphql';
|
|
|
|
import issuesQuery from './issues.query.graphql';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
// Give the extension a name
|
|
|
|
// Make it easier to track in Vue dev tools
|
2021-10-08 15:12:51 +00:00
|
|
|
name: 'WidgetIssues',
|
|
|
|
i18n: {
|
|
|
|
label: 'Issues',
|
|
|
|
loading: 'Loading issues...',
|
|
|
|
},
|
2021-10-26 18:09:19 +00:00
|
|
|
expandEvent: 'i_testing_load_performance_widget_total',
|
2020-10-27 12:08:33 +00:00
|
|
|
// Add an array of props
|
|
|
|
// These then get mapped to values stored in the MR Widget store
|
2021-10-06 15:11:48 +00:00
|
|
|
props: ['targetProjectFullPath', 'conflictsDocsPath'],
|
2020-10-27 12:08:33 +00:00
|
|
|
// Add any extra computed props in here
|
|
|
|
computed: {
|
|
|
|
// Small summary text to be displayed in the collapsed state
|
|
|
|
// Receives the collapsed data as an argument
|
|
|
|
summary(count) {
|
2021-10-14 15:14:02 +00:00
|
|
|
return 'Summary text<br/>Second line';
|
2020-10-27 12:08:33 +00:00
|
|
|
},
|
|
|
|
// Status icon to be used next to the summary text
|
|
|
|
// Receives the collapsed data as an argument
|
|
|
|
statusIcon(count) {
|
2021-09-29 12:11:22 +00:00
|
|
|
return EXTENSION_ICONS.warning;
|
2020-10-27 12:08:33 +00:00
|
|
|
},
|
2021-10-06 15:11:48 +00:00
|
|
|
// Tertiary action buttons that will take the user elsewhere
|
|
|
|
// in the GitLab app
|
|
|
|
tertiaryButtons() {
|
|
|
|
return [{ text: 'Full report', href: this.conflictsDocsPath, target: '_blank' }];
|
|
|
|
},
|
2020-10-27 12:08:33 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
// Fetches the collapsed data
|
|
|
|
// Ideally, this request should return the smallest amount of data possible
|
|
|
|
// Receives an object of all the props passed in to the extension
|
|
|
|
fetchCollapsedData({ targetProjectFullPath }) {
|
|
|
|
return this.$apollo
|
|
|
|
.query({ query: issuesCollapsedQuery, variables: { projectPath: targetProjectFullPath } })
|
|
|
|
.then(({ data }) => data.project.issues.count);
|
|
|
|
},
|
|
|
|
// Fetches the full data when the extension is expanded
|
|
|
|
// Receives an object of all the props passed in to the extension
|
|
|
|
fetchFullData({ targetProjectFullPath }) {
|
|
|
|
return this.$apollo
|
|
|
|
.query({ query: issuesQuery, variables: { projectPath: targetProjectFullPath } })
|
|
|
|
.then(({ data }) => {
|
|
|
|
// Return some transformed data to be rendered in the expanded state
|
2020-12-23 21:10:24 +00:00
|
|
|
return data.project.issues.nodes.map((issue) => ({
|
2020-10-27 12:08:33 +00:00
|
|
|
id: issue.id, // Required: The ID of the object
|
|
|
|
text: issue.title, // Required: The text to get used on each row
|
|
|
|
// Icon to get rendered on the side of each row
|
|
|
|
icon: {
|
|
|
|
// Required: Name maps to an icon in GitLabs SVG
|
2021-09-30 12:12:36 +00:00
|
|
|
name: issue.state === 'closed' ? EXTENSION_ICONS.error : EXTENSION_ICONS.success,
|
2020-10-27 12:08:33 +00:00
|
|
|
},
|
|
|
|
// Badges get rendered next to the text on each row
|
2021-10-12 15:12:08 +00:00
|
|
|
// badge: issue.state === 'closed' && {
|
|
|
|
// text: 'Closed', // Required: Text to be used inside of the badge
|
|
|
|
// // variant: 'info', // Optional: The variant of the badge, maps to GitLab UI variants
|
|
|
|
// },
|
2020-10-27 12:08:33 +00:00
|
|
|
// Each row can have its own link that will take the user elsewhere
|
|
|
|
// link: {
|
|
|
|
// href: 'https://google.com', // Required: href for the link
|
|
|
|
// text: 'Link text', // Required: Text to be used inside the link
|
|
|
|
// },
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|