From ba6fc897c0539fe8c7cc3a40e6d8273cfaa093a5 Mon Sep 17 00:00:00 2001 From: ketan-canyon Date: Tue, 15 Oct 2024 20:37:59 +0000 Subject: [PATCH 1/3] After changing an article from public to internal, the article is still available via the link on the portal --- .../KnowledgeBaseArticleData.php | 2 +- ...ledgeManagementPortalArticleController.php | 50 ++++++++++--------- .../src/Pages/ViewArticle.vue | 25 ++++++++-- 3 files changed, 49 insertions(+), 28 deletions(-) diff --git a/app-modules/portal/src/DataTransferObjects/KnowledgeBaseArticleData.php b/app-modules/portal/src/DataTransferObjects/KnowledgeBaseArticleData.php index 91d800468..114a2038f 100644 --- a/app-modules/portal/src/DataTransferObjects/KnowledgeBaseArticleData.php +++ b/app-modules/portal/src/DataTransferObjects/KnowledgeBaseArticleData.php @@ -46,6 +46,6 @@ public function __construct( public string $name, public ?string $lastUpdated, public ?string $content, - public ?array $tags, + public ?array $tags ) {} } diff --git a/app-modules/portal/src/Http/Controllers/KnowledgeManagementPortal/KnowledgeManagementPortalArticleController.php b/app-modules/portal/src/Http/Controllers/KnowledgeManagementPortal/KnowledgeManagementPortalArticleController.php index 4ebc2cf92..4771c1431 100644 --- a/app-modules/portal/src/Http/Controllers/KnowledgeManagementPortal/KnowledgeManagementPortalArticleController.php +++ b/app-modules/portal/src/Http/Controllers/KnowledgeManagementPortal/KnowledgeManagementPortalArticleController.php @@ -49,28 +49,32 @@ public function show(KnowledgeBaseCategory $category, KnowledgeBaseItem $article { $article->increment('portal_view_count'); - return response()->json([ - 'category' => KnowledgeBaseCategoryData::from([ - 'id' => $category->getKey(), - 'name' => $category->name, - 'description' => $category->description, - ]), - 'article' => KnowledgeBaseArticleData::from([ - 'id' => $article->getKey(), - 'categoryId' => $article->category_id, - 'name' => $article->title, - 'lastUpdated' => $article->updated_at->format('M d Y, h:m a'), - 'content' => tiptap_converter()->record($article, attribute: 'article_details')->asHTML($article->article_details), - 'tags' => $article->tags() - ->orderBy('name') - ->select([ - 'id', - 'name', - ]) - ->get() - ->toArray(), - ]), - 'portal_view_count' => $article->portal_view_count, - ]); + if (! empty($article) && $article->public === true) { + return response()->json([ + 'category' => KnowledgeBaseCategoryData::from([ + 'id' => $category->getKey(), + 'name' => $category->name, + 'description' => $category->description, + ]), + 'article' => KnowledgeBaseArticleData::from([ + 'id' => $article->getKey(), + 'categoryId' => $article->category_id, + 'name' => $article->title, + 'lastUpdated' => $article->updated_at->format('M d Y, h:m a'), + 'content' => tiptap_converter()->record($article, attribute: 'article_details')->asHTML($article->article_details), + 'tags' => $article->tags() + ->orderBy('name') + ->select([ + 'id', + 'name', + ]) + ->get() + ->toArray(), + ]), + 'portal_view_count' => $article->portal_view_count, + ]); + } + + return response()->json([]); } } diff --git a/portals/knowledge-management/src/Pages/ViewArticle.vue b/portals/knowledge-management/src/Pages/ViewArticle.vue index 39a26e2cd..7bcade753 100644 --- a/portals/knowledge-management/src/Pages/ViewArticle.vue +++ b/portals/knowledge-management/src/Pages/ViewArticle.vue @@ -81,10 +81,13 @@ get(props.apiUrl + '/categories/' + route.params.categoryId + '/articles/' + route.params.articleId).then( (response) => { - category.value = response.data.category; - article.value = response.data.article; + if (response.data) { + category.value = response.data.category; + article.value = response.data.article; + portalViewCount.value = response.data.portal_view_count; + } + loading.value = false; - portalViewCount.value = response.data.portal_view_count; }, ); } @@ -104,11 +107,12 @@ { name: category.name, route: 'view-category', params: { categoryId: category.id } }, ]" currentCrumb="Articles" + v-if="article" >
-
+

{{ article.name }}

@@ -124,6 +128,19 @@
+
+
+

+ The link you are attempting to access is invalid. +

