@@ -91,7 +91,7 @@ export default {
currentPortalSlug() {
return this.$route.params.portalSlug;
},
- categoryByLocaleCode() {
+ categoriesByLocaleCode() {
return this.$store.getters['categories/categoriesByLocaleCode'](
this.currentLocaleCode
);
@@ -131,6 +131,12 @@ export default {
closeEditCategoryModal() {
this.showEditCategoryModal = false;
},
+ async fetchCategoriesByPortalSlugAndLocale(localeCode) {
+ await this.$store.dispatch('categories/index', {
+ portalSlug: this.currentPortalSlug,
+ locale: localeCode,
+ });
+ },
async deleteCategory(categoryId) {
try {
await this.$store.dispatch('categories/delete', {
@@ -152,6 +158,7 @@ export default {
changeCurrentCategory(event) {
const localeCode = event.target.value;
this.currentLocaleCode = localeCode;
+ this.fetchCategoriesByPortalSlugAndLocale(localeCode);
},
},
};
diff --git a/app/javascript/dashboard/store/modules/auth.js b/app/javascript/dashboard/store/modules/auth.js
index 17806959b..e19d8d34c 100644
--- a/app/javascript/dashboard/store/modules/auth.js
+++ b/app/javascript/dashboard/store/modules/auth.js
@@ -48,6 +48,14 @@ export const getters = {
return currentAccount.availability;
},
+ getCurrentUserAutoOffline($state, $getters) {
+ const { accounts = [] } = $state.currentUser;
+ const [currentAccount = {}] = accounts.filter(
+ account => account.id === $getters.getCurrentAccountId
+ );
+ return currentAccount.auto_offline;
+ },
+
getCurrentAccountId(_, __, rootState) {
if (rootState.route.params && rootState.route.params.accountId) {
return Number(rootState.route.params.accountId);
@@ -174,6 +182,15 @@ export const actions = {
}
},
+ updateAutoOffline: async ({ commit }, { accountId, autoOffline }) => {
+ try {
+ const response = await authAPI.updateAutoOffline(accountId, autoOffline);
+ commit(types.SET_CURRENT_USER, response.data);
+ } catch (error) {
+ // Ignore error
+ }
+ },
+
setCurrentUserAvailability({ commit, state: $state }, data) {
if (data[$state.currentUser.id]) {
commit(types.SET_CURRENT_USER_AVAILABILITY, data[$state.currentUser.id]);
diff --git a/app/javascript/dashboard/store/modules/helpCenterArticles/actions.js b/app/javascript/dashboard/store/modules/helpCenterArticles/actions.js
index e62901835..3ab840105 100644
--- a/app/javascript/dashboard/store/modules/helpCenterArticles/actions.js
+++ b/app/javascript/dashboard/store/modules/helpCenterArticles/actions.js
@@ -41,11 +41,11 @@ export const actions = {
portalSlug,
articleObj,
});
- const { id: articleId, portal } = payload;
+ const { id: articleId } = payload;
commit(types.ADD_ARTICLE, payload);
commit(types.ADD_ARTICLE_ID, articleId);
commit(types.ADD_ARTICLE_FLAG, articleId);
- dispatch('portals/updatePortal', portal, { root: true });
+ dispatch('portals/updatePortal', portalSlug, { root: true });
return articleId;
} catch (error) {
return throwErrorMessage(error);
diff --git a/app/javascript/dashboard/store/modules/specs/auth/actions.spec.js b/app/javascript/dashboard/store/modules/specs/auth/actions.spec.js
index 6c1c85996..c933333be 100644
--- a/app/javascript/dashboard/store/modules/specs/auth/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/auth/actions.spec.js
@@ -88,6 +88,38 @@ describe('#actions', () => {
});
});
+ describe('#updateAutoOffline', () => {
+ it('sends correct actions if API is success', async () => {
+ axios.post.mockResolvedValue({
+ data: {
+ id: 1,
+ name: 'John',
+ accounts: [
+ {
+ account_id: 1,
+ auto_offline: false,
+ },
+ ],
+ },
+ headers: { expiry: 581842904 },
+ });
+ await actions.updateAutoOffline(
+ { commit, dispatch },
+ { autoOffline: false, accountId: 1 }
+ );
+ expect(commit.mock.calls).toEqual([
+ [
+ types.default.SET_CURRENT_USER,
+ {
+ id: 1,
+ name: 'John',
+ accounts: [{ account_id: 1, auto_offline: false }],
+ },
+ ],
+ ]);
+ });
+ });
+
describe('#updateUISettings', () => {
it('sends correct actions if API is success', async () => {
axios.put.mockResolvedValue({
diff --git a/app/javascript/shared/components/ui/dropdown/DropdownHeader.vue b/app/javascript/shared/components/ui/dropdown/DropdownHeader.vue
index d96865abd..c3719ada4 100644
--- a/app/javascript/shared/components/ui/dropdown/DropdownHeader.vue
+++ b/app/javascript/shared/components/ui/dropdown/DropdownHeader.vue
@@ -1,6 +1,7 @@