Skip to content

Commit 8132320

Browse files
Merge pull request #5745 from christianbeeznest/ofaj-21572-2
Social: Hide social groups menu item based on config setting - refs BT#21572
2 parents d0264ae + 824308e commit 8132320

File tree

1 file changed

+32
-27
lines changed

1 file changed

+32
-27
lines changed
Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { computed, ref } from 'vue';
2-
import { useI18n } from 'vue-i18n';
1+
import { computed, ref } from 'vue'
2+
import { useI18n } from 'vue-i18n'
33
import { useMessageRelUserStore } from "../store/messageRelUserStore"
44
import { useSecurityStore } from "../store/securityStore"
55
import { usePlatformConfig } from "../store/platformConfig"
6-
import axios from 'axios';
6+
import axios from 'axios'
77
import { useSocialInfo } from "./useSocialInfo"
88
import { storeToRefs } from "pinia"
99

@@ -15,60 +15,65 @@ export function useSocialMenuItems() {
1515
const invitationsCount = ref(0);
1616
const groupLink = ref({ name: "UserGroupShow" });
1717

18-
const { isCurrentUser} = useSocialInfo()
18+
const { isCurrentUser } = useSocialInfo()
1919
const { user } = storeToRefs(securityStore)
2020

21-
const unreadMessagesCount = computed(() => messageRelUserStore.countUnread);
22-
const globalForumsCourse = computed(() => platformConfigStore.getSetting("forum.global_forums_course_id"));
21+
const unreadMessagesCount = computed(() => messageRelUserStore.countUnread)
22+
const globalForumsCourse = computed(() => platformConfigStore.getSetting("forum.global_forums_course_id"))
23+
const hideSocialGroupBlock = computed(() => platformConfigStore.getSetting("social.hide_social_groups_block") === "true")
24+
2325
const isValidGlobalForumsCourse = computed(() => {
24-
const courseId = globalForumsCourse.value;
25-
return courseId !== null && courseId !== undefined && courseId > 0;
26+
const courseId = globalForumsCourse.value
27+
return courseId !== null && courseId !== undefined && courseId > 0
2628
});
2729

2830
const fetchInvitationsCount = async (userId) => {
29-
if (!userId) return;
31+
if (!userId) return
3032
try {
31-
const { data } = await axios.get(`/social-network/invitations/count/${userId}`);
32-
invitationsCount.value = data.totalInvitationsCount;
33+
const { data } = await axios.get(`/social-network/invitations/count/${userId}`)
34+
invitationsCount.value = data.totalInvitationsCount
3335
} catch (error) {
34-
console.error("Error fetching invitations count:", error);
36+
console.error("Error fetching invitations count:", error)
3537
}
3638
};
3739

3840
const getGroupLink = async () => {
3941
try {
40-
const response = await axios.get("/social-network/get-forum-link");
42+
const response = await axios.get("/social-network/get-forum-link")
4143
if (isValidGlobalForumsCourse.value) {
42-
groupLink.value = response.data.go_to;
44+
groupLink.value = response.data.go_to
4345
} else {
44-
groupLink.value = { name: "UserGroupList" };
46+
groupLink.value = { name: "UserGroupList" }
4547
}
4648
} catch (error) {
47-
console.error("Error fetching forum link:", error);
48-
groupLink.value = { name: "UserGroupList" };
49+
console.error("Error fetching forum link:", error)
50+
groupLink.value = { name: "UserGroupList" }
4951
}
5052
};
5153

52-
console.log('user.value ::: ', user.value.id)
53-
5454
if (user.value && user.value.id) {
55-
fetchInvitationsCount(user.value.id);
56-
getGroupLink();
55+
fetchInvitationsCount(user.value.id)
56+
getGroupLink()
5757
}
5858

5959
const items = computed(() => {
60-
return isCurrentUser.value ? [
60+
const menuItems = [
6161
{ icon: 'mdi mdi-home', label: t("Home"), route: '/social' },
6262
{ icon: 'mdi mdi-email', label: t("Messages"), route: '/resources/messages', badgeCount: unreadMessagesCount.value },
6363
{ icon: 'mdi mdi-handshake', label: t("My friends"), route: { name: 'UserRelUserList' } },
64-
{ icon: 'mdi mdi-group', label: t("Social groups"), route: groupLink.value, isLink: isValidGlobalForumsCourse.value },
6564
{ icon: 'mdi mdi-briefcase', label: t("My files"), route: { name: 'PersonalFileList', params: { node: securityStore.user.resourceNode.id } } },
6665
{ icon: 'mdi mdi-account', label: t("Personal data"), route: '/resources/users/personal_data' },
67-
] : [
66+
]
67+
68+
if (!hideSocialGroupBlock.value) {
69+
menuItems.splice(3, 0, { icon: 'mdi mdi-group', label: t("Social groups"), route: groupLink.value, isLink: isValidGlobalForumsCourse.value })
70+
}
71+
72+
return isCurrentUser.value ? menuItems : [
6873
{ icon: 'mdi mdi-home', label: t("Home"), route: '/social' },
6974
{ icon: 'mdi mdi-email', label: t("Send message"), link: `/main/inc/ajax/user_manager.ajax.php?a=get_user_popup&user_id=${user.value.id}`, isExternal: true }
70-
];
71-
});
75+
]
76+
})
7277

73-
return { items };
78+
return { items }
7479
}

0 commit comments

Comments
 (0)