Skip to content

Commit

Permalink
fix: handle not allowed articles on customer portal
Browse files Browse the repository at this point in the history
  • Loading branch information
RitvikSardana committed Jan 16, 2025
1 parent 26598ef commit f3964cd
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
2 changes: 1 addition & 1 deletion desk/src/components/knowledge-base/CategoryModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
placeholder="Support Issues"
v-model="newTitle"
:rows="1"
maxlength="80"
maxlength="50"
autofocus
@input="(e: Event) => {
const target = e.target as HTMLTextAreaElement;
Expand Down
33 changes: 25 additions & 8 deletions desk/src/pages/knowledge-base/Article.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ import LayoutHeader from "@/components/LayoutHeader.vue";
import MoveToCategoryModal from "@/components/knowledge-base/MoveToCategoryModal.vue";
import DiscardButton from "@/components/DiscardButton.vue";
import ArticleFeedback from "@/components/knowledge-base/ArticleFeedback.vue";
import { Resource, Article, FeedbackAction } from "@/types";
import { Resource, Article, FeedbackAction, Error } from "@/types";
import {
createToast,
textEditorMenuButtons,
Expand Down Expand Up @@ -195,6 +195,13 @@ const article: Resource<Article> = createResource({
},
});
},
onError: (err: Error) => {
if (err.exc_type === "PermissionError") {
router.replace({
name: "CustomerKnowledgeBase",
});
}
},
});
const toggleStatus = debounce(() => {
Expand Down Expand Up @@ -344,11 +351,6 @@ function scrollToHeading() {
}, 500);
}, 1000);
}
onMounted(() => {
setTimeout(() => {
scrollToHeading();
}, 100);
});
watch([() => content.value, () => title.value], ([newContent, newTitle]) => {
isDirty.value =
Expand Down Expand Up @@ -413,13 +415,22 @@ const breadcrumbs = computed(() => {
const items = [
{
label: "Knowledge Base",
route: { name: "AgentKnowledgeBase" },
route: {
name: isCustomerPortal.value
? "CustomerKnowledgeBase"
: "AgentKnowledgeBase",
},
},
];
if (article.data?.category_name) {
items.push({
label: article.data?.category_name,
route: { name: "AgentKnowledgeBase" },
route: {
name: isCustomerPortal.value ? "Articles" : "AgentKnowledgeBase",
params: {
categoryId: article.data?.category_id,
},
},
});
}
if (article.data?.title) {
Expand All @@ -430,6 +441,12 @@ const breadcrumbs = computed(() => {
}
return items;
});
onMounted(() => {
setTimeout(() => {
scrollToHeading();
}, 100);
});
</script>

<style scoped></style>
10 changes: 10 additions & 0 deletions desk/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ export interface Resource<T = unknown> {
update: (r: unknown) => void;
}

export interface Error {
exc_type: string;
exc: string;
response: string;
status: string;
messages: string;
stack: string;
message: string;
}

export interface Comment {
commented_by: string;
content: string;
Expand Down

0 comments on commit f3964cd

Please sign in to comment.