diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-08 12:09:43 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-08 12:09:43 +0300 |
commit | f5050253469fc0961c02deec0e698ad62bdd9de5 (patch) | |
tree | 30bbd8f8b556fd5b730f0123921138ee1d6bdaa2 /app/assets/javascripts/logs/stores/actions.js | |
parent | f6cdec670b9b757fc2225a2c6627ab79765e5b8a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/logs/stores/actions.js')
-rw-r--r-- | app/assets/javascripts/logs/stores/actions.js | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/app/assets/javascripts/logs/stores/actions.js b/app/assets/javascripts/logs/stores/actions.js index 1e71b2c7314..be847108a49 100644 --- a/app/assets/javascripts/logs/stores/actions.js +++ b/app/assets/javascripts/logs/stores/actions.js @@ -1,20 +1,10 @@ import { backOff } from '~/lib/utils/common_utils'; import httpStatusCodes from '~/lib/utils/http_status'; import axios from '~/lib/utils/axios_utils'; -import flash from '~/flash'; -import { s__ } from '~/locale'; import { convertToFixedRange } from '~/lib/utils/datetime_range'; import * as types from './mutation_types'; -const flashTimeRangeWarning = () => { - flash(s__('Metrics|Invalid time range, please verify.'), 'warning'); -}; - -const flashLogsError = () => { - flash(s__('Metrics|There was an error fetching the logs, please try again')); -}; - const requestUntilData = (url, params) => backOff((next, stop) => { axios @@ -31,7 +21,7 @@ const requestUntilData = (url, params) => }); }); -const requestLogsUntilData = state => { +const requestLogsUntilData = ({ commit, state }) => { const params = {}; const { logs_api_path } = state.environments.options.find( ({ name }) => name === state.environments.current, @@ -49,7 +39,7 @@ const requestLogsUntilData = state => { params.start_time = start; params.end_time = end; } catch { - flashTimeRangeWarning(); + commit(types.SHOW_TIME_RANGE_INVALID_WARNING); } } if (state.logs.cursor) { @@ -101,26 +91,22 @@ export const fetchEnvironments = ({ commit, dispatch }, environmentsPath) => { }) .catch(() => { commit(types.RECEIVE_ENVIRONMENTS_DATA_ERROR); - flash(s__('Metrics|There was an error fetching the environments data, please try again')); }); }; export const fetchLogs = ({ commit, state }) => { commit(types.REQUEST_LOGS_DATA); - return requestLogsUntilData(state) + return requestLogsUntilData({ commit, state }) .then(({ data }) => { const { pod_name, pods, logs, cursor } = data; commit(types.RECEIVE_LOGS_DATA_SUCCESS, { logs, cursor }); - commit(types.SET_CURRENT_POD_NAME, pod_name); - commit(types.RECEIVE_PODS_DATA_SUCCESS, pods); }) .catch(() => { commit(types.RECEIVE_PODS_DATA_ERROR); commit(types.RECEIVE_LOGS_DATA_ERROR); - flashLogsError(); }); }; @@ -132,16 +118,27 @@ export const fetchMoreLogsPrepend = ({ commit, state }) => { commit(types.REQUEST_LOGS_DATA_PREPEND); - return requestLogsUntilData(state) + return requestLogsUntilData({ commit, state }) .then(({ data }) => { const { logs, cursor } = data; commit(types.RECEIVE_LOGS_DATA_PREPEND_SUCCESS, { logs, cursor }); }) .catch(() => { commit(types.RECEIVE_LOGS_DATA_PREPEND_ERROR); - flashLogsError(); }); }; +export const dismissRequestEnvironmentsError = ({ commit }) => { + commit(types.HIDE_REQUEST_ENVIRONMENTS_ERROR); +}; + +export const dismissRequestLogsError = ({ commit }) => { + commit(types.HIDE_REQUEST_LOGS_ERROR); +}; + +export const dismissInvalidTimeRangeWarning = ({ commit }) => { + commit(types.HIDE_TIME_RANGE_INVALID_WARNING); +}; + // prevent babel-plugin-rewire from generating an invalid default during karma tests export default () => {}; |