Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AIDAPP-309]: After changing an article from public to internal, the article is still available via the link on the portal #282

Merged
merged 4 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ public function __construct(
public string $name,
public ?string $lastUpdated,
public ?string $content,
public ?array $tags,
public ?array $tags
Orrison marked this conversation as resolved.
Show resolved Hide resolved
) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 ($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([]);
Orrison marked this conversation as resolved.
Show resolved Hide resolved
}
}
25 changes: 21 additions & 4 deletions portals/knowledge-management/src/Pages/ViewArticle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
);
}
Expand All @@ -104,11 +107,12 @@
{ name: category.name, route: 'view-category', params: { categoryId: category.id } },
]"
currentCrumb="Articles"
v-if="article"
></Breadcrumbs>

<div class="grid space-y-2">
<div class="flex flex-col gap-3">
<div class="prose max-w-none">
<div class="prose max-w-none" v-if="article">
<h1 class="font-semibold">{{ article.name }}</h1>
<div class="flex mb-4">
<div class="text-gray-500 flex items-center space-x-1 mr-2">
Expand All @@ -124,6 +128,19 @@
<hr class="my-4" />
<div v-html="DOMPurify.sanitize(article.content)"></div>
</div>
<div class="flex items-center justify-center min-h-screen bg-gray-100" v-else>
<div class="text-center">
<p class="text-lg font-semibold text-gray-800">
The link you are attempting to access is invalid.
</p>
<router-link
:to="{ name: 'home' }"
class="mt-4 inline-block px-4 py-2 text-white bg-gradient-to-br from-primary-500 to-primary-800 m-3 p-2 rounded"
>
Return Home
</router-link>
</div>
</div>
</div>
</div>
</main>
Expand Down