Commit e5b265d8 authored by Phil Hughes's avatar Phil Hughes

Merge branch 'mw-cr-add-mr-module' into 'master'

Code Review Analytics: Add mergeRequests module

See merge request gitlab-org/gitlab!30043
parents 7aaf5fef 5f0e9379
......@@ -29,7 +29,7 @@ export default {
},
},
computed: {
...mapState({
...mapState('mergeRequests', {
isLoading: 'isLoading',
perPage: state => state.pageInfo.perPage,
totalItems: state => state.pageInfo.total,
......@@ -58,7 +58,7 @@ export default {
this.fetchMergeRequests();
},
methods: {
...mapActions(['setProjectId', 'fetchMergeRequests', 'setPage']),
...mapActions('mergeRequests', ['setProjectId', 'fetchMergeRequests', 'setPage']),
},
};
</script>
......
......@@ -20,7 +20,7 @@ export default {
GlTooltip: GlTooltipDirective,
},
computed: {
...mapState(['mergeRequests']),
...mapState('mergeRequests', ['mergeRequests']),
},
methods: {
getTimeAgoString(createdAt) {
......
......@@ -21,6 +21,6 @@ export default class FilteredSearchCodeReviewAnalytics extends FilteredSearchMan
*/
updateObject = path => {
const filters = urlParamsToObject(path);
store.dispatch('setFilters', filters);
store.dispatch('mergeRequests/setFilters', filters);
};
}
import Vue from 'vue';
import Vuex from 'vuex';
import * as actions from './actions';
import mutations from './mutations';
import state from './state';
import mergeRequests from './modules/merge_requests/index';
Vue.use(Vuex);
const createStore = () =>
new Vuex.Store({
state: state(),
actions,
mutations,
modules: {
mergeRequests,
},
});
export default createStore();
......@@ -15,11 +15,15 @@ export const setFilters = ({ commit, dispatch }, { label_name, milestone_title }
export const fetchMergeRequests = ({ dispatch, state }) => {
dispatch('requestMergeRequests');
const { projectId, filters, pageInfo } = state;
const {
projectId,
filters: { milestoneTitle, labelName },
pageInfo,
} = state;
const params = {
project_id: projectId,
milestone_title: filters.milestoneTitle,
label_name: filters.labelName,
milestone_title: milestoneTitle,
label_name: labelName,
page: pageInfo.page,
};
......
import * as actions from './actions';
import mutations from './mutations';
import state from './state';
export default {
namespaced: true,
state: state(),
actions,
mutations,
};
......@@ -3,7 +3,7 @@ import Vuex from 'vuex';
import { GlLoadingIcon, GlEmptyState, GlBadge, GlPagination } from '@gitlab/ui';
import CodeReviewAnalyticsApp from 'ee/analytics/code_review_analytics/components/app.vue';
import MergeRequestTable from 'ee/analytics/code_review_analytics/components/merge_request_table.vue';
import createState from 'ee/analytics/code_review_analytics/store/state';
import createState from 'ee/analytics/code_review_analytics/store/modules/merge_requests/state';
jest.mock('ee/analytics/code_review_analytics/filtered_search_code_review_analytics', () =>
jest.fn().mockImplementation(() => ({
......@@ -29,6 +29,9 @@ describe('CodeReviewAnalyticsApp component', () => {
const createStore = (initialState = {}, getters = {}) =>
new Vuex.Store({
modules: {
mergeRequests: {
namespaced: true,
state: {
...createState(),
...initialState,
......@@ -42,6 +45,8 @@ describe('CodeReviewAnalyticsApp component', () => {
showMrCount: () => false,
...getters,
},
},
},
});
const createComponent = store =>
......
......@@ -2,7 +2,7 @@ import { createLocalVue, mount } from '@vue/test-utils';
import Vuex from 'vuex';
import { GlTable } from '@gitlab/ui';
import MergeRequestTable from 'ee/analytics/code_review_analytics/components/merge_request_table.vue';
import createState from 'ee/analytics/code_review_analytics/store/state';
import createState from 'ee/analytics/code_review_analytics/store/modules/merge_requests/state';
import mergeRequests from '../mock_data';
const localVue = createLocalVue();
......@@ -14,10 +14,15 @@ describe('MergeRequestTable component', () => {
const createStore = (initialState = {}) =>
new Vuex.Store({
modules: {
mergeRequests: {
namespaced: true,
state: {
...createState(),
...initialState,
},
},
},
});
const createComponent = store =>
......
import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
import testAction from 'helpers/vuex_action_helper';
import * as actions from 'ee/analytics/code_review_analytics/store/actions';
import * as types from 'ee/analytics/code_review_analytics/store/mutation_types';
import getInitialState from 'ee/analytics/code_review_analytics/store/state';
import * as actions from 'ee/analytics/code_review_analytics/store/modules/merge_requests/actions';
import * as types from 'ee/analytics/code_review_analytics/store/modules/merge_requests/mutation_types';
import getInitialState from 'ee/analytics/code_review_analytics/store/modules/merge_requests/state';
import createFlash from '~/flash';
import mockMergeRequests from '../mock_data';
import mockMergeRequests from '../../../mock_data';
jest.mock('~/flash', () => jest.fn());
......
import * as types from 'ee/analytics/code_review_analytics/store/mutation_types';
import mutations from 'ee/analytics/code_review_analytics/store/mutations';
import getInitialState from 'ee/analytics/code_review_analytics/store/state';
import { mockMergeRequests } from '../../productivity_analytics/mock_data';
import * as types from 'ee/analytics/code_review_analytics/store/modules/merge_requests/mutation_types';
import mutations from 'ee/analytics/code_review_analytics/store/modules/merge_requests/mutations';
import getInitialState from 'ee/analytics/code_review_analytics/store/modules/merge_requests/state';
import mockMergeRequests from '../../../mock_data';
describe('Code review analytics mutations', () => {
let state;
......
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