+ + Return Home + +
+
From 39b0b78b5db26b9d5ec4ed6b5b9ffa77bfc8b450 Mon Sep 17 00:00:00 2001 From: ketan-canyon Date: Tue, 15 Oct 2024 20:55:33 +0000 Subject: [PATCH 2/3] resolved lint error --- .../KnowledgeManagementPortalArticleController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app-modules/portal/src/Http/Controllers/KnowledgeManagementPortal/KnowledgeManagementPortalArticleController.php b/app-modules/portal/src/Http/Controllers/KnowledgeManagementPortal/KnowledgeManagementPortalArticleController.php index 4771c1431..5fda5d6b7 100644 --- a/app-modules/portal/src/Http/Controllers/KnowledgeManagementPortal/KnowledgeManagementPortalArticleController.php +++ b/app-modules/portal/src/Http/Controllers/KnowledgeManagementPortal/KnowledgeManagementPortalArticleController.php @@ -49,7 +49,7 @@ public function show(KnowledgeBaseCategory $category, KnowledgeBaseItem $article { $article->increment('portal_view_count'); - if (! empty($article) && $article->public === true) { + if ($article->public === true) { return response()->json([ 'category' => KnowledgeBaseCategoryData::from([ 'id' => $category->getKey(), From c5d5ea2c8d038bc4a94bda99cfc89613c664de4e Mon Sep 17 00:00:00 2001 From: ketan-canyon Date: Wed, 16 Oct 2024 17:37:49 +0000 Subject: [PATCH 3/3] worked on PR review changes --- .../KnowledgeBaseArticleData.php | 2 +- ...ledgeManagementPortalArticleController.php | 50 +++++++++---------- .../src/Pages/ViewArticle.vue | 14 ++++-- 3 files changed, 36 insertions(+), 30 deletions(-) diff --git a/app-modules/portal/src/DataTransferObjects/KnowledgeBaseArticleData.php b/app-modules/portal/src/DataTransferObjects/KnowledgeBaseArticleData.php index 114a2038f..91d800468 100644 --- a/app-modules/portal/src/DataTransferObjects/KnowledgeBaseArticleData.php +++ b/app-modules/portal/src/DataTransferObjects/KnowledgeBaseArticleData.php @@ -46,6 +46,6 @@ public function __construct( public string $name, public ?string $lastUpdated, public ?string $content, - public ?array $tags + public ?array $tags, ) {} } diff --git a/app-modules/portal/src/Http/Controllers/KnowledgeManagementPortal/KnowledgeManagementPortalArticleController.php b/app-modules/portal/src/Http/Controllers/KnowledgeManagementPortal/KnowledgeManagementPortalArticleController.php index 5fda5d6b7..a29e5a7cf 100644 --- a/app-modules/portal/src/Http/Controllers/KnowledgeManagementPortal/KnowledgeManagementPortalArticleController.php +++ b/app-modules/portal/src/Http/Controllers/KnowledgeManagementPortal/KnowledgeManagementPortalArticleController.php @@ -49,32 +49,32 @@ public function show(KnowledgeBaseCategory $category, KnowledgeBaseItem $article { $article->increment('portal_view_count'); - if ($article->public === true) { - return response()->json([ - 'category' => KnowledgeBaseCategoryData::from([ - 'id' => $category->getKey(), - 'name' => $category->name, - 'description' => $category->description, - ]), - 'article' => KnowledgeBaseArticleData::from([ - 'id' => $article->getKey(), - 'categoryId' => $article->category_id, - 'name' => $article->title, - 'lastUpdated' => $article->updated_at->format('M d Y, h:m a'), - 'content' => tiptap_converter()->record($article, attribute: 'article_details')->asHTML($article->article_details), - 'tags' => $article->tags() - ->orderBy('name') - ->select([ - 'id', - 'name', - ]) - ->get() - ->toArray(), - ]), - 'portal_view_count' => $article->portal_view_count, - ]); + if (! $article->public) { + return response()->json([], 401); } - return response()->json([]); + return response()->json([ + 'category' => KnowledgeBaseCategoryData::from([ + 'id' => $category->getKey(), + 'name' => $category->name, + 'description' => $category->description, + ]), + 'article' => KnowledgeBaseArticleData::from([ + 'id' => $article->getKey(), + 'categoryId' => $article->category_id, + 'name' => $article->title, + 'lastUpdated' => $article->updated_at->format('M d Y, h:m a'), + 'content' => tiptap_converter()->record($article, attribute: 'article_details')->asHTML($article->article_details), + 'tags' => $article->tags() + ->orderBy('name') + ->select([ + 'id', + 'name', + ]) + ->get() + ->toArray(), + ]), + 'portal_view_count' => $article->portal_view_count, + ]); } } diff --git a/portals/knowledge-management/src/Pages/ViewArticle.vue b/portals/knowledge-management/src/Pages/ViewArticle.vue index 7bcade753..8b874b380 100644 --- a/portals/knowledge-management/src/Pages/ViewArticle.vue +++ b/portals/knowledge-management/src/Pages/ViewArticle.vue @@ -79,8 +79,8 @@ const { get } = consumer(); - get(props.apiUrl + '/categories/' + route.params.categoryId + '/articles/' + route.params.articleId).then( - (response) => { + get(props.apiUrl + '/categories/' + route.params.categoryId + '/articles/' + route.params.articleId) + .then((response) => { if (response.data) { category.value = response.data.category; article.value = response.data.article; @@ -88,8 +88,14 @@ } loading.value = false; - }, - ); + }) + .catch((error) => { + if (error.response && error.response.status === 401) { + loading.value = false; + } else { + console.log('An error occurred', error); + } + }); }