Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-10-21 10:08:36 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-10-21 10:08:36 +0300
commit48aff82709769b098321c738f3444b9bdaa694c6 (patch)
treee00c7c43e2d9b603a5a6af576b1685e400410dee /app/assets/javascripts/milestones/stores/actions.js
parent879f5329ee916a948223f8f43d77fba4da6cd028 (diff)
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc42
Diffstat (limited to 'app/assets/javascripts/milestones/stores/actions.js')
-rw-r--r--app/assets/javascripts/milestones/stores/actions.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/app/assets/javascripts/milestones/stores/actions.js b/app/assets/javascripts/milestones/stores/actions.js
new file mode 100644
index 00000000000..3859771aeba
--- /dev/null
+++ b/app/assets/javascripts/milestones/stores/actions.js
@@ -0,0 +1,58 @@
+import Api from '~/api';
+import * as types from './mutation_types';
+
+export const setProjectId = ({ commit }, projectId) => commit(types.SET_PROJECT_ID, projectId);
+
+export const setSelectedMilestones = ({ commit }, selectedMilestones) =>
+ commit(types.SET_SELECTED_MILESTONES, selectedMilestones);
+
+export const toggleMilestones = ({ commit, state }, selectedMilestone) => {
+ const removeMilestone = state.selectedMilestones.includes(selectedMilestone);
+
+ if (removeMilestone) {
+ commit(types.REMOVE_SELECTED_MILESTONE, selectedMilestone);
+ } else {
+ commit(types.ADD_SELECTED_MILESTONE, selectedMilestone);
+ }
+};
+
+export const search = ({ dispatch, commit }, query) => {
+ commit(types.SET_QUERY, query);
+
+ dispatch('searchMilestones');
+};
+
+export const fetchMilestones = ({ commit, state }) => {
+ commit(types.REQUEST_START);
+
+ Api.projectMilestones(state.projectId)
+ .then(response => {
+ commit(types.RECEIVE_PROJECT_MILESTONES_SUCCESS, response);
+ })
+ .catch(error => {
+ commit(types.RECEIVE_PROJECT_MILESTONES_ERROR, error);
+ })
+ .finally(() => {
+ commit(types.REQUEST_FINISH);
+ });
+};
+
+export const searchMilestones = ({ commit, state }) => {
+ commit(types.REQUEST_START);
+
+ const options = {
+ search: state.query,
+ scope: 'milestones',
+ };
+
+ Api.projectSearch(state.projectId, options)
+ .then(response => {
+ commit(types.RECEIVE_PROJECT_MILESTONES_SUCCESS, response);
+ })
+ .catch(error => {
+ commit(types.RECEIVE_PROJECT_MILESTONES_ERROR, error);
+ })
+ .finally(() => {
+ commit(types.REQUEST_FINISH);
+ });
+};