diff --git a/package.json b/package.json index 7dde2750..4d6bc989 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "i18next-http-backend": "^3.0.2", "linkify-plugin-mention": "^4.2.0", "linkify-react": "^4.2.0", + "linkify-string": "^4.2.0", "linkifyjs": "^4.2.0", "localforage": "^1.10.0", "localforage-setitems": "^1.4.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7d19957a..2d67520f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -125,6 +125,9 @@ importers: linkify-react: specifier: ^4.2.0 version: 4.2.0(linkifyjs@4.2.0)(react@19.0.0) + linkify-string: + specifier: ^4.2.0 + version: 4.2.0(linkifyjs@4.2.0) linkifyjs: specifier: ^4.2.0 version: 4.2.0 @@ -3909,6 +3912,11 @@ packages: linkifyjs: ^4.0.0 react: '>= 15.0.0' + linkify-string@4.2.0: + resolution: {integrity: sha512-LqOKk0+RlqibFkxjPAGOL7Mfssqj6/SdG9QWGvzeVDpoWXhaw9OXxseCtFanjIl7C6UyTTZizhyGr4IWLfijiw==} + peerDependencies: + linkifyjs: ^4.0.0 + linkifyjs@4.2.0: resolution: {integrity: sha512-pCj3PrQyATaoTYKHrgWRF3SJwsm61udVh+vuls/Rl6SptiDhgE7ziUIudAedRY9QEfynmM7/RmLEfPUyw1HPCw==} @@ -10109,6 +10117,10 @@ snapshots: linkifyjs: 4.2.0 react: 19.0.0 + linkify-string@4.2.0(linkifyjs@4.2.0): + dependencies: + linkifyjs: 4.2.0 + linkifyjs@4.2.0: {} loader-runner@4.3.0: {} diff --git a/public/locales/en/setting.json b/public/locales/en/setting.json index f42b2344..cfc3afca 100644 --- a/public/locales/en/setting.json +++ b/public/locales/en/setting.json @@ -33,7 +33,7 @@ "id": "Channel ID", "name": "Channel Name", "topic": "Channel Topic", - "topic_placeholder": "Let everyone know how to use this channel.", + "topic_placeholder": "Let everyone know how to use this channel.(markdown supported)", "visibility": "Channel Visibility", "public": "Public", "private": "Private", @@ -86,6 +86,12 @@ "enable": "Enable", "disable": "Disable" }, + "admin_only_can_invite": { + "title": "Only Admins Can Invite Users", + "desc": "If enabled, only admins can invite new members.", + "enable": "Enable", + "disable": "Disable" + }, "enable_msg_url_preview": { "title": "Enable URL Preview in Message", "desc": "If enabled, url in message will show preview content.", diff --git a/public/locales/pt/setting.json b/public/locales/pt/setting.json index 5513a897..fc85d1a2 100644 --- a/public/locales/pt/setting.json +++ b/public/locales/pt/setting.json @@ -32,7 +32,7 @@ "delete_desc": "Are you sure want to delete this channel?", "name": "Channel Name", "topic": "Channel Topic", - "topic_placeholder": "Let everyone know how to use this channel.", + "topic_placeholder": "Let everyone know how to use this channel.(markdown supported)", "visibility": "Channel Visibility", "public": "Public", "private": "Private" diff --git a/public/locales/zh/setting.json b/public/locales/zh/setting.json index 6cc038b4..00b068fc 100644 --- a/public/locales/zh/setting.json +++ b/public/locales/zh/setting.json @@ -33,7 +33,7 @@ "id": "频道 ID", "name": "频道名", "topic": "频道主题", - "topic_placeholder": "让别人知道这个频道是用来做啥的", + "topic_placeholder": "让别人知道这个频道是用来做啥的(支持 markdown)", "visibility": "可见性", "public": "公开", "private": "私密", @@ -85,6 +85,12 @@ "enable": "开启", "disable": "关闭" }, + "admin_only_can_invite": { + "title": "只有管理员可以邀请新用户", + "desc": "如果开启,只有管理员才能邀请新用户", + "enable": "开启", + "disable": "关闭" + }, "enable_msg_url_preview": { "title": "开启消息网址预览", "desc": "如果开启,消息中的网址会显示预览内容", diff --git a/src/app/config.ts b/src/app/config.ts index 267d0444..4ad9a99e 100644 --- a/src/app/config.ts +++ b/src/app/config.ts @@ -208,6 +208,7 @@ export const getEmailNotifyDelayList = () => [ value: 12 * 60 * 60, }, ]; +export const KEY_ADMIN_ONLY_INVITE = `admin_only_can_invite`; export const KEY_ADMIN_SEE_CHANNEL_MEMBERS = `only_admin_can_see_channel_members`; export const KEY_MSG_URL_PREVIEW = `enable_msg_url_preview`; export default BASE_URL; diff --git a/src/components/AddEntriesMenu.tsx b/src/components/AddEntriesMenu.tsx index 1c6051c4..d75cd2ce 100644 --- a/src/components/AddEntriesMenu.tsx +++ b/src/components/AddEntriesMenu.tsx @@ -12,9 +12,13 @@ import InviteModal from "./InviteModal"; import SearchUser from "./SearchUser"; import UsersModal from "./UsersModal"; import { shallowEqual } from "react-redux"; +import useServerExtSetting from "../hooks/useServerExtSetting"; +import { KEY_ADMIN_ONLY_INVITE } from "../app/config"; export default function AddEntriesMenu() { const { t } = useTranslation(); + const { getExtSetting } = useServerExtSetting(); + const onlyAdminCanInvite = getExtSetting(KEY_ADMIN_ONLY_INVITE); const isAdmin = useAppSelector((store) => store.authData.user?.is_admin, shallowEqual); const onlyAdminCreateGroup = useAppSelector( (store) => store.server.only_admin_can_create_group, @@ -62,6 +66,7 @@ export default function AddEntriesMenu() { "rounded flex items-center gap-2 text-sm font-semibold cursor-pointer px-2 py-2.5 md:hover:bg-gray-800/20 md:dark:hover:bg-gray-200/20"; const iconClass = "w-5 h-5 dark:fill-gray-300"; const canPrivateGroup = onlyAdminCreateGroup ? isAdmin : true; + const showInvite = isAdmin || !onlyAdminCanInvite; return ( <>
{t("welcome_desc", { name: data?.name })}
+ {isAdmin && (