Commit baffddfe authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'tor/defect/overview-placeholder-message/endpoint-state' into 'master'

Add metadata endpoints to MR Notes app

See merge request gitlab-org/gitlab!56575
parents 1fd83711 0c3440b4
...@@ -25,6 +25,9 @@ export default () => { ...@@ -25,6 +25,9 @@ export default () => {
return { return {
noteableData, noteableData,
endpoints: {
metadata: notesDataset.endpointMetadata,
},
currentUserData: JSON.parse(notesDataset.currentUserData), currentUserData: JSON.parse(notesDataset.currentUserData),
notesData: JSON.parse(notesDataset.notesData), notesData: JSON.parse(notesDataset.notesData),
helpPagePath: notesDataset.helpPagePath, helpPagePath: notesDataset.helpPagePath,
...@@ -54,6 +57,7 @@ export default () => { ...@@ -54,6 +57,7 @@ export default () => {
}, },
created() { created() {
this.setActiveTab(window.mrTabs.getCurrentAction()); this.setActiveTab(window.mrTabs.getCurrentAction());
this.setEndpoints(this.endpoints);
}, },
mounted() { mounted() {
this.notesCountBadge = $('.issuable-details').find('.notes-tab .badge'); this.notesCountBadge = $('.issuable-details').find('.notes-tab .badge');
...@@ -65,7 +69,7 @@ export default () => { ...@@ -65,7 +69,7 @@ export default () => {
window.mrTabs.eventHub.$off('MergeRequestTabChange', this.setActiveTab); window.mrTabs.eventHub.$off('MergeRequestTabChange', this.setActiveTab);
}, },
methods: { methods: {
...mapActions(['setActiveTab']), ...mapActions(['setActiveTab', 'setEndpoints']),
updateDiscussionTabCounter() { updateDiscussionTabCounter() {
this.notesCountBadge.text(this.discussionTabCounter); this.notesCountBadge.text(this.discussionTabCounter);
}, },
......
import types from './mutation_types'; import types from './mutation_types';
export default { export function setActiveTab({ commit }, tab) {
setActiveTab({ commit }, tab) { commit(types.SET_ACTIVE_TAB, tab);
commit(types.SET_ACTIVE_TAB, tab); }
},
}; export function setEndpoints({ commit }, endpoints) {
commit(types.SET_ENDPOINTS, endpoints);
}
import actions from '../actions'; import * as actions from '../actions';
import getters from '../getters'; import getters from '../getters';
import mutations from '../mutations'; import mutations from '../mutations';
export default () => ({ export default () => ({
state: { state: {
endpoints: {},
activeTab: null, activeTab: null,
}, },
actions, actions,
......
export default { export default {
SET_ACTIVE_TAB: 'SET_ACTIVE_TAB', SET_ACTIVE_TAB: 'SET_ACTIVE_TAB',
SET_ENDPOINTS: 'SET_ENDPOINTS',
}; };
...@@ -4,4 +4,7 @@ export default { ...@@ -4,4 +4,7 @@ export default {
[types.SET_ACTIVE_TAB](state, tab) { [types.SET_ACTIVE_TAB](state, tab) {
Object.assign(state, { activeTab: tab }); Object.assign(state, { activeTab: tab });
}, },
[types.SET_ENDPOINTS](state, endpoints) {
Object.assign(state, { endpoints });
},
}; };
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
- add_page_specific_style 'page_bundles/reports' - add_page_specific_style 'page_bundles/reports'
- add_page_specific_style 'page_bundles/ci_status' - add_page_specific_style 'page_bundles/ci_status'
- add_page_startup_api_call @endpoint_metadata_url
.merge-request{ data: { mr_action: mr_action, url: merge_request_path(@merge_request, format: :json), project_path: project_path(@merge_request.project), lock_version: @merge_request.lock_version } } .merge-request{ data: { mr_action: mr_action, url: merge_request_path(@merge_request, format: :json), project_path: project_path(@merge_request.project), lock_version: @merge_request.lock_version } }
= render "projects/merge_requests/mr_title" = render "projects/merge_requests/mr_title"
...@@ -63,6 +65,7 @@ ...@@ -63,6 +65,7 @@
- add_page_startup_api_call widget_project_json_merge_request_path(@project, @merge_request, format: :json) - add_page_startup_api_call widget_project_json_merge_request_path(@project, @merge_request, format: :json)
- add_page_startup_api_call cached_widget_project_json_merge_request_path(@project, @merge_request, format: :json) - add_page_startup_api_call cached_widget_project_json_merge_request_path(@project, @merge_request, format: :json)
#js-vue-mr-discussions{ data: { notes_data: notes_data(@merge_request, Feature.enabled?(:paginated_notes, @project)).to_json, #js-vue-mr-discussions{ data: { notes_data: notes_data(@merge_request, Feature.enabled?(:paginated_notes, @project)).to_json,
endpoint_metadata: @endpoint_metadata_url,
noteable_data: serialize_issuable(@merge_request, serializer: 'noteable'), noteable_data: serialize_issuable(@merge_request, serializer: 'noteable'),
noteable_type: 'MergeRequest', noteable_type: 'MergeRequest',
target_type: 'merge_request', target_type: 'merge_request',
...@@ -75,8 +78,6 @@ ...@@ -75,8 +78,6 @@
= render "projects/merge_requests/tabs/pane", name: "pipelines", id: "pipelines", class: "pipelines" do = render "projects/merge_requests/tabs/pane", name: "pipelines", id: "pipelines", class: "pipelines" do
- if number_of_pipelines.nonzero? - if number_of_pipelines.nonzero?
= render 'projects/commit/pipelines_list', disable_initialization: true, endpoint: pipelines_project_merge_request_path(@project, @merge_request) = render 'projects/commit/pipelines_list', disable_initialization: true, endpoint: pipelines_project_merge_request_path(@project, @merge_request)
- if mr_action === "diffs"
- add_page_startup_api_call @endpoint_metadata_url
- params = request.query_parameters - params = request.query_parameters
- if Feature.enabled?(:default_merge_ref_for_diffs, @project, default_enabled: :yaml) - if Feature.enabled?(:default_merge_ref_for_diffs, @project, default_enabled: :yaml)
- params = params.merge(diff_head: true) - params = params.merge(diff_head: true)
......
import testAction from 'helpers/vuex_action_helper';
import { setEndpoints } from '~/mr_notes/stores/actions';
import mutationTypes from '~/mr_notes/stores/mutation_types';
describe('MR Notes Mutator Actions', () => {
describe('setEndpoints', () => {
it('should trigger the SET_ENDPOINTS state mutation', (done) => {
const endpoints = { endpointA: 'a' };
testAction(
setEndpoints,
endpoints,
{},
[
{
type: mutationTypes.SET_ENDPOINTS,
payload: endpoints,
},
],
[],
done,
);
});
});
});
import mutationTypes from '~/mr_notes/stores/mutation_types';
import mutations from '~/mr_notes/stores/mutations';
describe('MR Notes Mutations', () => {
describe(mutationTypes.SET_ENDPOINTS, () => {
it('should set the endpoints value', () => {
const state = {};
const endpoints = { endpointA: 'A', endpointB: 'B' };
mutations[mutationTypes.SET_ENDPOINTS](state, endpoints);
expect(state.endpoints).toEqual(endpoints);
});
});
});
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