diff --git a/src/LessPass.vue b/src/LessPass.vue
index 0666fa8..6f20a26 100644
--- a/src/LessPass.vue
+++ b/src/LessPass.vue
@@ -2,6 +2,7 @@
+
@@ -10,15 +11,18 @@
\ No newline at end of file
diff --git a/src/store/actions.js b/src/store/actions.js
index 9478db0..4d80881 100644
--- a/src/store/actions.js
+++ b/src/store/actions.js
@@ -82,4 +82,16 @@ export const deletePassword = ({commit, state}, payload) => {
.then(() => {
commit(types.DELETE_PASSWORD, payload);
});
-};
\ No newline at end of file
+};
+
+export const displayMessage = ({commit}, payload) => {
+ commit(types.SET_MESSAGE, {message: payload});
+ setTimeout(() => {
+ commit(types.CLEAN_MESSAGE);
+ }, 3000);
+};
+
+
+export const cleanMessage = ({commit}, payload) => {
+ commit(types.CLEAN_MESSAGE);
+};
diff --git a/src/store/getters.js b/src/store/getters.js
index 3b37521..036c6b6 100644
--- a/src/store/getters.js
+++ b/src/store/getters.js
@@ -10,7 +10,7 @@ export const isGuest = state => !state.authenticated;
export const baseURL = state => state.baseURL;
-export const passwordStatus = state => state.passwordStatus;
+export const message = state => state.message;
export const version = state => {
if (state.password === null || state.route.path === '/options/default') {
diff --git a/src/store/mutation-types.js b/src/store/mutation-types.js
index 63d6301..a5a8c11 100644
--- a/src/store/mutation-types.js
+++ b/src/store/mutation-types.js
@@ -10,3 +10,5 @@ export const SET_BASE_URL = 'SET_BASE_URL';
export const SET_VERSION = 'SET_VERSION';
export const LOAD_PASSWORD_FIRST_TIME = 'LOAD_PASSWORD_FIRST_TIME';
export const LOAD_PASSWORD_FOR_SITE = 'LOAD_PASSWORD_FOR_SITE';
+export const SET_MESSAGE = 'SET_MESSAGE';
+export const CLEAN_MESSAGE = 'CLEAN_MESSAGE';
diff --git a/src/store/mutations.js b/src/store/mutations.js
index 998f593..08493c3 100644
--- a/src/store/mutations.js
+++ b/src/store/mutations.js
@@ -60,5 +60,11 @@ export default {
break;
}
}
- }
+ },
+ [types.SET_MESSAGE](state, {message}){
+ state.message = message;
+ },
+ [types.CLEAN_MESSAGE](state){
+ state.message = {text: '', status: 'success'};
+ },
};
diff --git a/test/store.getters.js b/test/store.getters.js
index 5ec3a14..dd2ad9c 100644
--- a/test/store.getters.js
+++ b/test/store.getters.js
@@ -48,4 +48,13 @@ test('passwordURL', t => {
};
t.is(getters.passwordURL(state), 'https://lesspass.com/#/?login=test@example.org&site=example.org&uppercase=true&lowercase=true&numbers=true&symbols=false&length=16&counter=1&version=2')
+});
+
+test('message', t => {
+ const state = {
+ message: {text: 'error message', status:'error'}
+ };
+ const message = getters.message(state);
+ t.is(message.text, state.message.text);
+ t.is(message.status, state.message.status);
});
\ No newline at end of file
diff --git a/test/store.mutations.js b/test/store.mutations.js
index 227cb68..95115dc 100644
--- a/test/store.mutations.js
+++ b/test/store.mutations.js
@@ -278,4 +278,20 @@ test('LOAD_PASSWORD_FOR_SITE multiple accounts matching criteria', t => {
LOAD_PASSWORD_FOR_SITE(state, {site: 'www.google.com', url: 'https://www.google.com'});
t.is(state.password.id, '2');
t.is(state.password.site, 'www.google.com');
+});
+
+test('SET_MESSAGE', t => {
+ const SET_MESSAGE = mutations[types.SET_MESSAGE];
+ const state = {};
+ SET_MESSAGE(state, {message: {text: 'success message', status: 'success'}});
+ t.is(state.message.text, 'success message');
+ t.is(state.message.status, 'success');
+});
+
+test('CLEAN_MESSAGE', t => {
+ const CLEAN_MESSAGE = mutations[types.CLEAN_MESSAGE];
+ const state = {message: {text: 'error message', status: 'error'}};
+ CLEAN_MESSAGE(state);
+ t.is(state.message.text, '');
+ t.is(state.message.status, 'success');
});
\ No newline at end of file