From 9bc75225feedadc1b19a1a12bc422160803f1595 Mon Sep 17 00:00:00 2001 From: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Date: Wed, 10 Aug 2022 10:48:41 +0530 Subject: [PATCH] feat: Category store integration (#5218) * Add more actions * Complete sidebar store integration * Complete portal list store integration * Fixed the specs * Added missing specs * Add comment * Code cleanup * Fixed all the spec issues * Add portal and article API specs * Add category name in article list * Add more locales * Code beautification * Exclude locale from codeclimate ci * feat: Category store integration * chore: Minor fixes * chore: API call fixes * chore: Minor fixes * chore: Minor fixes * chore: Adds the ability for get articles based on categories * chore: minor fixes * chore: Minor fixes * chore: fixes specs and minor improvements * chore: Review fixes * chore: Minor fixes * chore: Review fixes * chore: Review fixes * chore: Spacing fixes * Code cleanup Co-authored-by: Muhsin Keloth --- .../dashboard/api/helpCenter/articles.js | 10 ++- .../sidebarComponents/SecondaryNavItem.vue | 33 +++++++-- .../components/widgets/forms/Input.vue | 3 + .../dashboard/i18n/locale/en/helpCenter.json | 4 + .../dashboard/i18n/locale/en/settings.json | 3 +- .../helpcenter/components}/AddCategory.vue | 61 +++++++++------ .../components/HelpCenterLayout.vue | 74 ++++++++++++------- .../helpcenter/components/Sidebar/Sidebar.vue | 13 ++++ .../stories}/AddCategory.stories.js | 2 +- .../dashboard/helpcenter/helpcenter.routes.js | 4 +- .../pages/articles/ListAllArticles.vue | 30 +++++++- .../modules/helpCenterArticles/actions.js | 3 +- .../modules/helpCenterCategories/actions.js | 27 ++++--- .../specs/actions.spec.js | 9 ++- 14 files changed, 196 insertions(+), 80 deletions(-) rename app/javascript/dashboard/{components/helpCenter => routes/dashboard/helpcenter/components}/AddCategory.vue (77%) rename app/javascript/dashboard/{components/helpCenter => routes/dashboard/helpcenter/components/stories}/AddCategory.stories.js (92%) diff --git a/app/javascript/dashboard/api/helpCenter/articles.js b/app/javascript/dashboard/api/helpCenter/articles.js index 3f3ab3a49..7430d65a4 100644 --- a/app/javascript/dashboard/api/helpCenter/articles.js +++ b/app/javascript/dashboard/api/helpCenter/articles.js @@ -7,10 +7,18 @@ class ArticlesAPI extends PortalsAPI { super('articles', { accountScoped: true }); } - getArticles({ pageNumber, portalSlug, locale, status, author_id }) { + getArticles({ + pageNumber, + portalSlug, + locale, + status, + author_id, + category_slug, + }) { let baseUrl = `${this.url}/${portalSlug}/articles?page=${pageNumber}&locale=${locale}`; if (status !== undefined) baseUrl += `&status=${status}`; if (author_id) baseUrl += `&author_id=${author_id}`; + if (category_slug) baseUrl += `&category_slug=${category_slug}`; return axios.get(baseUrl); } } diff --git a/app/javascript/dashboard/components/layout/sidebarComponents/SecondaryNavItem.vue b/app/javascript/dashboard/components/layout/sidebarComponents/SecondaryNavItem.vue index 6a7505cc2..861805589 100644 --- a/app/javascript/dashboard/components/layout/sidebarComponents/SecondaryNavItem.vue +++ b/app/javascript/dashboard/components/layout/sidebarComponents/SecondaryNavItem.vue @@ -5,8 +5,12 @@ {{ $t(`SIDEBAR.${menuItem.label}`) }} +

+ {{ $t('SIDEBAR.HELP_CENTER.CATEGORY_EMPTY_MESSAGE') }} +

@@ -98,6 +105,10 @@ export default { type: Boolean, default: false, }, + isCategoryEmpty: { + type: Boolean, + default: false, + }, }, computed: { ...mapGetters({ activeInbox: 'getSelectedInbox' }), @@ -134,11 +145,8 @@ export default { this.menuItem.toStateName === 'settings_applications' ); }, - isAllArticles() { - return ( - this.$store.state.route.name === 'list_all_locale_articles' && - this.menuItem.toStateName === 'all_locale_articles' - ); + isArticlesView() { + return this.$store.state.route.name === this.menuItem.toStateName; }, computedClass() { @@ -158,7 +166,7 @@ export default { return ' '; } if (this.isHelpCenterSidebar) { - if (this.isAllArticles) { + if (this.isArticlesView) { return 'is-active'; } return ' '; @@ -195,6 +203,9 @@ export default { showItem(item) { return this.isAdmin && item.newLink !== undefined; }, + onClickOpen() { + this.$emit('open'); + }, }, }; @@ -324,4 +335,10 @@ export default { } } } + +.empty-text { + color: var(--s-600); + font-size: var(--font-size-small); + margin: var(--space-smaller) 0; +} diff --git a/app/javascript/dashboard/components/widgets/forms/Input.vue b/app/javascript/dashboard/components/widgets/forms/Input.vue index 49e1a0cec..057438895 100644 --- a/app/javascript/dashboard/components/widgets/forms/Input.vue +++ b/app/javascript/dashboard/components/widgets/forms/Input.vue @@ -70,4 +70,7 @@ export default { color: var(--s-600); font-style: normal; } +.message { + margin-top: 0 !important; +} diff --git a/app/javascript/dashboard/i18n/locale/en/helpCenter.json b/app/javascript/dashboard/i18n/locale/en/helpCenter.json index 4e70fc58d..c17bb8c49 100644 --- a/app/javascript/dashboard/i18n/locale/en/helpCenter.json +++ b/app/javascript/dashboard/i18n/locale/en/helpCenter.json @@ -174,6 +174,10 @@ "BUTTONS": { "CREATE": "Create category", "CANCEL": "Cancel" + }, + "API": { + "SUCCESS_MESSAGE": "Category created successfully", + "ERROR_MESSAGE": "Unable to create category" } } } diff --git a/app/javascript/dashboard/i18n/locale/en/settings.json b/app/javascript/dashboard/i18n/locale/en/settings.json index 0db8e393d..038af64a5 100644 --- a/app/javascript/dashboard/i18n/locale/en/settings.json +++ b/app/javascript/dashboard/i18n/locale/en/settings.json @@ -197,7 +197,8 @@ "MY_ARTICLES": "My Articles", "DRAFT": "Draft", "ARCHIVED": "Archived", - "CATEGORY": "Category" + "CATEGORY": "Category", + "CATEGORY_EMPTY_MESSAGE": "No categories found" }, "DOCS": "Read docs" }, diff --git a/app/javascript/dashboard/components/helpCenter/AddCategory.vue b/app/javascript/dashboard/routes/dashboard/helpcenter/components/AddCategory.vue similarity index 77% rename from app/javascript/dashboard/components/helpCenter/AddCategory.vue rename to app/javascript/dashboard/routes/dashboard/helpcenter/components/AddCategory.vue index 370949cd1..fc56a684f 100644 --- a/app/javascript/dashboard/components/helpCenter/AddCategory.vue +++ b/app/javascript/dashboard/routes/dashboard/helpcenter/components/AddCategory.vue @@ -1,5 +1,5 @@