From 00a8c64ffd18e74df4b1cdeda7776b5221fddafe Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 15 Apr 2020 06:09:49 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- .../projects/commits/components/author_select.vue | 141 +++++++++++++++++++++ app/assets/javascripts/projects/commits/index.js | 26 ++++ .../javascripts/projects/commits/store/actions.js | 31 +++++ .../javascripts/projects/commits/store/index.js | 15 +++ .../projects/commits/store/mutation_types.js | 2 + .../projects/commits/store/mutations.js | 10 ++ .../javascripts/projects/commits/store/state.js | 5 + 7 files changed, 230 insertions(+) create mode 100644 app/assets/javascripts/projects/commits/components/author_select.vue create mode 100644 app/assets/javascripts/projects/commits/index.js create mode 100644 app/assets/javascripts/projects/commits/store/actions.js create mode 100644 app/assets/javascripts/projects/commits/store/index.js create mode 100644 app/assets/javascripts/projects/commits/store/mutation_types.js create mode 100644 app/assets/javascripts/projects/commits/store/mutations.js create mode 100644 app/assets/javascripts/projects/commits/store/state.js (limited to 'app/assets/javascripts/projects') diff --git a/app/assets/javascripts/projects/commits/components/author_select.vue b/app/assets/javascripts/projects/commits/components/author_select.vue new file mode 100644 index 00000000000..78f9389b80c --- /dev/null +++ b/app/assets/javascripts/projects/commits/components/author_select.vue @@ -0,0 +1,141 @@ + + + diff --git a/app/assets/javascripts/projects/commits/index.js b/app/assets/javascripts/projects/commits/index.js new file mode 100644 index 00000000000..6f85432a77e --- /dev/null +++ b/app/assets/javascripts/projects/commits/index.js @@ -0,0 +1,26 @@ +import Vue from 'vue'; +import Vuex from 'vuex'; +import AuthorSelectApp from './components/author_select.vue'; +import store from './store'; + +Vue.use(Vuex); + +export default el => { + if (!el) { + return null; + } + + store.dispatch('setInitialData', el.dataset); + + return new Vue({ + el, + store, + render(h) { + return h(AuthorSelectApp, { + props: { + projectCommitsEl: document.querySelector('.js-project-commits-show'), + }, + }); + }, + }); +}; diff --git a/app/assets/javascripts/projects/commits/store/actions.js b/app/assets/javascripts/projects/commits/store/actions.js new file mode 100644 index 00000000000..daeae071d6a --- /dev/null +++ b/app/assets/javascripts/projects/commits/store/actions.js @@ -0,0 +1,31 @@ +import * as types from './mutation_types'; +import axios from '~/lib/utils/axios_utils'; +import createFlash from '~/flash'; +import { __ } from '~/locale'; + +export default { + setInitialData({ commit }, data) { + commit(types.SET_INITIAL_DATA, data); + }, + receiveAuthorsSuccess({ commit }, authors) { + commit(types.COMMITS_AUTHORS, authors); + }, + receiveAuthorsError() { + createFlash(__('An error occurred fetching the project authors.')); + }, + fetchAuthors({ dispatch, state }, author = null) { + const { projectId } = state; + const path = '/autocomplete/users.json'; + + return axios + .get(path, { + params: { + project_id: projectId, + active: true, + search: author, + }, + }) + .then(({ data }) => dispatch('receiveAuthorsSuccess', data)) + .catch(() => dispatch('receiveAuthorsError')); + }, +}; diff --git a/app/assets/javascripts/projects/commits/store/index.js b/app/assets/javascripts/projects/commits/store/index.js new file mode 100644 index 00000000000..e864ef5716e --- /dev/null +++ b/app/assets/javascripts/projects/commits/store/index.js @@ -0,0 +1,15 @@ +import Vue from 'vue'; +import Vuex from 'vuex'; +import actions from './actions'; +import mutations from './mutations'; +import state from './state'; + +Vue.use(Vuex); + +export const createStore = () => ({ + actions, + mutations, + state: state(), +}); + +export default new Vuex.Store(createStore()); diff --git a/app/assets/javascripts/projects/commits/store/mutation_types.js b/app/assets/javascripts/projects/commits/store/mutation_types.js new file mode 100644 index 00000000000..0a6a5a0b902 --- /dev/null +++ b/app/assets/javascripts/projects/commits/store/mutation_types.js @@ -0,0 +1,2 @@ +export const SET_INITIAL_DATA = 'SET_INITIAL_DATA'; +export const COMMITS_AUTHORS = 'COMMITS_AUTHORS'; diff --git a/app/assets/javascripts/projects/commits/store/mutations.js b/app/assets/javascripts/projects/commits/store/mutations.js new file mode 100644 index 00000000000..11f703c0946 --- /dev/null +++ b/app/assets/javascripts/projects/commits/store/mutations.js @@ -0,0 +1,10 @@ +import * as types from './mutation_types'; + +export default { + [types.SET_INITIAL_DATA](state, data) { + Object.assign(state, data); + }, + [types.COMMITS_AUTHORS](state, data) { + state.commitsAuthors = data; + }, +}; diff --git a/app/assets/javascripts/projects/commits/store/state.js b/app/assets/javascripts/projects/commits/store/state.js new file mode 100644 index 00000000000..f074708ffa2 --- /dev/null +++ b/app/assets/javascripts/projects/commits/store/state.js @@ -0,0 +1,5 @@ +export default () => ({ + commitsPath: null, + projectId: null, + commitsAuthors: [], +}); -- cgit v1.2.3