Commit bb0d746e authored by Dennis Tang's avatar Dennis Tang

clear errors on successful gapi request

parent f884d598
/* global gapi */ /* global gapi */
import Flash from '~/flash'; import createFlash, { hideFlash } from '~/flash';
import { s__, sprintf } from '~/locale'; import { s__, sprintf } from '~/locale';
import * as types from './mutation_types'; import * as types from './mutation_types';
...@@ -18,7 +18,15 @@ export const setMachineType = ({ commit }, selectedMachineType) => { ...@@ -18,7 +18,15 @@ export const setMachineType = ({ commit }, selectedMachineType) => {
const displayError = (resp, errorMessage) => { const displayError = (resp, errorMessage) => {
if (resp.result && resp.result.error) { if (resp.result && resp.result.error) {
Flash(sprintf(errorMessage, { error: resp.result.error.message })); createFlash(sprintf(errorMessage, { error: resp.result.error.message }));
}
};
const hideError = () => {
const flashEl = document.querySelector('.flash-alert');
if (flashEl) {
hideFlash(flashEl);
} }
}; };
...@@ -30,6 +38,7 @@ const gapiRequest = ({ service, params, commit, mutation, payloadKey, errorMessa ...@@ -30,6 +38,7 @@ const gapiRequest = ({ service, params, commit, mutation, payloadKey, errorMessa
resp => { resp => {
const { result } = resp; const { result } = resp;
hideError();
commit(mutation, result[payloadKey]); commit(mutation, result[payloadKey]);
resolve(); resolve();
......
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